2024-03-29 02:35:49 +00:00
|
|
|
cmake_minimum_required(VERSION 3.26)
|
2024-01-05 15:50:26 +00:00
|
|
|
|
2024-03-13 06:53:31 +00:00
|
|
|
project(flow)
|
2024-07-09 12:42:01 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2024-01-05 15:50:26 +00:00
|
|
|
cmake_policy(SET CMP0144 NEW)
|
|
|
|
|
2024-03-29 02:35:49 +00:00
|
|
|
include(CMakeDependentOption)
|
2024-04-04 18:12:30 +00:00
|
|
|
include(CTest)
|
2024-08-14 09:01:37 +00:00
|
|
|
include(GNUInstallDirs)
|
2024-03-29 02:35:49 +00:00
|
|
|
enable_testing()
|
2024-04-04 18:12:30 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
2024-03-29 02:35:49 +00:00
|
|
|
|
|
|
|
# -- Build options
|
2024-08-14 09:01:37 +00:00
|
|
|
option(BUILD_CHISEL_EMIT_TARGET "Emit verilog file with chisel" ON)
|
2024-04-12 08:39:24 +00:00
|
|
|
option(BUILD_USE_BLOOP "Whether to use bloop to speed up elaborate" OFF)
|
2024-03-29 02:35:49 +00:00
|
|
|
option(BUILD_SIM_TARGET "Whether to build verilator simulation binary" ON)
|
2024-07-09 12:42:01 +00:00
|
|
|
cmake_dependent_option(
|
|
|
|
BUILD_SIM_NVBOARD_TARGET "Whether to build nvboard target" OFF
|
|
|
|
"BUILD_SIM_TARGET" OFF)
|
2024-04-11 06:07:05 +00:00
|
|
|
option(ENABLE_YSYX_GIT_TRACKER "Ysyx tracker support" ON)
|
2024-07-09 12:42:01 +00:00
|
|
|
set(TOPMODULE
|
|
|
|
"Flow"
|
|
|
|
CACHE STRING "Topmodule name in chisel")
|
|
|
|
set(DIFFTEST_LIB
|
|
|
|
""
|
|
|
|
CACHE FILEPATH "Dynamic library file used as difftest reference")
|
|
|
|
set(DIFFTEST_RESOURCE_DIR
|
|
|
|
""
|
|
|
|
CACHE PATH "Dynamic library file used as difftest reference")
|
2024-01-05 17:01:02 +00:00
|
|
|
|
2024-03-29 02:35:49 +00:00
|
|
|
# -- Ysyx tracker, configure
|
|
|
|
if(ENABLE_YSYX_GIT_TRACKER)
|
2024-07-09 12:42:01 +00:00
|
|
|
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh "configure(npc)"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..)
|
2024-03-29 02:35:49 +00:00
|
|
|
endif()
|
2024-01-05 15:50:26 +00:00
|
|
|
|
2024-03-29 02:35:49 +00:00
|
|
|
# -- Check dependencies
|
|
|
|
if(BUILD_SIM_TARGET)
|
|
|
|
find_package(verilator REQUIRED)
|
|
|
|
endif()
|
|
|
|
if(BUILD_SIM_NVBOARD_TARGET)
|
|
|
|
find_package(SDL2 REQUIRED)
|
|
|
|
find_package(SDL2_image REQUIRED)
|
|
|
|
endif()
|
2024-04-03 14:39:33 +00:00
|
|
|
find_package(CLI11 CONFIG REQUIRED)
|
2024-08-01 10:53:17 +00:00
|
|
|
find_package(spdlog REQUIRED)
|
2024-04-09 09:03:21 +00:00
|
|
|
|
2024-07-10 12:27:09 +00:00
|
|
|
option(ENABLE_SDB "Enable simple debugger" OFF)
|
2024-01-05 15:50:26 +00:00
|
|
|
|
|
|
|
find_library(NVBOARD_LIBRARY NAMES nvboard)
|
|
|
|
find_path(NVBOARD_INCLUDE_DIR NAMES nvboard.h)
|
|
|
|
|
2024-08-14 09:01:37 +00:00
|
|
|
if(BUILD_CHISEL_EMIT_TARGET)
|
|
|
|
# FIXME: all scala source file are tracked here, cause all files to rebuild
|
|
|
|
# after a source update.
|
|
|
|
set(SCALA_CORE "${CMAKE_CURRENT_SOURCE_DIR}/core")
|
|
|
|
set(CHISEL_MODULE_CLASS "${CMAKE_PROJECT_NAME}.${TOPMODULE}")
|
2024-03-29 02:35:49 +00:00
|
|
|
|
2024-08-14 09:01:37 +00:00
|
|
|
set(CHISEL_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc)
|
2024-03-29 02:35:49 +00:00
|
|
|
|
2024-08-14 09:01:37 +00:00
|
|
|
set(CHISEL_OUTPUT_VERILATOR_CONF ${CHISEL_OUTPUT_DIR}/conf.vlt)
|
|
|
|
set(CHISEL_OUTPUT_TOPMODULE ${CHISEL_OUTPUT_DIR}/${TOPMODULE}.sv)
|
|
|
|
set(CHISEL_EMIT_ARGS "--target-dir ${CHISEL_OUTPUT_DIR}")
|
|
|
|
endif()
|
2024-03-29 02:35:49 +00:00
|
|
|
|
|
|
|
# -- Build NVBoard executable
|
|
|
|
if(BUILD_SIM_NVBOARD_TARGET)
|
2024-04-04 18:12:30 +00:00
|
|
|
add_subdirectory(csrc_nvboard)
|
2024-03-29 02:35:49 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# -- Build Verilator executable and add to test
|
2024-04-09 09:03:21 +00:00
|
|
|
add_subdirectory(utils)
|
2024-04-04 16:16:58 +00:00
|
|
|
|
2024-04-04 18:12:30 +00:00
|
|
|
add_subdirectory(csrc)
|
2024-01-10 12:20:45 +00:00
|
|
|
|
2024-03-29 02:35:49 +00:00
|
|
|
# -- Add build tracking
|
|
|
|
if(ENABLE_YSYX_GIT_TRACKER)
|
2024-04-11 06:07:05 +00:00
|
|
|
add_custom_target(
|
|
|
|
ysyx_git_tracer ALL
|
2024-07-09 12:42:01 +00:00
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh
|
|
|
|
"build_${CMAKE_PROJECT_NAME}_V${TOPMODULE}"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..)
|
2024-03-29 02:35:49 +00:00
|
|
|
endif()
|