As an interim solution to this question, I've settled on using the \matrix command to position coordinates. Eventually I would like to see a simple graphical utility or other such parser that can take a VHDL template or schematic symbol and automatically generate the source-code for the IC, using the following as a template:
%% An IC is essentially a matrix with connection points (coordinates) at its upper, lower, left and right edges.
%% The matrix command facilitates this nicely using nodes combined with the label option
%% The matrix command for any IC can be placed in a custom command for reuse:
%% Use the folllowing as a template
\newcommand{\drawff}[2]{%
\matrix (DFF#1) [draw,very thick,inner sep=0pt,outer sep=0pt,column sep=2pt,label distance=0.6ex,
font=\sffamily\scriptsize,
ampersand replacement=\&] at #2 {
% Top Row:
\& \& \& \& \& \node [coordinate,label=270:R] (R#1) {}; \& \& \& \& \& \&\\
% Left and right rows:
\& \& \& \& \& \& \& \& \& \& \& \\[1ex]
\node [coordinate,label=0:D] (D#1) {};
\& \& \& \& \& \& \& \& \& \& \& \node [coordinate,label=180:Q] (Q#1) {}; \\[6ex]
\node [coordinate,label=0:CE] (CE#1) {};
\& \& \& \& \& \& \& \& \& \& \& \\
\& \& \& \& \& \& \& \& \& \& \&
\node [coordinate,label=180:$\overline{\text{Q}}$] (Qb#1) {}; \\
\node [label=0:$\large >$,anchor=west] (CLK#1) {};
\& \& \& \& \& \& \& \& \& \& \& \\[1ex]
% Bottom row:
\& \& \& \& \& \node [coordinate,label=90:S] (S#1) {}; \& \& \& \& \& \&\\
} ;
}
Once the symbols are defined, graphical software that manipulates a grid can define coordinates where ICs and I/O markers are to be placed. The output of this software should look something like:
{[start chain=placements]
%% Place the parts
% D registers, with labels
%% Step 1: anchor placement (a graphical editor should be able to handle this)
\foreach \m in {0,...,\N}
\node [coordinate] (tlDFF\m) at ($ 3*(\m,0) $) {};
% 'Reset' port label
\path (tlDFF0) +(-2,+2.5) coordinate (reset) node [anchor=east] {reset};
% 'Set' port label
\path (tlDFF0) +(-2,-2.5) coordinate (set) node [anchor=east] {set};
% Clock port label
\path (tlDFF0) +(-2,-3) coordinate (clock) node [anchor=east] {clock};
% Clock enable port label
\path (tlDFF0) +(-2,-3.5) coordinate (clocken) node [anchor=east] {clock enable};
}
The third task would be simply to place the appropriate symbols at the coordinates. This is just a matter of picking unique names, and placing the shape as follows:
\foreach \m in {0,...,\N}
\drawff{\m}{(tlDFF\m)};
%% annotate the ics as desired
\foreach \m in {0,...,\N}
\node [fit=(DFF\m),font=\sffamily\scriptsize] {Bit \#\m};
%% Place input and output ports, junctions, etc:
% data in- and output port
\path [ultra thick] (D0) -- +(-1,0) node [anchor=east] (in0) {input} ;
\path [ultra thick] (Q\N) -- +(1,0) node [anchor=west] (out\N) {output};
Finally, connect the nets with wires. The graphical routine need only be able to identify what coordinate is being referenced when the user clicks on a specific location in the image. Drawing can be accomplished using the \chainin command, similar to that shown below:
{[start chain=nets]
%% Connect the nets
% Connect reset lines
\chainin (reset);
{[start branch=reset]
\foreach \m in {0,...,\N}
\chainin (R\m) [join=with reset by {hv path,tip}];
}
% Connect FFs (Q1 with D1, etc.)
\chainin (in0);
\chainin (D0) [join= by ultra thick];
\foreach \m in {1,...,\N} {[start branch=qd\p\m] % Note that it starts with 1, not 0
\chainin (Q\p);
\chainin (D\m) [join=by ultra thick];
\global\let\p\m
}
\chainin (Q\N);
\chainin (out\N) [join= by ultra thick];
% Connect set lines
\chainin (set);
{[start branch=set]
\foreach \m in {0,...,\N}
\chainin (S\m) [join=with set by {hv path,tip}];
}
% Connect clock lines
\chainin (clock);
{[start branch=clk]
\foreach \m in {0,...,\N}
\chainin (CLK\m) [join=with clock by {Z path=-0.55,tip}];
}
% Connect clock-enable lines
\chainin (clocken);
{[start branch=clken]
\foreach \m in {0,...,\N}
\chainin (CE\m) [join=with clocken by {Z path=-0.75,tip}];
}
}
Any reports of progress in this matter are appreciated!
backgroundpathetc. part of the shapre. – Martin Scharrer Feb 23 '11 at 14:29