Script_Language_Interface > SystemC
Block Name: SC_Module
Code File Location: VisualSim/interfaces/systemC/SC_Module
Note: The file name and file path for the SystemC file must not contain '_" and numbers.
The SC_Module block is instantiated in a model at the location where a new SystemC module must be added to the simulation. This block generates a template within a new directory that is in VS_C_Library/SystemC directory. The VS_C_Library is defined in the VisualSim.bat directory. If a SC_Sim is also instantiated in the model, then the interface of this model with systemC transfers time across the interface. If the interface is purely functional and no timing needs to be transfered, then the simulation can be an event-triggered. The SC_Sim will not be instantiated in this case.
The Use Model for the SC_Module Block is to add SC_Module blocks within a model where ever a connection to SystemC is desired. One 'SC_Sim' block per SystemC model is needed in the case of the 'Timed Interface'.
Before using VisualSim SC_Cosim block, make sure the following attributes have been :
C++ Compiler: Current support is Visual Studio 2008 and g++ 4.0 and higher. This must be set in $VS/VSconfig.Properties file for Windows and $VS/VSConfig_linux.Properties for Linux.
VS_C_Library: This is located in the VisualSim.bat (Windows) and VisualSim.sh (Unix). This is base directory that is included in the PATH environment variable. All SystemC and TLM source code must be located in directory structures within VS_C_Library/SystemC. The folder structure can have any hierarchy. A folder called blocks is automatically added to this directory. All the dynamic libraries that are used to compile the SystemC code are in this library. One dynamic library is created per model and saved in the blocks directory.
TLM_Home: Value has been preset. The Windows path is $VS\\VisualSim\\simulators\\SystemC\\tlm and the Linux path is $VS/VisualSim/simulators/SystemC/tlm. This is set in $VS/VSconfig.Properties file for Windows and $VS/VSConfig_linux.Properties for Linux.
SystemC Home: Compiled versions are provided for both Windows and Linux. The Windows path is $VS\\VisualSim\\simulators\\SystemC\\Win\\systemc-2.2.0 and the Linux path is $VS/VisualSim/simulators/SystemC/Linux/systemc-2.2.0. This is set in $VS/VSconfig.Properties file for Windows and $VS/VSConfig_linux.Properties for Linux.
Note: The user can provide an alternate SystemC and TLM library path.
Step 1: Drag the SC_Module block from the library onto the Block Diagram Editor.
Step 2: Configure the block with the values for the two field.
Step 3: Configure the port names by right-click on the block and selecting Configure Ports. "Add" a port, enter whether input or output and specify the SC_Type in the Remote_Type column. The SC_Type can be both C++ and SystemC types. Repeat this for as many ports as is required.
Step 4: From Menu-Bar, select "Generate Wrapper".
Step 5: From Menu-Bar, select "Compile Wrapper".
When the Generate Wrapper and Compile Wrapper is selected, this operates on all SystemC, C Interface, Verilog and VHDL blocks in the model.
These additional parameters can be a part of the model.
User_Properties
Include_Search_Path
Build_Files
Header_Files
When you create these user defined parameters, you need to modify the third line, class to VisualSim.data.expr.StringParameter. This will treat it as a string. When you set it to string, the tool treats the data as within “”.
To make the parameter window into text as opposed to line, click Preferences and select Text by the side of the relevant parameter.
The TLM header file links are set in VisualSim.bat/.sh file. Look for set TLM=””. If you wish to use a different TLM variation, specify the link here. The default is the one shipped with VisualSim. The SystemC simulator and include files are set, by default, in vsconf.bat. If you are using a modified a SystemC simulator, you modify the file destinations to incorporate your own and discard the pre-shipped version.
This can be used to include additional information needed for the compiler. Look at the TLM 2.0 example to understand the usage. To view the TLM 2.0 model in the BDE, click here. To look at these parameters, right-click on the white space and select Configure.
The method- and socket-based connections of TLM 1.0 and 2.0 are defined in the SC_Sim block field called Interface_Routing.
For TLM 2.0, the conenctions would look like this:
LtMinSystemTimed_m_initiator_1->processor_abstraction_socket(LtMinSystemTimed_m_bus->target_socket[0]);
LtMinSystemTimed_m_initiator_2->processor_abstraction_socket(LtMinSystemTimed_m_bus->target_socket[1]);
LtMinSystemTimed_m_bus->initiator_socket[0](LtMinSystemTimed_m_target_1->m_memory_socket);
LtMinSystemTimed_m_bus->initiator_socket[1](LtMinSystemTimed_m_target_2->m_memory_socket);
For TLM 1.0, the interface routing would look like this:
simple_bus_master_Wrapper->clock(*clk);
simple_bus_master_Wrapper->bus_port(*simple_bus);
To view the TLM 2.0 model in the BDE, click here.
It is possible to mix-and-match 1.0 and 2.0 in a single model. This is not recommended by the TLM standards.
The following requirements must be maintained.
File names must not contain _.
The block "Customize Name" must match the Module Name. If the block name does not change by itself, then the user must change. Else a java.lang.nullexception will be received.
If multiple c or cpp files are located in the same directory, then the $VS/bin/vsmake.{sh,bat} must be updated. All the delete lines mst be commented out: *.cpp, *.java, *.h, Jni*.cpp, Jni*.h, Jni*.xml, VS_*.h, VS_*.cpp and vs_intf.*.
C++ Types |
VisualSim RemoteTypes |
int |
int |
bool |
boolean |
double |
double |
long |
long |
float |
float |
char |
char |
Table 1. Types and equivalent Remote Types in VisualSim
SystemC Data Types |
VisualSim RemoteTypes |
sc_bit |
sc_bit |
sc_logic |
sc_logic |
sc_int |
sc_int |
sc_uint |
sc_uint |
sc_bigint |
sc_bigint |
sc_biguint |
sc_biguint |
sc_bv |
sc_bv |
sc_lv |
sc_lv |
sc_fixed |
Not supported |
sc_ufixed |
Not supported |
sc_fix |
Not supported |
sc_ufix |
Not supported |
user structs |
Not supported |
Table 2. SystemC types and their equivalent Remote Types in VisualSim
Parameter |
Explanation |
Type |
Example |
SC_Module_Name |
The name of the SC_Module is entered in this field. This name will appear on the top of the block and will be the name of the directory and generated file. |
String |
"SystemC_Module_Name" |
Created with the Personal Edition of HelpNDoc: Full-featured EBook editor