RVSCC/test/CMakeLists.txt

67 lines
1.8 KiB
CMake
Raw Normal View History

2023-02-01 16:23:11 +00:00
cmake_minimum_required(VERSION 3.10)
project(rvscc-tests CXX)
find_package(verilator HINTS $ENV{VERILATOR_ROOT})
if (NOT verilator_FOUND)
message(FATAL_ERROR "Verilator was not found. Either install it, or set the VERILATOR_ROOT environment variable")
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(SystemCLanguage QUIET)
2023-02-11 22:29:27 +00:00
function(rvscc_add_test)
2023-02-01 16:23:11 +00:00
cmake_parse_arguments(TEST
""
"NAME"
"SOURCES"
${ARGN}
)
set(TEST_TARGET_NAME test-${TEST_NAME})
2023-02-13 00:06:31 +00:00
add_executable(${TEST_TARGET_NAME} sim_main.cpp)
2023-02-01 16:23:11 +00:00
verilate(${TEST_TARGET_NAME}
SOURCES ${TEST_SOURCES}
2023-02-13 00:06:31 +00:00
TRACE
2023-02-18 20:48:02 +00:00
VERILATOR_ARGS --timing --assert
2023-02-01 16:23:11 +00:00
)
list(GET TEST_SOURCES 0 TEST_TOP_MODULE)
get_filename_component(TEST_TOP_MODULE_NAME ${TEST_TOP_MODULE} NAME_WE)
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE
TEST_HEADER="V${TEST_TOP_MODULE_NAME}.h"
TEST_CLASS=V${TEST_TOP_MODULE_NAME}
)
add_test(NAME ${TEST_TARGET_NAME} COMMAND ${TEST_TARGET_NAME})
endfunction()
2023-02-23 22:31:08 +00:00
rvscc_add_test(
NAME alu
TOP Test_ALU
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../rtl/RV32IDefs.sv
${CMAKE_CURRENT_SOURCE_DIR}/Test_ALU.sv
${CMAKE_CURRENT_SOURCE_DIR}/../rtl/ALU.sv
2023-02-01 16:23:11 +00:00
)
2023-02-11 22:29:27 +00:00
rvscc_add_test(NAME priority-encoder
2023-02-01 16:23:11 +00:00
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test_PriorityEncoder.sv
${CMAKE_CURRENT_SOURCE_DIR}/../rtl/PriorityEncoder.sv
)
2023-02-11 22:29:27 +00:00
rvscc_add_test(NAME data-memory
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test_DataMemory.sv
2023-02-23 22:31:08 +00:00
${CMAKE_CURRENT_SOURCE_DIR}/../rtl/DataMemory.sv
2023-02-11 22:29:27 +00:00
)
2023-02-18 20:48:02 +00:00
rvscc_add_test(NAME imm-extend
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test_ImmExtend.sv
2023-02-23 22:31:08 +00:00
${CMAKE_CURRENT_SOURCE_DIR}/../rtl/ImmExtend.sv
)
rvscc_add_test(
NAME register-file
TOP Test_RegisterFile
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test_RegisterFile.sv
${CMAKE_CURRENT_SOURCE_DIR}/../rtl/RegisterFile.sv
2023-02-18 20:48:02 +00:00
)