VS2012下systemC配置

一、编译System库

1.下载SystemC library source code
              到http://www.systemc.org注册会员账号后,即可下载SystemC library soure code

2. 以SystemC 23.0为例,下载后的文件名喂systemc-2.3.0.tgz,解压到C盘目录下:F:\systemc-2.2.0

3. 打开C:\systemc-2.3.0\msvc80\SystemC目录下的SystemC.sln

4.VS一般都是Debug模式,所以直接"生成(Build英文)"-->“生成解决方案(Build Solution)”,如果编译成功的话(忽略那些Warning)。在C:\systemc-2.3.0\msvc80\SystemC\debug目录下就生成了SystemC.lib

我在编译时遇到这样的问题:fatal error C1189: #error :  The C++ Standard Library forbids macroizing keywords. Enable warning C4005 to find the forbidden macro. 在这截下来跟大家分享下,解决方案是:

右键Properties -> configuration Properties ->C/C++ -> Preprocessor -> Preprocessor Definitions 添加_XKEYCHECK_H 。

二、新建一个控制台应用程序。添加测试代码,这里给出一个测试代码:

//mon.h

#ifndef _MON_H
#define _MON_H
#include <systemc>
SC_MODULE(mon){
sc_in<bool> A,B,F;
sc_in_clk Clk;
void monitor(){ //watch the inport and outport signal until simulatus stop
while(1){
wait();
cout<<sc_time_stamp()<<"\t"<<A.read()
<<" "<<B.read()<<" "<<F.read()<<endl;
}
}
SC_CTOR(mon){
SC_THREAD(monitor);
sensitive<<Clk.pos();
cout<<"Time\tA B F"<<endl;
}
};
#endif

//nand2.h

#ifndef _NAND2_H
#define _NAND2_H #include <systemc> SC_MODULE (nand2){ //declare nand2 module
sc_in<bool> A,B; //input signal ports
sc_out<bool> F; //output port
void do_nand(){ //simulate logic function of the nand
F.write(!( A.read() && B.read()));
};
SC_CTOR(nand2){ //constructor for nand2
SC_METHOD (do_nand); //register do_nand with kernel
sensitive<<A<<B; //sensitivity list
}
};
#endif

//stim.h

#ifndef _STIM_H
#define _STIM_H #include <systemc> SC_MODULE(stim){
sc_out<bool> A,B; //declare outport signal
sc_in<bool> Clk; //declare clock void gen_stim(){ //function to generate the test bench
A.write(0);
B.write(0);
wait();
A.write(0);
B.write(1);
wait();
A.write(1);
B.write(0);
wait();
A.write(1);
B.write(1);
wait();
sc_stop();
}
SC_CTOR(stim){
SC_THREAD(gen_stim);
sensitive<<Clk.pos();
}
};
#endif

//main.cpp

#include"nand2.h"
#include"stim.h"
#include"mon.h" int sc_main(int argc, char* argv[]){
sc_signal<bool> Asig, Bsig, Fsig;
sc_clock testClk("TestClock",10,SC_NS,0.5); nand2 nand("nand2");
nand.A(Asig);
nand.B(Bsig);
nand.F(Fsig); stim stim1("Stimulus");
stim1.A(Asig);
stim1.B(Bsig);
stim1.Clk(testClk); mon monitor1("Monitor");
monitor1.A(Asig);
monitor1.B(Bsig);
monitor1.F(Fsig);
monitor1.Clk(testClk); sc_start(); //stimulus start
return 0;
}

右击工程名选择Properties

VS2012下systemC配置

C/C++→General →Additional Include Directories (F:\systemc-2.3.0\src)

C/C++ →Language →Enable Run-Time Type Info→Yes

C/C++→Code Generation→Runtime Library→Multi-thread Debug(/MTd)

C/C++→ Command Line→Additional Options加上/vmg /D_CRT_SECURE_NO_DEPRECATE

Linker →General→Additional Library Directories (D:\systemc- 2.3.0\msvc80\SystemC\Debug)

Linker →Input→Additional Dependencies (SystemC.lib)

之后编译运行即可。

上一篇:Please Send Me a Card


下一篇:Js获取Gridview中Dropdownlist选中状态