Use Verilator CMake for calling verilator
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -71,6 +71,8 @@ if(RIPES_BUILD_VERILATOR_PROCESSORS)
endif()
message(STATUS "Building with Verilator processors")
include_directories(SYSTEM $ENV{VERILATOR_ROOT}/include)
+ set(verilator_DIR $ENV{VERILATOR_ROOT})
+ find_package(verilator)
# Create library containing Verilator runtime files, which verilator processors can link against
file(GLOB VERILATOR_SOURCES $ENV{VERILATOR_ROOT}/include/verilated.cpp)

MODIFY
src/CMakeLists.txt
src/CMakeLists.txt
@@ -35,8 +35,8 @@ target_include_directories (${RIPES_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(${RIPES_LIB} PRIVATE cxx_std_17)
# Link external libraries
-target_link_libraries(${RIPES_LIB} fancytabbar_lib)
-target_link_libraries(${RIPES_LIB} ${VSRTL_GRAPHICS_LIB} Qt5::Charts)
+target_link_libraries(${RIPES_LIB} PUBLIC fancytabbar_lib)
+target_link_libraries(${RIPES_LIB} PUBLIC ${VSRTL_GRAPHICS_LIB} Qt5::Charts)
add_subdirectory(processors)

MODIFY
src/processors/CMakeLists.txt
src/processors/CMakeLists.txt
@@ -25,23 +25,28 @@ macro(create_vsrtl_processor isa name)
target_compile_features(${name} PRIVATE cxx_std_17)
endmacro()
-macro(create_verilator_processor name verilatorDir)
- file(GLOB LIB_SOURCES
- ${name}/*.cpp
- ${name}/${verilatorDir}/*.cpp
- )
- file(GLOB LIB_HEADERS
- ${name}/*.h
- ${name}/${subfolder}/*.h
+macro(create_verilator_processor
+ SUBFOLDER
+ PROCFOLDER
+ SOURCES
+ TOP
+ ARGS
)
+ file(GLOB LIB_SOURCES ${SUBFOLDER}/*.cpp)
+ file(GLOB LIB_HEADERS ${SUBFOLDER}/*.h)
- add_library(${name} ${LIB_SOURCES} ${LIB_HEADERS})
- target_compile_features(${name} PRIVATE cxx_std_17)
+ add_library(${SUBFOLDER} ${LIB_SOURCES} ${LIB_HEADERS})
+ target_compile_features(${SUBFOLDER} PRIVATE cxx_std_17)
# Link processor against Verilator runtime library
- target_link_libraries(${name} ${VERILATOR_LIB})
+ target_link_libraries(${SUBFOLDER} PUBLIC ${VERILATOR_LIB})
# Link Ripes lib against the processor library (Verilator processors are not header-only)
- target_link_libraries(${RIPES_LIB} ${name})
+ target_link_libraries(${RIPES_LIB} PUBLIC ${SUBFOLDER})
+
+ verilate(${SUBFOLDER}
+ TOP_MODULE ${TOP}
+ SOURCES ${SOURCES}
+ VERILATOR_ARGS ${ARGS})
endmacro()

Use Verilator CMake for calling verilator