> configure(npc)
ysyx_22040000 李心杨 Linux calcite 6.1.69 #1-NixOS SMP PREEMPT_DYNAMIC Wed Dec 20 16:00:29 UTC 2023 x86_64 GNU/Linux 18:21:53 up 2 days 17:22, 2 users, load average: 1.06, 0.99, 0.87
This commit is contained in:
parent
16a3563224
commit
602c9bdd2b
1 changed files with 60 additions and 55 deletions
|
@ -17,74 +17,79 @@ find_package(verilator REQUIRED)
|
||||||
find_library(NVBOARD_LIBRARY NAMES nvboard)
|
find_library(NVBOARD_LIBRARY NAMES nvboard)
|
||||||
find_path(NVBOARD_INCLUDE_DIR NAMES nvboard.h)
|
find_path(NVBOARD_INCLUDE_DIR NAMES nvboard.h)
|
||||||
|
|
||||||
set(TOPMODULE "Keyboard")
|
set(TOPMODULES "Keyboard")
|
||||||
set(SCALA_CORE "${CMAKE_CURRENT_SOURCE_DIR}/core")
|
|
||||||
set(CHISEL_MODULE_CLASS "${CMAKE_PROJECT_NAME}.${TOPMODULE}")
|
|
||||||
file(GLOB_RECURSE SCALA_CORE_SOURCES "${SCALA_CORE}/src/main/scala/*.scala")
|
|
||||||
file(GLOB_RECURSE SCALA_CORE_TEST_SOURCES "${SCALA_CORE}/src/test/scala/*.scala")
|
|
||||||
|
|
||||||
# Configure time verilog source generation for verilator
|
foreach(TOPMODULE in LISTS TOPMODULES)
|
||||||
execute_process(
|
|
||||||
COMMAND sbt "runMain circt.stage.ChiselMain --target-dir ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc --module ${CHISEL_MODULE_CLASS} --target verilog"
|
|
||||||
WORKING_DIRECTORY ${SCALA_CORE}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_command(
|
set(SCALA_CORE "${CMAKE_CURRENT_SOURCE_DIR}/core")
|
||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc/${TOPMODULE}.v
|
set(CHISEL_MODULE_CLASS "${CMAKE_PROJECT_NAME}.${TOPMODULE}")
|
||||||
COMMAND sbt "runMain circt.stage.ChiselMain --target-dir ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc --module ${CHISEL_MODULE_CLASS} --target verilog"
|
file(GLOB_RECURSE SCALA_CORE_SOURCES "${SCALA_CORE}/src/main/scala/*.scala")
|
||||||
WORKING_DIRECTORY ${SCALA_CORE}
|
file(GLOB_RECURSE SCALA_CORE_TEST_SOURCES "${SCALA_CORE}/src/test/scala/*.scala")
|
||||||
DEPENDS ${SCALA_CORE_SOURCES}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_target(
|
# Configure time verilog source generation for verilator
|
||||||
ChiselBuild
|
execute_process(
|
||||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc/${TOPMODULE}.v
|
COMMAND sbt "runMain circt.stage.ChiselMain --target-dir ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc --module ${CHISEL_MODULE_CLASS} --target verilog"
|
||||||
)
|
WORKING_DIRECTORY ${SCALA_CORE}
|
||||||
|
)
|
||||||
|
|
||||||
# -- Build NVBoard executable
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc/${TOPMODULE}.v
|
||||||
|
COMMAND sbt "runMain circt.stage.ChiselMain --target-dir ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc --module ${CHISEL_MODULE_CLASS} --target verilog"
|
||||||
|
WORKING_DIRECTORY ${SCALA_CORE}
|
||||||
|
DEPENDS ${SCALA_CORE_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_target(
|
||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/auto_bind.cpp
|
ChiselBuild
|
||||||
COMMAND auto_pin_bind ${CMAKE_SOURCE_DIR}/constr/${TOPMODULE}.nxdc ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/auto_bind.cpp
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc/${TOPMODULE}.v
|
||||||
DEPENDS ${CMAKE_SOURCE_DIR}/constr/${TOPMODULE}.nxdc
|
)
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(V${TOPMODULE}_nvboard csrc_nvboard/${TOPMODULE}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/auto_bind.cpp)
|
# -- Build NVBoard executable
|
||||||
|
|
||||||
verilate(V${TOPMODULE}_nvboard TRACE COVERAGE THREADS
|
add_custom_command(
|
||||||
TOP_MODULE ${TOPMODULE}
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/auto_bind.cpp
|
||||||
PREFIX V${TOPMODULE}
|
COMMAND auto_pin_bind ${CMAKE_SOURCE_DIR}/constr/${TOPMODULE}.nxdc ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/auto_bind.cpp
|
||||||
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc/${TOPMODULE}.v)
|
DEPENDS ${CMAKE_SOURCE_DIR}/constr/${TOPMODULE}.nxdc
|
||||||
|
)
|
||||||
|
|
||||||
add_dependencies(V${TOPMODULE}_nvboard ChiselBuild)
|
add_executable(V${TOPMODULE}_nvboard csrc_nvboard/${TOPMODULE}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/auto_bind.cpp)
|
||||||
target_include_directories(V${TOPMODULE}_nvboard PRIVATE ${NVBOARD_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
|
|
||||||
target_link_libraries(V${TOPMODULE}_nvboard PRIVATE ${NVBOARD_LIBRARY} SDL2::SDL2 SDL2_image::SDL2_image)
|
|
||||||
|
|
||||||
install(TARGETS V${TOPMODULE}_nvboard)
|
verilate(V${TOPMODULE}_nvboard TRACE COVERAGE THREADS
|
||||||
|
TOP_MODULE ${TOPMODULE}
|
||||||
|
PREFIX V${TOPMODULE}
|
||||||
|
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc/${TOPMODULE}.v)
|
||||||
|
|
||||||
# -- Build Verilator executable and add to test
|
add_dependencies(V${TOPMODULE}_nvboard ChiselBuild)
|
||||||
|
target_include_directories(V${TOPMODULE}_nvboard PRIVATE ${NVBOARD_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(V${TOPMODULE}_nvboard PRIVATE ${NVBOARD_LIBRARY} SDL2::SDL2 SDL2_image::SDL2_image)
|
||||||
|
|
||||||
add_executable(V${TOPMODULE} csrc/main.cpp)
|
install(TARGETS V${TOPMODULE}_nvboard)
|
||||||
|
|
||||||
verilate(V${TOPMODULE} TRACE COVERAGE THREADS
|
# -- Build Verilator executable and add to test
|
||||||
TOP_MODULE ${TOPMODULE}
|
|
||||||
PREFIX V${TOPMODULE}
|
|
||||||
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc/${TOPMODULE}.v)
|
|
||||||
|
|
||||||
add_dependencies(V${TOPMODULE} ChiselBuild)
|
add_executable(V${TOPMODULE} csrc/main.cpp)
|
||||||
|
|
||||||
enable_testing()
|
verilate(V${TOPMODULE} TRACE COVERAGE THREADS
|
||||||
add_test(NAME V${TOPMODULE} COMMAND V${TOPMODULE})
|
TOP_MODULE ${TOPMODULE}
|
||||||
|
PREFIX V${TOPMODULE}
|
||||||
|
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc/${TOPMODULE}.v)
|
||||||
|
|
||||||
# -- Add build tracking
|
add_dependencies(V${TOPMODULE} ChiselBuild)
|
||||||
add_custom_command(
|
|
||||||
TARGET V${TOPMODULE}_nvboard PRE_BUILD
|
|
||||||
COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh "build_${CMAKE_PROJECT_NAME}_V${TOPMODULE}_nvboard"
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_command(
|
enable_testing()
|
||||||
TARGET V${TOPMODULE} PRE_BUILD
|
add_test(NAME V${TOPMODULE} COMMAND V${TOPMODULE})
|
||||||
COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh "build_${CMAKE_PROJECT_NAME}_V${TOPMODULE}"
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..
|
# -- Add build tracking
|
||||||
)
|
add_custom_command(
|
||||||
|
TARGET V${TOPMODULE}_nvboard PRE_BUILD
|
||||||
|
COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh "build_${CMAKE_PROJECT_NAME}_V${TOPMODULE}_nvboard"
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
TARGET V${TOPMODULE} PRE_BUILD
|
||||||
|
COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh "build_${CMAKE_PROJECT_NAME}_V${TOPMODULE}"
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..
|
||||||
|
)
|
||||||
|
|
||||||
|
endforeach()
|
||||||
|
|
Loading…
Reference in a new issue