\documentstyle[12pt,timrom]{article}
\setlength{\topmargin}{-.5in}
\addtolength{\textheight}{1in}
\addtolength{\oddsidemargin}{-.5in}
\addtolength{\evensidemargin}{-.5in}
\addtolength{\textwidth}{1in}
\markboth{{\bf funclib/tristate.c \today}}{{\bf funclib/tristate.c \today}}
\pagestyle{myheadings}
\thispagestyle{myheadings}
\newcommand{\four}{\hspace{6ex}}
\title{funclib/tristate.c}
\author{eichin}
\date{Apr 6 10:02}
\begin{document}
\maketitle
\newpage
\rm
\begin{tabbing}
\em/\=\em* \\
\>\em* tristate.c\\
\>\em* a few pieces for a running simulator.\\
\>\em* \verb+[+eichin:19880401.0606EST\verb+]+\\
 \em*/\\\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\four\=\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\kill\\
{\bf \#include} "../ms/macdefs.h"\\
{\bf \#include} "../decls.h"\\
\ \\
\em/\=\em* \\
\>\em* z = tristate(a, b): if (a==HI) then b else TRISTATE\\
 \em*/\\\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\four\=\four\{\}\=\four\{\}\=\four\{\}\=\four\{\}\=\kill \\
tristate\_func(dep)\\
\>\> {\bf Generics} dep;\\
\{\\
\>{\bf Event} futev = getblock();\\
\>{\bf Wire} outwire;\\
\>{\bf {\bf Time}line} outtime;\\
\ \\
\>START(futev);\\
\ \\
\>outwire = dep$\rightarrow$data.GENERIC.genwire;\\
\>find\_item(outwire, WIRE, FUTURE);\\
\>outtime = outwire$\rightarrow$data.WIRE.future;\\
\>INC(dep);\\
\ \\
\>\{\\
\>\>{\bf Wire} awire = dep$\rightarrow$data.GENERIC.genwire;\\
\>\>ASSERT(dep$\rightarrow$tag.GENERIC == GENWIRE);\\
\ \\
\>\>find\_item(awire, WIRE, NOW);\\
\ \\
\>\>if((awire$\rightarrow$data.WIRE.now)$\rightarrow$tag.EVENT == LOGIC\_HI)\\
\>\>  \{\\
\>\>\>INC(dep);\\
\>\>\>ASSERT(dep$\rightarrow$tag.GENERIC == GENWIRE);\\
\>\>\>awire = dep$\rightarrow$data.GENERIC.genwire;\\
\>\>\>find\_item(awire, WIRE, NOW);\\
\>\>\>\\
\>\>\>set\_event(futev, awire\verb+[+0\verb+]+.data.WIRE.now\verb+[+0\verb+]+.tag.EVENT, globaltime + 10);\\
\>\>  \}\\
\>\>else\\
\>\>  \{\\
\>\>\>set\_event(futev, TRISTATE, globaltime + 10);\\
\>\>  \}\\
\>\}\\
\ \\
\>add\_event(outtime, futev$\rightarrow$tag.EVENT, futev$\rightarrow$data.EVENT);\\
\>back\_trace(futev);\\
\}\\
\end{tabbing}
\end{document}
