# SystemC Enviroment 1.Download SystemC -- 以systemc-2.3.3為例 (1) 先檢查`g++`版本: `g++ -v` or `gcc -v`,沒有就安裝g++: `sudo apt-get install gcc g++` </br> 檢查make版本: `make -v`,沒有就安裝make:`sudo apt install make` (2) 下載systemc-2.3.3.tar.gz,並上傳至工作站或linux虛擬機 </br> 載點: https://www.accellera.org/downloads/standards/systemc</br> (3) 解壓縮: `tar xvf systemc-2.3.3.tar.gz` </br> (4) 移動至systemc-2.3.3資料夾: `cd systemc-2.3.3` </br> (5) 建立目錄build,以存放編譯檔案: `mkdir build/` </br> (6) 移動至build: `cd build/` </br> (7) 設定libsystenc安裝位置至build: `../configure --prefix=/usr/local/systemc-2.3.3` </br> (8) 編譯systemc-2.3.3: `make` </br> (9) 安裝libsystenc: `make install` or `sudo make install`<br/> (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份檔案</br> 切記include路徑要對</br> </br> (2) code如下 </br> hello_module.cpp: </br> ```cpp= #include "hello_module.h" void hello_module::method_func() { if(clk){ sc_time_stamp().print(); printf(" Hello Word! \n"); } } ``` hello_module.h: </br> ```clike= #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: </br> ```clike= #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: ```clike= 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 </br> </br> </br> (4) 執行檔案: `./hello_module` </br> </br>
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.