Skip to content

Commit 2875f35

Browse files
committed
Merge branch 'main' into feature/iif_upgrades
2 parents 9f0f140 + d921fe4 commit 2875f35

23 files changed

Lines changed: 930 additions & 150 deletions

File tree

.github/workflows/ci-compile.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- '**.hpp'
8+
- '**.cpp'
9+
- '**.h'
10+
- '**.c'
11+
- '**.S'
12+
- '**CMakeLists.txt'
13+
- '.github/workflows/**'
14+
- 'conanfile.py'
15+
pull_request:
16+
paths:
17+
- '**.hpp'
18+
- '**.cpp'
19+
- '**.h'
20+
- '**.c'
21+
- '**.S'
22+
- '**CMakeLists.txt'
23+
- '.github/workflows/**'
24+
- 'conanfile.py'
25+
26+
jobs:
27+
cpp-compliance:
28+
name: C++ Std Compliance (C++${{ matrix.cpp_std }})
29+
runs-on: ubuntu-24.04
30+
strategy:
31+
matrix:
32+
cpp_std: [17, 20]
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Update submodules
37+
run: git submodule update --init --recursive
38+
39+
- name: Cache Conan
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/.conan2
43+
key: conan-${{ runner.os }}-unit-cpp${{ matrix.cpp_std }}-${{ hashFiles('conanfile.py') }}
44+
45+
- name: Install dependencies
46+
run: |
47+
sudo apt-get install -y g++ python3-pip cmake llvm-19-dev
48+
pip3 install conan
49+
cmake --version
50+
51+
- name: Configure
52+
run: cmake --preset Release -B build -DCMAKE_CXX_STANDARD=${{ matrix.cpp_std }} -DWITH_LLVM=ON -DWITH_SYSTEM_LLVM=ON
53+
54+
- name: Build
55+
run: cmake --build build -j
56+
57+
- name: Smoke test
58+
run: ./build/riscv-sim -h
59+
60+
# NOTE: .so filename is tied to VERSION in top-level CMakeLists.txt - update both together
61+
- name: Upload binary
62+
if: matrix.cpp_std == 20
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: riscv-sim
66+
path: |
67+
build/riscv-sim
68+
build/libdbt-rise-riscv.so.2.1.0
69+
70+
pmp-tests:
71+
name: PMP Functional Tests
72+
runs-on: ubuntu-24.04
73+
needs: cpp-compliance
74+
steps:
75+
- uses: actions/checkout@v4
76+
77+
- name: Install RISC-V toolchain
78+
run: sudo apt-get install -y gcc-riscv64-unknown-elf
79+
80+
- name: Download riscv-sim binary
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: riscv-sim
84+
85+
- name: Make binary executable
86+
run: chmod +x riscv-sim
87+
88+
- name: Build PMP CSR test firmware
89+
run: |
90+
riscv64-unknown-elf-gcc -nostdlib -march=rv64gc -mabi=lp64 \
91+
-Wl,-Ttext=0x10000,--no-dynamic-linker \
92+
-o pmp_csr_test \
93+
contrib/fw/pmp-csr-test/pmp_csr_test.S
94+
95+
- name: rv64gc_m CSR test - interp (no PMP, expect exit 2)
96+
run: |
97+
LD_LIBRARY_PATH=. ./riscv-sim -f pmp_csr_test --isa rv64gc_m --backend interp || rc=$?
98+
[ "${rc:-0}" -eq 2 ]
99+
100+
- name: rv64gc_mp CSR test - interp (with PMP)
101+
run: LD_LIBRARY_PATH=. ./riscv-sim -f pmp_csr_test --isa rv64gc_mp --backend interp
102+
103+
- name: Build PMP enforcement test firmware
104+
run: |
105+
riscv64-unknown-elf-gcc -nostdlib -march=rv64gc -mabi=lp64 \
106+
-Wl,-Ttext=0x10000,--no-dynamic-linker \
107+
-o pmp_enforce_test \
108+
contrib/fw/pmp-enforce-test/pmp_enforce_test.S
109+
110+
- name: rv64gc_mp enforcement test - interp
111+
run: LD_LIBRARY_PATH=. ./riscv-sim -f pmp_enforce_test --isa rv64gc_mp --backend interp
112+
113+
- name: Build PMP shift test firmware
114+
run: |
115+
riscv64-unknown-elf-gcc -nostdlib -march=rv64gc -mabi=lp64 \
116+
-Wl,-Ttext=0x10000,--no-dynamic-linker \
117+
-o pmp_shift_test \
118+
contrib/fw/pmp-shift-test/pmp_shift_test.S
119+
120+
- name: rv64gc_mp shift test - interp
121+
run: LD_LIBRARY_PATH=. ./riscv-sim -f pmp_shift_test --isa rv64gc_mp --backend interp
122+
123+
- name: Build PMP upper-cfg test firmware
124+
run: |
125+
riscv64-unknown-elf-gcc -nostdlib -march=rv64gc -mabi=lp64 \
126+
-Wl,-Ttext=0x10000,--no-dynamic-linker \
127+
-o pmp_upper_cfg_test \
128+
contrib/fw/pmp-upper-cfg-test/pmp_upper_cfg_test.S
129+
130+
- name: rv64gc_mp upper-cfg test - interp
131+
run: LD_LIBRARY_PATH=. ./riscv-sim -f pmp_upper_cfg_test --isa rv64gc_mp --backend interp
132+
133+
- name: Build PMP cfg2 test firmware
134+
run: |
135+
riscv64-unknown-elf-gcc -nostdlib -march=rv64gc -mabi=lp64 \
136+
-Wl,-Ttext=0x10000,--no-dynamic-linker \
137+
-o pmp_cfg2_test \
138+
contrib/fw/pmp-cfg2-test/pmp_cfg2_test.S
139+
140+
- name: rv64gc_mp cfg2 test - interp
141+
run: LD_LIBRARY_PATH=. ./riscv-sim -f pmp_cfg2_test --isa rv64gc_mp --backend interp
142+
143+
- name: Build PMP TOR test firmware
144+
run: |
145+
riscv64-unknown-elf-gcc -nostdlib -march=rv64gc -mabi=lp64 \
146+
-Wl,-Ttext=0x10000,--no-dynamic-linker \
147+
-o pmp_tor_test \
148+
contrib/fw/pmp-tor-test/pmp_tor_test.S
149+
150+
- name: rv64gc_mp TOR test - interp
151+
run: LD_LIBRARY_PATH=. ./riscv-sim -f pmp_tor_test --isa rv64gc_mp --backend interp
152+
153+
- name: Build PMP 64-entry pmpaddr test firmware
154+
run: |
155+
riscv64-unknown-elf-gcc -nostdlib -march=rv64gc -mabi=lp64 \
156+
-Wl,-Ttext=0x10000,--no-dynamic-linker \
157+
-o pmp_64entry_addr_test \
158+
contrib/fw/pmp-64entry-addr-test/pmp_64entry_addr_test.S
159+
160+
- name: rv64gc_mp 64-entry pmpaddr test - interp
161+
run: LD_LIBRARY_PATH=. ./riscv-sim -f pmp_64entry_addr_test --isa rv64gc_mp --backend interp
162+
163+
- name: Build PMP 64-entry pmpcfg test firmware
164+
run: |
165+
riscv64-unknown-elf-gcc -nostdlib -march=rv64gc -mabi=lp64 \
166+
-Wl,-Ttext=0x10000,--no-dynamic-linker \
167+
-o pmp_64entry_cfg_test \
168+
contrib/fw/pmp-64entry-cfg-test/pmp_64entry_cfg_test.S
169+
170+
- name: rv64gc_mp 64-entry pmpcfg test - interp
171+
run: LD_LIBRARY_PATH=. ./riscv-sim -f pmp_64entry_cfg_test --isa rv64gc_mp --backend interp
172+
173+
- name: Build PMP 8-entry guard test firmware (VP/S5 model)
174+
run: |
175+
riscv64-unknown-elf-gcc -nostdlib -march=rv64gc -mabi=lp64 \
176+
-Wl,-Ttext=0x10000,--no-dynamic-linker \
177+
-o pmp_8entry_guard_test \
178+
contrib/fw/pmp-8entry-guard-test/pmp_8entry_guard_test.S
179+
180+
- name: rv64gc_mp_8 8-entry enforcement test - interp (VP/S5 model)
181+
run: LD_LIBRARY_PATH=. ./riscv-sim -f pmp_8entry_guard_test --isa rv64gc_mp_8 --backend interp

