# How to draw the following diagram using tikz-cd?

How to draw this diagram using tikz-cd?

Here is my code

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,shapes}
\begin{document}
\tikzstyle{block} = [draw,rectangle,node distance=5em]
\tikzstyle{line}=[draw,-stealth]
\begin{tikzpicture}
\node[block] (1) {Reserved};
\node[block, right of=1] (2) {Aero length};
\node[block,right of=2] (3) {DET};
\node[block,right of=3] (4) {Bob's Signature};
\node[block,right of=4] (5) {CPU};
\node[block,right of=5] (6) {Working};
\node[block,below of=1] (7) {Subframe 1};
\node[block,below of=2] (8) {Subframe 2};
\node[block,below of=3] (9) {Subframe 3};
\node[block,below of=4] (10) {...};
\node[block,below of=5] (11) {Subframe N};
\path[line](9)--(1);\path[line](11)--(6);
\node[block,below of=7] (12) {Memory};
\node[block,below of=9] (13) {ALU};
\path[line](13)--(7);\path[line](13)--(11);
\end{tikzpicture}
\end{document}

• A some one has marked you down, probably because a lot of people take exception to questions of the form "Please draw this for me". You will get more help if you post some code showing what you have tried and give a minimal working example. – user30471 Feb 4 '16 at 5:45
• Why tikz-cd? Not sure if it's the best choice here. Are the dashed lines supposed to indicate expansion of the single node below? – Alenanno Feb 4 '16 at 7:56
• @Alenanno Yes, the dashed lines indicate expansion of the single node. – Litun Feb 4 '16 at 10:04

This kind of groups can be easily drawn with a matrix of nodes. Following code shows this option:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix,positioning}
\begin{document}
\begin{tikzpicture}[
field/.style={draw, rounded corners, minimum height=8mm, anchor=center, align=center},
frame/.style={matrix of nodes, column sep=-\pgflinewidth, nodes={field}}]

\matrix (F1) [frame, row 1/.style={nodes={field, minimum height=12mm, text width=16mm}}]{
Reserved & {Areo \\ length} & DET & {Bob's\\ signature} & CPU & working \\};

\matrix (F2) [frame, below=of F1]{
Subframe 1 & Subframe 2 &|[minimum width=2cm]| \dots & Subframe n \\};

\matrix (F3) [frame, below=of F2]{
Memory & |[minimum width=6cm]| ALU \\};

\draw[dotted] (F1-1-1.south west) -- (F2-1-2.north west);
\draw[dotted] (F1-1-6.south east) -- (F2-1-2.north east);
\draw[dotted] (F2-1-1.south west) -- (F3-1-2.north west);
\draw[dotted] (F2-1-4.south east) -- (F3-1-2.north east);
\end{tikzpicture}
\end{document}


Update:

If no mimimum width or text width are fixed, all nodes are adjusted at their size. In case you want to break lines (like in Aero length), text width and {...} are necessary to make breakline command (\\) work.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix,positioning}
\begin{document}
\begin{tikzpicture}[
field/.style={draw, rounded corners, minimum height=8mm, anchor=center, align=center},
frame/.style={matrix of nodes, column sep=-\pgflinewidth, nodes={field}}]

\matrix (F1) [frame, row 1/.style={nodes={minimum height=12mm}}]{%
Reserved&|[text width=1cm]|{Areo\\ length}&DET&|[text width=14mm]|{Bob's\\ signature}&CPU&working\\};

\matrix (F2) [frame, below=of F1]{%
Subframe 1&Subframe 2&\dots&Subframe n\\};

\matrix (F3) [frame, below=of F2]{%
Memory&ALU\\};

\draw[dotted] (F1-1-1.south west) -- (F2-1-2.north west);
\draw[dotted] (F1-1-6.south east) -- (F2-1-2.north east);
\draw[dotted] (F2-1-1.south west) -- (F3-1-2.north west);
\draw[dotted] (F2-1-4.south east) -- (F3-1-2.north east);
\end{tikzpicture}
\end{document}


• How to resize the box length proportional to the inside text . – Litun Feb 4 '16 at 8:30
• @LitunJohn Take a look at updated answer. – Ignasi Feb 4 '16 at 8:44
• The dotted lines are going out of the rectangular frames in the upper lines. – Litun Feb 4 '16 at 10:08
• @LitunJohn They are going out because rounded corners doesn't change anchors, then south west is still at non-rounded-corner position. You can horizontally shift their ends with ([xshift=...]south.west) and similar constructions. – Ignasi Feb 4 '16 at 10:13