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.

UM-210 7 - Mixed-language simulation<br />

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

Guidelines for manual creation<br />

Apply the following guidelines to the creation of foreign modules. A foreign module:<br />

contains ports corresponding to Verilog ports. These ports must be explicitly named in<br />

the foreign module’s constructor initializer list.<br />

must not contain any internal design elemen ts such as child instances, primitive channels,<br />

or processes.<br />

must pass a secondary constructor argument denoting the module’s HDL name to the<br />

sc_foreign_module base class constructor. For Verilog, the HDL name is simply the<br />

Verilog module name corresponding to the foreign module, or []..<br />

parameterized modules are allowed, see "Parameter support for SystemC instantiating<br />

Verilog" (UM-211) for details.<br />

Example #1<br />

A sample Verilog module to be instantiated in a SystemC design is:<br />

module vcounter (clock, topcount, count);<br />

input clock;<br />

input topcount;<br />

output count;<br />

reg count;<br />

...<br />

endmodule<br />

The SystemC foreign module declaration for the above Verilog module is:<br />

class counter : public sc_foreign_module {<br />

public:<br />

sc_in clock;<br />

sc_in topcount;<br />

sc_out count;<br />

counter(sc_module_name nm)<br />

: sc_foreign_module(nm, "lib.vcounter"),<br />

clock("clock"),<br />

topcount("topcount"),<br />

count("count")<br />

{}<br />

};<br />

The Verilog module is then instantiated in the SystemC source as follows:<br />

counter dut("dut");<br />

where the constructor argument (dut) is the instance name of the Verilog module.

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

Saved successfully!

Ooh no, something went wrong!