From 2a36de362639f891b12a07cb15896525e42e1465 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 3 Jan 2013 23:31:37 +0000 Subject: sa-tikz (3jan13) git-svn-id: svn://tug.org/texlive/trunk@28714 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/sa-tikz/README | 13 + .../doc/latex/sa-tikz/pgfmanual-en-macros.tex | 1206 ++++++++++++++++++++ .../texmf-dist/doc/latex/sa-tikz/sa-tikz-doc.pdf | Bin 0 -> 767226 bytes .../texmf-dist/doc/latex/sa-tikz/sa-tikz-doc.tex | 951 +++++++++++++++ Master/texmf-dist/tex/latex/sa-tikz/sa-tikz.sty | 1043 +++++++++++++++++ .../tikzlibraryswitching-architectures.code.tex | 1045 +++++++++++++++++ Master/tlpkg/bin/tlpkg-ctan-check | 6 +- Master/tlpkg/libexec/ctan2tds | 2 + Master/tlpkg/tlpsrc/collection-pictures.tlpsrc | 1 + Master/tlpkg/tlpsrc/sa-tikz.tlpsrc | 0 10 files changed, 4264 insertions(+), 3 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/sa-tikz/README create mode 100644 Master/texmf-dist/doc/latex/sa-tikz/pgfmanual-en-macros.tex create mode 100644 Master/texmf-dist/doc/latex/sa-tikz/sa-tikz-doc.pdf create mode 100644 Master/texmf-dist/doc/latex/sa-tikz/sa-tikz-doc.tex create mode 100644 Master/texmf-dist/tex/latex/sa-tikz/sa-tikz.sty create mode 100644 Master/texmf-dist/tex/latex/sa-tikz/tikzlibraryswitching-architectures.code.tex create mode 100644 Master/tlpkg/tlpsrc/sa-tikz.tlpsrc (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/sa-tikz/README b/Master/texmf-dist/doc/latex/sa-tikz/README new file mode 100644 index 00000000000..8d82de442fb --- /dev/null +++ b/Master/texmf-dist/doc/latex/sa-tikz/README @@ -0,0 +1,13 @@ +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% Sa-TikZ: TikZ library to draw switching architectures +% +% Version v0.5 03/01/2013 - (C) Claudio Fiandrino +% +% E-mail: claudio dot fiandrino at gmail dot com +% +% Released under the LaTeX Project Public License v1.3c or later +% See http://www.latex-project.org/lppl.txt +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% +% The library provides an easy way to draw switching architectures +% and to customize their aspect. diff --git a/Master/texmf-dist/doc/latex/sa-tikz/pgfmanual-en-macros.tex b/Master/texmf-dist/doc/latex/sa-tikz/pgfmanual-en-macros.tex new file mode 100644 index 00000000000..116cde6d9bf --- /dev/null +++ b/Master/texmf-dist/doc/latex/sa-tikz/pgfmanual-en-macros.tex @@ -0,0 +1,1206 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% $Header: /cvsroot/pgf/pgf/doc/generic/pgf/macros/pgfmanual-en-macros.tex,v 1.45 2009/11/15 13:13:24 ludewich Exp $ + + + +\providecommand\href[2]{\texttt{#1}} +\providecommand\hypertarget[2]{\texttt{#1}} +\providecommand\hyperlink[2]{\texttt{#1}} + + +\colorlet{examplefill}{yellow!80!black} +\definecolor{graphicbackground}{rgb}{0.96,0.96,0.8} +\definecolor{codebackground}{rgb}{0.8,0.8,1} + +\newenvironment{pgfmanualentry}{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}}{\endlist} +\newcommand\pgfmanualentryheadline[1]{\itemsep=0pt\parskip=0pt\item\strut{#1}\par\topsep=0pt} +\newcommand\pgfmanualbody{\parskip3pt} + + + +\newenvironment{pgflayout}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{\texttt{\string\pgfpagesuselayout\char`\{\declare{#1}\char`\}}\oarg{options}} + \index{#1@\protect\texttt{#1} layout}% + \index{Page layouts!#1@\protect\texttt{#1}}% + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + +\newenvironment{command}[1]{ + \begin{pgfmanualentry} + \extractcommand#1\@@ + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{commandlist}[1]{% + \begin{pgfmanualentry} + \foreach \xx in {#1} {% + \expandafter\extractcommand\xx\@@ + }% + \pgfmanualbody +}{% + \end{pgfmanualentry} +}% + +% \begin{internallist}[register]{\pgf@xa} +% \end{internallist} +% +% \begin{internallist}[register]{\pgf@xa,\pgf@xb} +% \end{internallist} +\newenvironment{internallist}[2][register]{% + \begin{pgfmanualentry} + \foreach \xx in {#2} {% + \expandafter\extractinternalcommand\expandafter{\xx}{#1}% + }% + \pgfmanualbody +}{% + \end{pgfmanualentry} +}% +\def\extractinternalcommand#1#2{% + \pgfmanualentryheadline{Internal #2 \declare{\texttt{\string#1}}}% + \removeats{#1}% + \index{Internals!\strippedat @\protect\myprintocmmand{\strippedat}}% + \index{\strippedat @\protect\myprintocmmand{\strippedat}}% + \pgfmanualpdflabel{\textbackslash\strippedat}{}% +} + +%% MW: START MATH MACROS +\def\mvar#1{{\ifmmode\textrm{\textit{#1}}\else\rmfamily\textit{#1}\fi}} + +\makeatletter + +\def\extractmathfunctionname#1{\extractmathfunctionname@#1(,)\tmpa\tmpb} +\def\extractmathfunctionname@#1(#2)#3\tmpb{\def\mathname{#1}} + +\makeatother + +\newenvironment{math-function}[1]{ + \def\mathdefaultname{#1} + \extractmathfunctionname{#1} + \edef\mathurl{{math:\mathname}}\expandafter\hypertarget\expandafter{\mathurl}{}% + \begin{pgfmanualentry} + \pgfmanualentryheadline{\texttt{#1}}% + \index{\mathname @\protect\texttt{\mathname} math function}% + \index{Math functions!\mathname @\protect\texttt{\mathname}}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\pgfmanualemptytext{} +\def\pgfmanualvbarvbar{\char`\|\char`\|} + +\newenvironment{math-operator}[4][]{% + \begin{pgfmanualentry} + \csname math#3operator\endcsname{#2}{#4} + \def\mathtest{#4}% + \ifx\mathtest\pgfmanualemptytext% + \def\mathtype{(#3 operator)} + \else% + \def\mathtype{(#3 operator; uses the \texttt{#4} function)} + \fi% + \pgfmanualentryheadline{\mathexample\hfill\mathtype}% + \def\mathtest{#1}% + \ifx\mathtest\pgfmanualemptytext% + \index{#2@\protect\texttt{#2} #3 math operator}% + \index{Math operators!#2@\protect\texttt{#2}}% + \fi% + \pgfmanualbody +} +{\end{pgfmanualentry}} + +\newenvironment{math-operators}[5][]{% + \begin{pgfmanualentry} + \csname math#4operator\endcsname{#2}{#3} + \def\mathtest{#5}% + \ifx\mathtest\pgfmanualemptytext% + \def\mathtype{(#4 operators)} + \else% + \def\mathtype{(#4 operators; use the \texttt{#5} function)} + \fi% + \pgfmanualentryheadline{\mathexample\hfill\mathtype}% + \def\mathtest{#1}% + \ifx\mathtest\pgfmanualemptytext% + \index{#2#3@\protect\texttt{#2\protect\ #3} #4 math operators}% + \index{Math operators!#2#3@\protect\texttt{#2\protect\ #3}}% + \fi% + \pgfmanualbody +} +{\end{pgfmanualentry}} + +\def\mathinfixoperator#1#2{% + \def\mathoperator{\texttt{#1}}% + \def\mathexample{\mvar{x}\space\texttt{#1}\space\mvar{y}}% +} + +\def\mathprefixoperator#1#2{% + \def\mathoperator{\texttt{#1}}% + \def\mathexample{\texttt{#1}\mvar{x}}% +} + +\def\mathpostfixoperator#1#2{% + \def\mathoperator{\texttt{#1}} + \def\mathexample{\mvar{x}\texttt{#1}}% +} + +\def\mathgroupoperator#1#2{% + \def\mathoperator{\texttt{#1\ #2}}% + \def\mathexample{\texttt{#1}\mvar{x}\texttt{#2}}% +} + +\expandafter\let\csname matharray accessoperator\endcsname=\mathgroupoperator +\expandafter\let\csname matharrayoperator\endcsname=\mathgroupoperator + +\def\mathconditionaloperator#1#2{% + \def\mathoperator{#1\space#2} + \def\mathexample{\mvar{x}\ \texttt{#1}\ \mvar{y}\ {\texttt{#2}}\ \mvar{z}} +} + +\newcommand\mathcommand[1][\mathdefaultname]{% + \expandafter\makemathcommand#1(\empty)\stop% + \expandafter\extractcommand\mathcommandname\@@% + \medskip +} +\makeatletter + +\def\makemathcommand#1(#2)#3\stop{% + \expandafter\def\expandafter\mathcommandname\expandafter{\csname pgfmath#1\endcsname}% + \ifx#2\empty% + \else% + \@makemathcommand#2,\stop, + \fi} +\def\@makemathcommand#1,{% + \ifx#1\stop% + \else% + \expandafter\def\expandafter\mathcommandname\expandafter{\mathcommandname{\ttfamily\char`\{#1\char`\}}}% + \expandafter\@makemathcommand% + \fi} +\makeatother + +\def\calcname{\textsc{calc}} +%% MW: END MATH MACROS + + +\def\extractcommand#1#2\@@{% + \pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}% + \removeats{#1}% + \index{\strippedat @\protect\myprintocmmand{\strippedat}} + \pgfmanualpdflabel{\textbackslash\strippedat}{}% +} + + +% \begin{environment}{{name}\marg{arguments}} +\renewenvironment{environment}[1]{ + \begin{pgfmanualentry} + \extractenvironement#1\@@ + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\extractenvironement#1#2\@@{% + \pgfmanualentryheadline{{\ttfamily\char`\\begin\char`\{\declare{#1}\char`\}}#2}% + \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% + \pgfmanualentryheadline{{\ttfamily\char`\\end\char`\{\declare{#1}\char`\}}}% + \index{#1@\protect\texttt{#1} environment}% + \index{Environments!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% +} + + +\newenvironment{plainenvironment}[1]{ + \begin{pgfmanualentry} + \extractplainenvironement#1\@@ + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\extractplainenvironement#1#2\@@{% + \pgfmanualentryheadline{{\ttfamily\declare{\char`\\#1}}#2}% + \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% + \pgfmanualentryheadline{{\ttfamily\declare{\char`\\end#1}}}% + \index{#1@\protect\texttt{#1} environment}% + \index{Environments!#1@\protect\texttt{#1}}% +} + + +\newenvironment{contextenvironment}[1]{ + \begin{pgfmanualentry} + \extractcontextenvironement#1\@@ + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\extractcontextenvironement#1#2\@@{% + \pgfmanualentryheadline{{\ttfamily\declare{\char`\\start#1}}#2}% + \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% + \pgfmanualentryheadline{{\ttfamily\declare{\char`\\stop#1}}}% + \index{#1@\protect\texttt{#1} environment}% + \index{Environments!#1@\protect\texttt{#1}}} + + +\newenvironment{shape}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Shape {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} shape}% + \index{Shapes!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{shading}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Shading {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} shading}% + \index{Shadings!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + +\newenvironment{dataformat}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Format {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} format}% + \index{Formats!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{handler}[1]{ + \begin{pgfmanualentry} + \extracthandler#1\@nil% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\gobble#1{} +\def\extracthandler#1#2\@nil{% + \pgfmanualentryheadline{Key handler \meta{key}{\ttfamily/\declare{#1}}#2}% + \index{\gobble#1@\protect\texttt{#1} handler}% + \index{Key handlers!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{/handlers/#1}% +} + + +\makeatletter + + +\newenvironment{stylekey}[1]{ + \begin{pgfmanualentry} + \def\extrakeytext{style, } + \extractkey#1\@nil% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\choicesep{$\vert$}% +\def\choicearg#1{\texttt{#1}} + +\newif\iffirstchoice + +% \mchoice{choice1,choice2,choice3} +\newcommand\mchoice[1]{% + \begingroup + \firstchoicetrue + \foreach \mchoice@ in {#1} {% + \iffirstchoice + \global\firstchoicefalse + \else + \choicesep + \fi + \choicearg{\mchoice@}% + }% + \endgroup +}% + +% \begin{key}{/path/x=value} +% \begin{key}{/path/x=value (initially XXX)} +% \begin{key}{/path/x=value (default XXX)} +\newenvironment{key}[1]{ + \begin{pgfmanualentry} + \def\extrakeytext{} + %\def\altpath{\emph{\color{gray}or}}% + \extractkey#1\@nil% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +% \insertpathifneeded{a key}{/pgf} -> assign mykey={/pgf/a key} +% \insertpathifneeded{/tikz/a key}{/pgf} -> assign mykey={/tikz/a key} +% +% #1: the key +% #2: a default path (or empty) +\def\insertpathifneeded#1#2{% + \def\insertpathifneeded@@{#2}% + \ifx\insertpathifneeded@@\empty + \def\mykey{#1}% + \else + \insertpathifneeded@#2\@nil + \ifpgfutil@in@ + \def\mykey{#2/#1}% + \else + \def\mykey{#1}% + \fi + \fi +}% +\def\insertpathifneeded@#1#2\@nil{% + \def\insertpathifneeded@@{#1}% + \def\insertpathifneeded@@@{/}% + \ifx\insertpathifneeded@@\insertpathifneeded@@@ + \pgfutil@in@true + \else + \pgfutil@in@false + \fi +}% + +% \begin{keylist}[default path] +% {/path/option 1=value,/path/option 2=value2} +% \end{keylist} +\newenvironment{keylist}[2][]{% + \begin{pgfmanualentry} + \def\extrakeytext{}% + \foreach \xx in {#2} {% + \expandafter\insertpathifneeded\expandafter{\xx}{#1}% + \expandafter\extractkey\mykey\@nil% + }% + \pgfmanualbody +}{% + \end{pgfmanualentry} +}% + +\def\extractkey#1\@nil{% + \pgfutil@in@={#1}% + \ifpgfutil@in@% + \extractkeyequal#1\@nil + \else% + \pgfutil@in@{(initial}{#1}% + \ifpgfutil@in@% + \extractequalinitial#1\@nil% + \else + \pgfmanualentryheadline{{\ttfamily\declare{#1}}\hfill(\extrakeytext no value)}% + \def\mykey{#1}% + \def\mypath{}% + \def\myname{}% + \firsttimetrue% + \decompose#1/\nil% + \fi + \fi% +} + +\def\extractkeyequal#1=#2\@nil{% + \pgfutil@in@{(default}{#2}% + \ifpgfutil@in@% + \extractdefault{#1}#2\@nil% + \else% + \pgfutil@in@{(initial}{#2}% + \ifpgfutil@in@% + \extractinitial{#1}#2\@nil% + \else + \pgfmanualentryheadline{{\ttfamily\declare{#1}=}#2\hfill(\extrakeytext no default)}% + \fi% + \fi% + \def\mykey{#1}% + \def\mypath{}% + \def\myname{}% + \firsttimetrue% + \decompose#1/\nil% +} + +\def\extractdefault#1#2(default #3)\@nil{% + \pgfmanualentryheadline{{\ttfamily\declare{#1}\opt{=}}\opt{#2}\hfill (\extrakeytext default {\ttfamily#3})}% +} + +\def\extractinitial#1#2(initially #3)\@nil{% + \pgfmanualentryheadline{{\ttfamily\declare{#1}=}#2\hfill (\extrakeytext no default, initially {\ttfamily#3})}% +} + +\def\extractequalinitial#1 (initially #2)\@nil{% + \pgfmanualentryheadline{{\ttfamily\declare{#1}}\hfill (\extrakeytext initially {\ttfamily#2})}% + \def\mykey{#1}% + \def\mypath{}% + \def\myname{}% + \firsttimetrue% + \decompose#1/\nil% +} + +% Introduces a key alias '/#1/' +% to be used inside of \begin{key} ... \end{key} +\def\keyalias#1{\vspace{-3pt}\item{\small alias {\ttfamily/#1/\myname}}\vspace{-2pt}\par + \pgfmanualpdflabel{/#1/\myname}{}% +} + +\newif\iffirsttime + +\makeatother + +\def\decompose/#1/#2\nil{% + \def\test{#2}% + \ifx\test\empty% + % aha. + \index{#1@\protect\texttt{#1} key}% + \index{\mypath#1@\protect\texttt{#1}}% + \def\myname{#1}% + \else% + \iffirsttime + \begingroup + % also make a pdf link anchor with full key path. + \def\hyperlabelwithoutslash##1/\nil{% + \pgfmanualpdflabel{##1}{}% + }% + \hyperlabelwithoutslash/#1/#2\nil + \endgroup + \def\mypath{#1@\protect\texttt{/#1/}!}% + \firsttimefalse + \else + \expandafter\def\expandafter\mypath\expandafter{\mypath#1@\protect\texttt{#1/}!}% + \fi + \def\firsttime{} + \decompose/#2\nil% + \fi% +} + +\def\indexkey#1{% + \def\mypath{}% + \decompose#1/\nil% +} + +\newenvironment{predefinedmethod}[1]{ + \begin{pgfmanualentry} + \extractpredefinedmethod#1\@nil + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} +\def\extractpredefinedmethod#1(#2)\@nil{% + \pgfmanualentryheadline{Method \declare{\ttfamily #1}\texttt(#2\texttt) \hfill(predefined for all classes)} + \index{#1@\protect\texttt{#1} method}% + \index{Methods!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% +} + + +\newenvironment{ooclass}[1]{ + \begin{pgfmanualentry} + \def\currentclass{#1} + \pgfmanualentryheadline{Class \declare{\texttt{#1}}} + \index{#1@\protect\texttt{#1} class}% + \index{Class #1@Class \protect\texttt{#1}}% + \index{Classes!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{method}[1]{ + \begin{pgfmanualentry} + \extractmethod#1\@nil + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} +\def\extractmethod#1(#2)\@nil{% + \def\test{#1} + \ifx\test\currentclass + \pgfmanualentryheadline{Constructor \declare{\ttfamily #1}\texttt(#2\texttt)} + \else + \pgfmanualentryheadline{Method \declare{\ttfamily #1}\texttt(#2\texttt)} + \fi + \index{#1@\protect\texttt{#1} method}% + \index{Methods!#1@\protect\texttt{#1}} + \index{Class \currentclass!#1@\protect\texttt{#1}}% + \pgfmanualpdflabel{#1}{}% +} + +\newenvironment{attribute}[1]{ + \begin{pgfmanualentry} + \extractattribute#1\@nil + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} +\def\extractattribute#1=#2;\@nil{% + \def\test{#2}% + \ifx\test\@empty + \pgfmanualentryheadline{Private attribute \declare{\ttfamily #1} \hfill (initially empty)} + \else + \pgfmanualentryheadline{Private attribute \declare{\ttfamily #1} \hfill (initially {\ttfamily #2})} + \fi + \index{#1@\protect\texttt{#1} attribute}% + \index{Attributes!#1@\protect\texttt{#1}} + \index{Class \currentclass!#1@\protect\texttt{#1}}% + \pgfmanualpdflabel{#1}{}% +} + + + +\newenvironment{predefinednode}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Predefined node {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} node}% + \index{Predefined node!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{coordinatesystem}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Coordinate system {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} coordinate system}% + \index{Coordinate systems!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{snake}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Snake {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} snake}% + \index{Snakes!#1@\protect\texttt{#1}} + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{decoration}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Decoration {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} decoration}% + \index{Decorations!#1@\protect\texttt{#1}} + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + +\def\pgfmanualbar{\char`\|} +\makeatletter +\newenvironment{pathoperation}[3][]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\path}\ + \ \dots} + \declare{\texttt{#2}}#3\ \textcolor{gray}{\dots\texttt{;}}}% + \def\pgfmanualtest{#1}% + \ifx\pgfmanualtest\@empty% + \index{#2@\protect\texttt{#2} path operation}% + \index{Path operations!#2@\protect\texttt{#2}}% + \pgfmanualpdflabel{#2}{}% + \fi% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} +\newenvironment{datavisualizationoperation}[3][]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\datavisualization}\ + \ \dots} + \declare{\texttt{#2}}#3\ \textcolor{gray}{\dots\texttt{;}}}% + \def\pgfmanualtest{#1}% + \ifx\pgfmanualtest\@empty% + \index{#2@\protect\texttt{#2} (data visualization)}% + \index{Data visualization!#2@\protect\texttt{#2}}% + \pgfmanualpdflabel{#2}{}% + \fi% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} +\makeatother + +\def\extractcommand#1#2\@@{% + \pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}% + \removeats{#1}% + \index{\strippedat @\protect\myprintocmmand{\strippedat}} + \pgfmanualpdflabel{\textbackslash\strippedat}{}% +} + +\def\doublebs{\texttt{\char`\\\char`\\}} + + +\newenvironment{package}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{{\ttfamily\char`\\usepackage\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space \LaTeX}} + \index{#1@\protect\texttt{#1} package}% + \index{Packages and files!#1@\protect\texttt{#1}}% + \pgfmanualentryheadline{{\ttfamily\char`\\input \declare{#1}.tex\space\space\space \char`\%\space\space plain \TeX}} + \pgfmanualentryheadline{{\ttfamily\char`\\usemodule[\declare{#1}]\space\space \char`\%\space\space Con\TeX t}} + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + +\newenvironment{pgfmodule}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{{\ttfamily\char`\\usepgfmodule\char`\{\declare{#1}\char`\}\space\space\space + \char`\%\space\space \LaTeX\space and plain \TeX\space and pure pgf}} + \index{#1@\protect\texttt{#1} module}% + \index{Modules!#1@\protect\texttt{#1}}% + \pgfmanualentryheadline{{\ttfamily\char`\\usepgfmodule[\declare{#1}]\space\space \char`\%\space\space Con\TeX t\space and pure pgf}} + \pgfmanualbody + \pgfmanualpdflabel{#1}{}% +} +{ + \end{pgfmanualentry} +} + +\newenvironment{pgflibrary}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{{\ttfamily\char`\\usepgflibrary\char`\{\declare{#1}\char`\}\space\space\space + \char`\%\space\space \LaTeX\space and plain \TeX\space and pure pgf}} + \index{#1@\protect\texttt{#1} library}% + \index{Libraries!#1@\protect\texttt{#1}}% + \pgfmanualentryheadline{{\ttfamily\char`\\usepgflibrary[\declare{#1}]\space\space \char`\%\space\space Con\TeX t\space and pure pgf}} + \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{#1}\char`\}\space\space + \char`\%\space\space \LaTeX\space and plain \TeX\space when using \tikzname}} + \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{#1}]\space + \char`\%\space\space Con\TeX t\space when using \tikzname}} + \pgfmanualbody + \pgfmanualpdflabel{#1}{}% +} +{ + \end{pgfmanualentry} +} + +\newenvironment{tikzlibrary}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space \LaTeX\space and plain \TeX}} + \index{#1@\protect\texttt{#1} library}% + \index{Libraries!#1@\protect\texttt{#1}}% + \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{#1}]\space \char`\%\space\space Con\TeX t}} + \pgfmanualbody + \pgfmanualpdflabel{#1}{}% +} +{ + \end{pgfmanualentry} +} + + + +\newenvironment{filedescription}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{File {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} file}% + \index{Packages and files!#1@\protect\texttt{#1}}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + +\newenvironment{packageoption}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{{\ttfamily\char`\\usepackage[\declare{#1}]\char`\{pgf\char`\}}} + \index{#1@\protect\texttt{#1} package option}% + \index{Package options for \textsc{pgf}!#1@\protect\texttt{#1}}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + + +\newcommand\opt[1]{{\color{black!50!green}#1}} +\newcommand\ooarg[1]{{\ttfamily[}\meta{#1}{\ttfamily]}} + +\def\opt{\afterassignment\pgfmanualopt\let\next=} +\def\pgfmanualopt{\ifx\next\bgroup\bgroup\color{black!50!green}\else{\color{black!50!green}\next}\fi} + + + +\def\beamer{\textsc{beamer}} +\def\pdf{\textsc{pdf}} +\def\eps{\texttt{eps}} +\def\pgfname{\textsc{pgf}} +\def\tikzname{Ti\emph{k}Z} +\def\pstricks{\textsc{pstricks}} +\def\prosper{\textsc{prosper}} +\def\seminar{\textsc{seminar}} +\def\texpower{\textsc{texpower}} +\def\foils{\textsc{foils}} + +{ + \makeatletter + \global\let\myempty=\@empty + \global\let\mygobble=\@gobble + \catcode`\@=12 + \gdef\getridofats#1@#2\relax{% + \def\getridtest{#2}% + \ifx\getridtest\myempty% + \expandafter\def\expandafter\strippedat\expandafter{\strippedat#1} + \else% + \expandafter\def\expandafter\strippedat\expandafter{\strippedat#1\protect\printanat} + \getridofats#2\relax% + \fi% + } + + \gdef\removeats#1{% + \let\strippedat\myempty% + \edef\strippedtext{\stripcommand#1}% + \expandafter\getridofats\strippedtext @\relax% + } + + \gdef\stripcommand#1{\expandafter\mygobble\string#1} +} + +\def\printanat{\char`\@} + +\def\declare{\afterassignment\pgfmanualdeclare\let\next=} +\def\pgfmanualdeclare{\ifx\next\bgroup\bgroup\color{red!75!black}\else{\color{red!75!black}\next}\fi} + + +\let\textoken=\command +\let\endtextoken=\endcommand + +\def\myprintocmmand#1{\texttt{\char`\\#1}} + +\def\example{\par\smallskip\noindent\textit{Example: }} +\def\themeauthor{\par\smallskip\noindent\textit{Theme author: }} + + +\def\indexoption#1{% + \index{#1@\protect\texttt{#1} option}% + \index{Graphic options and styles!#1@\protect\texttt{#1}}% +} + +\def\itemcalendaroption#1{\item \declare{\texttt{#1}}% + \index{#1@\protect\texttt{#1} date test}% + \index{Date tests!#1@\protect\texttt{#1}}% +} + + + +\def\class#1{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}% +\extractclass#1@\par\topsep=0pt} +\def\endclass{\endlist} +\def\extractclass#1#2@{% +\item{{{\ttfamily\char`\\documentclass}#2{\ttfamily\char`\{\declare{#1}\char`\}}}}% + \index{#1@\protect\texttt{#1} class}% + \index{Classes!#1@\protect\texttt{#1}}} + +\def\partname{Part} + +\makeatletter +\def\index@prologue{\section*{Index}\addcontentsline{toc}{section}{Index} + This index only contains automatically generated entries. A good + index should also contain carefully selected keywords. This index is + not a good index. + \bigskip +} +\c@IndexColumns=2 + \def\theindex{\@restonecoltrue + \columnseprule \z@ \columnsep 29\p@ + \twocolumn[\index@prologue]% + \parindent -30pt + \columnsep 15pt + \parskip 0pt plus 1pt + \leftskip 30pt + \rightskip 0pt plus 2cm + \small + \def\@idxitem{\par}% + \let\item\@idxitem \ignorespaces} + \def\endtheindex{\onecolumn} +\def\noindexing{\let\index=\@gobble} + + + +\newcommand\symarrow[1]{ + \index{#1@\protect\texttt{#1} arrow tip}% + \index{Arrow tips!#1@\protect\texttt{#1}} + \texttt{#1}& yields thick + \begin{tikzpicture}[arrows={#1-#1},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} and thin + \begin{tikzpicture}[arrows={#1-#1},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} +} +\newcommand\symarrowdouble[1]{ + \index{#1@\protect\texttt{#1} arrow tip}% + \index{Arrow tips!#1@\protect\texttt{#1}} + \texttt{#1}& yields thick + \begin{tikzpicture}[arrows={#1-#1},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} + and thin + \begin{tikzpicture}[arrows={#1-#1},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture}, double + \begin{tikzpicture}[arrows={#1-#1},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} and + \begin{tikzpicture}[arrows={#1-#1},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} +} + +\newcommand\sarrow[2]{ + \index{#1@\protect\texttt{#1} arrow tip}% + \index{Arrow tips!#1@\protect\texttt{#1}} + \index{#2@\protect\texttt{#2} arrow tip}% + \index{Arrow tips!#2@\protect\texttt{#2}} + \texttt{#1-#2}& yields thick + \begin{tikzpicture}[arrows={#1-#2},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} and thin + \begin{tikzpicture}[arrows={#1-#2},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} +} + +\newcommand\sarrowdouble[2]{ + \index{#1@\protect\texttt{#1} arrow tip}% + \index{Arrow tips!#1@\protect\texttt{#1}} + \index{#2@\protect\texttt{#2} arrow tip}% + \index{Arrow tips!#2@\protect\texttt{#2}} + \texttt{#1-#2}& yields thick + \begin{tikzpicture}[arrows={#1-#2},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} and thin + \begin{tikzpicture}[arrows={#1-#2},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture}, double + \begin{tikzpicture}[arrows={#1-#2},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} and + \begin{tikzpicture}[arrows={#1-#2},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} +} + +\newcommand\carrow[1]{ + \index{#1@\protect\texttt{#1} arrow tip}% + \index{Arrow tips!#1@\protect\texttt{#1}} + \texttt{#1}& yields for line width 1ex + \begin{tikzpicture}[arrows={#1-#1},line width=1ex,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1.5cm,2ex); + \draw (0pt,.5ex) -- (1.5cm,.5ex); + \end{tikzpicture} +} +\def\myvbar{\char`\|} +\newcommand\plotmarkentry[1]{% + \index{#1@\protect\texttt{#1} plot mark}% + \index{Plot marks!#1@\protect\texttt{#1}} + \texttt{\char`\\pgfuseplotmark\char`\{\declare{#1}\char`\}} & + \tikz\draw[color=black!25] plot[mark=#1,mark options={fill=examplefill,draw=black}] coordinates{(0,0) (.5,0.2) (1,0) (1.5,0.2)};\\ +} +\newcommand\plotmarkentrytikz[1]{% + \index{#1@\protect\texttt{#1} plot mark}% + \index{Plot marks!#1@\protect\texttt{#1}} + \texttt{mark=\declare{#1}} & \tikz\draw[color=black!25] + plot[mark=#1,mark options={fill=examplefill,draw=black}] + coordinates {(0,0) (.5,0.2) (1,0) (1.5,0.2)};\\ +} + + + +\ifx\scantokens\@undefined + \PackageError{pgfmanual-macros}{You need to use extended latex + (elatex) or (pdfelatex) to process this document}{} +\fi + +\begingroup +\catcode`|=0 +\catcode`[= 1 +\catcode`]=2 +\catcode`\{=12 +\catcode `\}=12 +\catcode`\\=12 |gdef|find@example#1\end{codeexample}[|endofcodeexample[#1]] +|endgroup + +% define \returntospace. +% +% It should define NEWLINE as {}, spaces and tabs as \space. +\begingroup +\catcode`\^=7 +\catcode`\^^M=13 +\catcode`\^^I=13 +\catcode`\ =13% +\gdef\returntospace{\catcode`\ =13\def {\space}\catcode`\^^I=13\def^^I{\space}} +\gdef\showreturn{\show^^M} +\endgroup + +\begingroup +\catcode`\%=13 +\catcode`\^^M=13 +\gdef\commenthandler{\catcode`\%=13\def%{\@gobble@till@return}} +\gdef\@gobble@till@return#1^^M{} +\gdef\@gobble@till@return@ignore#1^^M{\ignorespaces} +\gdef\typesetcomment{\catcode`\%=13\def%{\@typeset@till@return}} +\gdef\@typeset@till@return#1^^M{{\def%{\char`\%}\textsl{\char`\%#1}}\par} +\endgroup + +% Define tab-implementation functions +% \codeexample@tabinit@replacementchars@ +% and +% \codeexample@tabinit@catcode@ +% +% They should ONLY be used in case that tab replacement is active. +% +% This here is merely a preparation step. +% +% Idea: +% \codeexample@tabinit@catcode@ will make TAB active +% and +% \codeexample@tabinit@replacementchars@ will insert as many spaces as +% /codeexample/tabsize contains. +{ +\catcode`\^^I=13 +% ATTENTION: do NOT use tabs in these definitions!! +\gdef\codeexample@tabinit@replacementchars@{% + \begingroup + \count0=\pgfkeysvalueof{/codeexample/tabsize}\relax + \toks0={}% + \loop + \ifnum\count0>0 + \advance\count0 by-1 + \toks0=\expandafter{\the\toks0\ }% + \repeat + \xdef\codeexample@tabinit@replacementchars@@{\the\toks0}% + \endgroup + \let^^I=\codeexample@tabinit@replacementchars@@ +}% +\gdef\codeexample@tabinit@catcode@{\catcode`\^^I=13}% +}% + +% Called after any options have been set. It assigns +% \codeexample@tabinit@catcode +% and +% \codeexample@tabinit@replacementchars +% which are used inside of +%\begin{codeexample} +% ... +%\end{codeexample} +% +% \codeexample@tabinit@catcode is either \relax or it makes tab +% active. +% +% \codeexample@tabinit@replacementchars is either \relax or it inserts +% a proper replacement sequence for tabs (as many spaces as +% configured) +\def\codeexample@tabinit{% + \ifnum\pgfkeysvalueof{/codeexample/tabsize}=0\relax + \let\codeexample@tabinit@replacementchars=\relax + \let\codeexample@tabinit@catcode=\relax + \else + \let\codeexample@tabinit@catcode=\codeexample@tabinit@catcode@ + \let\codeexample@tabinit@replacementchars=\codeexample@tabinit@replacementchars@ + \fi +} + +\pgfqkeys{/codeexample}{% + width/.code= {\setlength\codeexamplewidth{#1}}, + graphic/.code= {\colorlet{graphicbackground}{#1}}, + code/.code= {\colorlet{codebackground}{#1}}, + execute code/.is if=code@execute, + code only/.code= {\code@executefalse}, + pre/.store in=\code@pre, + post/.store in=\code@post, + % #1 is the *complete* environment contents as it shall be + % typeset. In particular, the catcodes are NOT the normal ones. + typeset listing/.code= {#1}, + render instead/.store in=\code@render, + vbox/.code= {\def\code@pre{\vbox\bgroup\setlength{\hsize}{\linewidth-6pt}}\def\code@post{\egroup}}, + ignorespaces/.code= {\let\@gobble@till@return=\@gobble@till@return@ignore}, + leave comments/.code= {\def\code@catcode@hook{\catcode`\%=12}\let\commenthandler=\relax\let\typesetcomment=\relax}, + tabsize/.initial=0,% FIXME : this here is merely used for indentation. It is just a TAB REPLACEMENT. + every codeexample/.style={width=4cm+7pt}, +} + +\let\code@pre\pgfutil@empty +\let\code@post\pgfutil@empty +\let\code@render\pgfutil@empty +\def\code@catcode@hook{} + +\newdimen\codeexamplewidth +\newif\ifcode@execute +\newbox\codeexamplebox +\def\codeexample[#1]{% + \begingroup% + \code@executetrue + \pgfqkeys{/codeexample}{every codeexample,#1}% + \codeexample@tabinit% assigns \codeexample@tabinit@[catcode,replacementchars] + \parindent0pt + \begingroup% + \par% + \medskip% + \let\do\@makeother% + \dospecials% + \obeylines% + \@vobeyspaces% + \catcode`\%=13% + \catcode`\^^M=13% + \code@catcode@hook% + \codeexample@tabinit@catcode + \relax% + \find@example} +\def\endofcodeexample#1{% + \endgroup% + \ifcode@execute% + \setbox\codeexamplebox=\hbox{% + \ifx\code@render\pgfutil@empty% + {% + {% + \returntospace% + \commenthandler% + \xdef\code@temp{#1}% removes returns and comments + }% + \catcode`\^^M=9% + \colorbox{graphicbackground}{\color{black}\ignorespaces% + \code@pre\expandafter\scantokens\expandafter{\code@temp\ignorespaces}\code@post\ignorespaces}% + }% + \else% + \colorbox{graphicbackground}{\color{black}\ignorespaces% + \code@render}% + \fi% + }% + \ifdim\wd\codeexamplebox>\codeexamplewidth% + \def\code@start{\par}% + \def\code@flushstart{}\def\code@flushend{}% + \def\code@mid{\parskip2pt\par\noindent}% + \def\code@width{\linewidth-6pt}% + \def\code@end{}% + \else% + \def\code@start{% + \linewidth=\textwidth% + \parshape \@ne 0pt \linewidth + \leavevmode% + \hbox\bgroup}% + \def\code@flushstart{\hfill}% + \def\code@flushend{\hbox{}}% + \def\code@mid{\hskip6pt}% + \def\code@width{\linewidth-12pt-\codeexamplewidth}% + \def\code@end{\egroup}% + \fi% + \code@start% + \noindent% + \begin{minipage}[t]{\codeexamplewidth}\raggedright + \hrule width0pt% + \footnotesize\vskip-1em% + \code@flushstart\box\codeexamplebox\code@flushend% + \vskip-1ex + \leavevmode% + \end{minipage}% + \else% + \def\code@mid{\par} + \def\code@width{\linewidth-6pt} + \def\code@end{} + \fi% + \code@mid% + \colorbox{codebackground}{% + \begin{minipage}[t]{\code@width}% + {% + \let\do\@makeother + \dospecials + \frenchspacing\@vobeyspaces + \normalfont\ttfamily\footnotesize + \typesetcomment% + \codeexample@tabinit@replacementchars + \@tempswafalse + \def\par{% + \if@tempswa + \leavevmode \null \@@par\penalty\interlinepenalty + \else + \@tempswatrue + \ifhmode\@@par\penalty\interlinepenalty\fi + \fi}% + \obeylines + \everypar \expandafter{\the\everypar \unpenalty}% + \pgfkeysvalueof{/codeexample/typeset listing/.@cmd}{#1}\pgfeov + } + \end{minipage}}% + \code@end% + \par% + \medskip + \end{codeexample} +} + +\def\endcodeexample{\endgroup} + + +\makeatother + +\usepackage{pgfmanual} + +\makeatletter +% \pgfautoxrefs will be defined by 'make dist' +\pgfutil@ifundefined{pgfautoxrefs}{% + \def\pgfmanualpdflabel#1#2{#2}% NO-OP + \def\pgfmanualpdfref#1#2{#2}% + \pgfkeys{ + /pdflinks/codeexample links=false,% DISABLED. + }% +}{} +\makeatother + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "beameruserguide" +%%% End: diff --git a/Master/texmf-dist/doc/latex/sa-tikz/sa-tikz-doc.pdf b/Master/texmf-dist/doc/latex/sa-tikz/sa-tikz-doc.pdf new file mode 100644 index 00000000000..9a8b3359610 Binary files /dev/null and b/Master/texmf-dist/doc/latex/sa-tikz/sa-tikz-doc.pdf differ diff --git a/Master/texmf-dist/doc/latex/sa-tikz/sa-tikz-doc.tex b/Master/texmf-dist/doc/latex/sa-tikz/sa-tikz-doc.tex new file mode 100644 index 00000000000..51901421f07 --- /dev/null +++ b/Master/texmf-dist/doc/latex/sa-tikz/sa-tikz-doc.tex @@ -0,0 +1,951 @@ +\pdfminorversion=5 +\pdfobjcompresslevel=2 +\documentclass{ltxdoc} +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} +\usepackage{amsmath} +\usepackage{lmodern} +\usepackage[ruled, lined,linesnumbered]{algorithm2e} + +%% Use the tikz package and loading the library +\usepackage{tikz} +\usetikzlibrary{switching-architectures} + +%% Loading only the package +%\usepackage{sa-tikz} + +\usepackage{calc} +\usepackage{imakeidx} + +\usepackage[naturalnames]{hyperref} + \hypersetup{% + colorlinks=true, + linkcolor=blue, + filecolor=blue, + urlcolor=blue, + citecolor=blue, + pdfborder=0 0 0, + } + +% dedicated commands: +\newcommand\Tikz{Ti\textit kZ} +\newcommand{\saTikZ}{S\textit{a}-\Tikz} + +\def\pgfautoxrefs{1} +\input ./macros/pgfmanual-en-macros.tex + +\makeatletter +\def\index@prologue{% +\section*{Index}\addcontentsline{toc}{section}{Index} +} +\makeatother + +\usepackage{pgfmanual} + +\pgfkeys{ + /pdflinks/search key prefixes in={/tikz/,/pgf/}, + /pdflinks/internal link prefix=pgfp, + /pdflinks/codeexample links=true, + /pdflinks/warnings=false, + /pdflinks/show labels=false, +} +\makeindex +\newcommand{\version}{0.5} +\newcommand{\versiondate}{January 3, 2013} + +\title{\saTikZ\footnote{This package has version number \textit{v}\version\ of \versiondate; it is released under and subject to the \href{http://www.latex-project.org/lppl/}{\LaTeX\ Project Public License (LPPL)}.}} +\author{Claudio Fiandrino \\ \small\href{mailto:claudio.fiandrino@gmail.com}{\texttt{claudio.fiandrino@gmail.com}}} +\date{\versiondate} + +\begin{document} +\maketitle +\tableofcontents + +\section*{Introduction} +\addcontentsline{toc}{section}{Introduction} +The \saTikZ\ library helps in drawing \emph{switching-architectures}. In particular, one of its aims, is to help students to verify the correctness of their exercises, but it could also help teachers in preparing lecture notes. The repository of the library is \href{https://github.com/cfiandra/Sa-TikZ}{https://github.com/cfiandra/Sa-TikZ}. + +The \saTikZ\ library can be loaded in the preamble by means of: +\begin{flushleft} +\verb|\usetikzlibrary{|\bgroup\color{red!75!black}\verb|switching-architectures|\egroup\verb|}| +\end{flushleft} +and in this case you should also load manually: +\begin{flushleft} +\verb|\usepackage{|\bgroup\color{red!75!black}\verb|tikz|\egroup\verb|}| +\end{flushleft} +or by means of: +\begin{flushleft} +\verb|\usepackage{|\bgroup\color{red!75!black}\verb|sa-tikz|\egroup\verb|}| +\end{flushleft} +In both cases the libraries \bgroup\color{red!75!black}\verb|calc|\egroup{}, \bgroup\color{red!75!black}\verb|positioning|\egroup\ and \bgroup\color{red!75!black}\verb|decorations.pathreplacing|\egroup\ are loaded automatically and in the latter case also the \Tikz\ package is loaded. + +The version \textit{v}\version\ provides a way to draw Clos Networks Strictly-non-Blocking (snb) and Rearrangeable (rear) and Benes Networks; moreover, there is the possibility to fully customize the aspect of the network drawn starting from the dimensions of module, their distance and the font used. Finally, \saTikZ\ let the user to draw connections among the stages by accessing the single ports of the modules. + +\section{Basic usage} +The simplest use of the package is to define a +\begin{command}{{\node}} + Basic command definition. +\end{command} +with one of the following options +\begin{key}{/tikz/clos snb} + Option for drawing a Clos Network Strictly-non-Blocking. +\end{key} +\begin{key}{/tikz/clos rear} + Option for drawing a Clos Network Rearrangeable. +\end{key} +\begin{key}{/tikz/benes} + Option for drawing a Benes Network. +\end{key} +\begin{key}{/tikz/benes complete} + Option for drawing a Benes Network with the lowest level of recursion. +\end{key} +inside a |tikzpicture| environment: +\begin{environment}{{tikzpicture}\opt{\oarg{options}}} +\end{environment} + +\subsection{Examples of Clos Networks} + +The following example shows a Rearrangeable Clos Network. + +\begin{codeexample}[] +\begin{tikzpicture} + \node[clos rear] {}; +\end{tikzpicture} +\end{codeexample} + +The following example shows a Strictly-non-Blocking Clos Network. + +\begin{codeexample}[] +\begin{tikzpicture} + \node[clos snb] {}; +\end{tikzpicture} +\end{codeexample} + +Notice from the examples that automatically the library is able to compute the constraints that define a Clos Network to be Strictly-non-Blocking or Rearrangeable. Moreover, the network drawn is characterized by: +\begin{itemize} +\item the first stage with: +\begin{itemize} +\item a number of modules equal to 5; +\item each one with two input ports; +\end{itemize} +\item the last stage with: +\begin{itemize} +\item a number of modules equal to 5; +\item each one with two output ports. +\end{itemize} +\end{itemize} +Each module of the network is numbered according to the stage it belongs to. + +\subsection{Examples of Benes Networks} + +The simplest example of a Benes Network: +\begin{codeexample}[] +\begin{tikzpicture} + \node[benes] {}; +\end{tikzpicture} +\end{codeexample} +is a Benes Network in which there are 8 input and output ports. To draw a Benes Network in which all modules are visible, the key |benes complete| should be used rather than the |benes| key. An example: + +\begin{codeexample}[] +\begin{tikzpicture} + \node[benes complete] {}; +\end{tikzpicture} +\end{codeexample} + +The algorithm in which the internal connections of the |benes complete| networks are drawn is explained in detail in the appendix \ref{sec:benesconnalg}. + +\section{The options} +\subsection{Designing choices} +This subsection illustrates which are the parameters that could be customized to draw Clos and Benes Networks. In particular: +\begin{itemize} +\item Clos Networks are analysed in \ref{subsubsec:clos}; +\item Benes Networks are analysed in \ref{subsubsec:benes}. +\end{itemize} +In each part the keys will be presented and simple examples will be provided. + +\subsubsection{Clos Networks} +\label{subsubsec:clos} +The two first important design parameters are the total number of input ports of the first stage and the total number of output ports of the last stage. These two parameters could be modified by means of: + +\begin{key}{/tikz/N=\marg{value} (initially 10)} + This is the number of total input ports in the first stage. +\end{key} + +\begin{key}{/tikz/M=\marg{value} (initially 10)} + This is the number of total output ports in the last stage. +\end{key} + +Usually, a second design parameter is the number of modules present in the first and last stage. \saTikZ\ defines: + +\begin{key}{/tikz/r1=\marg{value} (initially 5)} + This is the number of modules in the first stage. +\end{key} + +\begin{key}{/tikz/r3=\marg{value} (initially 5)} + This is the number of modules in the last stage. +\end{key} + +The two design parameters provide the number of ports of each module: +\[m_1=\dfrac{N}{r_1} \hspace*{2cm} m_3=\dfrac{M}{r_3} \] + +Some examples considering |N|=9, |r1|=3, |M|=9 and |r3|=3. +\begin{codeexample}[] +\begin{tikzpicture} + \node[N=9,r1=3,M=9,r3=3,clos rear] {}; +\end{tikzpicture} +\end{codeexample} + +\begin{codeexample}[] +\begin{tikzpicture} + \node[N=9,r1=3,M=9,r3=3,clos snb] {}; +\end{tikzpicture} +\end{codeexample} + +Notice a very important thing: the type of the architecture should be loaded \emph{after} all the design choices in case they have been set in the \cs{node}; indeed, if you do not respect this constraint you will end up with an architecture with default values. For example: + +\begin{codeexample}[] +\begin{tikzpicture} + \node[clos rear,N=9,r1=3,M=9,r3=3] {}; +\end{tikzpicture} +\end{codeexample} + +\subsubsection{Benes Networks} +\label{subsubsec:benes} +Benes Networks are Clos Rearrangeable Networks composed of $2 \times 2$ modules, so as design choice it just possible to select which is the number of input/output ports: + +\begin{key}{/tikz/P=\marg{value} (initially 8)} + This is the number of total input/output ports in the first/third stage. +\end{key} + +Notice that |P| could assume values +\[P=2^p \qquad p=2,3,4,\ldots\] +and the user is responsible to correctly set this parameter. + +For low values of $p$ there are no problems in visualizing the network, but as $p$ increases the user should take care of the modules' dimension and the modules' separation (vertical and horizontal): they could be customized as explained in the subsection \ref{subsec:customization}. Actually, for |benes complete| networks, the number of $p$ is crucial: when it is above 7, thus for networks bigger than $128\times 128$, PGF can not properly work due to internal limitations. + +Notice that actually, for |P|=4 the |benes| network and the |benes complete| network are indistinguishable: +\begin{codeexample}[] +\begin{tikzpicture} +\tikzset{module size=0.5cm, + pin length factor=0.5, + module ysep=1} + \node[P=4,benes] {}; + \begin{scope}[xshift=6cm] + \node[module xsep=2.5,P=4,benes complete]{}; + \end{scope} +\end{tikzpicture} +\end{codeexample} + + +Here is an example of Benes Network with |P|=16: +\begin{codeexample}[] +\begin{tikzpicture} + \node[P=16,benes] {}; +\end{tikzpicture} +\end{codeexample} + +It holds the same concept already said for Clos Networks: set the parameter |P| before declaring the \cs{node} be a |Benes| Network. + + +\subsection{Output customization} +\label{subsec:customization} +This subsection focuses on how to customize the aspect of the networks. + +\begin{key}{/tikz/module size=\marg{value} (initially 1cm)} + This option allows to set the module dimension. +\end{key} + +\begin{key}{/tikz/module ysep=\marg{value} (initially 1.5)} + This option allows to set the vertical module distance factor. +\end{key} + +\begin{key}{/tikz/module xsep=\marg{value} (initially 3)} + This option allows to set the horizontal module distance factor. +\end{key} + +\begin{key}{/tikz/module label opacity=\marg{value} (initially 1)} + This option allows to mask the module label when the \meta{value} is set to 0. +\end{key} + +\begin{key}{/tikz/pin length factor=\marg{value} (initially 1)} + This option allows to reduce/increase the length of the pins drawn in input/output. Use a \meta{value} [0,1] to reduce the length or, viceversa, a \meta{value} greater than 1 to increase the length. +\end{key} + +\begin{key}{/tikz/module font=\marg{font commands} (default \cs{normalfont})} + This option sets the font used for module labels. The \meta{font commands} that could be used are those ones related to the font size (i.e. \cs{Large}) and font shape (i.e \cs{itshape}). +\end{key} + +\begin{key}{/tikz/connections disabled=\mchoice{true,false} (default false)} + This option, not active by default |connections disabled/.default=false|, allows to remove the connections between the stages when it is set to \opt{true}. Beware: this option is valid only for |clos snb|, |clos rear|, |benes| and |benes complete| networks, but it does not holds for the architectures explained in section \ref{sec:dida}. +\end{key} + +The following example shows a Rearrangeable Clos Network with some options customized. Notice that the |module label opacity| should be given as parameter of the desired network. + +\begin{codeexample}[] +\begin{tikzpicture}[N=9,r1=3,M=9,r3=3] + \node[module size=0.5cm,pin length factor=0.5, + module ysep=1, module xsep=1.25, + clos rear={module label opacity=0}] {}; +\end{tikzpicture} +\end{codeexample} + +The options could also be introduced with the standard \Tikz\ syntax: +\begin{command}{{\tikzset}\marg{options}} + Command that process the various \meta{options}: they should be provided separated by commas. +\end{command} + +Therefore, the previous example could be modified into: +\begin{codeexample}[] +\tikzset{module size=0.5cm,pin length factor=0.5, + module ysep=1, module xsep=1.25,} +\begin{tikzpicture}[N=9,r1=3,M=9,r3=3] + \node[clos rear={module label opacity=0}] {}; +\end{tikzpicture} +\end{codeexample} + +It is also possible to declare \opt{styles} to set some options for later use: this helps to keep the code clean especially when the same options are re-used several times; an example: +\begin{codeexample}[code only] +\tikzset{module size definition/.style={ + module size=0.75cm, + pin length factor=0.75, + module xsep=2, + module ysep=2, + } +} +\tikzset{module size definition, + P=16, +} +\begin{tikzpicture} + \node[benes] {}; +\end{tikzpicture} +\end{codeexample} + +Here is a Benes Network $4 \times 4$ with an extremely large font size for the module labels with the connections disabled: +\begin{codeexample}[] +\tikzset{my style/.style={ + module size=0.75cm, + pin length factor=0.75, + module xsep=2, + } +} +\tikzset{my style, P=4, + module font=\huge\slshape, + connections disabled=true +} +\begin{tikzpicture} + \node[benes complete] {}; +\end{tikzpicture} +\end{codeexample} +\pagebreak + +An example of Benes Network $32 \times 32$: +\begin{codeexample}[] +\tikzset{module size=0.6cm,pin length factor=0.6, + module ysep=0.9, module xsep=1.7,} +\begin{tikzpicture}[P=32] + \node[benes] {}; +\end{tikzpicture} +\end{codeexample} +\pagebreak + +and its complete form: +\begin{codeexample}[] +\tikzset{module size=0.6cm,pin length factor=0.6, + module ysep=1, module xsep=2.275} +\begin{tikzpicture}[P=32] + \node[benes complete={module label opacity=0}] {}; +\end{tikzpicture} +\end{codeexample} + + +\section{Advanced usage} +In this section some more advanced examples are shown. + +\subsection{Identifying front input/output ports} +In this subsection it is shown how to reference the front input and output ports for the first and last stage. Each front input port could be accessed by means of: +\begin{flushleft} +\verb|r1-|\bgroup\color{red!75!black}\verb|module number|\egroup\verb|-|\bgroup\color{red!75!black}\verb|front input|\egroup\verb|-|\bgroup\color{red!75!black}\verb|port number|\egroup; example: \verb|r1-1-front input-1|; +\end{flushleft} +Each front output port could be accessed by means of: +\begin{flushleft} +\verb|r3-|\bgroup\color{red!75!black}\verb|module number|\egroup\verb|-|\bgroup\color{red!75!black}\verb|front output|\egroup\verb|-|\bgroup\color{red!75!black}\verb|port number|\egroup; example: \verb|r3-1-front output-1|; +\end{flushleft} +Noticed that the first stage is always 1, but the last stage may be different from 3 in case the |benes complete| network is drawn. Errors will occur in case the last stage number is not correct and the user is responsible for the correct setting. + +A simple example with a Rearrangeable Clos network of 4 input and output ports; the first stage and the last one have both 2 modules. + +\begin{codeexample}[] +\begin{tikzpicture}[module xsep=2] + \node[N=4,r1=2,M=4,r3=2,clos rear={module label opacity=0}] {}; + \foreach \name + in {r1-1-front input-1,r1-1-front input-2, + r1-2-front input-1,r1-2-front input-2} + \node[left] at (\name) {\scriptsize{\texttt{\name}}}; + \foreach \name + in {r3-1-front output-1,r3-1-front output-2, + r3-2-front output-1,r3-2-front output-2} + \node[right] at (\name) {\scriptsize{\texttt{\name}}}; +\end{tikzpicture} +\end{codeexample} + +The following is a Strictly-non-Blocking Clos network of 9 input and output ports in which the first and last stage have 3 modules each one. + +\begin{codeexample}[] +\begin{tikzpicture} + \node[N=9,r1=3,M=9,r3=3,clos snb={module label opacity=0}] {}; + + \foreach \startmodule in {1,...,3}{ + \foreach \port in {1,...,3} + \node[left] at (r1-\startmodule-front input-\port) + {\scriptsize{input \startmodule-\port}}; + } + \foreach \startmodule in {1,...,3}{ + \foreach \port in {1,...,3} + \node[right] at (r3-\startmodule-front output-\port) + {\scriptsize{output \startmodule-\port}}; + } +\end{tikzpicture} +\end{codeexample} + +The same applies also for Benes Networks: +\begin{codeexample}[] +\begin{tikzpicture} + \node[benes={module label opacity=0}] {}; + + \foreach \startmodule in {1,...,4}{ + \foreach \port in {1,...,2} + \node[left] at (r1-\startmodule-front input-\port) + {\scriptsize{input \startmodule-\port}}; + } + \foreach \startmodule in {1,...,4}{ + \foreach \port in {1,...,2} + \node[right] at (r3-\startmodule-front output-\port) + {\scriptsize{output \startmodule-\port}}; + } +\end{tikzpicture} +\end{codeexample} +and for the complete form: +\begin{codeexample}[] +\begin{tikzpicture} + \node[benes complete={module label opacity=0}] {}; + \newcounter{port} + \setcounter{port}{0} + \foreach \startmodule in {1,...,4}{ + \foreach \port in {1,...,2} + \stepcounter{port} + \node[left] at (r1-\startmodule-front input-\port) + {\scriptsize{input \theport}}; + } + \setcounter{port}{0} + \foreach \startmodule in {1,...,4}{ + \foreach \port in {1,...,2} + \stepcounter{port} + \node[right] at (r5-\startmodule-front output-\port) + {\scriptsize{output \theport}}; + } +\end{tikzpicture} +\end{codeexample} +Notice that in this case to access the \verb|front output| ports, the stage number correct is 5 and not 3 as usual. + +\subsection{Identifying input/output ports per module} + +It is also possible to access, for each module of each stage, its input and output ports. The syntax is similar to the one used for the front input and output ports; each input port could be accessed by means of: +\begin{flushleft} +\verb|r|\bgroup\color{red!75!black}\verb|stage number|\egroup\verb|-|\bgroup\color{red!75!black}\verb|module number|\egroup\verb|-|\bgroup\color{red!75!black}\verb|input|\egroup\verb|-|\bgroup\color{red!75!black}\verb|port number|\egroup; example: \verb|r1-1-input-1|; +\end{flushleft} +Each output port could be accessed by means of: +\begin{flushleft} +\verb|r|\bgroup\color{red!75!black}\verb|stage number|\egroup\verb|-|\bgroup\color{red!75!black}\verb|module number|\egroup\verb|-|\bgroup\color{red!75!black}\verb|front output|\egroup\verb|-|\bgroup\color{red!75!black}\verb|port number|\egroup; example: \verb|r2-1-output-1|; +\end{flushleft} +This allows to derive connections from the first stage to the last stage. Here is an example. + +\begin{codeexample}[] +\begin{tikzpicture} + \node[N=8,r1=4,M=8,r3=4,clos rear={module label opacity=0}] {}; + \draw[red,ultra thick](r1-2-input-1)--(r1-2-output-2) + (r2-2-input-2)--(r2-2-output-3) + (r3-3-input-2)--(r3-3-output-2); + \draw[red,ultra thick](r1-4-input-1)--(r1-4-output-1) + (r2-1-input-4)--(r2-1-output-1) + (r3-1-input-1)--(r3-1-output-2); +\end{tikzpicture} +\end{codeexample} +Similarly, an example in a Benes Network: +\begin{codeexample}[] +\begin{tikzpicture} + \node[benes={module label opacity=0}] {}; + \draw[red,ultra thick](r1-2-input-1)--(r1-2-output-2) + (r2-2-input-2)--(r2-2-output-3) + (r3-3-input-2)--(r3-3-output-2); + \draw[red,ultra thick](r1-4-input-1)--(r1-4-output-1) + (r2-1-input-4)--(r2-1-output-1) + (r3-1-input-1)--(r3-1-output-2); +\end{tikzpicture} +\end{codeexample} +and in its complete form: +\begin{codeexample}[] +\begin{tikzpicture} + \node[benes complete={module label opacity=0}] {}; + \draw[red,ultra thick](r1-2-input-1)--(r1-2-output-2)-- + (r2-3-input-2)--(r2-3-output-2)-- + (r3-3-input-1)--(r3-3-output-2)-- + (r4-4-input-1)--(r4-4-output-1)-- + (r5-3-input-2)--(r5-3-output-2); + \draw[blue,ultra thick](r1-4-input-1)--(r1-4-output-1)-- + (r2-2-input-2)--(r2-2-output-1)-- + (r3-1-input-2)--(r3-1-output-1)-- + (r4-1-input-1)--(r4-1-output-1)-- + (r5-1-input-1)--(r5-1-output-2); +\end{tikzpicture} +\end{codeexample} + +\section{Didactic purposes} +\label{sec:dida} +To quickly draw a Clos Network it is possible to exploit: +\begin{key}{/tikz/clos snb example} + Option for quickly drawing a Clos Network Strictly-non-Blocking. +\end{key} +\begin{key}{/tikz/clos rear example} + Option for quickly drawing a Clos Network Rearrangeable. +\end{key} +In this way the network is not seen in its whole complexity, but it is synthetically depicted. An example of a Strictly-non-Blocking Clos Network drawn with this approach: +\begin{codeexample}[] +\begin{tikzpicture}[N=12,r1=4,M=8,r3=4] + \node[clos snb example] {}; +\end{tikzpicture} +\end{codeexample} + +Similarly, an example of a Rearrangeable Clos Network: +\begin{codeexample}[] +\begin{tikzpicture}[N=12,r1=4,M=8,r3=4] + \node[clos rear example] {}; +\end{tikzpicture} +\end{codeexample} + +The networks drawn, automatically display the values at which the input parameters |N|, |M|, |r1| and |r3| have been set. However, to let the user to have the possibility of deploying labels rather than the input parameter values, the following option is available: + +\begin{key}{/tikz/clos example with labels} + Option for quickly drawing a Clos Network with custom labels. +\end{key} + +The labels could be customized by means of: +\begin{key}{/tikz/N label=\marg{value} (default N)} + This options sets the label representing the total number of ports in the first stage. +\end{key} + +\begin{key}{/tikz/r1 label=\marg{value} (default r$_1$)} + This options sets the label representing the number of modules in the first stage. +\end{key} + +\begin{key}{/tikz/m1 label=\marg{value} (default m$_1$)} + This options sets the label representing the number of ports per module in the first stage. +\end{key} + +\begin{key}{/tikz/r2 label=\marg{value} (default r$_2$)} + This options sets the label representing the number of modules in the second stage. +\end{key} + +\begin{key}{/tikz/M label=\marg{value} (default M)} + This options sets the label representing the total number of ports in the last stage. +\end{key} + +\begin{key}{/tikz/r3 label=\marg{value} (default r$_3$)} + This options sets the label representing the number of modules in the last stage. +\end{key} + +\begin{key}{/tikz/m3 label=\marg{value} (default m$_3$)} + This options sets the label representing the number of ports per module in the last stage. +\end{key} + +An example with the default values for the labels: + +\begin{codeexample}[] +%\tikzset{N=8,r1=4,M=8,r3=4} % setting the parameters here is useless +\begin{tikzpicture} + \node[clos example with labels] {}; +\end{tikzpicture} +\end{codeexample} + +To have automatically all labels in math mode, use: +\begin{key}{/tikz/set math mode labels=\mchoice{true,false} (default false)} + This option is normally disabled |set math mode labels/.default=false|; to ensure labels be set completely in math mode is sufficient set |set math mode labels=true| before the type of the network. +\end{key} + +An example: +\begin{codeexample}[] +\begin{tikzpicture}[set math mode labels=true] + \node[clos example with labels] {}; +\end{tikzpicture} +\end{codeexample} + +This example, instead, represents a |clos example with labels| network with custom labels introduced by means of the |\tikzset| syntax. + +\begin{codeexample}[] +\tikzset{N label={p$_1$ $\times$ q$_1$},M label={p$_3$ $\times$ q$_3$}, +r1 label=p$_1$, m1 label=q$_1$, r2 label=p$_2$,r3 label=p$_3$, m3 label=q$_3$} +\begin{tikzpicture} + \node[clos example with labels] {}; +\end{tikzpicture} +\end{codeexample} + +Notice that it does not exist an equivalent of |clos example with labels| or |clos rear example| for Benes Networks: this because Benes Networks are a particular type of Rearrangeable Clos Networks where |P|=|N|=|M| and $m1$=$m3$=$z$=2, thus |r1|=|r3|=$q=P/z$. + +For example: + +\begin{codeexample}[] +\begin{tikzpicture}[N=8,r1=4,M=8,r3=4] + \node[clos rear example] {}; +\end{tikzpicture} +\end{codeexample} + +\begin{codeexample}[] +\tikzset{N label={P},M label={P}, +r1 label=q, m1 label=z, r2 label=z,r3 label=q, m3 label=z} +\begin{tikzpicture} + \node[set math mode labels=true,clos example with labels] {}; +\end{tikzpicture} +\end{codeexample} + +\clearpage +\appendix + +\section{Benes complete internal connections algorithm} +\label{sec:benesconnalg} +To explain how the connections of the |benes complete| networks are drawn, the following reference example will be considered: +\begin{center} +\scalebox{0.75}{ + \begin{tikzpicture}[module size=0.75cm, module ysep=1, module xsep=2.5] + \node[P=16, benes complete]{}; + \end{tikzpicture} +} +\end{center} +The network is $16\times 16$ (|P|=16), thus the number of stages $\mathcal{S}$ is: +\[\mathcal{S}=2\log_2{P}-1 \implies \mathcal{S}_{16}=7\] +Indeed: +\begin{center} +\scalebox{0.75}{ + \begin{tikzpicture}[module size=0.75cm, module ysep=1, module xsep=2.5] + \node[P=16, benes complete]{}; + \foreach \x in {1,...,7} + \node[above of=r\x-1, red] {\x}; + \draw[red,thick,decorate,decoration={brace}]([yshift=0.1cm]r1-1.north west)--([yshift=0.1cm]r7-1.north east); + \end{tikzpicture} +} +\end{center} +This parameter, therefore, allows to correctly draw all the modules of the network and, as it will be pointed out later better, its knowledge is important also to define the stages range of applicability of the algorithm. Notice the network symmetry: the connections from stage 1 to stage 4 are exactly the same from stage 7 to stage 4. +\pagebreak + +The first step is \emph{labelling} modules and ports. \saTikZ\ uses this philosophy: +\begin{itemize} +\item progressive numeration for modules of the same stage; +\item progressive numeration for ports of the same module. +\end{itemize} + +Thus: +\begin{center} +\scalebox{0.75}{ + \begin{tikzpicture}[module size=0.75cm, module ysep=1, module xsep=3.5, connections disabled=true] + \node[P=16, benes complete]{}; + \foreach \stg in {2,...,6}{ + \foreach \module in {1,...,8}{ + \node[right,font=\scriptsize] at (r\stg-\module-output-1) {1}; + \node[right,font=\scriptsize] at (r\stg-\module-output-2) {2}; + \node[left,font=\scriptsize] at (r\stg-\module-input-1) {1}; + \node[left,font=\scriptsize] at (r\stg-\module-input-2) {2}; + } + } + \foreach \module in {1,...,8}{ + \node[right,font=\scriptsize] at (r1-\module-output-1) {1}; + \node[right,font=\scriptsize] at (r1-\module-output-2) {2}; + } + \foreach \module in {1,...,8}{ + \node[left,font=\scriptsize] at (r7-\module-input-1) {1}; + \node[left,font=\scriptsize] at (r7-\module-input-2) {2}; + } + \end{tikzpicture} +} +\end{center} + +Due to the network symmetry, at the beginning the attention will be focused only on the left side of the network, because for the right part things are dual: + +\begin{center} +\scalebox{0.75}{ + \begin{tikzpicture}[module size=0.75cm, module ysep=1, module xsep=3.5, connections disabled=true] + \node[P=16, benes complete]{}; + \foreach \stg in {2,...,6}{ + \foreach \module in {1,...,8}{ + \node[right,font=\scriptsize] at (r\stg-\module-output-1) {1}; + \node[right,font=\scriptsize] at (r\stg-\module-output-2) {2}; + \node[left,font=\scriptsize] at (r\stg-\module-input-1) {1}; + \node[left,font=\scriptsize] at (r\stg-\module-input-2) {2}; + } + } + \foreach \module in {1,...,8}{ + \node[right,font=\scriptsize] at (r1-\module-output-1) {1}; + \node[right,font=\scriptsize] at (r1-\module-output-2) {2}; + } + \foreach \module in {1,...,8}{ + \node[left,font=\scriptsize] at (r7-\module-input-1) {1}; + \node[left,font=\scriptsize] at (r7-\module-input-2) {2}; + } + \begin{pgfonlayer}{background} + \draw[dashed, ultra thick, red, fill=red!10] + ($(r1-1-front input-1)+(-0.2,0.5)$)--($(r4-1-output-1)+(0.5,0.5)$)--($(r4-8-output-2)-(-0.5,0.5)$)--($(r1-8-front input-2)-(0.2,0.5)$)--cycle; + \end{pgfonlayer} + \end{tikzpicture} +} +\end{center} +\pagebreak + +Now, by drawing some connections, it is possible to find a common behaviour: + +\begin{center} +\scalebox{0.75}{ + \begin{tikzpicture}[module size=0.75cm, module ysep=1, module xsep=3.5, connections disabled=true] + \node[P=16, benes complete]{}; + \foreach \stg in {2,...,6}{ + \foreach \module in {1,...,8}{ + \node[right,font=\scriptsize] at (r\stg-\module-output-1) {1}; + \node[right,font=\scriptsize] at (r\stg-\module-output-2) {2}; + \node[left,font=\scriptsize] at (r\stg-\module-input-1) {1}; + \node[left,font=\scriptsize] at (r\stg-\module-input-2) {2}; + } + } + \foreach \module in {1,...,8}{ + \node[right,font=\scriptsize] at (r1-\module-output-1) {1}; + \node[right,font=\scriptsize] at (r1-\module-output-2) {2}; + } + \foreach \module in {1,...,8}{ + \node[left,font=\scriptsize] at (r7-\module-input-1) {1}; + \node[left,font=\scriptsize] at (r7-\module-input-2) {2}; + } + % some connections + \begin{pgfonlayer}{background} + % first-second stage + \draw[thick,red](r1-1-output-1)--(r2-1-input-1); + \draw[thick,red](r1-1-output-2)--(r2-5-input-1); + \draw[thick,red](r1-2-output-1)--(r2-1-input-2); + \draw[thick,red](r1-2-output-2)--(r2-5-input-2); + % second-third stage + \draw[thick,red](r2-1-output-1)--(r3-1-input-1); + \draw[thick,red](r2-1-output-2)--(r3-3-input-1); + \draw[thick,red](r2-2-output-1)--(r3-1-input-2); + \draw[thick,red](r2-2-output-2)--(r3-3-input-2); + \draw[thick,red](r2-3-output-1)--(r3-2-input-1); + \draw[thick,red](r2-3-output-2)--(r3-4-input-1); + \draw[thick,red](r2-4-output-1)--(r3-2-input-2); + \draw[thick,red](r2-4-output-2)--(r3-4-input-2); + % third-fourth stage + \draw[thick,red](r3-1-output-1)--(r4-1-input-1); + \draw[thick,red](r3-1-output-2)--(r4-2-input-1); + \draw[thick,red](r3-2-output-1)--(r4-1-input-2); + \draw[thick,red](r3-2-output-2)--(r4-2-input-2); + \end{pgfonlayer} + \end{tikzpicture} +} +\end{center} +\begin{itemize} +\item if the start module $st$ and the output port are odd (i.e. module 1, port 1), then it will be connected to +\[\textrm{end module}=\dfrac{st+1}{2} \; , \; \textrm{port}=1 \] +\item if the start module $st$ is odd and the output port is even (i.e. module 1, port 2), then it will be connected to +\[\textrm{end module}=\dfrac{st+1+\gamma}{2} \; , \; \textrm{port}=1 \] +\item if the start module $st$ is even and the output port is odd (i.e. module 2, port 1), then it will be connected to +\[\textrm{end module}=\dfrac{st}{2} \; , \; \textrm{port}=2 \] +\item if the start module $st$ and the output port are even (i.e. module 2, port 2), then it will be connected to +\[\textrm{end module}=\dfrac{st+\gamma}{2}\; , \; \textrm{port}=2 \] +\end{itemize} + +What is the term $\gamma$? It is a corrective term that depends on the starting stage. Consider indeed the connections of the output port 2 of the module 1 for the first and the second starting stages: +\begin{flushleft} +\texttt{r1-1-output-2} \tikz[baseline=-0.5ex]\draw[-stealth](0,0)--(0.5,0); \texttt{r2-5-input-1}\\ +\texttt{r2-1-output-2} \tikz[baseline=-0.5ex]\draw[-stealth](0,0)--(0.5,0); \texttt{r3-3-input-1} +\end{flushleft} +In the first case it points to module 5 while in the second case to module 3, thus in the first case $\gamma=8$ and in the second case $\gamma=4$. This suggest that $\gamma$ is related in some sense to the stage of the start module: in the example |P|=16 so the relation is +\[\gamma=\dfrac{P}{2^{stage}}\] + +Following this strategy, however, allows to draw just part of the connections: +\begin{center} +\scalebox{0.75}{ + \begin{tikzpicture}[module size=0.75cm, module ysep=1, module xsep=3.5, connections disabled=true] + \node[P=16, benes complete]{}; + \foreach \stg in {2,...,6}{ + \foreach \module in {1,...,8}{ + \node[right,font=\scriptsize] at (r\stg-\module-output-1) {1}; + \node[right,font=\scriptsize] at (r\stg-\module-output-2) {2}; + \node[left,font=\scriptsize] at (r\stg-\module-input-1) {1}; + \node[left,font=\scriptsize] at (r\stg-\module-input-2) {2}; + } + } + \foreach \module in {1,...,8}{ + \node[right,font=\scriptsize] at (r1-\module-output-1) {1}; + \node[right,font=\scriptsize] at (r1-\module-output-2) {2}; + } + \foreach \module in {1,...,8}{ + \node[left,font=\scriptsize] at (r7-\module-input-1) {1}; + \node[left,font=\scriptsize] at (r7-\module-input-2) {2}; + } + % some connections + \begin{pgfonlayer}{background} + \foreach \stg[evaluate=\stg as \nextstg using int(\stg+1)] in {1,...,3}{ + \pgfmathtruncatemacro\applicationon{16/(2^\stg)}% number of modules over which the algorithm is applied + \foreach \startmodule in {1,...,\applicationon}{ + \pgfmathisodd{\startmodule}{initmodule} + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2)} + \pgfmathtruncatemacro\endmoduleii{int(ceil(\startmodule+1+\applicationon)/2)} + \draw[red](r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-1); + \draw[red](r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2)} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2)} + \draw[red](r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-2); + \draw[red](r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-2); + \fi + } + } + \end{pgfonlayer} + \end{tikzpicture} +} +\end{center} +thus it is possible to claim that the algorithm has a \emph{module applicability range} that ultimately depends on the stage: +\begin{itemize} +\item in the first stage it could be applied for all modules; +\item in the second stage it could be applied for half of the modules; +\item in the third stage it could be applied just for two modules. +\end{itemize} +But, in the first stage $\gamma=8$ ($P/2^1$), in the second stage $\gamma=4$ ($P/2^2$) and in the third stage $\gamma=2$ ($P/2^3$): this means that $\gamma$ defines the \emph{module applicability range}. + +Notice now, that actually for the second stage and the third stage, the algorithm should be simply repeated: +\begin{itemize} +\item in the second stage 2 times; +\item in the third stage 4 times. +\end{itemize} +The repetition $\psi$ depends on the stage with this relation: +\[\psi= 2^{stage-1}\] +Now, to draw automatically all the connections, the algorithm should know which are the starting module and ending module of the \emph{module applicability range} during the repetitions: for example, in the second stage, how to identify automatically the applicability range \texttt{1-4}, \texttt{5-8}? +\pagebreak + +They could be defined as: +\begin{itemize} +\item starting module: $st_m=1+(\psi-1)\cdot\gamma $; +\item ending module: $end_m=(st_m+\gamma)-1$. +\end{itemize} +Indeed for the second stage we have that $\gamma=4$ and $\psi=2\implies \{1,\, 2\}$, thus there are two starting and ending modules: +\begin{itemize} +\item starting modules: $st_{m_1}=1+(1-1)\cdot 4=1$ and $st_{m_2}=1+(2-1)\cdot 4=5$; +\item ending modules: $end_{m_1}=(1+4)-1=4$ and $end_{m_2}=(5+4)-1=8$. +\end{itemize} +Unfortunately, the knowledge of the starting and ending modules per stage is not sufficient to reach the goal: this because the algorithm works and draws the connections perfectly when the module labels start with 1, but during the repetitions the new starting module labels are different, so the computation of the end connection point fails. This difference should be compensated with \emph{shifts} of the ending modules that depend on the level of repetition. The rules are: +\begin{itemize} +\item if $\psi=1$ (the algorithm works for all modules of the stage), then the ending module of the connection is computed as: +\begin{itemize} +\item if the start module $st$ and the output port are odd (i.e. module 1, port 1), then it will be connected to +\[\textrm{end module}=\dfrac{st+1}{2} \; , \; \textrm{port}=1 \] +\item if the start module $st$ is odd and the output port is even (i.e. module 1, port 2), then it will be connected to +\[\textrm{end module}=\dfrac{st+1+\gamma}{2}\; , \; \textrm{port}=1 \] +\item if the start module $st$ is even and the output port is odd (i.e. module 2, port 1), then it will be connected to +\[\textrm{end module}=\dfrac{st}{2} \; , \; \textrm{port}=2 \] +\item if the start module $st$ and the output port are even (i.e. module 2, port 2), then it will be connected to +\[\textrm{end module}=\dfrac{st+\gamma}{2}\; , \; \textrm{port}=2 \] +\end{itemize} +\item if $\psi=2$ (the algorithm should be repeated twice), then the ending module of the connection is computed as +\begin{itemize} +\item if the start module $st$ and the output port are odd (i.e. module 1, port 1), then it will be connected to +\[\textrm{end module}=\dfrac{st+1}{2}+\dfrac{\gamma}{2} \; , \; \textrm{port}=1 \] +\item if the start module $st$ is odd and the output port is even (i.e. module 1, port 2), then it will be connected to +\[\textrm{end module}=\dfrac{st+1+\gamma}{2}+\dfrac{\gamma}{2}\; , \; \textrm{port}=1 \] +\item if the start module $st$ is even and the output port is odd (i.e. module 2, port 1), then it will be connected to +\[\textrm{end module}=\dfrac{st}{2}+\dfrac{\gamma}{2} \; , \; \textrm{port}=2 \] +\item if the start module $st$ and the output port are even (i.e. module 2, port 2), then it will be connected to +\[\textrm{end module}=\dfrac{st+\gamma}{2}+\dfrac{\gamma}{2}\; , \; \textrm{port}=2 \] +\end{itemize} +\item if $\psi>2\implies t=3,\ldots, \psi$ (the algorithm should be repeated more than twice), then the ending module of the connection is computed as: +\begin{itemize} +\item if the start module $st$ and the output port are odd (i.e. module 1, port 1), then it will be connected to +\[\textrm{end module}=\dfrac{st+1}{2}+\left(\dfrac{\gamma}{2}\cdot (t-2)\right) \; , \; \textrm{port}=1 \] +\item if the start module $st$ is odd and the output port is even (i.e. module 1, port 2), then it will be connected to +\[\textrm{end module}=\dfrac{st+1+\gamma}{2}+\dfrac{\gamma}{2}+\left(\dfrac{\gamma}{2}\cdot (t-2)\right)\; , \; \textrm{port}=1 \] +\item if the start module $st$ is even and the output port is odd (i.e. module 2, port 1), then it will be connected to +\[\textrm{end module}=\dfrac{st}{2}+\left(\dfrac{\gamma}{2}\cdot (t-2)\right)\; , \; \textrm{port}=2 \] +\item if the start module $st$ and the output port are even (i.e. module 2, port 2), then it will be connected to +\[\textrm{end module}=\dfrac{st+\gamma}{2}+\dfrac{\gamma}{2}+\left(\dfrac{\gamma}{2}\cdot (t-2)\right)\; , \; \textrm{port}=2 \] +\end{itemize} +\end{itemize} +Unfortunately, the rule $\psi>2$ when applied to the intermediate stages +\[I_1=\lfloor\mathcal{S}\div 2\rfloor \hspace*{1cm} I_2=\mathcal{S}-(I_1-1)\] +does not work; this implies that: +\begin{itemize} +\item on the left side of the network the applicability of the algorithm is from the starting stage 1 up to the starting stage $I_1-1$ (in the example |P|=16: from the starting stage 1 up to the starting stage 2); +\item on the right side of the network the applicability of the algorithm is from the starting stage $\mathcal{S}$ up to the starting stage $I_2-1$ (in the example |P|=16: from the starting stage 7 up to the starting stage 6); +\item for the intermediate starting stages $I_1$ and $I_2$ (in the example |P|=16: the stages 3 and 5) another rule should be used: +\begin{itemize} +\item if the start module $st$ and the output port are odd (i.e. module 1, port 1), then it will be connected to +\[\textrm{end module}=st\; , \; \textrm{port}=1 \] +\item if the start module $st$ is odd and the output port is even (i.e. module 1, port 2), then it will be connected to +\[\textrm{end module}=st+1\; , \; \textrm{port}=1 \] +\item if the start module $st$ is even and the output port is odd (i.e. module 2, port 1), then it will be connected to +\[\textrm{end module}=st-1 \; , \; \textrm{port}=2 \] +\item if the start module $st$ and the output port are even (i.e. module 2, port 2), then it will be connected to +\[\textrm{end module}=st\; , \; \textrm{port}=2 \] +\end{itemize} +\end{itemize} + +To summarize, the algorithm to \textbf{d}raw \textbf{B}enes \textbf{n}etwork \textbf{c}onnections (dBnc) is reported in~\ref{algo_dBnc}: for the rules, please refer to the descriptions mentioned above. + +\begin{algorithm} +compute $\mathcal{S}=2\log_2{P}-1$\; +compute $I_1=\lfloor\mathcal{S}\div 2\rfloor$\; +compute $I_2=\mathcal{S}-(I_1-1)$\; +\emph{from left to right}\; +\For{$stg\leftarrow 1$ \KwTo $(I_1-1)$}{ + compute $\gamma=P\div 2^{stg}$\; + compute $\psi=2^{stg-1}$\; + \For{$t\leftarrow 1$ \KwTo $\psi$}{ + compute starting point $x=1+((t-1)\cdot\gamma)$\; + compute ending point $y=(x+\gamma)-1$\; + \ForEach{$\textrm{ start module } s \textrm{ in set } (x,y)$}{ + \uIf{$t==1$}{ + \uIf{$s$ is odd}{ + use rules $\psi=1$ for starting module odd\; + } + \Else{ + use rules $\psi=1$ for starting module even\; + } + } + \uIf{$t==2$}{ + \uIf{$s$ is odd}{ + use rules $\psi=2$ for starting module odd\; + } + \Else{ + use rules $\psi=2$ for starting module even\; + } + } + \uIf{$t>2$}{ + \uIf{$s$ is odd}{ + use rules $\psi>2$ for starting module odd\; + } + \Else{ + use rules $\psi>2$ for starting module even\; + } + } + } + } +} +\emph{from right to left}\; +\For{$stg\leftarrow \mathcal{S}$ \KwTo $(I_2-1)$}{ + repeat in dual mode $\textbf{6}-\textbf{32}$\; +} +\emph{complete with intermediate stages}\; +\ForEach{$stg$ in set $(I_1,\, I_2)$}{ + use rules for intermediate stages\; +} +\caption{\textbf{d}raw \textbf{B}enes \textbf{n}etwork \textbf{c}onnections (dBnc)}\label{algo_dBnc} +\end{algorithm} + + +% * * * * * * * * * * * * * * * * * * * * * * * * * * +% belongs to \usepackage{makeindex} +\printindex +\end{document} diff --git a/Master/texmf-dist/tex/latex/sa-tikz/sa-tikz.sty b/Master/texmf-dist/tex/latex/sa-tikz/sa-tikz.sty new file mode 100644 index 00000000000..8ddb5185519 --- /dev/null +++ b/Master/texmf-dist/tex/latex/sa-tikz/sa-tikz.sty @@ -0,0 +1,1043 @@ +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% +% Sa-TikZ package v0.5 * * (C) Claudio Fiandrino 2012 +% +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{sa-tikz}[2013/1/3 v0.5 Switching architectures design library.] +\RequirePackage{tikz} +\usetikzlibrary{calc,positioning,decorations.pathreplacing} + +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% UTILITY +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +% PGFMATHISODD: 1 = true, 0 = false +% +% #1: number to be checked +% #2: output macro +% +% example: +%% \pgfmathisodd{32}{output} +%% \ifnum\output=1 +%% \node{\output}; +%% \fi +\newcommand*{\pgfmathisodd}[2]{ + \pgfmathparse{mod(#1,2)} + \pgfmathtruncatemacro\res\pgfmathresult + \global\expandafter\edef\csname #2\endcsname{\res} +} + +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% KEY DEFINITION - Design choices +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +% * * * * * * * * * * * * * * * * * * +% CLOS +% * * * * * * * * * * * * * * * * * * + +% N is the key representing the number of inputs x number of modules first stage +\pgfkeys{/tikz/.cd,% + N/.initial=10,% + N/.get=\N,% + N/.store in=\N,% +}% + +% N label +\pgfkeys{/tikz/.cd,% + N label/.initial=N,% + N label/.store in=\Nlabel,% + N label/.get=\Nlabel,% +}% + +% r1 is the number of modules first stage +% m1 is the number of inputs first stage per module + +\pgfkeys{/tikz/.cd,% + r1/.initial=5,% + r1/.store in=\rone,% + r1/.get=\rone,% +}% + +% r1 label +\pgfkeys{/tikz/.cd,% + r1 label/.initial={r\ensuremath{_1}},% + r1 label/.store in=\ronelabel,% + r1 label/.get=\ronelabel,% +}% + +% m1 label +\pgfkeys{/tikz/.cd, + m1 label/.initial={m\ensuremath{_1}},% + m1 label/.store in=\monelabel,% + m1 label/.get=\monelabel,% +}% + +% r2 label +\pgfkeys{/tikz/.cd,% + r2 label/.initial={r\ensuremath{_2}},% + r2 label/.store in=\rtwolabel,% + r2 label/.get=\rtwolabel,% +}% + +% M is the key representing the number of inputs x number of modules last stage +\pgfkeys{/tikz/.cd,% + M/.initial=10,% + M/.get=\M,% + M/.store in=\M,% +}% + +% M label +\pgfkeys{/tikz/.cd,% + M label/.initial=M,% + M label/.store in=\Mlabel,% + M label/.get=\Mlabel,% +}% + +% r3 is the number of modules last stage +% m3 is the number of inputs last stage per module +\pgfmathtruncatemacro\rthree{5}% +\pgfkeys{/tikz/.cd, r3/.initial=5}% +\pgfkeys{/tikz/.cd, r3/.store in=\rthree}% + +% r3 label +\pgfkeys{/tikz/.cd,% + r3 label/.initial={r\ensuremath{_3}},% + r3 label/.store in=\rthreelabel,% + r3 label/.get=\rthreelabel,% +}% + +% m3 label +\pgfkeys{/tikz/.cd, + m3 label/.initial={m\ensuremath{_3}},% + m3 label/.store in=\mthreelabel,% + m3 label/.get=\mthreelabel,% +}% + +% * * * * * * * * * * * * * * * * * * +% BENES +% * * * * * * * * * * * * * * * * * * + +% P is the number of input/output ports +\pgfkeys{/tikz/.cd,% + P/.initial=8,% + P/.get=\P,% + P/.store in=\P,% +}% + +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% GENERAL SETTINGS - Keys and styles +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +% module customization +\pgfkeys{/tikz/.cd,% + module size/.initial={1cm},% + module size/.get=\modulesize,% + module size/.store in=\modulesize,% +}% + +\pgfkeys{/tikz/.cd,% + module ysep/.initial={1.5},% + module ysep/.get=\moduleysep,% + module ysep/.store in=\moduleysep,% +}% + +\pgfkeys{/tikz/.cd,% + module xsep/.initial={3},% + module xsep/.get=\modulexsep,% + module xsep/.store in=\modulexsep,% +}% + +\pgfkeys{/tikz/.cd,% + module font/.initial=\normalfont,% + module font/.get=\modulefont,% + module font/.store in=\modulefont,% +}% + +\tikzset{module/.style={% + draw,rectangle, minimum size=\modulesize, + font=\modulefont, + } +} + +\tikzset{module extensible/.style={% + draw,rectangle, minimum size=#1, + }, + module extensible/.default={\modulesize} +} + +\pgfkeys{/tikz/.cd,% + module label opacity/.initial={1},% + module label opacity/.get=\modulelabelopacity,% + module label opacity/.store in=\modulelabelopacity,% +}% + +\tikzset{module opacity/.style={ + text opacity=\modulelabelopacity, + } +} + +\pgfkeys{/tikz/.cd,% + pin length factor/.initial={1},% + pin length factor/.get=\pinlength,% + pin length factor/.store in=\pinlength,% +}% + +% setting labels in math mode + +\tikzset{math mode labels/.style={% + execute at begin node=$,% + execute at end node=$,% + } +} +\pgfkeys{/tikz/.cd,% + use math mode labels/.is choice,% + use math mode labels/true/.style={math mode labels},% + use math mode labels/false/.style={},% +}% + +\tikzset{set math mode labels/.style={% + use math mode labels=#1,% + },% + set math mode labels/.default=false,% +} + +% disable the connections +\newif\ifconnectiondisabled% +\pgfkeys{/tikz/.cd, connections disabled/.is if=connectiondisabled}% +\pgfkeys{/tikz/.cd, connections disabled/.default=false}% + +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% CODE +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +% CLOS SNB +\tikzset{clos snb/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\mone}{\N/\rone} + \pgfmathtruncatemacro{\mthree}{\M/\rthree} + + % COMPUTATION SNB CONDITION + \pgfmathtruncatemacro\rtwo{\mone+\mthree-1} + + % MODULE 1 + \foreach \i in {1,...,\rone}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r1-\i) at +(0,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 1 + % the number of inputs module one is exactly \mone + \pgfmathsetmacro\roneintervalspace{1/(\mone+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,...,\mone} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % the number of outputs of module one is the number of modules stage 2 \rtwo + \pgfmathsetmacro\roneintervalspace{1/(\rtwo+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \foreach \i in {1,...,\rtwo}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r2-\i) at +(\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 2 + % the number of inputs of module two is the number of modules stage 1 \rone + \pgfmathsetmacro\rtwointervalspace{1/(\rone+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,...,\rone} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % the number of outputs module two is exactly \rthree + \pgfmathsetmacro\rtwointervalspace{1/(\rthree+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,...,\rthree} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + + } + + % MODULE 3 + \foreach \i in {1,...,\rthree}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r3-\i) at +(2*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 3 + % the number of inputs of module three is the number of modules stage 2 \rtwo + \pgfmathsetmacro\rthreeintervalspace{1/(\rtwo+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % the number of outputs module three is exactly \mthree + \pgfmathsetmacro\rthreeintervalspace{1/(\mthree+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,...,\mthree} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + + } + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,...,\rone}{ + \foreach \conn in {1,...,\rtwo} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,...,\rthree}{ + \foreach \conn in {1,...,\rtwo} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + \fi + }, +} + +\tikzset{clos snb example/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\mone}{\N/\rone} + \pgfmathtruncatemacro{\mthree}{\M/\rthree} + + % COMPUTATION SNB CONDITION + \pgfmathtruncatemacro\rtwo{\mone+\mthree-1} + + % MODULE 1 + \node[module,#1,module opacity](r1-1) at (0,0) {1}; + \node[below of=r1-1,yshift=0.75ex](r1-dots) {\vdots}; + \node[module,#1,module opacity,below of=r1-dots](r1-2) {\rone}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,2} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,2} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \node[module,#1,module opacity](r2-1) at (\modulexsep,0) {1}; + \node[below of=r2-1,yshift=0.75ex](r2-dots) {\vdots}; + \node[module,#1,module opacity,below of=r2-dots](r2-2) {\rtwo}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + } + + % MODULE 3 + \node[module,#1,module opacity](r3-1) at (2*\modulexsep,0) {1}; + \node[below of=r3-1,yshift=0.75ex](r3-dots) {\vdots}; + \node[module,#1,module opacity,below of=r3-dots](r3-2) {\rthree}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,2} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,2} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + } + + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + + % SETTING LABELS + \node[below of=r1-2,set math mode labels] {\mone~\ensuremath{\times}~\rtwo}; + \node[below of=r2-2,set math mode labels] {\rone~\ensuremath{\times}~\rthree}; + \node[below of=r3-2,set math mode labels] {\rtwo~\ensuremath{\times}~\mthree}; + \draw[decorate,decoration={brace}]($(r1-2-front input-2)-(0.1,0)$)--($(r1-1-front input-1)-(0.1,0)$) node[midway,left=0.1cm,set math mode labels]{\N}; + \draw[decorate,decoration={brace}]($(r3-1-front output-1)+(0.1,0)$)--($(r3-2-front output-2)+(0.1,0)$) node[midway,right=0.1cm,set math mode labels]{\M}; + }, +} + +% CLOS REAR + +\tikzset{clos rear/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\mone}{\N/\rone} + \pgfmathtruncatemacro{\mthree}{\M/\rthree} + + % COMPUTATION REAR CONDITION + \pgfmathtruncatemacro\rtwo{max(\mone,\mthree)} + + % MODULE 1 + \foreach \i in {1,...,\rone}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r1-\i) at +(0,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 1 + % the number of inputs module one is exactly \mone + \pgfmathsetmacro\roneintervalspace{1/(\mone+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,...,\mone} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % the number of outputs of module one is the number of modules stage 2 \rtwo + \pgfmathsetmacro\roneintervalspace{1/(\rtwo+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \foreach \i in {1,...,\rtwo}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r2-\i) at +(\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 2 + % the number of inputs of module two is the number of modules stage 1 \rone + \pgfmathsetmacro\rtwointervalspace{1/(\rone+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,...,\rone} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % the number of outputs module two is exactly \rthree + \pgfmathsetmacro\rtwointervalspace{1/(\rthree+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,...,\rthree} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + + } + + % MODULE 3 + \foreach \i in {1,...,\rthree}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r3-\i) at +(2*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 3 + % the number of inputs of module three is the number of modules stage 2 \rtwo + \pgfmathsetmacro\rthreeintervalspace{1/(\rtwo+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % the number of outputs module three is exactly \mthree + \pgfmathsetmacro\rthreeintervalspace{1/(\mthree+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,...,\mthree} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + } + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,...,\rone}{ + \foreach \conn in {1,...,\rtwo} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,...,\rthree}{ + \foreach \conn in {1,...,\rtwo} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + \fi + } +} + +\tikzset{clos rear example/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\mone}{\N/\rone} + \pgfmathtruncatemacro{\mthree}{\M/\rthree} + + % COMPUTATION REAR CONDITION + \pgfmathtruncatemacro\rtwo{max(\mone,\mthree)} + + % MODULE 1 + \node[module,#1,module opacity](r1-1) at (0,0) {1}; + \node[below of=r1-1,yshift=0.75ex](r1-dots) {\vdots}; + \node[module,#1,module opacity,below of=r1-dots](r1-2) {\rone}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,2} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,2} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \node[module,#1,module opacity](r2-1) at (\modulexsep,0) {1}; + \node[below of=r2-1,yshift=0.75ex](r2-dots) {\vdots}; + \node[module,#1,module opacity,below of=r2-dots](r2-2) {\rtwo}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + } + + % MODULE 3 + \node[module,#1,module opacity](r3-1) at (2*\modulexsep,0) {1}; + \node[below of=r3-1,yshift=0.75ex](r3-dots) {\vdots}; + \node[module,#1,module opacity,below of=r3-dots](r3-2) {\rthree}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,2} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,2} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + } + + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + + % SETTING LABELS + \node[below of=r1-2, set math mode labels] {\mone~\ensuremath{\times}~\rtwo}; + \node[below of=r2-2, set math mode labels] {\rone~\ensuremath{\times}~\rthree}; + \node[below of=r3-2, set math mode labels] {\rtwo~\ensuremath{\times}~\mthree}; + \draw[decorate,decoration={brace}]($(r1-2-front input-2)-(0.1,0)$)--($(r1-1-front input-1)-(0.1,0)$) node[midway,left=0.1cm, set math mode labels]{\N}; + \draw[decorate,decoration={brace}]($(r3-1-front output-1)+(0.1,0)$)--($(r3-2-front output-2)+(0.1,0)$) node[midway,right=0.1cm, set math mode labels]{\M}; + }, +} + +% CLOS EXAMPLE WITH LABELS + +\tikzset{clos example with labels/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\mone}{\N/\rone} + \pgfmathtruncatemacro{\mthree}{\M/\rthree} + + % COMPUTATION REAR CONDITION + \pgfmathtruncatemacro\rtwo{max(\mone,\mthree)} + + % MODULE 1 + \node[module,#1,module opacity](r1-1) at (0,0) {1}; + \node[below of=r1-1,yshift=0.75ex](r1-dots) {\vdots}; + \node[module,#1,module opacity,below of=r1-dots](r1-2) {\ronelabel}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,2} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,2} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \node[module,#1,module opacity](r2-1) at (\modulexsep,0) {1}; + \node[below of=r2-1,yshift=0.75ex](r2-dots) {\vdots}; + \node[module,#1,module opacity,below of=r2-dots](r2-2) {\rtwolabel}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + } + + % MODULE 3 + \node[module,#1,module opacity](r3-1) at (2*\modulexsep,0) {1}; + \node[below of=r3-1,yshift=0.75ex](r3-dots) {\vdots}; + \node[module,#1,module opacity,below of=r3-dots](r3-2) {\rthreelabel}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,2} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,2} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + } + + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + + % SETTING LABELS + \node[below of=r1-2,set math mode labels] {\monelabel~\ensuremath{\times}~\rtwolabel}; + \node[below of=r2-2,set math mode labels] {\ronelabel~\ensuremath{\times}~\rthreelabel}; + \node[below of=r3-2,set math mode labels] {\rtwolabel~\ensuremath{\times}~\mthreelabel}; + \draw[decorate,decoration={brace}]($(r1-2-front input-2)-(0.1,0)$)--($(r1-1-front input-1)-(0.1,0)$) node[midway,left=0.1cm,set math mode labels]{\Nlabel}; + \draw[decorate,decoration={brace}]($(r3-1-front output-1)+(0.1,0)$)--($(r3-2-front output-2)+(0.1,0)$) node[midway,right=0.1cm,set math mode labels]{\Mlabel}; + }, +} + +% BENES +% uses modules 2x2 + +\tikzset{benes/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\m}{2} + + % Numbers of modules in the second stage + \pgfmathtruncatemacro\rtwo{\m} + + % Number of modules in the first/third stage + \pgfmathtruncatemacro{\r}{\P/\m} + + \ifnum\P=4 + \def\increment{0-\i*0.5*\r*\moduleysep} + \def\xincrement{\r*0.25*\modulexsep} + \else + \def\increment{0-\i*0.39*\r*\moduleysep} + \def\xincrement{\r*0.2*\modulexsep} + \fi + + % MODULE 1 + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r1-\i) at +(0,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 1 + % the number of inputs module one is exactly \mone + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,...,\m} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % the number of outputs of module one is the number of modules stage 2 \rtwo + \pgfmathsetmacro\roneintervalspace{1/(\rtwo+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \foreach \i in {1,...,\rtwo}{ + + \path let \n1 = {int(0-\i)}, \n2={\increment} + in + node[module extensible={\r*0.5*\modulesize},#1,module opacity,yshift=1cm] (r2-\i) at +(\xincrement,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 2 + % the number of inputs of module two is the number of modules stage 1 \rone + \pgfmathsetmacro\rtwointervalspace{1/(\r+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,...,\r} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % the number of outputs module two is exactly \rthree + \pgfmathsetmacro\rtwointervalspace{1/(\r+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,...,\r} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + + } + + % MODULE 3 + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r3-\i) at +(2*\xincrement,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 3 + % the number of inputs of module three is the number of modules stage 2 \rtwo + \pgfmathsetmacro\rthreeintervalspace{1/(\rtwo+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % the number of outputs module three is exactly \m + \pgfmathsetmacro\rthreeintervalspace{1/(\m+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,...,\m} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + } + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,...,\r}{ + \foreach \conn in {1,...,\rtwo} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,...,\r}{ + \foreach \conn in {1,...,\rtwo} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + \fi + } +} + +% BENES COMPLETE + +\tikzset{benes complete/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\m}{2} + + % Number of modules in the first/third stage + \pgfmathtruncatemacro{\r}{\P/\m} + + % Number of stages + \pgfmathtruncatemacro{\stages}{2*round(log2(\P))-1} + + % MODULES for all stages + \foreach \s [evaluate=\s as \numstage using int(\s-1)] in {1,...,\stages}{ + \ifnum\s=1 + % FIRST 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 +(0,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 1 + % the number of inputs module one is exactly \mone + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,...,\m} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % the number of outputs of module one is the number of modules stage 2 + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,...,\m} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + \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}; + + % INPUTS MODULE \s + % the number of inputs of module three is the number of modules stage 2 \rtwo + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \rinput[evaluate=\rinput as \rinterval using \rintervalspace*\rinput] + in {1,...,\m} + \node[circle,draw,scale=0.1] (r\s-\i-input-\rinput)at($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)$) {}; + + % OUTPUTS MODULE \s + % the number of outputs module three is exactly \mthree + \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*\pinlength,0)$)node[scale=0.1](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>1,\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}; + + % INPUTS MODULE \s + % the number of inputs of module three is the number of modules stage 2 \rtwo + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \rinput[evaluate=\rinput as \rinterval using \rintervalspace*\rinput] + in {1,...,\m} + \node[circle,draw,scale=0.1] (r\s-\i-input-\rinput)at($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)$) {}; + + % OUTPUTS MODULE \s + % the number of outputs module three is exactly \mthree + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] + in {1,...,\m} + \node[circle,draw,scale=0.1] (r\s-\i-output-\routput) at($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$) {}; + } + \fi + } + % end modules + + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % CONNECTIONS + + % the algorithm works for all the stages a part from the two in the middle + \ifnum\P>4 % in this case there are just two stages, thus the algorithm fails: treat it separately + % Compute \stages/2: they are the stages from left to the middle or from right to the middle + \pgfmathparse{floor(divide(\stages,2))} + \pgfmathtruncatemacro\stagesondirection{\pgfmathresult-1} + + % on left + \foreach \stg[evaluate=\stg as \nextstg using int(\stg+1)] in {1,...,\stagesondirection}{ + \pgfmathtruncatemacro\applicationon{\P/(2^\stg)}% number of modules over which the algorithm is applied + \pgfmathtruncatemacro\repetition{int(2^(\stg-1))}% the algorithm should be repeated for \repetition times + \foreach \t in {1,...,\repetition}{ + \pgfmathtruncatemacro\startingpoint{1+((\t-1)*\applicationon)} + \pgfmathtruncatemacro\endingpoint{(\startingpoint+\applicationon)-1} + \foreach \startmodule in {\startingpoint,...,\endingpoint}{ + \pgfmathisodd{\startmodule}{initmodule} + \ifnum\t=1 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2)} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2)} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-1); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2)} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2)} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-2); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-2); + \fi + \fi + \ifnum\t=2 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2+(\applicationon/2))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2+(\applicationon/2))} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-1); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2+(\applicationon/2))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2+(\applicationon/2))} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-2); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-2); + \fi + \fi + \ifnum\t>2 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-1); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-2); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-2); + \fi + \fi + } + } + } + + % on the right + + \foreach \stg[evaluate=\stg as \currstg using int(\stages-(\stg-1)), + evaluate=\stg as \nextstg using int(\currstg-1)] in {1,...,\stagesondirection}{ + \pgfmathtruncatemacro\applicationon{\P/(2^\stg)}% number of modules over which the algorithm is applied + \pgfmathtruncatemacro\repetition{int(2^(\stg-1))}% the algorithm should be repeated for \repetition times + \foreach \t in {1,...,\repetition}{ + \pgfmathtruncatemacro\startingpoint{1+((\t-1)*\applicationon)} + \pgfmathtruncatemacro\endingpoint{(\startingpoint+\applicationon)-1} + \foreach \startmodule in {\startingpoint,...,\endingpoint}{ + \pgfmathisodd{\startmodule}{initmodule} + \ifnum\t=1 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2)} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2)} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-1); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2)} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2)} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-2); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-2); + \fi + \fi + \ifnum\t=2 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2+(\applicationon/2))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2+(\applicationon/2))} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-1); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2+(\applicationon/2))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2+(\applicationon/2))} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-2); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-2); + \fi + \fi + \ifnum\t>2 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-1); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-2); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-2); + \fi + \fi + } + } + } + + \fi + + + % * * * * + % 2 Intermediate stages + + % Compute \stages/2 + \pgfmathparse{floor(divide(\stages,2))} + \pgfmathtruncatemacro\middlestage{\pgfmathresult} + \pgfmathtruncatemacro\middlestagei{int(\middlestage+1)} + \pgfmathtruncatemacro\middlestageii{int(\middlestagei+1)} + + % Drawing + \foreach \startmodule in {1,...,\r}{ + \pgfmathisodd{\startmodule}{initmodule} + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodule{int(\startmodule+1)} + \draw(r\middlestage-\startmodule-output-1)--(r\middlestagei-\startmodule-input-1); + \draw(r\middlestage-\startmodule-output-2)--(r\middlestagei-\endmodule-input-1); + \draw(r\middlestagei-\startmodule-output-1)--(r\middlestageii-\startmodule-input-1); + \draw(r\middlestagei-\startmodule-output-2)--(r\middlestageii-\endmodule-input-1); + \else + % if even + \pgfmathtruncatemacro\endmodule{int(\startmodule-1)} + \draw(r\middlestage-\startmodule-output-1)--(r\middlestagei-\endmodule-input-2); + \draw(r\middlestage-\startmodule-output-2)--(r\middlestagei-\startmodule-input-2); + \draw(r\middlestagei-\startmodule-output-1)--(r\middlestageii-\endmodule-input-2); + \draw(r\middlestagei-\startmodule-output-2)--(r\middlestageii-\startmodule-input-2); + \fi + } + % end connections + \fi % disable connections + } +} + + +\endinput 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 new file mode 100644 index 00000000000..2be4187b89a --- /dev/null +++ b/Master/texmf-dist/tex/latex/sa-tikz/tikzlibraryswitching-architectures.code.tex @@ -0,0 +1,1045 @@ +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% +% Sa-TikZ package v0.5 * * (C) Claudio Fiandrino 2012 +% +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% LOADING NECESSARY LIBRARIES +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +\usetikzlibrary{backgrounds,calc,positioning,decorations.pathreplacing} + +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% UTILITY +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +% PGFMATHISODD: 1 = true, 0 = false +% +% #1: number to be checked +% #2: output macro +% +% example: +%% \pgfmathisodd{32}{output} +%% \ifnum\output=1 +%% \node{\output}; +%% \fi +\newcommand*{\pgfmathisodd}[2]{ + \pgfmathparse{mod(#1,2)} + \pgfmathtruncatemacro\res\pgfmathresult + \global\expandafter\edef\csname #2\endcsname{\res} +} + +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% KEY DEFINITION - Design choices +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +% * * * * * * * * * * * * * * * * * * +% CLOS +% * * * * * * * * * * * * * * * * * * + +% N is the key representing the number of inputs x number of modules first stage +\pgfkeys{/tikz/.cd,% + N/.initial=10,% + N/.get=\N,% + N/.store in=\N,% +}% + +% N label +\pgfkeys{/tikz/.cd,% + N label/.initial=N,% + N label/.store in=\Nlabel,% + N label/.get=\Nlabel,% +}% + +% r1 is the number of modules first stage +% m1 is the number of inputs first stage per module + +\pgfkeys{/tikz/.cd,% + r1/.initial=5,% + r1/.store in=\rone,% + r1/.get=\rone,% +}% + +% r1 label +\pgfkeys{/tikz/.cd,% + r1 label/.initial={r\ensuremath{_1}},% + r1 label/.store in=\ronelabel,% + r1 label/.get=\ronelabel,% +}% + +% m1 label +\pgfkeys{/tikz/.cd, + m1 label/.initial={m\ensuremath{_1}},% + m1 label/.store in=\monelabel,% + m1 label/.get=\monelabel,% +}% + +% r2 label +\pgfkeys{/tikz/.cd,% + r2 label/.initial={r\ensuremath{_2}},% + r2 label/.store in=\rtwolabel,% + r2 label/.get=\rtwolabel,% +}% + +% M is the key representing the number of inputs x number of modules last stage +\pgfkeys{/tikz/.cd,% + M/.initial=10,% + M/.get=\M,% + M/.store in=\M,% +}% + +% M label +\pgfkeys{/tikz/.cd,% + M label/.initial=M,% + M label/.store in=\Mlabel,% + M label/.get=\Mlabel,% +}% + +% r3 is the number of modules last stage +% m3 is the number of inputs last stage per module +\pgfmathtruncatemacro\rthree{5}% +\pgfkeys{/tikz/.cd, r3/.initial=5}% +\pgfkeys{/tikz/.cd, r3/.store in=\rthree}% + +% r3 label +\pgfkeys{/tikz/.cd,% + r3 label/.initial={r\ensuremath{_3}},% + r3 label/.store in=\rthreelabel,% + r3 label/.get=\rthreelabel,% +}% + +% m3 label +\pgfkeys{/tikz/.cd, + m3 label/.initial={m\ensuremath{_3}},% + m3 label/.store in=\mthreelabel,% + m3 label/.get=\mthreelabel,% +}% + +% * * * * * * * * * * * * * * * * * * +% BENES +% * * * * * * * * * * * * * * * * * * + +% P is the number of input/output ports +\pgfkeys{/tikz/.cd,% + P/.initial=8,% + P/.get=\P,% + P/.store in=\P,% +}% + +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% GENERAL SETTINGS - Keys and styles +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +% module customization +\pgfkeys{/tikz/.cd,% + module size/.initial={1cm},% + module size/.get=\modulesize,% + module size/.store in=\modulesize,% +}% + +\pgfkeys{/tikz/.cd,% + module ysep/.initial={1.5},% + module ysep/.get=\moduleysep,% + module ysep/.store in=\moduleysep,% +}% + +\pgfkeys{/tikz/.cd,% + module xsep/.initial={3},% + module xsep/.get=\modulexsep,% + module xsep/.store in=\modulexsep,% +}% + +\pgfkeys{/tikz/.cd,% + module font/.initial=\normalfont,% + module font/.get=\modulefont,% + module font/.store in=\modulefont,% +}% + +\tikzset{module/.style={% + draw,rectangle, minimum size=\modulesize, + font=\modulefont, + } +} + +\tikzset{module extensible/.style={% + draw,rectangle, minimum size=#1, + }, + module extensible/.default={\modulesize} +} + +\pgfkeys{/tikz/.cd,% + module label opacity/.initial={1},% + module label opacity/.get=\modulelabelopacity,% + module label opacity/.store in=\modulelabelopacity,% +}% + +\tikzset{module opacity/.style={ + text opacity=\modulelabelopacity, + } +} + +\pgfkeys{/tikz/.cd,% + pin length factor/.initial={1},% + pin length factor/.get=\pinlength,% + pin length factor/.store in=\pinlength,% +}% + +% setting labels in math mode + +\tikzset{math mode labels/.style={% + execute at begin node=$,% + execute at end node=$,% + } +} +\pgfkeys{/tikz/.cd,% + use math mode labels/.is choice,% + use math mode labels/true/.style={math mode labels},% + use math mode labels/false/.style={},% +}% + +\tikzset{set math mode labels/.style={% + use math mode labels=#1,% + },% + set math mode labels/.default=false,% +} + +% disable the connections +\newif\ifconnectiondisabled% +\pgfkeys{/tikz/.cd, connections disabled/.is if=connectiondisabled}% +\pgfkeys{/tikz/.cd, connections disabled/.default=false}% + +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +% CODE +% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +% CLOS SNB +\tikzset{clos snb/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\mone}{\N/\rone} + \pgfmathtruncatemacro{\mthree}{\M/\rthree} + + % COMPUTATION SNB CONDITION + \pgfmathtruncatemacro\rtwo{\mone+\mthree-1} + + % MODULE 1 + \foreach \i in {1,...,\rone}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r1-\i) at +(0,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 1 + % the number of inputs module one is exactly \mone + \pgfmathsetmacro\roneintervalspace{1/(\mone+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,...,\mone} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % the number of outputs of module one is the number of modules stage 2 \rtwo + \pgfmathsetmacro\roneintervalspace{1/(\rtwo+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \foreach \i in {1,...,\rtwo}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r2-\i) at +(\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 2 + % the number of inputs of module two is the number of modules stage 1 \rone + \pgfmathsetmacro\rtwointervalspace{1/(\rone+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,...,\rone} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % the number of outputs module two is exactly \rthree + \pgfmathsetmacro\rtwointervalspace{1/(\rthree+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,...,\rthree} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + + } + + % MODULE 3 + \foreach \i in {1,...,\rthree}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r3-\i) at +(2*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 3 + % the number of inputs of module three is the number of modules stage 2 \rtwo + \pgfmathsetmacro\rthreeintervalspace{1/(\rtwo+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % the number of outputs module three is exactly \mthree + \pgfmathsetmacro\rthreeintervalspace{1/(\mthree+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,...,\mthree} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + + } + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,...,\rone}{ + \foreach \conn in {1,...,\rtwo} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,...,\rthree}{ + \foreach \conn in {1,...,\rtwo} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + \fi + }, +} + +\tikzset{clos snb example/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\mone}{\N/\rone} + \pgfmathtruncatemacro{\mthree}{\M/\rthree} + + % COMPUTATION SNB CONDITION + \pgfmathtruncatemacro\rtwo{\mone+\mthree-1} + + % MODULE 1 + \node[module,#1,module opacity](r1-1) at (0,0) {1}; + \node[below of=r1-1,yshift=0.75ex](r1-dots) {\vdots}; + \node[module,#1,module opacity,below of=r1-dots](r1-2) {\rone}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,2} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,2} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \node[module,#1,module opacity](r2-1) at (\modulexsep,0) {1}; + \node[below of=r2-1,yshift=0.75ex](r2-dots) {\vdots}; + \node[module,#1,module opacity,below of=r2-dots](r2-2) {\rtwo}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + } + + % MODULE 3 + \node[module,#1,module opacity](r3-1) at (2*\modulexsep,0) {1}; + \node[below of=r3-1,yshift=0.75ex](r3-dots) {\vdots}; + \node[module,#1,module opacity,below of=r3-dots](r3-2) {\rthree}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,2} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,2} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + } + + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + + % SETTING LABELS + \node[below of=r1-2,set math mode labels] {\mone~\ensuremath{\times}~\rtwo}; + \node[below of=r2-2,set math mode labels] {\rone~\ensuremath{\times}~\rthree}; + \node[below of=r3-2,set math mode labels] {\rtwo~\ensuremath{\times}~\mthree}; + \draw[decorate,decoration={brace}]($(r1-2-front input-2)-(0.1,0)$)--($(r1-1-front input-1)-(0.1,0)$) node[midway,left=0.1cm,set math mode labels]{\N}; + \draw[decorate,decoration={brace}]($(r3-1-front output-1)+(0.1,0)$)--($(r3-2-front output-2)+(0.1,0)$) node[midway,right=0.1cm,set math mode labels]{\M}; + }, +} + +% CLOS REAR + +\tikzset{clos rear/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\mone}{\N/\rone} + \pgfmathtruncatemacro{\mthree}{\M/\rthree} + + % COMPUTATION REAR CONDITION + \pgfmathtruncatemacro\rtwo{max(\mone,\mthree)} + + % MODULE 1 + \foreach \i in {1,...,\rone}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r1-\i) at +(0,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 1 + % the number of inputs module one is exactly \mone + \pgfmathsetmacro\roneintervalspace{1/(\mone+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,...,\mone} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % the number of outputs of module one is the number of modules stage 2 \rtwo + \pgfmathsetmacro\roneintervalspace{1/(\rtwo+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \foreach \i in {1,...,\rtwo}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r2-\i) at +(\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 2 + % the number of inputs of module two is the number of modules stage 1 \rone + \pgfmathsetmacro\rtwointervalspace{1/(\rone+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,...,\rone} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % the number of outputs module two is exactly \rthree + \pgfmathsetmacro\rtwointervalspace{1/(\rthree+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,...,\rthree} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + + } + + % MODULE 3 + \foreach \i in {1,...,\rthree}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r3-\i) at +(2*\modulexsep,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 3 + % the number of inputs of module three is the number of modules stage 2 \rtwo + \pgfmathsetmacro\rthreeintervalspace{1/(\rtwo+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % the number of outputs module three is exactly \mthree + \pgfmathsetmacro\rthreeintervalspace{1/(\mthree+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,...,\mthree} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + } + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,...,\rone}{ + \foreach \conn in {1,...,\rtwo} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,...,\rthree}{ + \foreach \conn in {1,...,\rtwo} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + \fi + } +} + +\tikzset{clos rear example/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\mone}{\N/\rone} + \pgfmathtruncatemacro{\mthree}{\M/\rthree} + + % COMPUTATION REAR CONDITION + \pgfmathtruncatemacro\rtwo{max(\mone,\mthree)} + + % MODULE 1 + \node[module,#1,module opacity](r1-1) at (0,0) {1}; + \node[below of=r1-1,yshift=0.75ex](r1-dots) {\vdots}; + \node[module,#1,module opacity,below of=r1-dots](r1-2) {\rone}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,2} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,2} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \node[module,#1,module opacity](r2-1) at (\modulexsep,0) {1}; + \node[below of=r2-1,yshift=0.75ex](r2-dots) {\vdots}; + \node[module,#1,module opacity,below of=r2-dots](r2-2) {\rtwo}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + } + + % MODULE 3 + \node[module,#1,module opacity](r3-1) at (2*\modulexsep,0) {1}; + \node[below of=r3-1,yshift=0.75ex](r3-dots) {\vdots}; + \node[module,#1,module opacity,below of=r3-dots](r3-2) {\rthree}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,2} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,2} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + } + + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + + % SETTING LABELS + \node[below of=r1-2, set math mode labels] {\mone~\ensuremath{\times}~\rtwo}; + \node[below of=r2-2, set math mode labels] {\rone~\ensuremath{\times}~\rthree}; + \node[below of=r3-2, set math mode labels] {\rtwo~\ensuremath{\times}~\mthree}; + \draw[decorate,decoration={brace}]($(r1-2-front input-2)-(0.1,0)$)--($(r1-1-front input-1)-(0.1,0)$) node[midway,left=0.1cm, set math mode labels]{\N}; + \draw[decorate,decoration={brace}]($(r3-1-front output-1)+(0.1,0)$)--($(r3-2-front output-2)+(0.1,0)$) node[midway,right=0.1cm, set math mode labels]{\M}; + }, +} + +% CLOS EXAMPLE WITH LABELS + +\tikzset{clos example with labels/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\mone}{\N/\rone} + \pgfmathtruncatemacro{\mthree}{\M/\rthree} + + % COMPUTATION REAR CONDITION + \pgfmathtruncatemacro\rtwo{max(\mone,\mthree)} + + % MODULE 1 + \node[module,#1,module opacity](r1-1) at (0,0) {1}; + \node[below of=r1-1,yshift=0.75ex](r1-dots) {\vdots}; + \node[module,#1,module opacity,below of=r1-dots](r1-2) {\ronelabel}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,2} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % just two modules + \pgfmathsetmacro\roneintervalspace{1/(2+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,2} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \node[module,#1,module opacity](r2-1) at (\modulexsep,0) {1}; + \node[below of=r2-1,yshift=0.75ex](r2-dots) {\vdots}; + \node[module,#1,module opacity,below of=r2-dots](r2-2) {\rtwolabel}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % just two modules + \pgfmathsetmacro\rtwointervalspace{1/(2+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,2} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + } + + % MODULE 3 + \node[module,#1,module opacity](r3-1) at (2*\modulexsep,0) {1}; + \node[below of=r3-1,yshift=0.75ex](r3-dots) {\vdots}; + \node[module,#1,module opacity,below of=r3-dots](r3-2) {\rthreelabel}; + + \foreach \i in {1,2}{ + % INPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,2} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % just two modules + \pgfmathsetmacro\rthreeintervalspace{1/(2+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,2} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + } + + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,2}{ + \foreach \conn in {1,2} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + + % SETTING LABELS + \node[below of=r1-2,set math mode labels] {\monelabel~\ensuremath{\times}~\rtwolabel}; + \node[below of=r2-2,set math mode labels] {\ronelabel~\ensuremath{\times}~\rthreelabel}; + \node[below of=r3-2,set math mode labels] {\rtwolabel~\ensuremath{\times}~\mthreelabel}; + \draw[decorate,decoration={brace}]($(r1-2-front input-2)-(0.1,0)$)--($(r1-1-front input-1)-(0.1,0)$) node[midway,left=0.1cm,set math mode labels]{\Nlabel}; + \draw[decorate,decoration={brace}]($(r3-1-front output-1)+(0.1,0)$)--($(r3-2-front output-2)+(0.1,0)$) node[midway,right=0.1cm,set math mode labels]{\Mlabel}; + }, +} + +% BENES +% uses modules 2x2 + +\tikzset{benes/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\m}{2} + + % Numbers of modules in the second stage + \pgfmathtruncatemacro\rtwo{\m} + + % Number of modules in the first/third stage + \pgfmathtruncatemacro{\r}{\P/\m} + + \ifnum\P=4 + \def\increment{0-\i*0.5*\r*\moduleysep} + \def\xincrement{\r*0.25*\modulexsep} + \else + \def\increment{0-\i*0.39*\r*\moduleysep} + \def\xincrement{\r*0.2*\modulexsep} + \fi + + % MODULE 1 + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r1-\i) at +(0,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 1 + % the number of inputs module one is exactly \mone + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,...,\m} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % the number of outputs of module one is the number of modules stage 2 \rtwo + \pgfmathsetmacro\roneintervalspace{1/(\rtwo+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + + % MODULE 2 + \foreach \i in {1,...,\rtwo}{ + + \path let \n1 = {int(0-\i)}, \n2={\increment} + in + node[module extensible={\r*0.5*\modulesize},#1,module opacity,yshift=1cm] (r2-\i) at +(\xincrement,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 2 + % the number of inputs of module two is the number of modules stage 1 \rone + \pgfmathsetmacro\rtwointervalspace{1/(\r+1)} + \foreach \rtwoinput[evaluate=\rtwoinput as \rtwointerval using \rtwointervalspace*\rtwoinput] + in {1,...,\r} + \node[circle,draw,scale=0.1] (r2-\i-input-\rtwoinput)at($(r2-\i.north west)!\rtwointerval!(r2-\i.south west)$) {}; + + % OUTPUTS MODULE 2 + % the number of outputs module two is exactly \rthree + \pgfmathsetmacro\rtwointervalspace{1/(\r+1)} + \foreach \rtwooutput[evaluate=\rtwooutput as \rtwointerval using \rtwointervalspace*\rtwooutput] + in {1,...,\r} + \node[circle,draw,scale=0.1] (r2-\i-output-\rtwooutput)at ($(r2-\i.north east)!\rtwointerval!(r2-\i.south east)$) {}; + + } + + % MODULE 3 + \foreach \i in {1,...,\r}{ + \path let \n1 = {int(0-\i)}, \n2={0-\i*\moduleysep} + in + node[module,#1,module opacity,yshift=1cm] (r3-\i) at +(2*\xincrement,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 3 + % the number of inputs of module three is the number of modules stage 2 \rtwo + \pgfmathsetmacro\rthreeintervalspace{1/(\rtwo+1)} + \foreach \rthreeinput[evaluate=\rthreeinput as \rthreeinterval using \rthreeintervalspace*\rthreeinput] + in {1,...,\rtwo} + \node[circle,draw,scale=0.1] (r3-\i-input-\rthreeinput)at($(r3-\i.north west)!\rthreeinterval!(r3-\i.south west)$) {}; + + % OUTPUTS MODULE 3 + % the number of outputs module three is exactly \m + \pgfmathsetmacro\rthreeintervalspace{1/(\m+1)} + \foreach \rthreeoutput[evaluate=\rthreeoutput as \rthreeinterval using \rthreeintervalspace*\rthreeoutput] + in {1,...,\m} + \draw ($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)+(0.5*\pinlength,0)$)node[scale=0.1](r3-\i-front output-\rthreeoutput){}--($(r3-\i.north east)!\rthreeinterval!(r3-\i.south east)$) node[circle,draw,scale=0.1] (r3-\i-output-\rthreeoutput) {}; + } + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % DRAWING CONNECTIONS + %% from r1 to r2 + \foreach \startmodule in {1,...,\r}{ + \foreach \conn in {1,...,\rtwo} + \draw(r1-\startmodule-output-\conn)--(r2-\conn-input-\startmodule); + } + %% from r2 to r3 + \foreach \startmodule in {1,...,\r}{ + \foreach \conn in {1,...,\rtwo} + \draw(r3-\startmodule-input-\conn)--(r2-\conn-output-\startmodule); + } + \fi + } +} + +% BENES COMPLETE + +\tikzset{benes complete/.code={ + + % Number of ports per module + \pgfmathtruncatemacro{\m}{2} + + % Number of modules in the first/third stage + \pgfmathtruncatemacro{\r}{\P/\m} + + % Number of stages + \pgfmathtruncatemacro{\stages}{2*round(log2(\P))-1} + + % MODULES for all stages + \foreach \s [evaluate=\s as \numstage using int(\s-1)] in {1,...,\stages}{ + \ifnum\s=1 + % FIRST 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 +(0,\n2) {\pgfmathparse{int(multiply(\n1,-1))}\pgfmathresult}; + + % INPUTS MODULE 1 + % the number of inputs module one is exactly \mone + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneinput[evaluate=\roneinput as \roneinterval using \roneintervalspace*\roneinput] + in {1,...,\m} + \draw ($(r1-\i.north west)!\roneinterval!(r1-\i.south west)-(0.5*\pinlength,0)$)node[scale=0.1](r1-\i-front input-\roneinput){}--($(r1-\i.north west)!\roneinterval!(r1-\i.south west)$) node[circle,draw,scale=0.1] (r1-\i-input-\roneinput) {}; + + % OUTPUTS MODULE 1 + % the number of outputs of module one is the number of modules stage 2 + \pgfmathsetmacro\roneintervalspace{1/(\m+1)} + \foreach \roneoutput[evaluate=\roneoutput as \roneinterval using \roneintervalspace*\roneoutput] + in {1,...,\m} + \node[circle,draw,scale=0.1] (r1-\i-output-\roneoutput)at($(r1-\i.north east)!\roneinterval!(r1-\i.south east)$) {}; + } + \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}; + + % INPUTS MODULE \s + % the number of inputs of module three is the number of modules stage 2 \rtwo + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \rinput[evaluate=\rinput as \rinterval using \rintervalspace*\rinput] + in {1,...,\m} + \node[circle,draw,scale=0.1] (r\s-\i-input-\rinput)at($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)$) {}; + + % OUTPUTS MODULE \s + % the number of outputs module three is exactly \mthree + \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*\pinlength,0)$)node[scale=0.1](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>1,\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}; + + % INPUTS MODULE \s + % the number of inputs of module three is the number of modules stage 2 \rtwo + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \rinput[evaluate=\rinput as \rinterval using \rintervalspace*\rinput] + in {1,...,\m} + \node[circle,draw,scale=0.1] (r\s-\i-input-\rinput)at($(r\s-\i.north west)!\rinterval!(r\s-\i.south west)$) {}; + + % OUTPUTS MODULE \s + % the number of outputs module three is exactly \mthree + \pgfmathsetmacro\rintervalspace{1/(\m+1)} + \foreach \routput[evaluate=\routput as \rinterval using \rintervalspace*\routput] + in {1,...,\m} + \node[circle,draw,scale=0.1] (r\s-\i-output-\routput) at($(r\s-\i.north east)!\rinterval!(r\s-\i.south east)$) {}; + } + \fi + } + % end modules + + + % Test if connections should be removed + \ifconnectiondisabled + \relax + \else + % CONNECTIONS + + % the algorithm works for all the stages a part from the two in the middle + \ifnum\P>4 % in this case there are just two stages, thus the algorithm fails: treat it separately + % Compute \stages/2: they are the stages from left to the middle or from right to the middle + \pgfmathparse{floor(divide(\stages,2))} + \pgfmathtruncatemacro\stagesondirection{\pgfmathresult-1} + + % on left + \foreach \stg[evaluate=\stg as \nextstg using int(\stg+1)] in {1,...,\stagesondirection}{ + \pgfmathtruncatemacro\applicationon{\P/(2^\stg)}% number of modules over which the algorithm is applied + \pgfmathtruncatemacro\repetition{int(2^(\stg-1))}% the algorithm should be repeated for \repetition times + \foreach \t in {1,...,\repetition}{ + \pgfmathtruncatemacro\startingpoint{1+((\t-1)*\applicationon)} + \pgfmathtruncatemacro\endingpoint{(\startingpoint+\applicationon)-1} + \foreach \startmodule in {\startingpoint,...,\endingpoint}{ + \pgfmathisodd{\startmodule}{initmodule} + \ifnum\t=1 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2)} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2)} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-1); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2)} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2)} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-2); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-2); + \fi + \fi + \ifnum\t=2 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2+(\applicationon/2))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2+(\applicationon/2))} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-1); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2+(\applicationon/2))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2+(\applicationon/2))} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-2); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-2); + \fi + \fi + \ifnum\t>2 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-1); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \draw(r\stg-\startmodule-output-1)--(r\nextstg-\endmodulei-input-2); + \draw(r\stg-\startmodule-output-2)--(r\nextstg-\endmoduleii-input-2); + \fi + \fi + } + } + } + + % on the right + + \foreach \stg[evaluate=\stg as \currstg using int(\stages-(\stg-1)), + evaluate=\stg as \nextstg using int(\currstg-1)] in {1,...,\stagesondirection}{ + \pgfmathtruncatemacro\applicationon{\P/(2^\stg)}% number of modules over which the algorithm is applied + \pgfmathtruncatemacro\repetition{int(2^(\stg-1))}% the algorithm should be repeated for \repetition times + \foreach \t in {1,...,\repetition}{ + \pgfmathtruncatemacro\startingpoint{1+((\t-1)*\applicationon)} + \pgfmathtruncatemacro\endingpoint{(\startingpoint+\applicationon)-1} + \foreach \startmodule in {\startingpoint,...,\endingpoint}{ + \pgfmathisodd{\startmodule}{initmodule} + \ifnum\t=1 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2)} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2)} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-1); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2)} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2)} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-2); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-2); + \fi + \fi + \ifnum\t=2 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2+(\applicationon/2))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2+(\applicationon/2))} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-1); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2+(\applicationon/2))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2+(\applicationon/2))} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-2); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-2); + \fi + \fi + \ifnum\t>2 + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodulei{int((\startmodule+1)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+1+\applicationon)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-1); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-1); + \else + % if even + \pgfmathtruncatemacro\endmodulei{int((\startmodule)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \pgfmathtruncatemacro\endmoduleii{int((\startmodule+\applicationon)/2+(\applicationon/2)+((\applicationon/2)*(\t-2)))} + \draw(r\currstg-\startmodule-input-1)--(r\nextstg-\endmodulei-output-2); + \draw(r\currstg-\startmodule-input-2)--(r\nextstg-\endmoduleii-output-2); + \fi + \fi + } + } + } + + \fi + + + % * * * * + % 2 Intermediate stages + + % Compute \stages/2 + \pgfmathparse{floor(divide(\stages,2))} + \pgfmathtruncatemacro\middlestage{\pgfmathresult} + \pgfmathtruncatemacro\middlestagei{int(\middlestage+1)} + \pgfmathtruncatemacro\middlestageii{int(\middlestagei+1)} + + % Drawing + \foreach \startmodule in {1,...,\r}{ + \pgfmathisodd{\startmodule}{initmodule} + \ifnum\initmodule=1 + % if odd + \pgfmathtruncatemacro\endmodule{int(\startmodule+1)} + \draw(r\middlestage-\startmodule-output-1)--(r\middlestagei-\startmodule-input-1); + \draw(r\middlestage-\startmodule-output-2)--(r\middlestagei-\endmodule-input-1); + \draw(r\middlestagei-\startmodule-output-1)--(r\middlestageii-\startmodule-input-1); + \draw(r\middlestagei-\startmodule-output-2)--(r\middlestageii-\endmodule-input-1); + \else + % if even + \pgfmathtruncatemacro\endmodule{int(\startmodule-1)} + \draw(r\middlestage-\startmodule-output-1)--(r\middlestagei-\endmodule-input-2); + \draw(r\middlestage-\startmodule-output-2)--(r\middlestagei-\startmodule-input-2); + \draw(r\middlestagei-\startmodule-output-1)--(r\middlestageii-\endmodule-input-2); + \draw(r\middlestagei-\startmodule-output-2)--(r\middlestageii-\startmodule-input-2); + \fi + } + % end connections + \fi % disable connections + } +} + + +\endinput diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index c41efa6deb8..75396b9e780 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -363,9 +363,9 @@ my @TLP_working = qw( rotating rotfloat rotpages roundbox rrgtrees rsc rsfs rsfso rtkinenc rtklage russ rviewport rvwrite ryethesis - sageep sansmath sansmathaccent sapthesis sasnrdisplay sauerj sauterfonts - savefnmark savesym savetrees scale - scalebar schemabloc schulschriften schwalbe-chess + sa-tikz sageep sansmath sansmathaccent sapthesis sasnrdisplay sauerj + sauterfonts savefnmark savesym savetrees + scale scalebar schemabloc schulschriften schwalbe-chess sciposter screenplay scrjrnl sdrt secdot section sectionbox sectsty selectp semantic semaphor diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index b09e9ecbf37..9ba6ddd3940 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -859,6 +859,7 @@ chomp ($Build = `cd $Master/../Build/source && pwd`); 'rst', "die 'skipping, nonfree license'", 'rtsched', "die 'skipping, Elisp package'", 'russian', "die 'skipping, babel non-update, must install as doc only'", + 'sa-tikz', "&MAKEflatten", 'sae', "die 'skipping, nosell license'", 'saferef', "die 'skipping, nonfree license'", 'sagetex', "die 'skipping, omitted at author request (25 Jan 2010 19:50:16)'", @@ -1438,6 +1439,7 @@ $standardtex='\.(.bx|cfg|sty|clo|ldf|cls|def|fd|cmap|4ht)$'; 'revtex', '\.sty|\.cls|\.rtx', 'rlepsf', 'rlepsf.tex', 'rsfs', 'scrload\.tex|' . $standardtex, + 'sa-tikz', 'tikzlib.*tex|' . $standardtex, 'sansmath', '^..[^s].*\.sty', # not miscdoc.sty 'seminar', '\.bug|\.bg2|\.cls|\.sty|2up.tex', 'shade', 'shade\.tex', # not description.tex diff --git a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc index 58a42b760a0..d89b4727df2 100644 --- a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc @@ -69,6 +69,7 @@ depend randomwalk depend reotex depend roundbox depend rviewport +depend sa-tikz depend schemabloc depend setdeck depend smartdiagram diff --git a/Master/tlpkg/tlpsrc/sa-tikz.tlpsrc b/Master/tlpkg/tlpsrc/sa-tikz.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d -- cgit v1.2.3