An Introduction to IC Design Under Linux

A discussion of various Linux tools for integrated circuit board design.

Before beginning a simulation, first create a SPICE file and add transistor models and SPICE commands to it. Next, simulate the inverter to verify that it was laid out correctly.

Creating the SPICE File

First, translate the inverter.ext file into something that SPICE can understand. The ext2spice program by Stefanos Sidiropolous that comes with the Magic distribution performs this translation. Simply enter:

ext2spice -f spice3 inverter.ext

We specify “spice3” format output, because earlier SPICE versions can't handle text strings for labels.

Transistor Models

We now have a file that SPICE can understand, but it's incomplete in an important way. For SPICE to simulate a device correctly, it needs a model, a mathematical description of the device's behavior. In particular, we now need models for the two transistors (n-type and p-type) that we've used in our design.

SPICE has a variety of built-in transistor models specified in terms of sets of parameters. These parameters vary according to the fabrication process used, so it's up to the user to specify the correct parameters for the process being used. Fortunately, you don't have to figure these out yourselves—you can get them from MOSIS at This FTP site contains a whole slew of data from past runs; we chose a typical one from the “Level 2 Parameters” section. One minor detail—note that you need to change the “CMOSN” and “CMOSP” to match ext2spice's output, “NFET” and “PFET”.

After pasting in the transistor models, the inverter.spice file should look like Listing 1.

Digital vs. Analog

We've drawn the inverter and extracted a netlist. Now we need to simulate the chip to make sure it'll perform as expected when the chip is fabricated. A simulator such as SPICE can do many different types of circuit analysis. We will demonstrate two that are very useful for the digital circuit designer.

It might seem curious to use an analog circuit simulator for a digital circuit. We think of digital circuits as being in one of two states, 0 or 1, while analog circuits can take any of a continuous range of values. What's important to realize is that a digital circuit is actually a special kind of analog circuit. At the circuit level, a signal is either a voltage or current, and these are really analog quantities. The conventional 0 and 1 representations of a bit are simply abstractions of two particular voltage values; the actual values depend on the process in which the chip is fabricated. With CMOS in particular, you can generally ignore the currents and deal only with the voltages, due to the FET's mode of operation. For example, in the particular process for which we extracted our inverter, a 1 corresponds to 5 Volts (5V). In other processes, it might correspond to 3.3V or 2.5V. Happily enough, a 0 generally means 0V. As we all know, digital circuits don't switch instantaneously between their two values. It takes time to change voltages, and this delay is one of the things that makes your CPU run at 100MHz instead of 133MHz.

The upshot is that SPICE simulates analog behavior, but as digital circuit designers, we will interpret the circuit's output as digital bits rather than the analog voltages they actually are.

Simulators specialized for digital circuits do not provide the level of detail, that is, accuracy, that SPICE does, but they are orders of magnitude faster. IRSIM, which is available through the Magic WWW home page (see Resources at the end of the article) is an example of such a simulator.

Transient Analysis

Suppose we apply the test vector 101 to the inverter over a period of 75 nanoseconds (1 ns = 10-9 seconds). How will the output change over this time interval? To answer this question, SPICE can do a transient analysis. In a transient analysis, you define the input signal(s) and tell SPICE to simulate the circuit for a certain amount of time from the circuit's point-of-view, not real time. A transient analysis provides timing information, for example, how long the output takes to switch from 1 to 0. This analysis is also useful for verifying the circuit's functionality; you simply apply the test vector and check the output for correctness.

Let's apply the vector 101 to our inverter. Add the following lines to the end of the inverter.spice file:

Vpwr Vdd Gnd 5
Vgnd Gnd 0 0
Vinput in Gnd 0 PULSE( 0V 5V 0ns 2.5ns 2.5ns 25ns 50ns )
 .TRAN 0.1ns 75ns

Let's go over this specification line-by-line. Line 1 defines a 5V voltage source between Vdd and Gnd; this is the power supply. Line 2 is necessary because of a SPICE artifact of always referring to ground as 0. We simply tie Gnd and 0 together (electrically speaking) by using a 0V voltage source, i.e., a short-circuit. Line 3 defines a voltage source between “in” and ground; this is the inverter's input. Looking at the parameters in parentheses, we have a voltage source whose initial voltage is 0V and “pulsed” voltage is 5V, and it starts after a 0ns delay. It has a rise time (i.e., the time required to switch from 0 to 1) of 2.5ns, and a fall time (i.e., the time required to switch from 1 to 0) also of 2.5ns. The width of each pulse is 25ns, and it repeats after 50ns have elapsed. Line 4 means that we want to do a transient analysis with a resolution of 0.1ns that lasts for 75ns. Line 5 ends the circuit file. Save the file, then run the simulation by typing:

spice3 -r inverter.out < inverter.spice
Now, let's view the results by typing:
sigview inverter.out
We're interested only in the top two signals, “out” and “in”, as shown in Figure 6.

Figure 6. SPICE Inverter Output

From the digital point-of-view we see that the inverter correctly produces a 010 pattern; from the analog point-of-view we see that the output's rise time is about 0.91ns and its fall time is about 0.89ns.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Simulation support for Gnucap / ngspice

G.Ravi Teja's picture

It was a wonderful tutorial. It was really helpful. I want to know if there are any ways to simulate the layout design using gnucap. Thank in advance.