SystemC是一个支持系统建模的开源的C++ library;主要用于芯片设计,SystemC可以让软硬件并行开发,加快产品面市时间。
下载
下载地址:SystemC (accellera.org)
github地址:GitHub - accellera-official/systemc: SystemC Reference Implementation
systemc官网:systemc.org
我这里下载的是3.0.0版本
wget https://github.com/accellera-official/systemc/archive/refs/tags/3.0.0.tar.gz
编译
# 进入主目录
cd systemc
mkdir build
cd build
cmake ..
make -j4
make install
# 默认会安装到/opt/systemc
Hello World
- hello.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
- hello.cpp
#include "hello.h"
int sc_main (int argc, char* argv[]) {
cout <<"Hello World "<< endl;
return 0;// Terminate simulation
}
- Makefile
LIB_DIR=-L /opt/systemc/lib
INC_DIR=-I /opt/systemc/include
LIB=-lsystemc -Wl,-rpath,/opt/systemc/lib
App=hello
all:
g++ -o $(App) $(App).cpp $(LIB_DIR) $(INC_DIR) $(LIB)
clean:
RM -RF $(App)
- 编译/运行
make
export LD_LIBRARY_PATH=/opt/systemc/lib:$LD_LIBRARY_PATH
./hello