CMakeLists.txt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,34 @@ if(OPTIMIZE_FOR_NATIVE AND COMPILER_SUPPORTS_MARCH_NATIVE)
2222
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
2323
endif()
2424

25+
option(WITH_SYSTEM_LLVM "Use system-installed LLVM (llvm-dev from apt) instead of Conan-built" OFF)
26+
set(LLVM_MAJOR_VERSION "19" CACHE STRING "System LLVM major version when WITH_SYSTEM_LLVM=ON")
27+
if(WITH_SYSTEM_LLVM)
28+
set(LLVM_DIR "/usr/lib/llvm-${LLVM_MAJOR_VERSION}/lib/cmake/llvm" CACHE PATH "" FORCE)
29+
find_package(LLVM REQUIRED CONFIG BYPASS_PROVIDER)
30+
message(STATUS "Found system LLVM ${LLVM_VERSION}")
31+
if(NOT TARGET llvm-core::llvm-core)
32+
add_library(llvm-core::llvm-core INTERFACE IMPORTED GLOBAL)
33+
target_include_directories(llvm-core::llvm-core INTERFACE ${LLVM_INCLUDE_DIRS})
34+
target_compile_definitions(llvm-core::llvm-core INTERFACE ${LLVM_DEFINITIONS})
35+
target_link_libraries(llvm-core::llvm-core INTERFACE LLVM-${LLVM_VERSION_MAJOR})
36+
endif()
37+
if(NOT WITH_LLVM)
38+
set(WITH_LLVM ON CACHE BOOL "Build LLVM backend" FORCE)
39+
endif()
40+
endif()
41+
2542
include(FetchContent)
2643
if(NOT TARGET dbt-rise-core)
2744
FetchContent_Declare(
2845
dbt_rise_core_git
2946
GIT_REPOSITORY "https://github.com/Minres/DBT-RISE-Core.git"
30-
GIT_TAG daa01b423360e7677a30d61f913cfa1bf09a1251
47+
GIT_TAG 9b571ff9
3148
GIT_SHALLOW OFF
3249
UPDATE_DISCONNECTED NOT ${UPDATE_EXTERNAL_PROJECT} # When enabled, this option causes the update step to be skipped.
3350
)
3451
FetchContent_GetProperties(dbt_rise_core_git)
35-
if(NOT dbt_rise_core_git_POPULATED)
36-
FetchContent_Populate(dbt_rise_core_git)
37-
endif()
38-
add_subdirectory(${dbt_rise_core_git_SOURCE_DIR} ${dbt_rise_core_git_BINARY_DIR})
52+
FetchContent_MakeAvailable(dbt_rise_core_git)
3953
endif()
4054
FetchContent_GetProperties(scc_git)
4155
list(APPEND CMAKE_MODULE_PATH ${scc_git_SOURCE_DIR}/cmake)
@@ -73,6 +87,7 @@ set(LIB_SOURCES
7387
src/vm/interp/vm_rv64i.cpp
7488
src/vm/interp/vm_rv64imac.cpp
7589
src/vm/interp/vm_rv64gc.cpp
90+
src/vm/interp/vm_rv64gc_mp.cpp
7691
src/vm/interp/vm_rv64gcv.cpp
7792
src/iss/debugger/csr_names.cpp
7893
src/iss/semihosting/semihosting.cpp
@@ -249,7 +264,7 @@ endif()
249264
###############################################################################
250265
if(TARGET scc-sysc)
251266
project(dbt-rise-riscv_sc VERSION 1.0.0)
252-
set(USE_SC_SIGNAL4IRQ OFF CACHE BOOL "Enable the use of ssc_signals for interrupt delivery")
267+
set(USE_SC_SIGNAL4IRQ OFF CACHE BOOL "Enable the use of sc_signals for interrupt delivery")
253268

254269
set(LIB_SOURCES
255270
src/sysc/core_complex.cpp
@@ -265,7 +280,6 @@ if(TARGET scc-sysc)
265280
set(LIB_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/sysc/core_complex.h)
266281

267282
add_library(${PROJECT_NAME}_sig ${LIB_SOURCES})
268-
target_compile_definitions(${PROJECT_NAME}_sig PUBLIC SC_SIGNAL_IF)
269283
target_compile_definitions(${PROJECT_NAME}_sig PUBLIC WITH_SYSTEMC SC_SIGNAL_IF)
270284
target_link_libraries(${PROJECT_NAME}_sig PUBLIC dbt-rise-riscv scc-sysc)
271285

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![CI C++ Std compliance](https://github.com/Minres/DBT-RISE-RISCV/actions/workflows/ci-compile.yml/badge.svg)](https://github.com/Minres/DBT-RISE-RISCV/actions/workflows/ci-compile.yml)
1+
[![CI](https://github.com/Minres/DBT-RISE-RISCV/actions/workflows/ci.yml/badge.svg)](https://github.com/Minres/DBT-RISE-RISCV/actions/workflows/ci.yml)
22

33
# DBT-RISE-RISCV
44
A instruction set simulator based on DBT-RISE implementing the RISC-V ISA.
@@ -63,4 +63,4 @@ make -C build/Firmwares/hello-world/ ISA=imc BOARD=iss
6363
- JIT-backends for higher execution speeds
6464
- Built-in plugin support to inspect or manipulate architectural state before and after each instruction
6565
- Full GDB-server
66-
- Easy integration into SystemC or similar (eg. Platform Architect)
66+
- Easy integration into SystemC or similar (eg. Platform Architect)

conanfile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ class Pkg(ConanFile):
3636
}
3737

3838
def requirements(self):
39-
self.requires("fmt/12.0.0")
40-
self.requires("spdlog/1.16.0")
39+
self.requires("fmt/12.1.0")
40+
self.requires("spdlog/1.17.0")
4141
self.requires("boost/1.85.0")
4242
self.requires("elfio/3.12")
4343
self.requires("lz4/1.10.0")
44-
self.requires("yaml-cpp/0.8.0")
44+
self.requires("yaml-cpp/0.9.0")
4545
self.requires("jsoncpp/1.9.6")
4646
self.requires("zlib/1.3.1")
4747
self.requires("asmjit/cci.20240531")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Verify pmpaddr32 (CSR 0x3D0) is accessible - tests 64-entry pmpaddr support.
2+
// Pass: readback matches written sentinel -> j . (exit 0)
3+
// Fail: any trap (unregistered CSR) or readback mismatch -> semihosting SYS_EXIT (exit 2)
4+
5+
.section .text
6+
.globl _start
7+
_start:
8+
la t0, fail
9+
csrw mtvec, t0
10+
11+
li t0, 0xDEAD
12+
csrw 0x3D0, t0 // pmpaddr32
13+
csrr t1, 0x3D0
14+
bne t0, t1, fail
15+
16+
j . // pass
17+
18+
fail:
19+
li a0, 0x18
20+
.option push
21+
.option norvc
22+
slli zero, zero, 0x1f
23+
ebreak
24+
srai zero, zero, 7
25+
.option pop
26+
j .
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Verify pmpcfg4 (CSR 0x3A4, holds entries 32-39 on RV64) is accessible and persistent.
2+
// Tests 64-entry pmpcfg registration.
3+
// Pass: write 0x9F -> read back 0x9F -> write 0 -> read back 0 -> j . (exit 0)
4+
// Fail: any trap or readback mismatch -> semihosting SYS_EXIT (exit 2)
5+
6+
.section .text
7+
.globl _start
8+
_start:
9+
la t0, fail
10+
csrw mtvec, t0
11+
12+
// Write and verify a non-zero value
13+
li t0, 0x9F
14+
csrw 0x3A4, t0 // pmpcfg4 write
15+
csrr t1, 0x3A4 // pmpcfg4 read
16+
bne t0, t1, fail // must match
17+
18+
// Clear and verify zero
19+
li t0, 0
20+
csrw 0x3A4, t0
21+
csrr t1, 0x3A4
22+
bne t0, t1, fail
23+
24+
j . // pass
25+
26+
fail:
27+
li a0, 0x18
28+
.option push
29+
.option norvc
30+
slli zero, zero, 0x1f
31+
ebreak
32+
srai zero, zero, 7
33+
.option pop
34+
j .

0 commit comments

Comments
 (0)