[Tex/LaTex] Drawing a custom node and arrows in tikz

tikz-arrowstikz-pgftikz-styles

I am trying to draw the picture that I have drawn here in paint using tikz. I have managed to get this far (please see the code and the output diagram on the right hand side) but cannot quite get it to be what I want it to be (which is illustrated on the left hand side in the drawing in paint). Namely, there are three things I can't quite do:

  1. Change the box around f to be the irregular quadrilateral rather than a rectangle.

  2. Make the arrow going from the 'b bits' to the box around f not be diagonal and point to the left hand side of the box (rather than the top) but for the arrow not to merge with the arrow from 'l bits', and

  3. I would like an arrow between two nodes that is dashed for the first half, and a standard arrow for the second half.

Any help/suggestions for how to do any one of these things would be greatly appreciated.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzstyle{arrow} = [thick,->,>=stealth]

\begin{document}

\begin{tikzpicture}
[nodes={draw, thick, fill=black!0}]

\node (fone) [rectangle, minimum width=1cm, minimum height=1cm] {$f$};
\node (xone) [draw=none,fill=none, above left=1cm and 0cm of fone] {$b$ bits};
\node (ktwo) [draw=none,fill=none, left of=fone, xshift=-1cm] {$\ell$ bits};
\node (ftwo) [draw=none, fill=none, right of=fone, xshift=1cm]{$\ell$ bits};

\draw [arrow] (xone) -- (fone);[![enter image description here][2]][2]
\draw [arrow] (ktwo) -- (fone);
\draw [arrow] (fone) -- (ftwo);

\end{tikzpicture}
\end{document}

The diagram the code outputs
enter image description here

Best Answer

A solution that does not require you to place everything with specific coordinates is as follows:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzstyle{arrow} = [thick,->,>=stealth]

\usetikzlibrary{shapes,shapes.multipart} % Required for the trapezoid shape
\usetikzlibrary{calc} % Required for the computation of the angle arrow

\begin{document}

\begin{tikzpicture}
% Draw the trapezium and rotate by 90 degrees. A rotation of the text is also needed
\node (fone) [draw,trapezium,trapezium left angle=70,trapezium right angle=0,rotate=-90,minimum width=1cm, minimum height=1cm] {\rotatebox{90}{$f$}};

% Inotrduce a coordinate to lean on for drawing the angle shape
\node[coordinate, left of=fone] (x) {};

\node (xone) [draw=none,fill=none, above of=x,node distance=1.5cm] {$b$ bits};
\node (ktwo) [draw=none,fill=none, left of=fone, xshift=-1cm] {$\ell$ bits};
\node (ftwo) [draw=none, fill=none, right of=fone, xshift=1cm]{$\ell$ bits};

% The following connects xone with the coordinate x at the exact point where
% fone has 245 degrees (Note that it was rotated by 90 deg), then draw the line.
\draw [arrow] (xone) |- ($(x.north east)!(fone.245)!(x.south east)$) |- (fone.245);
\draw [arrow] (ktwo) -- (fone);
\draw [arrow] (fone) -- (ftwo);

\end{tikzpicture}
\end{document}

The resulting scheme is the following: Picture of the resulting figure

Related Question