Visual Studio 2008配置SystemC開發環境

步驟一、編譯System庫

1.下載SystemC library source code
       到http://www.systemc.org 註冊會員賬號後,即可下載SystemC library soure code

2. 以SystemC 2.2.0爲例,下載後的文件名喂systemc-2.2.0.tgz,解壓到C盤目錄下:C:\systemc-2.2.0

3. 打開C:\systemc-2.2.0\msvc71\SystemC目錄下的SystemC.sln

4.VS一般都是Debug模式,所以直接"生成(Build英文)"-->“生成解決方案(Build Solution)”,如果編譯成功的話(忽略那些Warning)。在C:\systemc-2.2.0\msvc71\SystemC\debug目錄下就生成了SystemC.lib

 

步驟二:更新SystemC include file 和 library

1. Select Tools(工具) -> Options(選項) . . . and the Projects(項目和解決方案) -> VC++ Directories tab(Vc++目錄)
2. Select show directories for: Library files(庫文件)

3. Select the 'New' icon and browse to: C:\systemc-2.2.0\msvc71\SystemC\Debug

4. Select show directories for: Include files(包含文件)

5. Select the 'New' icon and browse to: C:\systemc-2.2.0\src

 

步驟三:創建SystemC應用程序

1. Start Visual Studio. From the Start Page select New Project and Win32 Console Project (Windows 控制檯應用程序). Type the project name and select a suitable location then click OK.
2. Select the Application Settings page of the Win32 Application Wizard and make sure the 'Empty project' box is ticked(把空項目勾起來). Click 'Finish' to complete the wizard.

3. Add new/existing C++ files to the project and edit code.【一定要添加某個C++文件否則下一步就找不到C/c++的選項了】
4. Display the project Property Pages by selecting 'Properties...' from the Project menu.

5. C/C++ -> General properties Warning level= Level 1(/W1) 
6. C/C++ -> Code Generation Runtime Library =Multi-thread Debug (/MTd) 
7. C/C++ -> Command Line properties Additional Options = /vmg /D_CRT_SECURE_NO_DEPRECATE 
8. Linker -> Input properties Additional Dependiences = systemc.lib 
9. Click

結束


附上一個測試文件: 一個加法器:

adder.h

#ifndef _ADDER_H
#define _ADDER_H

SC_MODULE(Adder){
 public:
	 sc_in<int> data_in_1;
     sc_in<int> data_in_2;
	 sc_out<int> data_out;
SC_CTOR(Adder){
      SC_METHOD(adder_action);
	  sensitive << data_in_1 <<data_in_2;
	 }

	 void adder_action(){
         data_out = data_in_1 + data_in_2;
	 }
};

#endif

 adder.cpp

#include <systemc.h>
#include "adder.h"

SC_MODULE(Stimulator) {
 public:
	sc_out<int> data_out_1, data_out_2;

	SC_CTOR(Stimulator){
		SC_THREAD(send_data);
		dont_initialize();
	};

 private:
	void send_data() {
		int i = 3;
		while(true){
			wait(i, SC_NS);
			cout << "Time: " <<	sc_time_stamp() << "::";
			cout << "Send data: " << 4*i << ", " << 5*i-2 << endl;
			data_out_1 = 4*i;
			data_out_2 = 5*i-2;
			i++;
			if(i >= 14) {
				wait(1,SC_NS);
				sc_stop();
			}
		}
	};
};

SC_MODULE(Monitor) {
public:
	sc_in<int> data_in;

	SC_CTOR(Monitor){
		SC_METHOD(display);
		dont_initialize();
		sensitive << data_in;
	};

private:
	void display(){
		cout << "Time: " <<	sc_time_stamp() << "::";
		cout << "Receive data: " << data_in.read() << endl;
	};	
};

int sc_main(int argc, char* argv[]) {
	Stimulator *stim;
	Monitor *mon;
	Adder *adder;

	stim = new Stimulator("Stimulator");
	mon = new Monitor("Monitor");
	adder = new Adder("Adder");

	sc_signal<int> data_in_1, data_in_2, data_out;

	stim->data_out_1(data_in_1);
	stim->data_out_2(data_in_2);
	mon->data_in(data_out);
	adder->data_in_1(data_in_1);
	adder->data_in_2(data_in_2);
	adder->data_out(data_out);

	sc_start();

	return 0;
}

轉載:http://yexin218.iteye.com/blog/356620
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章