ECE/CS 314: Computer Organization Fall 2004

Project 3: Logic Design
IRSIM Reference

IRSIM

There is quite a bit of on-line documentation for irsim. Try man irsim for information on all the commands that irsim supports. irsim is a switch-level simulator, in the sense it models the circuit at the level of transistors.

Commonly Used Commands

The most frequently used commands in irsim are those that set the values of inputs and those that are used to view signals.
h node1 node2 ... set list of nodes to logic 1 (high)
l node1 node2 ... set list of nodes to logic 0 (low)
u node1 node2 ... set list of nodes to "X" (undefined)
x node1 node2 ... stop setting the list of nodes
d node1 node2 ... display current value of nodes
ana node1 node2 ... display current value of nodes in waveform viewer
clear clear waveform viewer display
s run simulation for one step
stepsize tm set step size to tm nanoseconds
IMPORTANT. When you set a node high or low using the h or l commands, the node keeps being set to high or low (no matter what the circuit is trying to do to the node!) until you use the x command to stop setting the node.

Vectors

Since nodes typically are grouped into vectors, it is usually easier to look at N-bit quantities as single vector entities. The following commands can be used to define vectors and display them.
vector name node1 node2 ... define a new vector called name consisting of the list of nodes
d name display a vector as an array of bits
ana name add vector name to the waveform viewer
set name value set the bits of vector name using the binary string value

To set a vector to a hexadecimal number, use:

   set name %xhexstring

For instance, you can now say: set Va %xff if Va is an 8-bit vector instead of set Va 11111111. The prefix %x says that what follows is a hex constant.

A useful shortcut to defining arrays as long vectors is to say:

   vector name a.b[{31:0}]

Clock Definition

The standard clock definition for EE/CS 314 is shown below:
   vector CLOCK CLK _CLK
   clock CLOCK 01 10

The first line defines CLOCK to be a vector of two signals: CLK and _CLK. These signals are defined as globals in the 314/parts.cast file (located in $CAST_HOME/cast/314/parts.cast). The second line states that a single cycle of the clock consists of setting the vector first to 01 and then to 10. Once this clock is defined, you can run the simulation for a clock step by saying:

   c

The following runs the simulation for 10 cycles:

   c 10

Scripts

All the text commands shown above can be typed into a text file and then read in at once. If you create a file called foo.src, you can read it into irsim by saying:
   @ foo.src
If your script is called foo.cmd, then simply saying:
   foo
in irsim will execute it. foo is treated as a new irsim command that is defined by the contents of script foo.cmd .

Some useful commands for scripts are given below.

| comment A vertical pipe defines the rest of the line to be a comment. Comments must be on separate lines (i.e. these are not like C++ style comments)
assert name value This checks if name has value value. If this is true, the command does nothing. Otherwise, the command prints an error message.
print text Echos text on the output. Useful to separate the outputs of different major tests.