ISP/CMakeLists.txt

133 lines
4.1 KiB
CMake
Raw Permalink Normal View History

2024-10-03 15:13:24 +08:00
cmake_minimum_required(VERSION 3.29.6)
cmake_policy(SET CMP0074 NEW)
project(ISP CXX)
# Add Macro to get all subdir
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
2024-11-03 20:38:29 +08:00
SET(dirlist ${curdir})
2024-10-03 15:13:24 +08:00
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${curdir}/${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
# Set C++ Standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED true)
# Find Verilator
find_package(verilator HINTS $ENV{VERILATOR_ROOT} ${VERILATOR_ROOT})
if(NOT verilator_FOUND)
message(
FATAL_ERROR
"Verilator was not found. Either install it, or set the VERILATOR_ROOT environment variable"
)
endif()
# SystemC dependencies
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# Find SystemC using SystemC's CMake integration
find_package(SystemCLanguage QUIET)
# Find Spdlog
if(NOT TARGET spdlog)
2024-11-03 20:38:29 +08:00
# Stand-alone build
find_package(spdlog REQUIRED)
endif()
# Find zlib
if(NOT TARGET ZLIB)
find_package(ZLIB REQUIRED)
endif()
2024-10-03 15:13:24 +08:00
# Create software image process library
2024-10-03 17:06:40 +08:00
# file(GLOB_RECURSE IMG_SRC ${PROJECT_SOURCE_DIR}/src/img_process/*.cpp)
# add_library(img_process STATIC ${IMG_SRC})
2024-10-03 15:13:24 +08:00
# Set input and output location
set(INPUT_IMG ${PROJECT_SOURCE_DIR}/src/transform/test.bin)
set(OUTPUT_DIR ${PROJECT_SOURCE_DIR}/logs/)
add_compile_definitions(
INPUT_IMG="${INPUT_IMG}"
OUTPUT_DIR="${OUTPUT_DIR}"
SPDLOG_FMT_EXTERNAL # Fix Error: fmt not found
DEBUG
)
# Get RTL source code dir
SUBDIRLIST(RTL_SUBDIR ${PROJECT_SOURCE_DIR}/rtl)
2024-11-03 20:38:29 +08:00
set(VERILATOR_ARGS +librescan +libext+.v+.sv+.vh+.svh -y . -x-assign fast --timing -Wno-WIDTHEXPAND -Wno-WIDTHTRUNC -Wno-BLKANDNBLK -Wno-SELRANGE)
2024-10-03 17:06:40 +08:00
# ---------------------- EXE ---------------------------
# Visp
2024-10-03 17:06:40 +08:00
# ---------------------- EXE ---------------------------
add_executable(Visp ${PROJECT_SOURCE_DIR}/src/sc_main.cpp)
2024-10-03 15:13:24 +08:00
target_include_directories(Visp PRIVATE ${PROJECT_SOURCE_DIR}/src/img_process)
2024-11-03 20:38:29 +08:00
target_link_libraries(Visp PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32> PRIVATE ZLIB::ZLIB)
2024-10-03 17:06:40 +08:00
# target_link_libraries(Visp PRIVATE img_process)
2024-10-03 15:13:24 +08:00
2024-10-03 17:06:40 +08:00
# Add the Verilated circuit to the target
2024-10-03 15:13:24 +08:00
verilate(Visp SYSTEMC COVERAGE TRACE
INCLUDE_DIRS ${RTL_SUBDIR}
2024-11-03 20:38:29 +08:00
VERILATOR_ARGS ${VERILATOR_ARGS}
2024-10-03 15:13:24 +08:00
SOURCES ${PROJECT_SOURCE_DIR}/rtl/isp.sv
TOP_MODULE isp
)
# SystemC Link
verilator_link_systemc(Visp)
2024-10-03 17:06:40 +08:00
# ---------------------- EXE ---------------------------
# Visp_Pipeline
2024-10-03 17:06:40 +08:00
# ---------------------- EXE ---------------------------
add_executable(Visp_Pipeline ${PROJECT_SOURCE_DIR}/src/sc_main_pipeline.cpp)
target_include_directories(
Visp_Pipeline
PRIVATE ${PROJECT_SOURCE_DIR}/src/img_process
PRIVATE ${PROJECT_SOURCE_DIR}/src
2024-11-03 20:38:29 +08:00
PRIVATE ${ZLIB_INCLUDE_DIR}
2024-10-03 17:06:40 +08:00
)
2024-11-03 20:38:29 +08:00
target_link_libraries(Visp_Pipeline PRIVATE ZLIB::ZLIB PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
2024-10-03 17:06:40 +08:00
# target_link_libraries(Visp_Pipeline PRIVATE img_process)
# Add the Verilated circuit to the target
2024-11-03 20:38:29 +08:00
verilate(Visp_Pipeline SYSTEMC COVERAGE TRACE_FST TRACE_THREADS 4 THREADS 12
2024-10-03 17:06:40 +08:00
INCLUDE_DIRS ${RTL_SUBDIR}
2024-11-03 20:38:29 +08:00
VERILATOR_ARGS ${VERILATOR_ARGS}
SOURCES ${PROJECT_SOURCE_DIR}/rtl/isp_Pipeline.sv ${PROJECT_SOURCE_DIR}/rtl/SimLib/prim_sim.v
2024-10-03 17:06:40 +08:00
TOP_MODULE isp_Pipeline
)
# SystemC Link
verilator_link_systemc(Visp_Pipeline)
2024-11-03 20:38:29 +08:00
# ---------------------- EXE ---------------------------
# VWindows
# ---------------------- EXE ---------------------------
add_executable(VWindows ${PROJECT_SOURCE_DIR}/src/modules_tb/windows_tb.cpp)
target_include_directories(
VWindows
PRIVATE ${ZLIB_INCLUDE_DIR}
)
target_link_libraries(VWindows PRIVATE ZLIB::ZLIB PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
# target_link_libraries(VWindows PRIVATE img_process)
# Add the Verilated circuit to the target
verilate(VWindows SYSTEMC COVERAGE TRACE_FST TRACE_THREADS 4 THREADS 12
INCLUDE_DIRS ${RTL_SUBDIR}
VERILATOR_ARGS ${VERILATOR_ARGS}
SOURCES ${PROJECT_SOURCE_DIR}/rtl/BayerProcess/Windows_tb.sv ${PROJECT_SOURCE_DIR}/rtl/SimLib/prim_sim.v
TOP_MODULE Windows_tb
)
# SystemC Link
verilator_link_systemc(VWindows)