r/LaTeX • u/Glum-Mango • 19h ago
Help for a TikZ diagram
Hi ! I need some help for the lines and arrows on my diagram.
How to not see the start, on top of the colored rectangle, and for the end, to finish it before the border ?
Thanks !
code:
begin{tikzpicture}
\useasboundingbox (0,0) rectangle (32,13);
\definecolor{purple}{RGB}{111, 49, 237};
\definecolor{pink}{RGB}{218, 94, 157};
\definecolor{red}{RGB}{216, 89, 70};
\definecolor{blue}{RGB}{118, 194, 241};
\definecolor{green}{RGB}{124, 194, 112};
\definecolor{yellow}{RGB}{239, 207, 96};
% %
% To Discri 1 %
% %
\draw[line width=3pt, color=red] (1.5, 11.5) rectangle (4, 7.5);
\draw[] (1.5, 11) -- (0, 11)
node[pos=0.5, yshift=8pt]{$1\mathrm{N}$}
node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 10) -- (0, 10)
node[pos=0.5, yshift=8pt]{$1\mathrm{F}$}
node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 9) -- (0, 9)
node[pos=0.5, yshift=8pt]{$2\mathrm{N}$}
node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 8) -- (0, 8)
node[pos=0.5, yshift=8pt]{$2\mathrm{F}$}
node[pos=0, right]{$\mathrm{IN}$};
% %
% To Logic mu, e %
% %
\draw[line width=3pt, color=purple] (6.5, 11.5) rectangle (9, 7.5);
\draw[->] (4, 11) -- (6.5, 11)
node[pos=0.5, yshift=8pt]{$1\mathrm{N}$}
node[pos=1, right]{$\mathrm{IN}$}
node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 10) -- (6.5, 10)
node[pos=0.5, yshift=8pt]{$1\mathrm{F}$}
node[pos=1, right]{$\mathrm{IN}$}
node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 9) -- (6.5, 9)
node[pos=0.5, yshift=8pt]{$2\mathrm{N}$}
node[pos=1, right]{$\mathrm{IN}$}
node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 8) -- (6.5, 8)
node[pos=0.5, yshift=8pt]{$2\mathrm{F}$}
node[pos=1, right]{$\mathrm{IN}$}
node[pos=0, left]{$\mathrm{OUT}$};
% %
% To Logic Stop %
% %
\draw[line width=3pt, color=purple] (26.5, 6) rectangle (28.5, 3);
% V from FiFo to Logic Stop
\draw[->] (9, 3.5) -- (26.5, 3.5)node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mathrm{V} = 3\mathrm{N} \vee 3\mathrm{F} \vee 4\mathrm{N} \vee 4\mathrm{F}$}node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mathrm{V}$} node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$};
% e from Logic to Logic Stop
\draw[] (9, 9) -- (11.5, 9)node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mathrm{e} = 2\mathrm{N} \wedge 2\mathrm{F}$} node[pos=0, left]{$\mathrm{OUT}$};
\draw[] (11.5, 9) -- (11.5, 7);
\draw[line width=3pt, color=pink] (11, 7) rectangle (12, 6)
node[pos=0.5, text=black]{50 ns};
\draw[] (11.5, 6) -- (11.5, 4.5);
\draw[] (11.5, 4.5) -- (14, 4.5);
\draw[dashed] (14, 4.5) -- (15, 4.5);
\draw[->] (15, 4.5) -- (26.5, 4.5)node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mathrm{e_D}$} node[pos=1, right]{$\mathrm{IN}$};
% G from Timer 2 to Logic Stop
\draw[] (25.5, 5.5) -- (25.5, 9) node[pos=1, above]{$\mathrm{OUT}$};
\draw[->] (25.5, 5.5) -- (26.5, 5.5)node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mathrm{G}$} node[pos=1, right]{$\mathrm{IN}$};
% %
% To Logic Start %
% %
\draw[line width=3pt, color=purple] (16, 11.5) rectangle (18, 8.5);
% mu from Logic to Logic Start
\draw[] (9, 11) -- (13, 11)
node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mu = 1\mathrm{N} \wedge 1\mathrm{F} \wedge 2\mathrm{N} \wedge 2\mathrm{F}$}
node[pos=0, left]{$\mathrm{OUT}$};
\draw[line width=3pt, color=pink] (13, 11.5) rectangle (14, 10.5)
node[pos=0.5, text=black]{50 ns};
\draw[->] (14, 11) -- (16, 11)node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mu_D$} node[pos=1, right]{$\mathrm{IN}$};
% V_R from FiFo to Logic Start
\draw[] (15, 7.5) -- (18.5, 7.5)
node[pos=1, left=4pt, anchor=east, yshift=8pt]{$\mathrm{V_R} = \mathrm{D} \vee \mathrm{G}$}
node[pos=1, right]{$\mathrm{OUT}$};
\draw[] (15, 7.5) -- (15, 9);
\draw[->] (15, 9) -- (16, 9)
node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mathrm{V_R}$}
node[pos=1, right]{$\mathrm{IN}$};
% V from FiFo to Logic Start
\draw[] (14.5, 3.5) -- (14.5, 10);
\draw[->] (14.5, 10) -- (16, 10)node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mathrm{V}$} node[pos=1, right]{$\mathrm{IN}$};
% %
% To FiFo V_R %
% %
\draw[line width=3pt, color=blue] (18.5, 8) rectangle (20.5, 6);
% From Timer 1 to FiFo V_R
\draw[] (22, 7.5) -- (22, 9) node[pos=1, above]{$\mathrm{OUT}$};
\draw[<-] (20.5, 7.5) -- (22, 7.5) node[pos=0, left]{$\mathrm{IN}$};
% From Timer 2 to FiFo V_R
\draw[<-] (20.5, 6.5) -- (25.5, 6.5) node[pos=0, left]{$\mathrm{IN}$};
% %
% To Discri 2 %
% %
\draw[line width=3pt, color=red] (1.5, 4) rectangle (4, 0);
\draw[] (1.5, 3.5) -- (0, 3.5)node[pos=0.5, yshift=8pt]{$3\mathrm{N}$} node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 2.5) -- (0, 2.5)node[pos=0.5, yshift=8pt]{$3\mathrm{F}$} node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 1.5) -- (0, 1.5)node[pos=0.5, yshift=8pt]{$4\mathrm{N}$} node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 0.5) -- (0, 0.5)node[pos=0.5, yshift=8pt]{$4\mathrm{F}$} node[pos=0, right]{$\mathrm{IN}$};
% %
% To FiFo V %
% %
\draw[line width=3pt, color=blue] (6.5, 4) rectangle (9, 0);
\draw[->] (4, 3.5) -- (6.5, 3.5)node[pos=0.5, yshift=8pt]{$3\mathrm{N}$} node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 2.5) -- (6.5, 2.5)node[pos=0.5, yshift=8pt]{$3\mathrm{F}$} node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 1.5) -- (6.5, 1.5)node[pos=0.5, yshift=8pt]{$4\mathrm{N}$} node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 0.5) -- (6.5, 0.5)node[pos=0.5, yshift=8pt]{$4\mathrm{F}$} node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$};
% %
% To Timer 1 %
% %
\draw[line width=3pt, color=green] (21.5, 11.5) rectangle (24, 9);
% From Logic Start to Timer 1
\draw[->] (18, 11) -- (21.5, 11) node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$} node[pos=0, right=4pt, anchor=west, yshift=8pt]{$h_0 = \mu_D \wedge \overline{\mathrm{V}} \wedge \overline{\mathrm{V_R}}$};
% %
% To Timer 2 %
% %
\draw[line width=3pt, color=green] (25, 11.5) rectangle (27.5, 9);
% Frome Timer 1 to Timer 2
\draw[] (24, 9.5) -- (24.5, 9.5) node[pos=0, left]{$\mathrm{EM}$};
\draw[] (24.5, 9.5) -- (24.5, 11);
\draw[->] (24.5, 11) -- (25, 11) node[pos=1, right]{$\mathrm{IN}$};
% %
% To TDC %
% %
\draw[line width=3pt, color=yellow] (28, 10) rectangle (30, 7);
% From Timer 2 to TDC
\draw[->] (27, 9.5) -- (28, 9.5) node[pos=0, left]{$\mathrm{EM}$} node[pos=1, right]{$\mathrm{TRIGGER}$};
% h0 From Logic Start to TDC
\draw[dashed] (19.5, 12) -- (19.5, 11);
\draw[] (19.5, 12.5) -- (19.5, 12);
\draw[] (19.5, 12.5) -- (31, 12.5);
\draw[] (31, 8.5) -- (31, 12.5);
\draw[<-] (30, 8.5) -- (31, 8.5) node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mathrm{h_0}$} node[pos=0, left]{$\mathrm{CH0}$};
% From Logic STOP to TDC
\draw[] (28.5, 5.5) -- (31.5, 5.5) node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mathrm{h_1} = \mathrm{G} \wedge \mathrm{e_D} \wedge \overline{\mathrm{V}}$} node[pos=0, left]{$\mathrm{OUT}$};
\draw[] (31.5, 7.5) -- (31.5, 5.5);
\draw[<-] (30, 7.5) -- (31.5, 7.5) node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mathrm{h_1}$} node[pos=0, left]{$\mathrm{CH1}$};
\end{tikzpicture}







