主要内容
- 如何安装SystemC
- SystemC风格的hello worl
- 如何编译SystemC下的hello world
1. 如何安装SystemC
SystemC是一组C++库,可以从下面这个网址进行下载。
复制代码
1
2https://accellera.org/downloads/standards/systemc
SystemC下有几个组件:
- SystemC 2.3.3 (Includes TLM)
- SystemC AMS 2.3
- SystemC CCI 1.0
- SystemC Verification 2.0.1
- SystemC Synthesis 1.4.7
下载第一个下的 Core SystemC Language and Examples (tar.gz)包即可,然后编译源代码,安装system c组件到/usr/local/systemc-2.3.3目录下。
复制代码
1
2
3
4
5
6
7
8tar -xvzf systemc-2.3.3.tar.gz cd systemc-2.3.3 mkdir build cd build ../configure --prefix=/usr/local/systemc-2.3.3 make make install
2. SystemC风格的Hello World
创建一个工作目录,mysysc,然后编辑一个hello.cpp
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include "systemc.h" SC_MODULE(hello_world){ SC_CTOR(hello_world){} void say(){ cout<<"hello world"<<endl; } }; int sc_main(){ hello_world inst0("instance 0"); inst0.say(); return 0; }
3. 如何编译Hello World
在之前解压缩的目录中或者在/usr/local/systemc-2.3.3的目录中,有example目录,其中有一个build-unix目录。
3.1 将其中的两个文件移动到工作目录mysysc
此刻,工作目录下有三个文件
- Makefile.config
- Makefile.rules
- hello.cpp
3.2 创建一个Makefile
内容如下
复制代码
1
2
3
4
5
6
7
8include Makefile.config PROJECT := hello SRCS := $(wildcard *.cpp) OBJS := $(SRCS:.cpp=.o) include Makefile.rules
3.4 修改Makefile.config
找到文件中的下面两个变量,设置system c的安装目录和linux类型
复制代码
1
2
3SYSTEMC_HOME?=/usr/local/systemc-2.3.3 TARGET_ARCH = linux64
到此,基本上就可以直接使用make编译了,会生成一个hello.x,该文件就是目标可执行文件了。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12mysysc$ make g++ -g -Wall -pedantic -Wno-long-long -Werror -I. -I.. -I/usr/local/systemc-2.3.3/include -c hello.cpp -o hello.o g++ -g -Wall -pedantic -Wno-long-long -Werror -L. -L.. -L /usr/local/systemc-2.3.3/lib-linux64 -Wl,-rpath=/usr/local/systemc-2.3.3/lib-linux64 -o hello.x hello.o -lsystemc -lm 2>&1 | c++filt mysysc$ ls hello.cpp hello.o hello.x Makefile Makefile.config Makefile.rules mysysc$ ./hello.x SystemC 2.3.3-Accellera --- May 28 2022 10:32:42 Copyright (c) 1996-2018 by all Contributors, ALL RIGHTS RESERVED hello world
最后
以上就是虚心秀发最近收集整理的关于SystemC快速实战指南的全部内容,更多相关SystemC快速实战指南内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复