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 #2<br />

SystemC: instantiating Verilog UM-211<br />

Another variation of the SystemC foreign module declaration for the same Verilog module<br />

might be:<br />

class counter : public sc_foreign_module {<br />

public:<br />

...<br />

...<br />

...<br />

counter(sc_module_name nm, char* hdl_name)<br />

: sc_foreign_module(nm, hdl_name),<br />

clock("clock"),<br />

...<br />

...<br />

...<br />

{}<br />

};<br />

The instantiation of this module would be:<br />

counter dut("dut", "lib.counter");<br />

Parameter support for SystemC instantiating Verilog<br />

Since the SystemC language has no concept of parameters, parameterized values must be<br />

passed from a SystemC parent to a Verilog child through the SystemC foreign module<br />

(sc_foreign_module). See "SystemC foreign module declaration" (UM-209) for information<br />

regarding the creation of sc_foreign_module.<br />

Generic parameters in sc_foreign_module constructor<br />

To instantiate a Verilog module containing parameterized values into the SystemC design,<br />

you must pass two parameters to the sc_foreign_module constructor: the number of<br />

parameters (int num_generics), <strong>and</strong> the parameter list (const char* generic_list). The<br />

generic_list is listed as an array of const char*.<br />

If you create your foreign module manually (see "Guidelines for manual creation" (UM-<br />

210)), you must also pass the parameter information to the sc_foreign_module constructor.<br />

If you use scgenmod to create the foreign module declaration, the parameter information<br />

is detected in the HDL child <strong>and</strong> is incorporated automatically.<br />

Example<br />

Following the example shown above (UM-211), let’s see the parameter information that<br />

would be passed to the SystemC foreign module declaration:<br />

class counter : public sc_foreign_module {<br />

public:<br />

sc_in clk;<br />

...<br />

counter(sc_midule_name nm, char* hdl_name<br />

int num_generics, const char* generic_list)<br />

: sc_foreign_module(nm, hdl_name, num_generics,<br />

generic_list),<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!