RVSCC/test/CMakeLists.txt

52 lines
1.4 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-01 16:23:11 +00:00
VERILATOR_ARGS --timing
)
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-11 22:29:27 +00:00
rvscc_add_test(NAME alu
2023-02-01 16:23:11 +00:00
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test_ALU.sv
${CMAKE_CURRENT_SOURCE_DIR}/../rtl/ALU.sv
)
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
${CMAKE_CURRENT_SOURCE_DIR}/../rtl/DataMemory.sv
)