3

I want to draw a diagram as follows: enter image description here

This is my tikz code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,fit,calc,positioning,automata}

\begin{document}


\tikzstyle{int}=[draw, minimum size=4em]
\tikzstyle{init} = [pin edge={to-,thin,black}]

\begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]
    \tikzstyle{line} = [draw, -latex']
    \node [int] (a) { $x^2$ };
   \node [int] (b) [right of=a] { $x^1$ };
    \node [int] (c) [right of=b] { $x^0$ };
    % \coordinate[right=1.75cm of a] (a1)  {};

    \path[->] (b) edge node { } (a);

\end{tikzpicture}

\end{document}

Output is:

enter image description here

How do I make those XOR symbols in tikz?

4
3

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,fit,calc,positioning,automata}
\begin{document}

\tikzstyle{int}     = [draw, minimum size=4em]
\tikzstyle{init}    = [pin edge={to-,thin,black}]
\tikzstyle{XORgate} = [draw,circle]
\tikzstyle{line}    = [draw, -latex']

%\pgfkeyssetvalue{/tikz/node distance}{4cm}           % needs next line to work
%\pgfkeysgetvalue{/tikz/node distance}{\nodedistance} % but than I can just say \def…
\newcommand*\nodedistance{4cm}
\begin{tikzpicture}[node distance=\nodedistance,auto,>=latex', scale = 0.75, transform shape]
    \tikzstyle{line}=[draw, -latex']
    \node [int] (a) { $x^2$ };
    \node [int,right of=a] (b) { $x^1$ };
    \node [int,right of=b] (c) { $x^0$ };
    \node [XORgate] at ($(b)!.5!(c)$) (XOR-b-c) {\large +};
    \node [XORgate] at ($(b)!1.5!(a)$) (XOR-aa) {\large +};
    \coordinate [below of=XOR-aa,node distance=.5*\nodedistance] (below-XOR-aa);
    \node [above of=XOR-aa,node distance=1.5cm,text width=1.5cm,anchor=south,align=center] (input) {Message\\Input};
    \path[line] (c) edge (XOR-b-c)
                (XOR-b-c) edge (b)
                (b) edge (a)
                (a) edge (XOR-aa)
                (XOR-aa) -- (below-XOR-aa) -| ($(c) + (.5*\nodedistance,0pt)$) -- (c)
                (input) edge (XOR-aa)
                ($(XOR-b-c)+(0,-.5*\nodedistance)$) -- (XOR-b-c);
\end{tikzpicture}
\end{document}

Output

Output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.