# 2023 NCKU Computer Architecture Term Project > contributor: <施柏安> > > reference: https://github.com/dcliche/xgsoc https://github.com/danodus/xgsoc ## Computer Info ```shell= Intel(R) Core(TM) i7-14700 28 cores ``` ## Environment Setup ``` Requirements: OSS CAD Suite (https://github.com/YosysHQ/oss-cad-suite-build) RISC-V GNU compiler toolchain for RV32IM (https://github.com/riscv-collab/riscv-gnu-toolchain) Python3 with the following PIP3 packages installed: pyserial SDL2 (for simulation only) ``` ### RISC-V GNU compiler toolchain for RV32IM I follow the steps of [LAB2](https://hackmd.io/@sysprog/SJAR5XMmi) to install GNU toolchain. The version of GNU toolchain is showing below. ![image](https://hackmd.io/_uploads/H1gGPA9FT.png) ### SDL2 Using below command to install libsdl-dev. ```shell $ sudo apt install libsdl2-dev ``` ### XGSOC I followed the steps in the [reference](https://github.com/dcliche/xgsoc). While doing the step which is copying site.template to site.mk, I changed the path in the markdown file to fit the right path like showing below. ```shell RISCV_TOOLCHAIN_PATH = /home/ubuntu20/riscv-none-elf-gcc/bin/ RISCV_TOOLCHAIN_PREFIX = riscv-none-elf- RISCV_CC_OPT = -march=rv32im -mabi=ilp32 OSS_CAD_SUITE_PATH = /home/ubuntu20/oss-cad-suite/bin/ ``` And after entering firmware directory in xgsoc, entering `make` command and got below output. ``` /home/ubuntu20/riscv-none-elf-gcc/bin/riscv-none-elf-gcc -march=rv32im -mabi=ilp32 -nostartfiles -nostdlib -Os -T firmware.ld -I ../lib start.S ../lib/io.c ../lib/sd_card.c firmware.c -o firmware.elf /home/ubuntu20/riscv-none-elf-gcc/bin/../lib/gcc/riscv-none-elf/13.2.0/../../../../riscv-none-elf/bin/ld: warning: firmware.elf has a LOAD segment with RWX permissions /home/ubuntu20/riscv-none-elf-gcc/bin/riscv-none-elf-objdump --disassemble firmware.elf > firmware.lst /home/ubuntu20/riscv-none-elf-gcc/bin/riscv-none-elf-objcopy -O binary firmware.elf firmware.bin python3 ../utils/makehex.py firmware.bin 2048 > firmware.hex ``` ## TODO: 參閱去年報告,確保 xgsoc (更新到 commit 6ff4ee5 或更晚) 得以正確用 Verilator 模擬,應當執行內附的 benchmark 並解讀數據 [去年報告](https://hackmd.io/@y8jRQNyoRe6WG-qekloIlA/HJOF9Nuui) using commit [708b694](https://github.com/danodus/xgsoc/commit/708b694e43651ce4364d1c987d840a9788f60f33) ## TODO: XGSoC 具備 set associative cache (4-way with random replacement policy),研讀其內部設計並探討,過程中應搭配 Verilator 和 GTKwave 實際模擬,來說明其行為。注意:你可能會遇到非預期的狀況,記錄下來並嘗試排除 ## TODO: 從範例程式中,選出至少二個,從訊號和 bus 的觀點,解讀 XGSoC 的運作機制,搭配 SDL2 進行輸出和驗證 ## TODO: 嘗試修改 XGSoC 的 random replacement policy,換成其他策略並比較。 <!-- #### Run Simulation When I followed the steps to start simulation, I got stuck at the make run PROGRAM commands. ```shell ubuntu20@ubuntu20-virtual-machine:~/xgsoc/rtl/sim$ make run PROGRAM=../../examples/gamepad_test/program.hex cp ../../examples/gamepad_test/program.hex program.hex cp ../../external/Xosera/rtl/*.mem . mkdir -p tilesets cp ../../external/Xosera/rtl/tilesets/*.mem tilesets verilator -cc --exe -CFLAGS "-I/usr/include/SDL2 -D_REENTRANT" -LDFLAGS "-lSDL2" --top-module top ../../external/Xosera/rtl/xosera_main.sv ../../external/Xosera/rtl/acia_rx.sv ../../external/Xosera/rtl/acia_tx.sv ../../external/Xosera/rtl/vram_arb.sv ../../external/Xosera/rtl/vram.sv ../../external/Xosera/rtl/video_blend_2bit.sv ../../external/Xosera/rtl/blitter_slim.sv ../../external/Xosera/rtl/video_blend_4bit.sv ../../external/Xosera/rtl/audio_dac.sv ../../external/Xosera/rtl/xosera_pkg.sv ../../external/Xosera/rtl/tilemem.sv ../../external/Xosera/rtl/pointermem.sv ../../external/Xosera/rtl/coppermem.sv ../../external/Xosera/rtl/audio_mem.sv ../../external/Xosera/rtl/xrmem_arb.sv ../../external/Xosera/rtl/bus_interface.sv ../../external/Xosera/rtl/video_timing.sv ../../external/Xosera/rtl/spi_target.sv ../../external/Xosera/rtl/audio_mixer_slim.sv ../../external/Xosera/rtl/video_gen.sv ../../external/Xosera/rtl/copper_slim.sv ../../external/Xosera/rtl/reg_interface.sv ../../external/Xosera/rtl/video_playfield.sv ../../external/Xosera/rtl/colormem.sv ../../external/Xosera/rtl/acia.sv top.sv sdl_ps2.cpp sim_main.cpp -DSDRAM -DPS2 -DXGA -DEN_PF_B -DEN_PF_B_BLEND -DMODE_848x480 -DNO_COPPER_INIT -I.. -I../../external/xglib/rtl -I../../external/Xosera/rtl -Wno-PINMISSING -Wno-WIDTH -Wno-CASEINCOMPLETE -Wno-TIMESCALEMOD -Wno-NULLPORT -Wno-MULTIDRIVEN %Error: Unknown warning specified: -Wno-TIMESCALEMOD make: *** [Makefile:21: sim] Error 1 ``` I even tried the suggested example "lua" for simulation and I still got the same error. Still figuring up... -->