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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值