预备打工人之SystemC学习
在学习SystemC入门这一本书
SystemC环境安装
我是使用linux环境
1、在网站上 下载systemc最新版
https://accellera.org/downloads/standards/systemc
目前是2.3.3
2、上传到到linux服务器
3、解压
tar -zxvf systemc-2.3.3
cd systemc-2.3.3
4、创建临时文件夹
mkdir tmp
cd tmp
5、安装
../configure
make
make install
6、在systemc文件夹下出现include和lib-linux64可以删除临时文件夹
7、可以添加到bashrc
测试程序hello world
1、像cpp程序一样,在.h文件中创建模块
#ifndef _HELLO_H
#define _HELLO_H
#include "systemc.h"
SC_MODULE(hello){
SC_CTOR(hello){
cout<<"Hello,SystemC!"<<endl;
cout<<"c_version():"<<endl;
cout<<sc_version()<<endl;
cout<<"sc_copyright() "<<endl;
cout<<sc_copyright()<<endl;
cout<<"sc_time_stamp() "<<sc_time_stamp()<<endl;
cout<<"sc_get_time_resolution() "<<sc_get_time_resolution()<<endl;
cout<<"sc_get_default_time_unit() "<<sc_get_default_time_unit()<<endl;
}
};
#endif
SC_MODULE这句表示是systemc模块
SC_CTOR块关联的模块必须和模块名称一致。下面是类似构造函数一样,输出信息。
2、像cpp程序一样,在.cpp文件中创建模块
#include "hello.h"
int sc_main (int argc, char* argv[]) {
cout <<"Hello World "<< endl;
return 0;// Terminate simulation
}
3、编译,使用makefile比较简单
LIB_DIR=-L /home/xxx/systemc/systemc-2.3.3/lib-linux64/
INC_DIR=-I /home/xxx/systemc/systemc-2.3.3/include/
LIB=-lsystemc -Wl,-rpath,/home/xxx/systemc/systemc-2.3.3/lib-linux64/
App=hello
all:
g++ -o $(App) $(App).cpp $(LIB_DIR) $(INC_DIR) $(LIB)
clean:
RM -RF $(App)
错误的可能:
- **** stop什么的,就是makefile中tab与空格问题,makefile中都要用tab
- ./hello:error while loading shared libraries: libsystemc-2.3.1.so: cannot open shared object file: No such file or directory 。这个错误在makefile中这句 -Wl,-rpath,/home/xxx/systemc/systemc-2.3.3/lib-linux64/,应该能解决,不能的话添加环境
4、运行./hello,但是这个程序没有调用systemc的模块。