Could someone explain to me how I could draw, using tikz, the following picture ? enter image description here

I would appreciate it if someone could show me an example of the connection between the Memory and the EES block,because I am struggling with this for many hours, without any progress. Thanks for your time.


The drawing itself may be simples but some details are tricky (like the line connecting mem_out to val_in). I won't provide the whole drawing, instead I'll leave a skeleton of it with the concept of how this tricky details can be done.

Since there's the need to connect specific parts of the big blocks, they should be drawn as nodes. To get the nodes aligned you can use a \matrix. A \matrix itself is a node, so node options like draw and anchor (or the positioning left=<dim> of <node>) works. And once you give the Matrix a <name>, the nodes inside of it are named automatically with (<name>-<row num>-<col num>), which makes them easy to be called upon.

For the crossing lines, I was working on an automated solution for this and have asked a question: Decorate path precisely on intersection(s) with TikZ - avoiding crossing lines, there's a working solution there, but it's very limited, there's also links to other solutions.


\usetikzlibrary{matrix, positioning, intersections, decorations.pathreplacing, calc}
    over path/.style={
        decoration={show path construction, lineto code={
          \path[name path=this path] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
          \path[name intersections={of=this path and #1, total=\t}, /utils/exec={\global\let\t=\t}]%
                                    let \n1={int(\t+1)} in%
                                    (\tikzinputsegmentfirst) coordinate (int-0)%
                                    foreach \i in {1,...,\n1}{%
                                      \ifnum \i<\n1%
                                          (intersection-\i) coordinate (int-\i)%
                                          (\tikzinputsegmentlast) coordinate (int-\n1)%
          \draw (\tikzinputsegmentfirst) foreach[remember=\i as \last (initially 0)] \i in {1,...,\t}{%
            let \p1=($(int-\last)-(int-\i)$), \n1={veclen(\x1,\y1)}, \n2={abs(4pt)}, \n3={\i+1}  in%
            [rounded corners=\n2/4] -- ($(int-\last)!\n1-\n2!(int-\i)$) to[bend left=90, looseness=1.7] ($(int-\last)!\n1+\n2!(int-\n3)$)} -- (\tikzinputsegmentlast);
\matrix (Memory) [matrix of nodes, draw, inner sep=0pt,
                  column 1/.style={anchor=west},
                  column 2/.style={anchor=east},
                  column sep=.5cm, row sep=.2cm,
                  nodes={font=\ttfamily, inner sep=4pt}]{%
rst & mem\_out \\
next\_val & \\};
\matrix (EES) [matrix of nodes, draw, inner sep=0pt,
               below right=0cm and 2cm of Memory.north east,
               column 1/.style={anchor=west},
               column 2/.style={anchor=east},
               column sep=1cm,
               nodes={font=\ttfamily, inner sep=4pt}]{%
val\_in & data\_out \\
clk & \\
rst & req\_val \\};
\foreach \block in {Memory, EES} \node[font=\sffamily\Large, above=0cm of \block]{\block};
\draw[name path=line] ([shift={(1cm,0.4cm)}]Memory.north east) -- ++(0,-2cm);
\draw[over path=line, ->] (Memory-1-2) -- (EES-1-1);

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.