Subject: checking sim files
From: [email-masked] (Bruce K. Holmer)
Date: 21 Sep 90 04:58:13 GMT
Newsgroups: comp.lsi.cad

The following is a set of Unix command lines (and small awk programs)
that I have found helpful in checking a layout for unconnected nodes
(a typical error in hand layout).  These scripts assume a CMOS sim
file with no aliases (our layout CAD tools can generate this
directly).  For those of you who have an alias file after extraction,
you would need to preprocess the sim file to substitute a unique name
for each node.

I'd be interested in finding out if there are more sophisticated tools
for discovering typical layout errors (either using Magic or sim as
input).

Enjoy,
--Bruce

----------------------------------------------------------------------

First gather only the n and p lines of the sim file:

	egrep '^[np]' design.sim | ... (continued below)

Rearrange the order of the source and drains fields to canonicalize
the transistor listing.  Then remove duplicate transistors and move
transistor pairs that make up inverters to adjacent lines:

	... | awk -f canonical.awk | sort -u +1 +0 | ...

%%%%%%%%%%%%%%%%%%%% canonical.awk %%%%%%%%%%%%%%%%%%%%
	{if (($3== "GND" && $4 != "Vdd") || $3 == "Vdd" || \
		($4 < $3 && $4 != "GND" && $4 != "Vdd")) print $1,$2,$4,$3;
	  else print $1,$2,$3,$4;}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Now find the n and p that makes up each inverter and replace them with
the line "inv input_node output_node":

	... | awk -f find_inv.awk > design.inv

%%%%%%%%%%%%%%%%%%%% find_inv.awk %%%%%%%%%%%%%%%%%%%%
BEGIN				{getline;
				 o1 = $1; o2 = $2;
				 o3 = $3; o4 = $4;}
($1 == "p") && ($4 == "Vdd")	{if (o1 == "n" && o4 == "GND" && \
					o2 == $2 && o3 == $3) {
						print "inv", $2, $3;
						getline;
						o1 = $1; o2 = $2;
						o3 = $3; o4 = $4;
						next;}}
				{print o1, o2, o3, o4;
				 o1 = $1; o2 = $2;
				 o3 = $3; o4 = $4;}
END				{if (o1 != "") print o1, o2, o3, o4;}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Collecting the fragments, the command line is:

	egrep '^[np]' design.sim | awk -f canonical.awk | sort -u +1 +0 | \
		awk -f find_inv.awk > design.inv

Now we can look for unconnected nodes.  The first thing we'll look for
is any node name that occurs just once:

	awk '{print $2; print $3; if ($1 != "inv") print $4}' design.inv | \
		sort | uniq -u > single.occurrence.nodes

The second test is to find all node names that appear only on
transistor gates (input pad nodes may be included):

	awk '{print $2}' design.inv | sort -u > gates
	awk '{print $3; if ($1 != "inv") print $4}' design.inv | \
		sort -u > srcdrns
	comm -23 gates srcdrns > gate.only.nodes