安裝
執行
1. 到資料夾底下(n26121779_hw3)
2. make all (執行Makefile)
3. make成功以後,在同個資料夾底下直接 ./Fulladder 才會有波型檔(.vcd)
Makefile:
(Ref : https://blog.csdn.net/tristan_tian/article/details/109555823)--------------------- Q&A ----------------------------------------------------------
QA:
Q : sudo gedit ~/.bashrc
----> sudo: gedit: command not found
A :
1.sudo apt-get remove gedit
2.sudo apt-get install gedit
Q : ./FullAdder
-----> error while loading shared libraries: libsystemc-3.0.0.
so: cannot open shared object file: No such file or directory
A : sudo gedit ~/.bashrc #在最下面添加 export SYSTEMC_HOME=/自己安装的路径/systemc export LD_LIBRARY_PATH=/自己安装的路径/systemc/lib-linux64:$LD_LIBRARY_PATH #保存退出 source ~/.bashrc
(SYSTEMC_HOME=/home/n26121779/systemc-3.0.1)
Ref : https://blog.csdn.net/qq_42556934/article/details/108304720
--------------------------------------------------------
1.Download SystemC
以systemc-2.3.3為例
(1) 先檢查g++版本: g++ -v or gcc -v,沒有就安裝g++: sudo apt-get install gcc g++
檢查make版本: make -v,沒有就安裝make:sudo apt install make
(2) 下載systemc-2.3.3.tar.gz,並上傳至工作站或linux虛擬機
載點: https://www.accellera.org/downloads/standards/systemc
(3) 解壓縮: tar xvf systemc-2.3.3.tar.gz
(4) 移動至systemc-2.3.3資料夾: cd systemc-2.3.3
(5) 建立目錄build,以存放編譯檔案: mkdir build/
(6) 移動至build: cd build/
(7) 設定libsystenc安裝位置至build: ../configure --prefix=/usr/local/systemc-2.3.3
(8) 編譯systemc-2.3.3: make
(9) 安裝libsystenc: make install or sudo make install
(10)解決報錯: error while loading shared libraries: libsystemc-2.3.3.so: cannot open shared object file: No such file or directory
在terminal輸入: export LD_LIBRARY_PATH=/usr/local/systemc-2.3.0/lib-linux64:$LD_LIBRARY_PATH
2.環境測試
(1) 範例程式共4份檔案
切記include路徑要對

(2) code如下
hello_module.cpp:
hello_module.h:
#include "/home/local/systemc-2.3.3/src/systemc.h"
SC_MODULE(hello_module)
{
// signal declaration
sc_in_clk clk;
// fuction declaration
void method_func();
//Constructor
SC_CTOR(hello_module) {
SC_METHOD(method_func);
sensitive << clk.pos();
}
};
main.cpp:
#include "/home/local/systemc-2.3.3/src/systemc.h"
#include "hello_module.h"
int sc_main(int argc, char* argv[])
{
// signal declaration
sc_clock clk("clk", 10, SC_NS, 0.5);
// module declaration
hello_module module0("hello_word");
// signal connection
module0.clk(clk);
// run simulation
sc_start(1000, SC_NS);
return 0;
}
Makefile:
LIB_DIR=-L/home/local/systemc-2.3.3/lib-linux64
INC_DIR=-I/home/local/systemc-2.3.3/include
LIB=-lsystemc-2.3.3
RPATH=-Wl,-rpath=/home/local/systemc-2.3.3/lib-linux64
APP=hello_module
BPP=main
all:
g++ -o $(APP) $(APP).cpp $(BPP).cpp $(LIB_DIR) $(INC_DIR) $(LIB) $(RPATH)
clean:
rm -rf $(APP)
(3) 編譯檔案: make all ,產生執行檔hello_module


(4) 執行檔案: ./hello_module

https://hackmd.io/@HankTsai/r1jAzGjh6
沒有留言:
張貼留言