Block diagram layout with dot/graphviz

前端 未结 1 1078
生来不讨喜
生来不讨喜 2020-12-08 05:49

I\'d like to implement the following mockup with dot:

\"mockup

So far I\'ve

相关标签:
1条回答
  • 2020-12-08 06:30

    Does this get you started?

    digraph G {
        graph [rankdir = LR];
    
        node[shape=record];
        Bar[label="{ \"Bar\"|{<p1>pin 1|<p2>     2|<p3>     3|<p4>     4|<p5>     5} }"];
        Foo[label="{ {<data0>data0|<data1>data1|<data2>data2|<data3>data3|<data4>data4}|\"Foo\" |{<out0>out0|<out1>out1|<out2>out2|<GND>gnd|<ex0>ex0|<hi>hi|<lo>lo} }"];
    
        Bew[label="{ {<clk>clk|<syn>syn|<mux0>mux0|<mux1>mux1|<signal>signal}|\"Bew\" |{<out0>out0|<out1>out1|<out2>out2} }"];
        Bar:p1 -> Foo:data0;
        Bar:p2 -> Foo:data1;
        Bar:p3 -> Foo:data2;
        Bar:p4 -> Foo:data3;
        Bar:p5 -> Foo:data4;
    
        Foo:out0 -> Bew:mux0;
        Foo:out1 -> Bew:mux1;
        Bew:clk -> Foo:ex0;
    
        Gate[label="{ {<a>a|<b>b}|OR|{<ab>a\|b} }"];
    
        Foo:hi -> Gate:a;
        Foo:lo -> Gate:b;
        Gate:ab -> Bew:signal;
    }
    

    enter image description here

    Note that I used nonbreaking spaces as a cheeky way to get the alignment (I think, I did C-kSpaceSpace in vim, leading to Hex 00a0 char)

    You can also employ HTML inside the label definitions, so you can use fonts, colors and create 'spacers': http://www.graphviz.org/doc/info/shapes.html#html

    I suppose aligning labels would be easier with HTML nodes.

    0 讨论(0)
提交回复
热议问题