System Level Design Languages:Test benches in SystemC

Testbenches in SystemC

In SystemC the sc_main function usually acts as a testbench for the whole system. We can define and instantiate modules and connect their ports within this function. sc_main in SystemC is a function similar to the main function in C/C++. Generally, the simulation and signal tracing functions are called in sc_main. Every design in SystemC must have one sc_main function. sc_main arguments (argc and argv) are similar to those in the main function in C/C++. Several methods useful in developing testbenches in SystemC are described here.

Module Instantiation

To instantiate a developed module in sc_main (or any other module), two approaches are available: instantiation by position and instantiation by name.

These alternatives are as follows:

• Instantiation by position

• Syntax: module_name (signal_name1, signal_name2, …);

• Example: sayeh cpu;

sc_signal<ADDRESSTYPE> abus, …; cpu (abus, dbus, …);

• Instantiaion of cpu connects abus, dbus, and other declared signals to ports of the sayeh module. The order of signals in this instantiation must be the same as those of the sayeh module.

System Level Design Languages-0245

sc_start

This function starts the simulation process and returns when the simulation time limit is reached or when there are no more events left. sc_start can be used in each of the following formats:

sc_start (): Simulation terminates when no events are left in the scheduler.

sc_start (double, sc_time_unit): Simulation terminates when the simulation time reaches the specified time in the argument. An example is sc_start (10, SC_NS).

sc_start (const sc_time&): This format is the same as sc_start (double, sc_time_unit). An example is sc_start (sim_time); where sim_time is a variable of type sc_time.

Trace Files

A trace file is a file where the sequence of events, happening on the system signals, is stored. SystemC supports the VCD format for its trace files. There are several predefined functions that help users create their own VCD trace files. These functions include:

sc_create_vcd_file: This function creates an empty VCD file.

sc_close_vcd_file: This function closes a previously generated and opened VCD file.

sc_write_comments: This function writes a comment to a VCD file.

sc_trace: This function has many overloads for accepting various data types. It writes the value of a specified signal or variable to a VCD trace file (in VCD format).

Comments

Popular posts from this blog

SRAM:Decoder and Word-Line Decoding Circuit [10–13].

ASIC and Custom IC Cell Information Representation:GDS2

Timing Description Languages:SDF