2

Is it possible to use vhdl in LaTeX code to get block diagrams?

    \package{vhdltoblockdiagram}
% ...
    \begin{vhdl}
% entity Comp is generic ( n : natural := 2 );
% port (
%    A       : in std_logic_vector(n-1 downto 0);
%    B       : in std_logic_vector(n-1 downto 0);
%    greater : out std_logic;
%    less    : out std_logic;
%--bottom--
%    equal   : out std_logic;
%);
%end Comp;
    \end{vhdl}

Result like here: http://vhdltolatex.mamikon.net/

How can I define block diagrams without telling the position of the elements? I would like an automatical layout.

1

I don't know vhdl, hence I'm not sure this is an answer your question.

If you want to change the diagram because you have more/less element before or after the item node, you have only to add/remove elements from the left/right matrices, change the factor who divide \myheight and adjust the \foreach conditions.

\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{matrix, positioning, arrows.meta}
\newlength{\myheight}
\setlength{\myheight}{2.5cm}
\tikzset{labels/.style={font=\sffamily\scriptsize},
    circuit/.style={draw,minimum width=2cm,minimum height=\myheight,very thick,inner sep=1mm,outer sep=0pt,cap=round,font=\sffamily\bfseries},
    triangle 45/.tip={Triangle[angle=45:8pt]}
}

\begin{document}
    \begin{figure}[htb]
        \centering
        \begin{tikzpicture}[font=\sffamily,>=triangle 45]
        \node [circuit] (item) {Comp};
        \matrix[
            matrix of nodes, 
            left= of item, 
            row sep=\myheight/5,
            nodes={anchor=east}
            ] (rightmatr) { 
            A\\
            B\\
        };
        \matrix[
            matrix of nodes, 
            right= of item, 
            row sep=\myheight/6,
            nodes={anchor=west}
            ] (leftmatr) { 
            greater\\
            less\\
            equal\\
        };
        \foreach \i in {1,2}
            \draw [->] (rightmatr-\i-1) -- (rightmatr-\i-1 -| item.west);
        \foreach \i in {1,2,3}
            \draw [<-] (leftmatr-\i-1) -- (leftmatr-\i-1 -| item.east);
        \end{tikzpicture}
        \caption{Entity of Comp}
    \end{figure}
\end{document}

enter image description here

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.