systemC的环境搭建
- 格式:pdf
- 大小:65.90 KB
- 文档页数:2
systemC的环境搭建
⼀、编译SystemC库
1.下载 (systemc-2.3.1版本)
2.解压到⼯作⽬录
3.打开...\systemc-2.3.0\msvc80\SystemC⽬录下的SystemC.sln
4.直接"⽣成(Build英⽂)"-->“⽣成解决⽅案(Build Solution)”,如果编译成功的话(忽略那些Warning)。在...\systemc-
2.3.0\msvc80\SystemC\debug⽬录下就⽣成了SystemC.lib
⼆、新建win32控制台应⽤程序,测试代码如下:
1 // All systemc modules should include systemc.h header file
2 #include "systemc.h"
3 // Hello_world is module name
4 SC_MODULE (hello_world) {
5 SC_CTOR (hello_world) {
6 // Nothing in constructor
7 }
8 void say_hello() {
9 //Print "Hello World" to the console.
10 cout << "Hello World.\n";
11 }
12 };
13
14 // sc_main in top level function like in C++ main
15 int sc_main(int argc, char* argv[]) {
16 hello_world hello("HELLO");
17 // Print the hello world
18 hello.say_hello();
19 return(0);
20 }
配置步骤
右击⼯程名->选择Properties
调试->环境(SC_SIGNAL_WRITE_CHECK=DISABLE)
VC++⽬录->包含⽬录(...\systemc-2.3.0\src)
VC++⽬录->库⽬录(...\systemc-2.3.2\msvc10\SystemC\Debug)
C/C++ ->语⾔->启⽤运⾏时类型信息->是
C/C++->代码⽣成->运⾏库->多线程调试 (/MTd)
C/C++->命令⾏->其它选项(/vmg)
Linker ->常规->附加⽬录库 (..systemc-2.3.1/msvc10/SystemC/Debug)
链接器->输⼊->附加依赖项(SystemC.lib)
C/C++->所有选项->警告等级 ->等级1(/W1)
⽣成编译。
Linux下载配置SystemC环境:
1.下载systemc源码包。systemc-2.3.1.tar.gz
2.解压缩。
1 tar -zxvf systemc-2.3.1.tar.gz
3.进⼊systemc-2.3.1⽂件夹。
cd systemc-2.3.1
4.新建⼀临时⽂件夹tmp,并进⼊其中。1 mkdir tmp
2 cd tmp
5.运⾏如下命令。
1 ../configure
2 make
此处会出现错误,错误指⽰⽂件../src/sysc/datatypes/bit/sc_bit_proxies.h⽂件中的mutable是多余的,需要删除!
还有⼀处错误,在⽂件../src/sysc/utils/sc_utils_ids.cpp⽂件中加⼊如下头⽂件:
#include
#include
再次make就能成功,然后再
1 make install
回到上⼀级⽬录中
1 cd ..
在此⽬录中⽣成了两个新的⽂件夹,include 与 lib-linux64
⼤功告成!
6.删除刚才新建的tmp⽂件夹。
1 rm -rf tmp
2 [cp@Server203 systemc]$ export LD_LIBRARY_PATH=/home/cp/Simulator/systemc/lib-linux64 (这⼀步⾮常重要)
7.运⾏⼀个systemc程序test.cpp进⾏测试。
1 g++ test.cpp -I/home/cp/Simulator/systemc/include -L/home/cp/Simulator/systemc/lib-linux64 -o test -lsystemc
2 ./test
Makefile
1 LIBDIR=-L/home/cp/Simulator/systemc/lib-linux64
2 INCDIR=-I/home/cp/Simulator/systemc/include
3 LIB=-lsystemc
4 all:
5 g++ -o test test.cpp $(LIBDIR) $(INCDIR) $(LIB)
6 clean:
7 rm -rf *.o