Add CMake support for Verilator-based processors
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -64,6 +64,21 @@ include_directories(SYSTEM external/ELFIO)
include_directories(SYSTEM external/Signals)
include_directories(external)
+option(RIPES_BUILD_VERILATOR_PROCESSORS "Build verilator processors" OFF)
+if(RIPES_BUILD_VERILATOR_PROCESSORS)
+ if(NOT DEFINED ENV{VERILATOR_ROOT})
+ message(FATAL_ERROR "'VERILATOR_ROOT' must be set when building Verilator-based processors!")
+ endif()
+ message(STATUS "Building with Verilator processors")
+ include_directories(SYSTEM $ENV{VERILATOR_ROOT}/include)
+
+ # Create library containing Verilator runtime files, which verilator processors can link against
+ file(GLOB VERILATOR_SOURCES $ENV{VERILATOR_ROOT}/include/verilated.cpp)
+ file(GLOB VERILATOR_HEADERS $ENV{VERILATOR_ROOT}/include/verilated.h)
+ set(VERILATOR_LIB verilator_lib)
+ add_library(${VERILATOR_LIB} ${VERILATOR_SOURCES} ${VERILATOR_HEADERS})
+endif()
+
# Platform specific pre-target setup(s)
if(${APPLE})
set(SYSTEM_FLAGS MACOSX_BUNDLE)

MODIFY
src/processors/CMakeLists.txt
src/processors/CMakeLists.txt
@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.9)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+# Allow linking parent libraries with libraries defined in subdirectories
+cmake_policy(SET CMP0079 NEW)
+
macro(create_isa_lib isa)
file(GLOB LIB_SOURCES ${isa}/*.cpp)
file(GLOB LIB_HEADERS
@@ -13,7 +16,7 @@ endmacro()
macro(create_vsrtl_processor isa name)
file(GLOB LIB_SOURCES ${isa}/${name}/*.cpp)
- file(GLOB LIB_HEADERS interface/* RipesVSRTLProcessor.h ${isa}/${name}/*.h)
+ file(GLOB LIB_HEADERS RipesVSRTLProcessor.h ${isa}/${name}/*.h)
add_library(${name} ${LIB_SOURCES} ${LIB_HEADERS})
target_link_libraries(${name} ${VSRTL_CORE_LIB} ${isa}_lib)
target_include_directories(${name} PUBLIC ${isa})
@@ -22,6 +25,26 @@ 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
+ )
+
+ add_library(${name} ${LIB_SOURCES} ${LIB_HEADERS})
+ target_compile_features(${name} PRIVATE cxx_std_17)
+
+ # Link processor against Verilator runtime library
+ target_link_libraries(${name} ${VERILATOR_LIB})
+ # Link Ripes lib against the processor library (Verilator processors are not header-only)
+ target_link_libraries(${RIPES_LIB} ${name})
+
+endmacro()
+
# RISC-V Processors
create_isa_lib(RISC-V)
create_vsrtl_processor(RISC-V rvss)

Add CMake support for Verilator-based processors