un-timed vs. timed 모델링 인터페이스 모델 실습
준비물:
1. Raspberry PI Pico + 어댑터 보드
2. Arduino DUE + 어댑터 보드
FIR 디지털 필터 알고리즘의 언-타임드 C++ 모델
환경변수 설정,
$ cd ~/ETRI050_DesignKit/Projects/HLS/FIR8
$ source env_settings
#****************************************************************
#* Environment setting for HLS, Co-Simulmatio/Emulation & ETRI050
#****************************************************************
Setting Environment variables as follows;
PROJECT_DIR=~/ETRI050_DesignKit/Projects/HLS/FIR8
TOP_MODULE=FIR8
HW_STYLE=FIR_MAC_VERSION
MODE=CA
MI=DUE_NORMAL
언-타임드 C++ 모델 빌드,
$ cd c_untimed
$ make
Makefile for un-timed C simulation of FIR8
TOP_MODULE=FIR8 HW_STYLE=FIR_MAC_VERSION make build
TOP_MODULE=FIR8 make run
TOP_MODULE=FIR8 make clean
$ make build
clang++ -I/opt/systemc/include -L/opt/systemc/lib \
-o FIR8_TB \
-DFIR_MAC_VERSION_SC \
./calcDFT.cpp ./cnoise.cpp ./FIR8.cpp ./FIR8_TB.cpp \
-lsystemc -lgsl
언-타임드 모델 실행: 알고리즘 시뮬레이션 출력 저장
$ make run | tee result.txt
./FIR8_TB
SystemC 3.0.2-Accellera --- Aug 19 2025 16:50:37
Copyright (c) 1996-2025 by all Contributors,
ALL RIGHTS RESERVED
0 124 26.243 496 36.263
1 90 13.222 1848 23.956
2 124 11.542 4676 22.473
......
4795 185 14.501 15444 24.305
4796 59 13.516 15475 23.078
4797 121 13.911 16278 23.623
4798 109 11.542 16676 22.473
4799 73 13.222 16634 23.956
시뮬레이션 데이터 가시화(파이썬)
plotDFT.py <TXT> <option>
Plot graph from text file. <option> is one of followings,
input, inputDFT, output, outputDFT
$ python3 plotDFT.py result.txt outputDFT
Traceback (most recent call last):
File ".../FIR8/c_untimed/plotDFT.py", line 32, in <module>
y1.append(int(lines[1]))
~~~~~^^^
IndexError: list index out of range
-----------------------------------
* result.txt 파일에서 첫줄 삭제
-----------------------------------
$ python3 plotDFT.py result.txt input
$ python3 plotDFT.py result.txt inputDFT
$ python3 plotDFT.py result.txt output
$ python3 plotDFT.py result.txt outputDFT
타임드 인터페이스 모델
인터페이스 모델 테스트벤치
sc_FIR8_TB.h [링크]
sc_FIR8_TB.cpp [링크]
에뮬레이터 프록시
EFIR8.h [링크]
모델링 인터페이스
a. Arduino DUE 에서 언-타임드 모델 실행
$ cd ~/ETRI050_DesignKit/Projects/HLS/FIR8/emulation/PSCE-MI
$ MODE=AL MI=DUE_NORMAL make build
Linking Un-Timed model...
arduino-cli compile --clean --fqbn arduino:sam:arduino_due_x_dbg \
EFIR8_AL \
--build-path ./EFIR8_AL/build \
--build-property compiler.cpp.extra_flags=\
"-DOLED_DISPLAY -DDUE_NORMAL -DUART_BPS=115200 -DCYCLONE_IV"\
" -DFIR_MAC_VERSION"
Error during build: Platform 'arduino:sam' not found:
platform not installed
Try running `arduino-cli core install arduino:sam`
make: *** [Makefile:66: build] Error 1
설치된 코어보드 목록 보기
$ arduino-cli board listall
Board Name FQBN
Adafruit Circuit Playground arduino:avr:circuitplay32u4cat
Arduino BT arduino:avr:bt
Arduino Duemilanove or Diecimila arduino:avr:diecimila
.....
Atmel ARM 코어 개발 툴 설치
$ arduino-cli core update-index
Downloading index: package_index.tar.bz2 downloaded
$ arduino-cli core install arduino:sam
Downloading packages...
arduino:arm-none-eabi-gcc@4.8.3-2014q1 downloaded
arduino:bossac@1.6.1-arduino downloaded
arduino:sam@1.6.12 downloaded
Installing arduino:arm-none-eabi-gcc@4.8.3-2014q1...
Configuring tool....
arduino:arm-none-eabi-gcc@4.8.3-2014q1 installed
Installing arduino:bossac@1.6.1-arduino...
Configuring platform....
Platform arduino:sam@1.6.12 installed
$ MODE=AL MI=DUE_NORMAL make build
arduino-cli compile --clean --fqbn arduino:sam:arduino_due_x_dbg \
EFIR8_AL \
--build-path ./EFIR8_AL/build \
--build-property compiler.cpp.extra_flags=\
"-DOLED_DISPLAY -DDUE_NORMAL -DUART_BPS=115200 -DCYCLONE_IV"\
" -DFIR_MAC_VERSION"
In file included from
.../HLS/FIR8/emulation/PSCE-MI/EFIR8_AL/PSCE_Config.h:33:0,
from
.../HLS/FIR8/emulation/PSCE-MI/EFIR8_AL/EFIR8_AL.ino:6:
.../HLS/FIR8/emulation/PSCE-MI/EFIR8_AL/PSCE_APIs.h:21:54:
fatal error: U8g2lib.h: No such file or directory
#include <U8g2lib.h> // OLED Display Libraries
^
compilation terminated.
Used library Version Path
Wire 1.0
~/.arduino15/packages/arduino/hardware/sam/1.6.12/libraries/Wire
Used platform Version Path
arduino:sam 1.6.12
~/.arduino15/packages/arduino/hardware/sam/1.6.12
Error during build: exit status 1
make: *** [Makefile:66: build] Error 1
u8g2 라이브러리 설치
$ arduino-cli lib install u8g2
Downloading U8g2@2.35.30...
U8g2@2.35.30 downloaded
Installing U8g2@2.35.30...
Installed U8g2@2.35.30
빌드,
$ MODE=AL MI=DUE_NORMAL make build
arduino-cli compile --clean --fqbn arduino:sam:arduino_due_x_dbg \
EFIR8_AL \
--build-path ./EFIR8_AL/build \
--build-property compiler.cpp.extra_flags=\
"-DOLED_DISPLAY -DDUE_NORMAL -DUART_BPS=115200 -DCYCLONE_IV"\
" -DFIR_MAC_VERSION"
Sketch uses 35048 bytes (6%) of program storage space.
Maximum is 524288 bytes.
USB에 연결된 장치 확인
$ lsusb
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 001 Device 003: ID 2341:003d Arduino SA Due Programming Port
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
인터페이스 모델 업로드
$ MODE=AL MI=DUE_NORMAL make upload
arduino-cli upload -p /dev/ttyACM0 --fqbn \
arduino:sam:arduino_due_x_dbg EFIR8_AL \
--input-file ./EFIR8_AL/build/EFIR8_AL.ino.bin
Cannot perform port reset: 1200-bps touch: opening port at
1200bps: Permission denied
No device found on ttyACM0
Failed uploading: uploading error: exit status 1
make: *** [Makefile:91: upload] Error 1
$ ls -l /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 Oct 27 17:22 /dev/ttyACM0
$ sudo chmod 666 /dev/ttyACM0
[sudo] password for mychip:
$ ls -l /dev/ttyACM0
crw-rw-rw- 1 root dialout 166, 0 Oct 27 17:22 /dev/ttyACM0
$ MODE=AL MI=DUE_NORMAL make upload
arduino-cli upload -p /dev/ttyACM0 --fqbn \
arduino:sam:arduino_due_x_dbg EFIR8_AL \
--input-file ./EFIR8_AL/build/EFIR8_AL.ino.bin
Atmel SMART device 0x285e0a60 found
Erase flash
Write 37140 bytes to flash (146 pages)
[==============================] 100% (146/146 pages)
done in 8.820 seconds
Set boot flash true
CPU reset.
New upload port: /dev/ttyACM0 (serial)
언-타임드 모델 재사용 빌드 확인
$ ls -l EFIR8_AL
total 8
-rw-rw-r-- 1 mychip ... EFIR8_AL.ino
lrwxrwxrwx 1 mychip ... FIR8.cpp -> ../../../c_untimed/FIR8.cpp
lrwxrwxrwx 1 mychip ... FIR8.h -> ../../../c_untimed/FIR8.h
......
에뮬레이터 실행
$ make run
./sc_FIR8_TB
SystemC 3.0.2-Accellera --- Aug 19 2025 16:50:37
Copyright (c) 1996-2025 by all Contributors,
ALL RIGHTS RESERVED
Info: (I703) tracing timescale unit set: 100 ps (EFIR8.vcd)
Request emulator connection......
make: *** [Makefile:73: run] Interrupt
모델링 인터페이스 보드 리셋
$ make run
./sc_FIR8_TB
SystemC 3.0.2-Accellera --- Aug 19 2025 16:50:37
Copyright (c) 1996-2025 by all Contributors,
ALL RIGHTS RESERVED
Info: (I703) tracing timescale unit set: 100 ps (EFIR8.vcd)
Request emulator connection......
Connection established...
Info: (I703) tracing timescale unit set: 100 ps (sc_FIR8_TB.vcd)
[ 0] y= 0 Y= 0 OK
[ 1] y= 0 Y= 628 ERROR
[ 2] y= 628 Y= 2056 ERROR
[ 3] y= 2056 Y= 4941 ERROR
[ 4] y= 4941 Y= 8345 ERROR
[ 5] y= 8345 Y=11513 ERROR
[ 6] y=11513 Y=13553 ERROR
[ 7] y=13553 Y=14122 ERROR
[ 8] y=14122 Y=14180 ERROR
[ 9] y=14180 Y=14007 ERROR
[ 10] y=14007 Y=14480 ERROR
......
[4793] y=15039 Y=15367 ERROR
[4794] y=15367 Y=15031 ERROR
[4795] y=15031 Y=14326 ERROR
[4796] y=14326 Y=14271 ERROR
[4797] y=14271 Y=14512 ERROR
[4798] y=14512 Y=15436 ERROR
[4799] y=15436 Y=15868 ERROR
Info: /OSCI/SystemC: Simulation stopped by user.
출력 타이밍 변경,
void loop()
{
psce.EMU_Blinker(0x40); // Blinker speed
psce.RxData(N_RX);
y_ap_vld = ap_ready = ap_idle = ap_done = false;
if (psce.rxByte[0] & C_AP_RST)
cState = S_RESET;
else
{
switch(cState)
{
case S_RESET:
ap_idle = true;
cState = S_IDLE;
break;
case S_IDLE:
if (psce.rxByte[0] & C_AP_START)
cState = S_READY;
else
ap_idle = true;
break;
case S_READY:
ap_ready = true;
cState = S_GET_INPUT;
break;
case S_GET_INPUT:
x = psce.rxByte[1];
cState = S_DONE;
break;
case S_DONE:
y_ap_vld = ap_done = true;
//FIR8(&y, x);
cState = S_SET_OUTPUT;
break;
case S_SET_OUTPUT:
cState = S_IDLE;
FIR8(&y, x);
break;
}
}
psce.txByte[0] = 0x00;
if (y_ap_vld) psce.txByte[0] |= C_Y_AP_VLD;
if (ap_ready) psce.txByte[0] |= C_AP_READY;
if (ap_idle) psce.txByte[0] |= C_AP_IDLE;
if (ap_done) psce.txByte[0] |= C_AP_DONE;
psce.txByte[1] = y;
psce.txByte[2] = (y>>8);
psce.TxData(N_TX);
}































