systemC 源码获取:
gitee上获取:https://gitee.com/soc-esl/systemc?_from=gitee_search
git clone git@gitee.com:soc-esl/systemc.git
systemC 编译安装
进入到systemc目录切换到2.3.3 tag
git check -b tag-2.3.3 2.3.3 mkdir build cd build cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_INSTALL_PREFIX=/home/jin/libs/systemc/ -DCMAKE_CXX_STANDARD=11 ..
make -j32
make check #自动跑example下面的例子
make install
至此systemc已经安装到/home/jin/libs/systemc/目录下面
尝试很多方法,cmake编译生成的.so不能完成配合自己的写model编译,卒……

放弃cmake编译,改用../configure编译
操作如上,创建临时目录执行
../configure --prefix=/home/jin/libs/system
make -j32
make install -j32
执行systemC例子
Cpp文件测试内容
// Learn with Examples, 2020, MIT license #include <systemc> // include the systemC header file using namespace sc_core; // use namespace void hello1() { // a normal c++ function std::cout << "Hello world using approach 1" << std::endl; } struct HelloWorld : sc_module { // define a systemC module SC_CTOR(HelloWorld) {// constructor function, to be explained later SC_METHOD(hello2); // register a member function to the kernel } void hello2(void) { // a function for systemC simulation kernel, void inside () can be omitted std::cout << "Hello world using approach 2" << std::endl; } }; int sc_main(int, char*[]) { // entry point hello1(); // approach #1: manually invoke a normal function HelloWorld helloworld("helloworld"); // approach #2, instantiate a systemC module sc_start(); // let systemC simulation kernel to invoke helloworld.hello2(); return 0; }
makefile文件
LIBDIR=-L /home/jin/libs/systemc/lib-linux64 INCDIR=-I /home/jin/libs/systemc/include LISTDIR=/home/jin/libs/systemc/lib-linux64 LIB=-lsystemc # LD_LIBRARY_PATH SRC=aa.cpp all: g++ $(SRC) $(LIBDIR) $(LIB) $(INCDIR) -o test clean: rm -rf *.o
并且需要在环境变量中加入
export LD_LIBRARY_PATH=/home/jin/libs/systemc/lib-linux64
执行后输出:
SystemC 2.3.4-Accellera --- Sep 13 2023 23:12:25 Copyright (c) 1996-2022 by all Contributors, ALL RIGHTS RESERVED Hello world using approach 1 Hello world using approach 2