systemC的环境搭建

window下systemc的环境搭建

安装视频

一、编译SystemC库

1.下载SystemC library source code (systemc-2.3.1版本)

2.解压到工作目录

3.打开...systemc-2.3.0msvc80SystemC目录下的SystemC.sln

4.直接"生成(Build英文)"-->“生成解决方案(Build Solution)”,如果编译成功的话(忽略那些Warning)。在...systemc-2.3.0msvc80SystemCdebug目录下就生成了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.
";
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.0src)

VC++目录->库目录(...systemc-2.3.2msvc10SystemCDebug)

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 <cstring>
   #include <cstdlib>
   再次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
原文地址:https://www.cnblogs.com/cpsmile/p/8044614.html