Está en la página 1de 6

Tutorial: How to create & build a new SystemC project

in a Visual Studio 2005 solution


Prerequisites:
Windows with Microsoft Visual Studio 2005 installed,
SystemC sources (here: v2.2.0) unzipped to a local folder (e.g.: e:\SystemC\systemc2.2.05jun06_beta)
Adding the environment variable SYSTEMC:
Go to Start -> Settings -> Control Panel -> System -> Advanced -> Environment
Variables. Add a new user variable SYSTEMC. The value must be the path to the
subfolder \msvc7of your unzipped SystemC source code.

You have to logoff and login your windows user to reload the user variables.
Building the SystemC project to get the import library SystemC.lib
Open solution SystemC.sln in subfolder \msvc71\SystemC with Visual Studio. Build the
solution with F7. This may take a while. Afterwards the SystemC.lib will be generated in
subfolder /msvc71/SystemC/Debug.
Creating a new VS 2005 C++ project for using SystemC
Open visual studio and create a new project. In New Project dialogue select C+ ->
Win32 -> Win32 Console Application and chose a project name. In the Win32

Application Wizard dialogue deselect Precompiled Headers under Application Settings


and finish.
Note: If you have created your project without a pre-existing solution an equal named
solution will be created around it automatically. You can also insert a new SystemC
project in an existing solution (e.g. the SystemC.sln).
Configuring your new solution/project to be able using SystemC extensions
Go to Tools - > Option s-> Projects and Solution -> VC++ Directories. Select Show
Directories for Include Files and add a new line with: $(SYSTEMC)\..\src

Select Show Directories for Library Files from the same dialogue and add a new line
with: $(SYSTEMC)\SystemC\Debug

For each project you just created or for existing projects in which you plan to integrate
SystemC you have to ensure your project settings to meet this options:
Open your projects properties and set the Detect 64-bit Portability Issues option under
C/C++ -> General to No.

Select C/C++ - > Code Generation and set the value of Runtime Library to Multithreaded Debug (/MTd).

Select C/C++ - > Command Line and insert the compiler option /vmg.

Note: Without the /vmg option you may be able to build your project but it maybe
behaves wrong.
Select Linker -> Input and add systemc.lib to Additional Dependencies.

Now you should be able to build your project. For a simple test you could insert a
HelloWorld.cpp containing this sample code:
// sc_hello_world.cpp : Defines the entry point for the console
application.
//
#include "systemc.h"
#include <iostream>
SC_MODULE(Hello_SystemC)
{
sc_in_clk iclk;
SC_CTOR(Hello_SystemC)
{
SC_METHOD(main_method);

sensitive << iclk.neg();


dont_initialize();

void main_method(void)
{
std::cout << sc_time_stamp() << " Hello World!" <<
std::endl;
}
};
int sc_main(int argc, char* argv[])
{
const sc_time t_PERIOD(8,SC_NS);
sc_clock clk("clk",t_PERIOD);
Hello_SystemC iHelloWorld("iHelloWorld");
iHelloWorld.iclk(clk);
sc_start(50,SC_NS);
return 0;
}
Your console output should look like this:

También podría gustarte