Skip to content

Commit

Permalink
Updates needed for a build system changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mmicko committed Jan 29, 2025
1 parent d3bbdc8 commit 38e9c9e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 31 deletions.
2 changes: 1 addition & 1 deletion himbaechel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ else()

endif()

set(HIMBAECHEL_UARCHES example gowin xilinx ng-ultra)
set(HIMBAECHEL_UARCHES example gowin xilinx ng-ultra gatemate)

set(HIMBAECHEL_UARCH "" CACHE STRING "Microarchitectures for nextpnr-himbaechel build")
set_property(CACHE HIMBAECHEL_UARCH PROPERTY STRINGS ${HIMBAECHEL_UARCHES})
Expand Down
80 changes: 50 additions & 30 deletions himbaechel/uarch/gatemate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,58 @@
message(STATUS "Configuring Himbaechel-GateMate uarch")
cmake_minimum_required(VERSION 3.5)
project(himbaechel-gatemate-chipdb NONE)
set(SOURCES
bitstream.cc
ccf.cc
config.cc
config.h
constids.inc
extra_data.h
gatemate.cc
gatemate.h
gfx.cc
gfxids.inc
pack.cc
pack.h
)

add_nextpnr_himbaechel_microarchitecture(${uarch}
CORE_SOURCES ${SOURCES}
)

set(HIMBAECHEL_PEPPERCORN_PATH "" CACHE STRING
"Path to a Project Peppercorn database scripts")
"Path to a Project Peppercorn database")
if (NOT HIMBAECHEL_PEPPERCORN_PATH)
message(FATAL_ERROR "HIMBAECHEL_PEPPERCORN_PATH must be set to a Project Peppercorn checkout")
endif()

set(ALL_HIMBAECHE_GATEMATE_DEVICES CCGM1A1 CCGM1A2 CCGM1A4 CCGM1A9 CCGM1A16 CCGM1A25)
set(HIMBAECHEL_GATEMATE_DEVICES "" CACHE STRING
#set(ALL_HIMBAECHE_GATEMATE_DEVICES CCGM1A1 CCGM1A2 CCGM1A4 CCGM1A9 CCGM1A16 CCGM1A25)
set(ALL_HIMBAECHE_GATEMATE_DEVICES CCGM1A1)
set(HIMBAECHEL_GATEMATE_DEVICES ${ALL_HIMBAECHE_GATEMATE_DEVICES} CACHE STRING
"Include support for these GateMate devices (available: ${ALL_HIMBAECHE_GATEMATE_DEVICES})")
message(STATUS "Enabled Himbaechel-GateMate devices: ${HIMBAECHEL_GATEMATE_DEVICES}")

set(chipdb_binaries)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/gatemate)
foreach(device ${HIMBAECHEL_GATEMATE_DEVICES})
set(device_bba ${CMAKE_BINARY_DIR}/share/himbaechel/gatemate/chipdb-${device}.bba)
set(device_bin ${CMAKE_BINARY_DIR}/share/himbaechel/gatemate/chipdb-${device}.bin)
if("${HIMBAECHEL_PEPPERCORN_PATH}" STREQUAL "")
message(SEND_ERROR "HIMBAECHEL_PEPPERCORN_PATH must be set to a Project Peppercorn checkout")
endif()
add_custom_command(
OUTPUT ${device_bin}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen/arch_gen.py --device ${device} --bba ${device_bba} --lib ${HIMBAECHEL_PEPPERCORN_PATH}/gatemate
COMMAND bbasm ${BBASM_ENDIAN_FLAG} ${device_bba} ${device_bin}.new
# atomically update
COMMAND ${CMAKE_COMMAND} -E rename ${device_bin}.new ${device_bin}
DEPENDS
bbasm
${CMAKE_CURRENT_SOURCE_DIR}/gen/arch_gen.py
${CMAKE_CURRENT_SOURCE_DIR}/constids.inc
foreach (device ${HIMBAECHEL_GATEMATE_DEVICES})
if (NOT device IN_LIST ALL_HIMBAECHE_GATEMATE_DEVICES)
message(FATAL_ERROR "Device ${device} is not a supported GateMate device")
endif()

add_bba_produce_command(
TARGET nextpnr-himbaechel-gatemate-bba
COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/gen/arch_gen.py
--lib ${HIMBAECHEL_PEPPERCORN_PATH}/gatemate
--device ${device}
--bba ${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba.new
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba
INPUTS
${CMAKE_CURRENT_SOURCE_DIR}/gen/arch_gen.py
${CMAKE_CURRENT_SOURCE_DIR}/constids.inc
${CMAKE_CURRENT_SOURCE_DIR}/gfxids.inc
VERBATIM)
list(APPEND chipdb_binaries ${device_bin})
endforeach()
)

add_custom_target(chipdb-himbaechel-gatemate ALL DEPENDS ${chipdb_binaries})
install(DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/gatemate/ DESTINATION share/nextpnr/himbaechel/gatemate
PATTERN "*.bba" EXCLUDE)
add_bba_compile_command(
TARGET nextpnr-himbaechel-gatemate-chipdb
OUTPUT himbaechel/gatemate/chipdb-${device}.bin
INPUT ${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba
MODE binary
)
endforeach()

0 comments on commit 38e9c9e

Please sign in to comment.