Download ModelSim SE User`s Manual

Transcript
Mixed-Language Simulation
SystemC Procedural Interface to SystemVerilog
To enable the registration of member functions, the SystemC source file must be compiled with
the -DMTI_BIND_SC_MEMBER_FUNCTION macro.
Calling Member Import Functions in a Specific SystemC Scope
A member import function can be registered for multiple module instances, as in the case when
registration routine SC_DPI_REGISTER_CPP_MEMBER_FUNCTION() is called from inside
a SystemC module constructor. At runtime, you must specify the proper scope when the
member import function call is initiated from SystemVerilog side. You can use the following
two routines to manipulate the SystemC scope before making the member import function call:
function string scSetScopeByName(input string sc_scope_name);
and
function string scGetScopeName();
scSetScopeByName() expects the full hierarchical name of a valid SystemC scope as the input.
The hierarchical name must use the Verilog-style path separator. The previous scope
hierarchical name before setting the new scope will be returned.
scGetScopeName() returns the current SystemC scope for next member import function call.
Since both routines are predefined in ModelSim built-in package mti_scdpi, you need to import
this package into the proper scope where the two routines are used, using the following
statement:
import mti_scdpi::*;
Example 10-16. Usage of scSetScopeByName and scGetScopeName
//test.cpp:
SC_MODULE(scmod)
{
void cppImportFn();
SC_CTOR(scmod)
{
........
SC_DPI_REGISTER_CPP_MEMBER_FUNCTION("cppImportFn",
&scmod::cppImportFn);
......
}
};
//test.sv:
module top();
ModelSim SE User’s Manual, v6.4a
437