diff options
author | Karl Berry <karl@freefriends.org> | 2013-09-28 22:27:29 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-09-28 22:27:29 +0000 |
commit | 2466b9b1303df3fffaad52e2ccb3242d05d24bc2 (patch) | |
tree | 8d19ebe005f1de6eccba5187ebbd43526a2109e4 /Master/texmf-dist/tex/latex/sa-tikz | |
parent | fec82b85f65033c21b23fe0e71cacec0b78f3eae (diff) |
sa-tikz (28sep13)
git-svn-id: svn://tug.org/texlive/trunk@31787 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/sa-tikz')
-rw-r--r-- | Master/texmf-dist/tex/latex/sa-tikz/sa-tikz.sty | 227 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/sa-tikz/tikzlibraryswitching-architectures.code.tex | 223 |
2 files changed, 444 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/latex/sa-tikz/sa-tikz.sty b/Master/texmf-dist/tex/latex/sa-tikz/sa-tikz.sty index 8ddb5185519..b54c154e131 100644 --- a/Master/texmf-dist/tex/latex/sa-tikz/sa-tikz.sty +++ b/Master/texmf-dist/tex/latex/sa-tikz/sa-tikz.sty @@ -1,12 +1,12 @@ % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % -% Sa-TikZ package v0.5 * * (C) Claudio Fiandrino 2012 +% Sa-TikZ package v0.6 * * (C) Claudio Fiandrino 2012-2013 % % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{sa-tikz}[2013/1/3 v0.5 Switching architectures design library.] +\ProvidesPackage{sa-tikz}[2013/9/28 v0.6 Switching architectures design library.] \RequirePackage{tikz} -\usetikzlibrary{calc,positioning,decorations.pathreplacing} +\usetikzlibrary{backgrounds,calc,positioning,decorations.pathreplacing} % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % UTILITY @@ -28,6 +28,25 @@ \global\expandafter\edef\csname #2\endcsname{\res} } +% PGFMATHOMEGAROTATION: +% +% #1: number to be rotated +% #2: numbers of bits +% #3: output macro +% +\newcommand*{\pgfmathomegarotation}[3]{ + \pgfmathisodd{#1}{test} + \ifnum\test=1 + \pgfmathparse{#1/2 + 2^#2} + \else + \pgfmathparse{#1/2} + \fi + \pgfmathtruncatemacro\res\pgfmathresult + \global\expandafter\edef\csname #3\endcsname{\res} +} + + + % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % KEY DEFINITION - Design choices % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -1039,5 +1058,205 @@ } } +% BANYAN NETWORKS + +% BANYAN-OMEGA (thanks to Joćo Gabriel Reis) + +\tikzset{banyan omega/.code={ + % Number of ports per module + \pgfmathtruncatemacro{\m}{2} + + % Number of modules in each stage + \pgfmathtruncatemacro{\r}{\P/\m} + + % Number of stages + \pgfmathtruncatemacro{\stages}{round(log2(\P))} + + % Modules for all stages + \foreach \s [evaluate=\s as \numstage using int(\s-1)] in {0,...,\stages}{ + \ifnum\s=0 + % Invisible modules + \foreach \i in {1,...,\r}{ + \path let \n2={-\i*\moduleysep} in + node[rectangle,minimum height=\modulesize,#1,module opacity,xshift=\modulesize/2,yshift=1cm] + (r\s-\i) at +(-0.6*\modulexsep,\n2) {}; + + % Invisible modules outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)+(0.5*0.3*\pinlength,0)$) node[coordinate] (r\s-\i-front output-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$)node[coordinate](r\s-\i-output-\routput) {}; + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)-(0.5*0.3*\pinlength,0)$) node[circle,draw,scale=0.1] (r\s-\i-front input-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$)node[coordinate](r\s-\i-input-\routput) {}; + } + \fi + \ifnum\s=\stages + % Final Module + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} in node[module,#1,module opacity,yshift=1cm] (r\s-\i) at + +(\numstage*0.6*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % Final module inputs + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)-(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front input-\roneinput) {} -- + ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)$)node[circle,draw,scale=0.1] (r\s-\i-input-\roneinput) {}; + + % Final module outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)+(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front output-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$)node[circle,draw,scale=0.1] (r\s-\i-output-\routput) {}; + } + \fi + + \pgfmathparse{and(\s>0,\s<\stages)} + \let\cond\pgfmathresult + \ifnum\cond=1 + % Intermediate modules + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} in node[module,#1,module opacity,yshift=1cm] + (r\s-\i) at +(\numstage*0.6*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % Intermediate modules inputs + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)-(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front input-\roneinput) {} -- + ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)$)node[circle,draw,scale=0.1] (r\s-\i-input-\roneinput) {}; + + % Intermediate modules outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)+(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front output-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$)node[circle,draw,scale=0.1] (r\s-\i-output-\routput) {}; + } + \fi + } + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % Connections + \foreach \stg[evaluate=\stg as \prevstg using int(\stg - 1)] in {1,...,\stages}{ + \foreach \startmod in {1,...,\r}{ + \pgfmathomegarotation{2*(\startmod - 1)}{\stages - 1}{address} + \pgfmathtruncatemacro\endmodi{\address/2 + 1} + \pgfmathtruncatemacro\endmodii{\endmodi + \r/2} + \pgfmathtruncatemacro\cond{mod(\startmod,2)} + \ifnum\cond=0 + \draw(r\stg-\startmod-front input-1)--(r\prevstg-\endmodi-front output-2); + \draw(r\stg-\startmod-front input-2)--(r\prevstg-\endmodii-front output-2); + \else + \draw(r\stg-\startmod-front input-1)--(r\prevstg-\endmodi-front output-1); + \draw(r\stg-\startmod-front input-2)--(r\prevstg-\endmodii-front output-1); + \fi + } + } + \fi +} +} + +% BANYAN-FLIP + +\tikzset{banyan flip/.code={ + % Number of ports per module + \pgfmathtruncatemacro{\m}{2} + + % Number of modules in each stage + \pgfmathtruncatemacro{\r}{\P/\m} + + % Number of stages + \pgfmathtruncatemacro{\stages}{round(log2(\P))} + + % Modules for all stages + \foreach \s [evaluate=\s as \numstage using int(\s-1)] in {0,...,\stages}{ + \ifnum\s=0 + % Final Module + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} in node[module,#1,module opacity,yshift=1cm] (r\s-\i) at + +(\numstage*0.6*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % Final module inputs + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)-(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front input-\roneinput) {} -- + ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)$) node[circle,draw,scale=0.1] (r\s-\i-input-\roneinput) {}; + + % Final module outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)+(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front output-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$) node[circle,draw,scale=0.1] (r\s-\i-output-\routput) {}; + } + \fi + \ifnum\s=\stages + % Invisible modules + \foreach \i in {1,...,\r}{ + \path let \n2={-\i*\moduleysep} in + node[rectangle,minimum height=\modulesize,#1,module opacity,xshift=\modulesize/2,yshift=1cm] + (r\s-\i) at +(\numstage*0.415*\modulexsep,\n2) {}; + + % Invisible modules outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \rinterval using \rintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)$)node [coordinate](r\s-\i-input-\roneinput) {} -- + ($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)-(0.5*0.3*\pinlength,0)$) + node [coordinate] (r\s-\i-front input-\roneinput) {}; + \foreach \roneinput[evaluate=\roneinput as \rinterval using \rintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)$)node [coordinate](r\s-\i-input-\roneinput) {} -- + ($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)+(0.5*0.3*\pinlength,0)$) + node [circle,draw,scale=0.1] (r\s-\i-front output-\roneinput) {}; + } + \fi + \pgfmathparse{and(\s>0,\s<\stages)} + \let\cond\pgfmathresult + \ifnum\cond=1 + % Intermediate modules + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} in node[module,#1,module opacity,yshift=1cm] + (r\s-\i) at +(\numstage*0.6*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % Intermediate modules inputs + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)-(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front input-\roneinput) {} -- + ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)$) node[circle,draw,scale=0.1] (r\s-\i-input-\roneinput) {}; + + % Intermediate modules outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach\routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)+(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front output-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$) node[circle,draw,scale=0.1] (r\s-\i-output-\routput) {}; + } + \fi + } + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % Connections + \foreach \stg[evaluate=\stg as \prevstg using int(\stg - 1)] in {1,...,\stages}{ + \foreach \startmod in {1,...,\r}{ + \pgfmathomegarotation{2*(\startmod - 1)}{\stages - 1}{address} + \pgfmathtruncatemacro\endmodi{\address/2 + 1} + \pgfmathtruncatemacro\endmodii{\endmodi + \r/2} + \pgfmathtruncatemacro\cond{mod(\startmod,2)} + \ifnum\cond=0 + \draw(r\stg-\startmod-front input-1)--(r\prevstg-\endmodi-front output-2); + \draw(r\stg-\startmod-front input-2)--(r\prevstg-\endmodii-front output-2); + \else + \draw(r\stg-\startmod-front input-1)--(r\prevstg-\endmodi-front output-1); + \draw(r\stg-\startmod-front input-2)--(r\prevstg-\endmodii-front output-1); + \fi + } + } + \fi +} +} + + -\endinput +\endinput
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/sa-tikz/tikzlibraryswitching-architectures.code.tex b/Master/texmf-dist/tex/latex/sa-tikz/tikzlibraryswitching-architectures.code.tex index 2be4187b89a..9b42c78ed5e 100644 --- a/Master/texmf-dist/tex/latex/sa-tikz/tikzlibraryswitching-architectures.code.tex +++ b/Master/texmf-dist/tex/latex/sa-tikz/tikzlibraryswitching-architectures.code.tex @@ -1,6 +1,6 @@ % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % -% Sa-TikZ package v0.5 * * (C) Claudio Fiandrino 2012 +% Sa-TikZ package v0.6 * * (C) Claudio Fiandrino 2012-2013 % % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -30,6 +30,25 @@ \global\expandafter\edef\csname #2\endcsname{\res} } +% PGFMATHOMEGAROTATION: +% +% #1: number to be rotated +% #2: numbers of bits +% #3: output macro +% +\newcommand*{\pgfmathomegarotation}[3]{ + \pgfmathisodd{#1}{test} + \ifnum\test=1 + \pgfmathparse{#1/2 + 2^#2} + \else + \pgfmathparse{#1/2} + \fi + \pgfmathtruncatemacro\res\pgfmathresult + \global\expandafter\edef\csname #3\endcsname{\res} +} + + + % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % KEY DEFINITION - Design choices % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -1041,5 +1060,205 @@ } } +% BANYAN NETWORKS + +% BANYAN-OMEGA (thanks to Joćo Gabriel Reis) + +\tikzset{banyan omega/.code={ + % Number of ports per module + \pgfmathtruncatemacro{\m}{2} + + % Number of modules in each stage + \pgfmathtruncatemacro{\r}{\P/\m} + + % Number of stages + \pgfmathtruncatemacro{\stages}{round(log2(\P))} + + % Modules for all stages + \foreach \s [evaluate=\s as \numstage using int(\s-1)] in {0,...,\stages}{ + \ifnum\s=0 + % Invisible modules + \foreach \i in {1,...,\r}{ + \path let \n2={-\i*\moduleysep} in + node[rectangle,minimum height=\modulesize,#1,module opacity,xshift=\modulesize/2,yshift=1cm] + (r\s-\i) at +(-0.6*\modulexsep,\n2) {}; + + % Invisible modules outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)+(0.5*0.3*\pinlength,0)$) node[coordinate] (r\s-\i-front output-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$)node[coordinate](r\s-\i-output-\routput) {}; + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)-(0.5*0.3*\pinlength,0)$) node[circle,draw,scale=0.1] (r\s-\i-front input-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$)node[coordinate](r\s-\i-input-\routput) {}; + } + \fi + \ifnum\s=\stages + % Final Module + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} in node[module,#1,module opacity,yshift=1cm] (r\s-\i) at + +(\numstage*0.6*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % Final module inputs + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)-(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front input-\roneinput) {} -- + ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)$)node[circle,draw,scale=0.1] (r\s-\i-input-\roneinput) {}; + + % Final module outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)+(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front output-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$)node[circle,draw,scale=0.1] (r\s-\i-output-\routput) {}; + } + \fi + + \pgfmathparse{and(\s>0,\s<\stages)} + \let\cond\pgfmathresult + \ifnum\cond=1 + % Intermediate modules + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} in node[module,#1,module opacity,yshift=1cm] + (r\s-\i) at +(\numstage*0.6*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % Intermediate modules inputs + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)-(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front input-\roneinput) {} -- + ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)$)node[circle,draw,scale=0.1] (r\s-\i-input-\roneinput) {}; + + % Intermediate modules outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)+(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front output-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$)node[circle,draw,scale=0.1] (r\s-\i-output-\routput) {}; + } + \fi + } + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % Connections + \foreach \stg[evaluate=\stg as \prevstg using int(\stg - 1)] in {1,...,\stages}{ + \foreach \startmod in {1,...,\r}{ + \pgfmathomegarotation{2*(\startmod - 1)}{\stages - 1}{address} + \pgfmathtruncatemacro\endmodi{\address/2 + 1} + \pgfmathtruncatemacro\endmodii{\endmodi + \r/2} + \pgfmathtruncatemacro\cond{mod(\startmod,2)} + \ifnum\cond=0 + \draw(r\stg-\startmod-front input-1)--(r\prevstg-\endmodi-front output-2); + \draw(r\stg-\startmod-front input-2)--(r\prevstg-\endmodii-front output-2); + \else + \draw(r\stg-\startmod-front input-1)--(r\prevstg-\endmodi-front output-1); + \draw(r\stg-\startmod-front input-2)--(r\prevstg-\endmodii-front output-1); + \fi + } + } + \fi +} +} + +% BANYAN-FLIP + +\tikzset{banyan flip/.code={ + % Number of ports per module + \pgfmathtruncatemacro{\m}{2} + + % Number of modules in each stage + \pgfmathtruncatemacro{\r}{\P/\m} + + % Number of stages + \pgfmathtruncatemacro{\stages}{round(log2(\P))} + + % Modules for all stages + \foreach \s [evaluate=\s as \numstage using int(\s-1)] in {0,...,\stages}{ + \ifnum\s=0 + % Final Module + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} in node[module,#1,module opacity,yshift=1cm] (r\s-\i) at + +(\numstage*0.6*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % Final module inputs + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)-(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front input-\roneinput) {} -- + ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)$) node[circle,draw,scale=0.1] (r\s-\i-input-\roneinput) {}; + + % Final module outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)+(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front output-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$) node[circle,draw,scale=0.1] (r\s-\i-output-\routput) {}; + } + \fi + \ifnum\s=\stages + % Invisible modules + \foreach \i in {1,...,\r}{ + \path let \n2={-\i*\moduleysep} in + node[rectangle,minimum height=\modulesize,#1,module opacity,xshift=\modulesize/2,yshift=1cm] + (r\s-\i) at +(\numstage*0.415*\modulexsep,\n2) {}; + + % Invisible modules outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \rinterval using \rintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)$)node [coordinate](r\s-\i-input-\roneinput) {} -- + ($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)-(0.5*0.3*\pinlength,0)$) + node [coordinate] (r\s-\i-front input-\roneinput) {}; + \foreach \roneinput[evaluate=\roneinput as \rinterval using \rintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)$)node [coordinate](r\s-\i-input-\roneinput) {} -- + ($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)+(0.5*0.3*\pinlength,0)$) + node [circle,draw,scale=0.1] (r\s-\i-front output-\roneinput) {}; + } + \fi + \pgfmathparse{and(\s>0,\s<\stages)} + \let\cond\pgfmathresult + \ifnum\cond=1 + % Intermediate modules + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} in node[module,#1,module opacity,yshift=1cm] + (r\s-\i) at +(\numstage*0.6*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % Intermediate modules inputs + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] in {1,...,\m} + \draw ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)-(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front input-\roneinput) {} -- + ($(r\s-\i.north west)!\roneinterval!(r\s-\i.south west)$) node[circle,draw,scale=0.1] (r\s-\i-input-\roneinput) {}; + + % Intermediate modules outputs + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach\routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] in {1,...,\m} + \draw ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)+(0.5*0.3*\pinlength,0)$) node[coordinate](r\s-\i-front output-\routput) {} -- + ($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$) node[circle,draw,scale=0.1] (r\s-\i-output-\routput) {}; + } + \fi + } + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % Connections + \foreach \stg[evaluate=\stg as \prevstg using int(\stg - 1)] in {1,...,\stages}{ + \foreach \startmod in {1,...,\r}{ + \pgfmathomegarotation{2*(\startmod - 1)}{\stages - 1}{address} + \pgfmathtruncatemacro\endmodi{\address/2 + 1} + \pgfmathtruncatemacro\endmodii{\endmodi + \r/2} + \pgfmathtruncatemacro\cond{mod(\startmod,2)} + \ifnum\cond=0 + \draw(r\stg-\startmod-front input-1)--(r\prevstg-\endmodi-front output-2); + \draw(r\stg-\startmod-front input-2)--(r\prevstg-\endmodii-front output-2); + \else + \draw(r\stg-\startmod-front input-1)--(r\prevstg-\endmodi-front output-1); + \draw(r\stg-\startmod-front input-2)--(r\prevstg-\endmodii-front output-1); + \fi + } + } + \fi +} +} + + -\endinput +\endinput
\ No newline at end of file |