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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Code modification examples<br />

Compiling SystemC files UM-165<br />

Removing calls to sc_initialize()<br />

vsim calls sc_initialize() by default at the end of elaboration, so calls to sc_initialize() are<br />

unnecessary.<br />

Exporting all top level SystemC modules<br />

For SystemC designs, you must export all top level modules in your design to <strong>ModelSim</strong>.<br />

You do this with the SC_MODULE_EXPORT() macro. SystemC<br />

templates are not supported as top level or boundary modules. See "Templatized SystemC<br />

modules" (UM-171). The sc_module_name is the name of the top level module to be<br />

simulated in <strong>ModelSim</strong>. You must specify this macro in a C++ source (.cpp) file. If the<br />

macro is contained in a header file instead of a C++ source file, an error may result.<br />

For HP-UX: Explicitly naming signals, ports, <strong>and</strong> modules<br />

Important: Verify that SystemC signals, ports, <strong>and</strong> modules are explicitly named to avoid<br />

port binding <strong>and</strong> debugging errors.<br />

Example 1<br />

The following is a simple example of how to convert sc_main to a module <strong>and</strong> elaborate it<br />

with vsim.<br />

Original OSCI code #1 (partial) Modified code #1 (partial)<br />

int sc_main(int argc, char* argv[])<br />

{<br />

sc_signal mysig;<br />

mymod mod("mod");<br />

mod.outp(mysig);<br />

}<br />

sc_start(100, SC_NS);<br />

The run comm<strong>and</strong> equivalent to the sc_start(100, SC_NS) statement is:<br />

run 100 ns<br />

SC_MODULE(mytop)<br />

{<br />

sc_signal mysig;<br />

mymod mod;<br />

};<br />

SC_CTOR(mytop)<br />

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

mod("mod")<br />

{<br />

mod.outp(mysig);<br />

}<br />

SC_MODULE_EXPORT(mytop);<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!