24.03.2013 Views

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example of parameter use<br />

format_char = 'a');<br />

Verilog: instantiating SystemC UM-215<br />

The first argument to sc_get_param defines the parameter name, the second defines the<br />

parameter value. For retrieving string values, <strong>ModelSim</strong> also provides a third optional<br />

argument, format_char. It is used to specify the format for displaying the retrieved string.<br />

The format can be ASCII ("a" or "A"), binary ("b" or "b"), decimal ("d" or "d"), octal ("o"<br />

or "O"), or hexadecimal ("h" or "H"). ASCII is the default.<br />

Alternatively, you can use the following forms of the above functions in the constructor<br />

initializer list:<br />

int sc_get_int_param(const char* param_name);<br />

double sc_get_real_param(const char* param_name);<br />

sc_string sc_get_string_param(const char* param_name, char format_char =<br />

'a');<br />

Here is a complete example, ring buffer, including all files necessary for simulation.<br />

// test_ringbuf.v<br />

`timescale 1ns / 1ps<br />

module test_ringbuf();<br />

reg clock;<br />

...<br />

parameter int_param = 4;<br />

parameter real_param = 2.6;<br />

parameter str_param = "Hello World";<br />

parameter [7:0] reg_param = 'b001100xz;<br />

// Instantiate SystemC module<br />

ringbuf #(.int_param(int_param),<br />

.real_param(real_param),<br />

.str_param(str_param),<br />

.reg_param(reg_param))<br />

chip(.clock(clock),<br />

...<br />

... };<br />

endmodule<br />

---------------------------------------------------------------------------<br />

// ringbuf.h<br />

#ifndef INCLUDED_RINGBUF<br />

#define INCLUDED_RINGBUF<br />

#include<br />

SC_MODULE(ringbuf)<br />

{<br />

public:<br />

// Module ports<br />

sc_in clock;<br />

...<br />

...<br />

SC_CTOR(ringbuf)<br />

: clock("clock"),<br />

...<br />

...<br />

<strong>ModelSim</strong> <strong>SE</strong> User’s <strong>Manual</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!