\documentstyle[12pt,timrom]{article}
\setlength{\topmargin}{-.5in}
\addtolength{\textheight}{1in}
\addtolength{\oddsidemargin}{-.5in}
\addtolength{\evensidemargin}{-.5in}
\addtolength{\textwidth}{1in}
\markboth{{\bf funclib/dff.c \today}}{{\bf funclib/dff.c \today}}
\pagestyle{myheadings}
\thispagestyle{myheadings}
\newcommand{\four}{\hspace{6ex}}
\title{funclib/dff.c}
\author{eichin}
\date{Apr 6 10:53}
\begin{document}
\maketitle
\newpage
\rm
\begin{tabbing}
\em/\=\em* \\
\>\em* dff.c\\
\>\em* a few pieces for a running simulator.\\
\>\em* \verb+[+eichin:19880406.1107EST\verb+]+\\
 \em*/\\\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\four\=\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\kill\\
{\bf \#include} "../ms/macdefs.h"\\
{\bf \#include} "../decls.h"\\
\ \\
{\bf \#define} dff\_tsetup 5\\
{\bf \#define} dff\_tprop0 11\\
{\bf \#define} dff\_tprop1 13\\
\ \\
\em/\=\em* \\
\>\em* z, z' = dff(clk, in, preset, clear)\\
 \em*/\\\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\four\=\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\kill\\
\ \\
\em/\=*\four{}\>\four{}\>\four{}\>\four{}\>\four{}\>\four{}\>\kill
\em/*\\
\>\em* Table from page 5-22, TI databook, for 7474:\\
\>\em* ========================================\\
\>\em* inputs\>\>\>outputs\\
\>\em* ----------------------------------------\\
\>\em* preset\>clear\>clock\>D\>Q\>Q'\\
\>\em* ========================================\\
\>\em* L\>H\>X\>X\>H\>L\\
\>\em* H\>L\>X\>X\>L\>H\\
\>\em* L\>L\>X\>X\>H*\>H*\\
\>\em* H\>H\>\^\>H\>H\>L\\
\>\em* H\>H\>\^\>L\>L\>H\\
\>\em* H\>H\>L\>X\>Q0\>Q'0\\
\>\em* ========================================\\
\>\em* *unstable.\\
\>\em* \verb+[+eichin:19880406.1148EST\verb+]+\\
\>\em*/\\
\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\four\=\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\kill\\
dff\_func(dep)\\
\>\> {\bf Generics} dep;\\
\{\\
\>{\bf Wire} outz, outznot;\\
\>{\bf {\bf Time}line} outz\_time, outznot\_time;\\
\>{\bf Wire} inclk, inin, inpreset, inclear;\\
\>{\bf {\bf Time}line} inclk\_time, inin\_time, inpreset\_time, inclear\_time;\\
\ \\
\>nextwire(dep, outz, outz\_time);\\
\>nextwire(dep, outznot, outznot\_time);\\
\ \\
\>readnexttime(dep, inclk, inclk\_time);\\
\>readnexttime(dep, inin, inin\_time);\\
\>readnexttime(dep, inpreset, inpreset\_time);\\
\>readnexttime(dep, inclear, inclear\_time);\\
\ \\
\> \`{\em /* was it preset? */} \\
\>if(inpreset\_time\verb+[+0\verb+]+.tag.EVENT == LOGIC\_LOW)\\
\>\>\{\\
\>\>  add\_event(outz\_time, LOGIC\_HI, globaltime + dff\_tprop0);\\
\>\>  add\_event(outznot\_time, LOGIC\_LOW, globaltime + dff\_tprop0);\\
\>\>\}\\
\> \`{\em /* was it clear? */} \\
\>else if(inclear\_time\verb+[+0\verb+]+.tag.EVENT == LOGIC\_LOW)\\
\>\>\{\\
\>\>  add\_event(outz\_time, LOGIC\_LOW, globaltime + dff\_tprop0);\\
\>\>  add\_event(outznot\_time, LOGIC\_HI, globaltime + dff\_tprop0);\\
\>\>\}\\
\> \`{\em /* was it a clock tick? */} \\
\>else if((inclk\_time\verb+[+0\verb+]+.data.EVENT == globaltime)\\
\>\>\>  \&\& (inclk\_time\verb+[+0\verb+]+.tag.EVENT == LOGIC\_HI))\\
\>\>\{\\
\>\>   \`{\em /* ok, was the input stable? */} \\
\>\>  if(inin\_time\verb+[+0\verb+]+.data.EVENT \verb+<+= globaltime - dff\_tsetup)\\
\>\>\>\{\\
\>\>\>   \`{\em /* Ok, changing now... */} \\
\>\>\>  add\_event(outz\_time,\\
\>\>\>\>\>\>    inin\_time\verb+[+0\verb+]+.tag.EVENT,\\
\>\>\>\>\>\>    inclk\_time\verb+[+0\verb+]+.data.EVENT + dff\_tprop1);\\
\>\>\>\}\\
\>\>\}\\
\}\\
\end{tabbing}
\end{document}
