prsim: Production rule simulation

Before using prsim to simulate a set of production rules, they must first be flattened using aflat. Assuming your production rules are in a file called circuit.act, you would run:

aflat circuit.act > circuit.prs
prsim circuit.prs

This will give you an interactive (Prsim) prompt. Type help to get a list of simulation commands.

Standard Test Script

When running prsim, it is good practice to use a test .act file that looks something like this:

import "circuit.act";
...
... // your test setup

bool Reset;

prs {
   Reset -> Vdd+
   Reset -> GND-
   Reset => _Reset-
}

In this example, I've assumed that the circuit reset signals are the global variables Reset and _Reset, and that both Vdd and GND are defined as globals for the power supplies. You should use the appropriate signals for your circuit there. The nice thing about this setup is that you can have a prsim script file that looks something like this:

random
set Reset 1
cycle
status U
... // watch various things
set Reset 0
cycle

Commands

General

help

display a list of commands with short descriptions

exit

terminate

source <file>

read in a script file and execute the commands within

Timing

random [<min> <max>]

Set the random timing mode and optionally specify the default random timing bounds for all nodes.

random_seed <seed>

set the seed for the random timing mode.

norandom

Set the deterministic timing mode.

random_excl on|off

turn on/off random exclhi/lo firings

after <n> <minu> <maxu> <mind> <maxd>

For the random timing mode, set the random timing bounds for the up and down transitions for a specified node.

Running Simulation

mode reset|run

set current running mode.

Mode Effect
reset reset turns off weak interference warnings (node still becomes X). During chip initialization, there can be weak interference since the simulator assumes all nodes are initially X. Setting the mode to reset during the reset phase prevents these warnings from being printed to the screen.
run Warnings of weak interference are enabled. This should be the standard mode after the reset phase has completed.
initialize

initialize the simulation, setting all nodes to X.

step [<steps>]

simulate <steps> transitions (default is 1)

advance [<duration>]

simulate for <duration> units of simulation time (default is 1)

cycle [<node>]

simulate until the next transition on <node> (default is forever)

break <node>

set a breakpoint on <node>

break-on-warn

toggles the break-on-warn flag which stops/doesn't stop simulation on instability or interference

exit-on-warn

like break-on-warn, but exits prsim

Setting/Getting Node Values

set <variable> <value>

set the node, bus, or vector <variable> to specified <value>

get <variable>

get value of a node, bus, or vector <variable>

assert <variable> <value>

assert that the node, bus, or vector <variable> is <value>

uget <n>

get value of node <n> but report its canonical name

set_principal <n>

select <n> as the canonical name for a node

watch <n>

add watchpoint for <n>

unwatch <n>

delete watchpoint for <n>

watchall

watch all nodes

Debug

status 0|1|X [[^]str]

list all nodes with specified value, optional prefix/string match

pending

print the prsim pending event queue

alias <node>

list all of the name aliases for <node>

fanin <node>

print the production rules that drive <node>

fanin-get <node>

print the production rules that drive <node> with the values of each expression and node in the guards evaluated.

fanout <node>

print the set of nodes for which <node> appears in the guard of a driving production rule

chk-save <file>

save a simulation checkpoint to <file>

chk-restore <file>

restore simulation state from a checkpoint

Tracing

dumptc <file>

dump transition counts for nodes to <file>

pairtc

turns on <input/output> pair transition counts

trace <file> <time>

Create atrace file for <time> duration

timescale <t>

set time scale to <t> picoseconds for tracing

ACT Attributes for simulation

Attributes can be added to production rules specified in ACT as follows:

    prs {
      [after=20] a & b #> c-
    }

Attributes currently recognized by prsim are:

Attribute Meaning
after used to set the delay in simulation time units for the production rule firing in non-random timing mode
weak if there is a weak attribute, it means the production rule has a weak drive and can be overridden by a stronger production rule during simulation
unstab if there is an unstab attribute, it means that the production rule may be unstable. prsim will suppress instability reporting on such rules

Large Files

The output of aflat can be very large, and designs with millions of gates can easily generate multi-gigabyte output files. To reduce the file size, the prspack command compresses the output of aflat by taking all the signal names in the production rule file ASCII output and converting them into an integer, saving all the names in the file on disk in a separate names file. To use this, say:

   aflat circuit.act | prspack table > circuit.packprs

This creates a packed production rule file, as well as a number of files called table_idx.dat, table_str.dat, table_alias.dat, and table_rev.dat. These files are used to store alias information, strings, and hash tables to make it easy to access the names in the packed production rule output. These files can be used by prsim as follows:

   prsim -n table circuit.packprs

The -n command line argument specifies where prsim can find all the signal names from the production rule file.