Skip to content

Commit 658caeb

Browse files
committed
[chip, gpio, sw] Adding Verilator as an option to .cmake
The motivation of this PR comes from #382 which is adding a chip level GPIO smoke test. That test fails on verilator. Reason being different tops used for different platforms ( DVSim(Xcelium), Verilator, FPGA). For Xcelium, an interface is connecting the UVM to the GPIO. UVM has the control to drive GPIOs inputs. In #382, SW waits for a specific pattern driven by UVM to arrive in data_in reg. If we run the exact test with the verilator top, which is using GPIO DPI, then the abilty to drive inputs depends on a host SW infrastructure which is currently missing. Second problem is that we use cmake to build software images for DVSim, verilator and FPGA. We run tests on FPGA and Verilator in CI. If the build system develops an Xcelium compatible image and feed that image to Verilator and FPGA to execute the test in CI then the test will fail due to the reason given in the first paragraph. Hence, the best way forward is to make images only for the compatible paltforms. Signed-off-by: Kinza Qamar <kqzaman@lowrisc.org>
1 parent f8c538b commit 658caeb

2 files changed

Lines changed: 26 additions & 16 deletions

File tree

sw/cmake/tests.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ set(ARCHS_FLAGS VANILLA_FLAGS CHERI_FLAGS ) # Flags
5959
# the output executable name and all of the libraries it is linked against.
6060
macro(mocha_add_test)
6161
# parse arguments
62-
set(options FPGA)
62+
set(options FPGA VERILATOR)
6363
set(one_value_args NAME)
6464
set(multi_value_args SOURCES LIBRARIES)
6565
cmake_parse_arguments(arg "${options}"
@@ -83,7 +83,7 @@ macro(mocha_add_test)
8383
# create artefacts
8484
mocha_add_executable_artefacts(${NAME})
8585

86-
if(SIM)
86+
if(SIM AND arg_VERILATOR)
8787
mocha_add_verilator_test(${NAME})
8888
endif()
8989

sw/device/tests/CMakeLists.txt

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,30 @@
44

55
set(LIBS hal runtime startup test_framework)
66

7-
mocha_add_test(NAME test_framework_test SOURCES test_framework/smoketest.c LIBRARIES ${LIBS} FPGA)
8-
mocha_add_test(NAME test_framework_exception_test SOURCES test_framework/exception.c LIBRARIES ${LIBS})
9-
mocha_add_test(NAME gpio_reg_access_test SOURCES gpio/reg_access_test.c LIBRARIES ${LIBS} FPGA)
10-
mocha_add_test(NAME i2c_smoketest SOURCES i2c/smoketest.c LIBRARIES ${LIBS} FPGA)
11-
mocha_add_test(NAME mailbox_smoketest SOURCES mailbox/smoketest.c LIBRARIES ${LIBS} FPGA)
12-
mocha_add_test(NAME plic_smoketest SOURCES plic/smoketest.c LIBRARIES ${LIBS} FPGA)
7+
mocha_add_test(NAME test_framework_test SOURCES test_framework/smoketest.c LIBRARIES ${LIBS} FPGA
8+
VERILATOR)
9+
mocha_add_test(NAME test_framework_exception_test SOURCES test_framework/exception.c LIBRARIES
10+
${LIBS} VERILATOR)
11+
mocha_add_test(NAME gpio_reg_access_test SOURCES gpio/reg_access_test.c LIBRARIES ${LIBS} FPGA
12+
VERILATOR)
13+
# Can't run this test on FPGA and verilators top and this test thinks that the GPIO inputs can be
14+
# driven
15+
mocha_add_test(NAME i2c_smoketest SOURCES i2c/smoketest.c LIBRARIES ${LIBS} FPGA VERILATOR)
16+
mocha_add_test(NAME mailbox_smoketest SOURCES mailbox/smoketest.c LIBRARIES ${LIBS} FPGA VERILATOR)
17+
mocha_add_test(NAME plic_smoketest SOURCES plic/smoketest.c LIBRARIES ${LIBS} FPGA VERILATOR)
1318
# Cannot currently run this on FPGA because the boot ROM expects the test to be provided on the SPI again.
14-
mocha_add_test(NAME rstmgr_software_reset SOURCES rstmgr/software_reset.c LIBRARIES ${LIBS})
15-
mocha_add_test(NAME spi_device_smoketest SOURCES spi_device/smoketest.c LIBRARIES ${LIBS} FPGA)
16-
mocha_add_test(NAME spi_host_smoketest SOURCES spi_host/smoketest.c LIBRARIES ${LIBS} FPGA)
17-
mocha_add_test(NAME tag_controller_smoketest SOURCES tag_controller/smoketest.c LIBRARIES ${LIBS} FPGA)
18-
mocha_add_test(NAME tag_controller_tag_test SOURCES tag_controller/tag_test.c LIBRARIES ${LIBS} FPGA)
19-
mocha_add_test(NAME timer_smoketest SOURCES timer/smoketest.c LIBRARIES ${LIBS} FPGA)
20-
mocha_add_test(NAME timer_interrupt_test SOURCES timer/interrupt.c LIBRARIES ${LIBS})
21-
mocha_add_test(NAME uart_smoketest SOURCES uart/smoketest.c LIBRARIES ${LIBS})
19+
mocha_add_test(NAME rstmgr_software_reset SOURCES rstmgr/software_reset.c LIBRARIES ${LIBS}
20+
VERILATOR)
21+
mocha_add_test(NAME spi_device_smoketest SOURCES spi_device/smoketest.c LIBRARIES ${LIBS} FPGA
22+
VERILATOR)
23+
mocha_add_test(NAME spi_host_smoketest SOURCES spi_host/smoketest.c LIBRARIES ${LIBS} FPGA
24+
VERILATOR)
25+
mocha_add_test(NAME tag_controller_smoketest SOURCES tag_controller/smoketest.c LIBRARIES ${LIBS}
26+
FPGA VERILATOR)
27+
mocha_add_test(NAME tag_controller_tag_test SOURCES tag_controller/tag_test.c LIBRARIES ${LIBS} FPGA
28+
VERILATOR)
29+
mocha_add_test(NAME timer_smoketest SOURCES timer/smoketest.c LIBRARIES ${LIBS} FPGA VERILATOR)
30+
mocha_add_test(NAME timer_interrupt_test SOURCES timer/interrupt.c LIBRARIES ${LIBS} VERILATOR)
31+
mocha_add_test(NAME uart_smoketest SOURCES uart/smoketest.c LIBRARIES ${LIBS} VERILATOR)
2232

2333
add_subdirectory(dram)

0 commit comments

Comments
 (0)