Script_Language_Interface > SystemC
Block Name: SC_Cosim
Code File Location: VisualSim/interfaces/systemC/SC_Cosim
Note: The file name and file path for the SystemC file must not contain '_" and numbers.
The SC_Cosim block is used to instantiated an existing SystemC file to the simulation. One instance of the SC_Sim is required for a timed simulation. If the interface is purely functional and timing is not required, SC_Sim will not be instantiated. SC_Cosim is used to add each instance of a SC_Module. To view a SystemC model in the BDE, click here.
If you are using the TLM 2.0 type modeling, use the TLM_Cosim block.
Before using VisualSim SC_Cosim block, make sure the following attributes have been :
JAVA_HOME: Make sure the JAVA_HOME variable in VisualSim.sh and VisualSim.bat is set to jdk and not jre. BY default, VisualSim only requires jre.
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.
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.
LIBPATH_OPTIONS: In <VS 10.2>/VS_AR/bin/buildJNISO.sh, make sure the path to the gcc libraries is set correctly. It is set by default to -L/usr/lib/gcc/x86_64-redhat-linux/4.1.1.
Note: The user can provide an alternate SystemC library path.
SystemC installation - This must be built the first time you use SystemC so that it is customized to your machine/compiler
Step 1: Drag the SC_Cosim 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 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. All these parameters can be added to a model by Right-click on the white space and selecting Configure.
User_Properties: This is a parameter available from the GUI but is not used.
Include_Search_Paths: This is added to the bat or sh that is generated as part of the interface. The list can have any number of items. The first item should not have a -I prefix. All other items must have a -I prefix.
Build_Files: This is added to the bat or sh that is generated as part of the interface. The list can have any number of items. The parameter must be setup for Text preference. Each file name must be on a separate line and must be separated by a carriage return.
Header_Files: This is a list of files. These files are added to the vs_intf.h file. The parameter must be setup for Text preference. Each file name must be on a separate line and must be separated by a carriage return.
Compiler_Options: This is added to the bat or sh that is generated as part of the interface. The list can have any number of items.
Link_Options: This is added to the bat or sh that is generated as part of the interface. The list can have any number of items.
Struct_Def: This defines the struct for the ports. Multiple structs can be defined here. The struct are reference in the Remote Type column of the Port.
Block_Parameters: This is to add constructor parameters for each SC_Cosim block in the model. The user can add a array of any length. An example of the values are: {"arbiter", true}and {"mem2", 0x80, 0xff, 1}. Only a single Block_Parameters field can be added per block. Block_Parameters is a keyword and is recognized as a parameter of the block by the wrapper. If the same cpp/h code are instantiated multiple times, then the first index location would be a unique instance identifier, and the remaining would be the values. This Block_Parameters is appended to the Module name as a constructor parameter/
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 on Preferences and select Text by the side of the relevant parameter.
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. To look at these parameters, right-click on the white space and select Configure.
This feature is deprecated as we will not support TLM 1.0 in future releases.
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. 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.
The method- and socket-based connections of TLM 1.0 are defined in the SC_Sim block field called Interface_Routing.
For TLM 2.0, use TLM_Cosim block.
For TLM 1.0, the interface routing is as follows:
simple_bus_master_Wrapper->clock(*clk);
simple_bus_master_Wrapper->bus_port(*simple_bus);
It is possible to mix-and-match 1.0 and 2.0 in a single model. To view a model of TLM 1.0 in the BDE, click here.
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 |
sc_fixed |
sc_ufixed |
sc_ufixed |
sc_fix |
sc_fix |
sc_ufix |
sc_ufix |
user structs |
Supported |
Table 2. SystemC types and their equivalent Remote Types in VisualSim
Parameter |
Explanation |
Type |
Example |
SC_Module_Name |
This field is used to enter the name of the SystemC module. This name will appear as block name. This is a unique name in the model. |
String |
"SystemC_Module_Name" |
SC_File_Path |
This is the path to the .cpp or .h that contains the SystemC module code. The path can be a absolute or relative to the VisualSim C Interface library location. For example, the VS_C_Library in the VisualSim.bat points to C:/VisualSim/UserNativeC and the SystemC source code is in SystemC/bitmodel within that VS_C_Library. Then this parameter will contain SystemC/bitmodel/bitmodel.h. |
- |
"SystemC_Module_Source_Path" |
Created with the Personal Edition of HelpNDoc: Produce electronic books easily