[Home]IRSIM/FAQ

OpenCircuitWiki | IRSIM | RecentChanges | Preferences | Sandbox
Open Circuit Design | Magic | XCircuit | IRSIM | Netgen | PCB

FAQ

1. How do I convert Verilog testbench code to IRSIM?
2. Help! My project's due tomorrow and I need to generate a large command file in a hurry!

1. How do I convert Verilog testbench code to IRSIM?

A: The latest versions of IRSIM (9.7.32 and newer) have two new commands "at" and "every":

   at time [start] {procedure}
   every [+]time {procedure}

These are specifically designed to make translation from a Verilog testbench easier. These commands work best with the Tcl/Tk-based compilation of IRSIM, because the procedure can be a chain of any number and mixture of IRSIM and Tcl commands. The procedure defined by the IRSIM command "at" corresponds (roughly) to the Verilog "initial" block, while the procedure defined by the IRSIM command "every" corresponds to the Verilog "always" block. The principle limitation of the IRSIM command is the inability to schedule an event at a signal rising or falling edge; events can only be scheduled at a specific time, although for the "at" command that time can be absolute or relative. Relative times are specified by adding "+" in front of time, indicating that the event should be scheduled time nanoseconds from "now" (the current timestep). The "every" command is repeatedly rescheduled, and the "time" value is always interpreted as a relative time. To schedule an event to start at a specific (absolute) time, use the optional "start" time argument.

In the Tcl version of IRSIM, both commands return an event number associated with the scheduled event. This event number can be used to cancel the event using the command forms:

   at cancel id
   every cancel id

These commands allow very complicated sequences of events to be set up easily, such as two clock sources running at different frequencies, or a short clock burst, or even an arbitrary input serial data stream. These sort of things were previously very tedious to set up in a command file (or worse, to type in on the command line).

See the IRSIM tutorial and reference pages on OpenCircuitDesign for more information.

2. Help! My project's due tomorrow and I need to generate a large command file in a hurry!

That's not a question, but I was in that position when I whipped up a Python script to help me. Read about it at CmdFileGenerator.py.

Note that recent versions of IRSIM have added convenient methods for defining vectors, for example, "vector a a0:9", and for setting vectors in decimal notation, for example "setvector a %d255". The latter notation works well with scripting languages like Tcl and Python, for which working in binary numbers is awkward.

Sometimes generating a huge sequence of events in IRSIM is just a matter of writing a simple "for" loop in Tcl. The example below clocks any arbitrary sequence of values into node "A":

    set Avals
    "10101101110011000xxxxx0010011010..."
    vector Av A
    for {set i 0} {$i < [string length $Avals]} {incr i}
    {
       setvector Av [string range $Avals $i $i]
       c
    }

This also demonstrates a simplifying technique by which a node ("A") is made into a 1-bit vector ("Av") so that it can be assigned the numerical value 1 or 0 (note also the value 'x' used to stop forcing the node to a specific state) instead of having to be set with the commands "l" and "h" (and "x").


OpenCircuitWiki | IRSIM | RecentChanges | Preferences | Sandbox
Open Circuit Design | Magic | XCircuit | IRSIM | Netgen | PCB
Page is read-only (use admin password ocd_edit to make writeable) | View other revisions
Last edited January 5, 2008 10:19 am by R. Timothy Edwards (diff)
Search: