预备打工人之SystemC学习(一)——安装环境并测试

预备打工人之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的模块。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值