LibreVNA/Documentation/DeveloperInfo/DigitalBlockdiagram.tex

223 lines
8.9 KiB
TeX
Raw Normal View History

2020-09-22 00:49:17 +08:00
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage[european,siunitx,rotatelabels]{circuitikzgit}
\usetikzlibrary{arrows,calc,positioning}
\newcommand{\divider}[1]
{ % #1 = name
\begin{scope}[transform shape]
\draw[thick] (#1)node[](a){} +(-12pt,-12pt) rectangle +(12pt,12pt);
\draw (a)+(12pt, 12pt)--+(-12pt,-12pt);
\draw (a)+(-5pt,6pt) node[](){\footnotesize -45};
\draw (a)+(4pt,-7pt) node[](){\footnotesize +45};
\end{scope}
}
\newlength{\ResUp} \newlength{\ResDown}
\newlength{\ResLeft} \newlength{\ResRight}
\newlength{\ResRadius} \newlength{\ResMiddle}
\makeatletter
%%%% new anchors: "out A" and "out B"
\expandafter\def\csname pgf@anchor@rectangle@out A\endcsname{% output A: below .east
\pgf@process{\southwest}%
\pgf@ya=0.25\pgf@y%
\pgf@process{\northeast}%
\pgf@y=0.75\pgf@y%
\advance\pgf@y by\pgf@ya }% end of out A
\expandafter\def\csname pgf@anchor@rectangle@out B\endcsname{% output B: above .east
\pgf@process{\southwest}%
\pgf@ya=0.75\pgf@y%
\pgf@process{\northeast}%
\pgf@y=0.25\pgf@y%
\advance\pgf@y by\pgf@ya } % end of out B
\expandafter\def\csname pgf@anchor@rectangle@DUT\endcsname{% output DUT: above .east
\pgf@process{\southwest}%
\pgf@ya=0.1\pgf@y%
\pgf@process{\northeast}%
\pgf@y=0.9\pgf@y%
\advance\pgf@y by\pgf@ya } % end of DUT
\expandafter\def\csname pgf@anchor@rectangle@ret p\endcsname{% output ret p: above .east
\pgf@process{\northeast}%
\pgf@ya=0.9\pgf@y%
\pgf@process{\southwest}%
\pgf@y=0.1\pgf@y%
\advance\pgf@y by\pgf@ya } % end of ret p
\expandafter\def\csname pgf@anchor@rectangle@ret n\endcsname{% output ret n: above .east
\pgf@process{\northeast}%
\pgf@ya=0.7\pgf@y%
\pgf@process{\southwest}%
\pgf@y=0.3\pgf@y%
\advance\pgf@y by\pgf@ya } % end of ret n
\expandafter\def\csname pgf@anchor@rectangle@ret c\endcsname{% output ret c: above .east
\pgf@process{\northeast}%
\pgf@ya=0.8\pgf@y%
\pgf@process{\southwest}%
\pgf@y=0.2\pgf@y%
\advance\pgf@y by\pgf@ya } % end of ret c
\def\TikzBipolePath#1#2{\pgf@circ@bipole@path{#1}{#2}}
\def\CircDirection{\pgf@circ@direction}
%\pgf@circ@Rlen = \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\let\ResLen=\pgf@circ@Rlen
\makeatother
\newcommand{\Compass}% define anchors for compass points
{\anchor{north east}{\northeast}
\anchor{south west}{\southwest}
\anchor{north}{\pgfextracty{\ResUp}{\northeast}\pgfpoint{0cm}{\ResUp}}
\anchor{north west}{\pgfextracty{\ResUp}{\northeast}\pgfextractx{\ResLeft}{\southwest}\pgfpoint{\ResLeft}{\ResUp}}
\anchor{west}{\pgfextractx{\ResLeft}{\southwest}\pgfpoint{\ResLeft}{0cm}}
\anchor{south}{\pgfextracty{\ResDown}{\southwest}\pgfpoint{0cm}{\ResDown}}
\anchor{south east}{\pgfextracty{\ResDown}{\southwest}\pgfextractx{\ResRight}{\northeast}\pgfpoint{\ResRight}{\ResDown}}
\anchor{east}{\pgfextractx{\ResRight}{\northeast}\pgfpoint{\ResRight}{0cm}}}
% ***************************** ADC *********************************
% extra anchors out,in1,in2,vref
\ctikzset{bipoles/ADC/width/.initial=1}
\ctikzset{bipoles/ADC/height/.initial=.5}
\ctikzset{bipoles/ADC/middle/.initial=-.25}
\ctikzset{bipoles/ADC/part/.initial={}}
\def\drawADC{% used by both bipole and node
\ResRight=\ctikzvalof{bipoles/ADC/width}\ResLen
\ResRight=0.5\ResRight
\ResLeft=-\ResRight
\ResUp=\ctikzvalof{bipoles/ADC/height}\ResLen
\ResUp=0.5\ResUp
\ResDown=-\ResUp
\ResMiddle=\ctikzvalof{bipoles/ADC/middle}\ResLen
\pgfpathmoveto{\pgfpoint{\ResLeft}{0pt}}
\pgfpathlineto{\pgfpoint{\ResMiddle}{\ResUp}}
\pgfpathlineto{\pgfpoint{\ResRight}{\ResUp}}
\pgfpathlineto{\pgfpoint{\ResRight}{\ResDown}}
\pgfpathlineto{\pgfpoint{\ResMiddle}{\ResDown}}
\pgfpathlineto{\pgfpoint{\ResLeft}{0pt}}
\pgfpathclose
\pgfusepath{draw}
\pgftext{\texttt{\ctikzvalof{bipoles/ADC/part}}}
}
\pgfcircdeclarebipole{}% no extra anchors for bipole version
{\ctikzvalof{bipoles/ADC/height}}
{ADC}
{\ctikzvalof{bipoles/ADC/height}}
{\ctikzvalof{bipoles/ADC/width}}
{\pgfsetlinewidth{\ctikzvalof{bipoles/thickness}\pgfstartlinewidth}\drawADC}
\def\ADCpath#1{\TikzBipolePath{ADC}{#1}}
\tikzset{ADC/.style = {\circuitikzbasekey, /tikz/to path=\ADCpath, l_=#1}}
\pgfdeclareshape{dADC}{%
\anchor{center}{\pgfpointorigin} % within the node, (0,0) is the center
\anchor{text} % this is used to center the text in the node
{\pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}}
\savedmacro{\resize}{ % called automatically
\ResRight=\ctikzvalof{bipoles/ADC/width}\ResLen
\ResRight=0.5\ResRight
\ResLeft=-\ResRight
\ResUp=\ctikzvalof{bipoles/ADC/height}\ResLen
\ResUp=0.5\ResUp
\ResDown=-\ResUp
\ResMiddle=\ctikzvalof{bipoles/ADC/middle}\ResLen
\ResRadius=\ResMiddle% location of in1 and in2
\advance\ResRadius by \ResLeft
\ResRadius=0.5\ResRadius
}% while these can be used for savedanchors, they will be fogotten by anchors
\savedanchor{\northeast}{\pgfpoint{\ResRight}{\ResUp}}
\savedanchor{\southwest}{\pgfpoint{\ResLeft}{\ResDown}}
\savedanchor\InOne{\pgfpoint{\ResRadius}{0.5\ResUp}}
\savedanchor\InTwo{\pgfpoint{\ResRadius}{0.5\ResDown}}
\savedanchor\Out{\pgfpoint{\ResRight}{0pt}}
\savedanchor\Vref{\pgfpoint{0pt}{\ResDown}}
\Compass% standard anchors
\anchor{in1}{\InOne}
\anchor{in2}{\InTwo}
\anchor{out}{\Out}
\anchor{vref}{\Vref}
\foregroundpath{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgflinewidth}
\drawADC}
}
\tikzset%
{
synthesizer/.style ={rectangle, draw, semithick, minimum height=20mm, minimum width=25mm,
append after command={\pgfextra{\let\LN\tikzlastnode
\node[draw, right=0.15cm,font=\footnotesize, anchor=west](pll) at (\LN.west) {PLL};
\node[oscillator,box,left=0.15cm,anchor=east](osc) at ( \LN.east){};
\node[anchor=north] at(\LN.north){#1};
\draw[-latex] (pll.east)--(osc.west);
\draw[-latex] (osc.south)--++(0,-0.2cm)-|(pll.south);
}}
},
synthesizer/.default = {}
}
\begin{document}
\begin{circuitikz}
% Microcontroller
\node[draw,minimum width=3cm, minimum height = 2cm, align=center] (uC) at (-3,0) {Microcontroller\\STM32G431};
\node[anchor=east] (usb) at (-6, 0){USB C};
\draw[latex-latex] ([yshift=1mm]usb.east)--([yshift=1mm]uC.west) node[midway,above, anchor=south,font=\tiny]{USB 2.0 FS};
\draw[latex-latex] ([yshift=-1mm]usb.east)--([yshift=-1mm]uC.west) node[midway,below, anchor=north,font=\tiny]{USB PD};
\node[anchor=south, align=center] (led) at (-3.5, 2) {Booting\\LED};
\draw[-latex]([xshift=-0.5cm]uC.north)--(led);
% Flash
\node[draw, align=center] (flash) at (-3,-2) {FLASH};
\draw[latex-latex] (uC.south)--(flash.north) node[midway,above, anchor=west,font=\tiny]{SPI};
% FPGA
\node[draw,minimum width=3cm, minimum height = 2cm, align=center] (fpga) at (2,0) {FPGA\\Spartan 6\\XC6SLX9};
\draw[latex-latex] ([yshift=7.5mm]uC.east)--([yshift=7.5mm]fpga.west) node[midway,above, anchor=south,font=\tiny]{SPI};
\draw[-latex] ([yshift=2.5mm]uC.east)--([yshift=2.5mm]fpga.west) node[midway,above, anchor=south,font=\tiny]{Control};
\draw[latex-] ([yshift=-2.5mm]uC.east)--([yshift=-2.5mm]fpga.west) node[midway,above, anchor=south,font=\tiny]{IRQ};
\draw[-latex] ([yshift=-7.5mm]uC.east)--([yshift=-7.5mm]fpga.west) node[midway,above, anchor=south,font=\tiny]{Configuration};
\node[anchor=north, below=1cm of fpga] (leds) {LEDs};
\draw[-latex](fpga.south)--(leds);
\node[synthesizer={Si5351C},label={[align=center]CLK Distributor}] (Si5351) at (2,3) {};
\draw[-latex]([xshift=5mm]uC.north)|-(Si5351.west) node[midway,above, anchor=south,font=\tiny]{I\textsuperscript{2}C};
\draw[-latex](Si5351.south)--(fpga.north) node[midway, font=\tiny, anchor=east]{\SI{16}{\mega\hertz} CLK};
\node[dADC,above right=2cm and 3cm of fpga,xscale=-1] (ADC1) {};
\node[font=\footnotesize, align=center] at (ADC1){Port1\\ADC};
\node[anchor=south, font=\footnotesize] at (ADC1.north){MCP33131D-10};
\draw[-latex](ADC1.east)--++(-1,0)|-([yshift=7.5mm]fpga.east);
\node[dADC,below=0.5cm of ADC1,xscale=-1] (ADC2) {};
\node[font=\footnotesize, align=center] at (ADC2){Port2\\ADC};
\node[anchor=south, font=\footnotesize] at (ADC2.north){MCP33131D-10};
\draw[-latex](ADC2.east)--++(-0.75,0)|-([yshift=5mm]fpga.east);
\node[dADC,below=0.5cm of ADC2,xscale=-1] (ADC3) {};
\node[font=\footnotesize, align=center] at (ADC3){Ref.\\ADC};
\node[anchor=south, font=\footnotesize] at (ADC3.north){MCP33131D-10};
\draw[-latex](ADC3.east)--++(-0.5,0)|-([yshift=2.5mm]fpga.east);
\node[draw, right =1.5cm of fpga, align=center] (rfswitches) {RF attenuator\\and switches};
\draw[-latex](fpga.east)--(rfswitches.west);
\node[synthesizer={MAX2871},below = 0.5cm of rfswitches, label={[align=center]HF Source}] (HFSource) {};
\draw[latex-](HFSource.west)--++(-0.5,0)|-([yshift=-2.5mm]fpga.east);
\node[synthesizer={MAX2871},below = 0.5cm of HFSource, label={[align=center]1.LO}] (LO1) {};
\draw[latex-](LO1.west)--++(-0.75,0)|-([yshift=-5mm]fpga.east);
\end{circuitikz}
\end{document}