aboutsummaryrefslogtreecommitdiff
path: root/rv64cpu/tb
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-03-15 16:07:39 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-03-15 16:07:39 +0800
commitf6441a2e6f901748b504ef93872649c9463a404e (patch)
tree54332548c2e2b74b44aba646a09cffb543856050 /rv64cpu/tb
downloadrcc-project-f6441a2e6f901748b504ef93872649c9463a404e.tar.gz
rcc-project-f6441a2e6f901748b504ef93872649c9463a404e.tar.xz
initial commit: project architecture
Diffstat (limited to 'rv64cpu/tb')
-rw-r--r--rv64cpu/tb/CMakeLists.txt99
-rw-r--r--rv64cpu/tb/common/.gitkeep0
-rw-r--r--rv64cpu/tb/compliance/.gitkeep0
-rw-r--r--rv64cpu/tb/compliance/CMakeLists.txt36
-rw-r--r--rv64cpu/tb/core/.gitkeep0
-rw-r--r--rv64cpu/tb/soc/.gitkeep0
-rw-r--r--rv64cpu/tb/unit/.gitkeep0
7 files changed, 135 insertions, 0 deletions
diff --git a/rv64cpu/tb/CMakeLists.txt b/rv64cpu/tb/CMakeLists.txt
new file mode 100644
index 0000000..8679562
--- /dev/null
+++ b/rv64cpu/tb/CMakeLists.txt
@@ -0,0 +1,99 @@
+# ─── Testbench CMake ──────────────────────────────────────────────────────────────
+#
+# Each testbench is registered as a Verilator simulation target + CTest.
+#
+# To add a new unit test, call:
+# add_verilator_target(
+# NAME tb_<module>
+# TOP_MODULE <module>
+# SOURCES ${RTL_CORE_DIR}/<module>.sv [... dependencies ...]
+# INCLUDE_DIRS ${RTL_INCLUDE_DIR}
+# TB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/unit/tb_<module>.cpp
+# )
+#
+
+enable_testing()
+
+# ─── Collect common RTL include dirs ─────────────────────────────────────────────
+set(RTL_COMMON_INCLUDES
+ ${RTL_INCLUDE_DIR}
+)
+
+# ─── Collect all RTL sources for SoC-level sim ───────────────────────────────────
+file(GLOB_RECURSE ALL_RTL_SOURCES
+ ${RTL_DIR}/*.sv
+)
+
+# ═══════════════════════════════════════════════════════════════════════════════════
+# Unit Tests
+# ═══════════════════════════════════════════════════════════════════════════════════
+#
+# Uncomment and fill in as you implement each module, for example:
+#
+# add_verilator_target(
+# NAME tb_alu
+# TOP_MODULE alu
+# SOURCES ${RTL_CORE_DIR}/include/rv64_pkg.sv
+# ${RTL_CORE_DIR}/alu.sv
+# INCLUDE_DIRS ${RTL_COMMON_INCLUDES}
+# TB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/unit/tb_alu.cpp
+# )
+#
+# add_verilator_target(
+# NAME tb_decoder
+# TOP_MODULE decoder
+# SOURCES ${RTL_CORE_DIR}/include/rv64_pkg.sv
+# ${RTL_CORE_DIR}/decoder.sv
+# INCLUDE_DIRS ${RTL_COMMON_INCLUDES}
+# TB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/unit/tb_decoder.cpp
+# )
+#
+# add_verilator_target(
+# NAME tb_regfile
+# TOP_MODULE regfile
+# SOURCES ${RTL_CORE_DIR}/include/rv64_pkg.sv
+# ${RTL_CORE_DIR}/regfile.sv
+# INCLUDE_DIRS ${RTL_COMMON_INCLUDES}
+# TB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/unit/tb_regfile.cpp
+# )
+#
+# add_verilator_target(
+# NAME tb_csr
+# TOP_MODULE csr_unit
+# SOURCES ${RTL_CORE_DIR}/include/rv64_pkg.sv
+# ${RTL_CORE_DIR}/include/csr_pkg.sv
+# ${RTL_CORE_DIR}/csr_unit.sv
+# INCLUDE_DIRS ${RTL_COMMON_INCLUDES}
+# TB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/unit/tb_csr.cpp
+# )
+
+# ═══════════════════════════════════════════════════════════════════════════════════
+# Core Integration Test
+# ═══════════════════════════════════════════════════════════════════════════════════
+#
+# add_verilator_target(
+# NAME tb_core
+# TOP_MODULE richard_core
+# SOURCES ${ALL_RTL_SOURCES}
+# INCLUDE_DIRS ${RTL_COMMON_INCLUDES}
+# TB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/core/tb_core.cpp
+# )
+
+# ═══════════════════════════════════════════════════════════════════════════════════
+# SoC Integration Test
+# ═══════════════════════════════════════════════════════════════════════════════════
+#
+# add_verilator_target(
+# NAME tb_soc
+# TOP_MODULE richard_soc
+# SOURCES ${ALL_RTL_SOURCES}
+# INCLUDE_DIRS ${RTL_COMMON_INCLUDES}
+# TB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/soc/tb_soc.cpp
+# EXTRA_FLAGS --threads 2
+# )
+
+# ═══════════════════════════════════════════════════════════════════════════════════
+# Compliance Tests
+# ═══════════════════════════════════════════════════════════════════════════════════
+#
+# add_subdirectory(compliance)
diff --git a/rv64cpu/tb/common/.gitkeep b/rv64cpu/tb/common/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/rv64cpu/tb/common/.gitkeep
diff --git a/rv64cpu/tb/compliance/.gitkeep b/rv64cpu/tb/compliance/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/rv64cpu/tb/compliance/.gitkeep
diff --git a/rv64cpu/tb/compliance/CMakeLists.txt b/rv64cpu/tb/compliance/CMakeLists.txt
new file mode 100644
index 0000000..b832f01
--- /dev/null
+++ b/rv64cpu/tb/compliance/CMakeLists.txt
@@ -0,0 +1,36 @@
+# ─── Compliance Test CMake ───────────────────────────────────────────────────────
+#
+# Builds the compliance test runner and registers riscv-arch-test tests.
+#
+# ─────────────────────────────────────────────────────────────────────────────────
+
+# The compliance runner needs the SoC sim binary
+# Uncomment when both the SoC and compliance_runner are implemented:
+#
+# add_verilator_target(
+# NAME compliance_runner
+# TOP_MODULE richard_soc
+# SOURCES ${ALL_RTL_SOURCES}
+# INCLUDE_DIRS ${RTL_COMMON_INCLUDES}
+# TB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/compliance_runner.cpp
+# EXTRA_FLAGS --threads 2
+# )
+#
+# ─── Register individual compliance tests via CTest ──────────────────────────────
+# This is done dynamically by the compliance_runner binary and run_compliance.py.
+# You can also manually register tests like:
+#
+# set(RISCV_ARCH_TEST_DIR ${CMAKE_SOURCE_DIR}/sw/riscv-arch-test)
+#
+# file(GLOB RV64I_TESTS ${RISCV_ARCH_TEST_DIR}/riscv-test-suite/rv64i_m/I/src/*.S)
+# foreach(test_src ${RV64I_TESTS})
+# get_filename_component(test_name ${test_src} NAME_WE)
+# add_test(
+# NAME compliance_rv64i_${test_name}
+# COMMAND compliance_runner --test ${test_src}
+# )
+# set_tests_properties(compliance_rv64i_${test_name} PROPERTIES
+# LABELS "compliance;rv64i"
+# TIMEOUT 30
+# )
+# endforeach()
diff --git a/rv64cpu/tb/core/.gitkeep b/rv64cpu/tb/core/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/rv64cpu/tb/core/.gitkeep
diff --git a/rv64cpu/tb/soc/.gitkeep b/rv64cpu/tb/soc/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/rv64cpu/tb/soc/.gitkeep
diff --git a/rv64cpu/tb/unit/.gitkeep b/rv64cpu/tb/unit/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/rv64cpu/tb/unit/.gitkeep