CMake: align Himbaechel targets with non-Himbaechel ones.

Primarily, this commit makes both of them use the `BBAsm` functions
to build and compile `.bba` files.

In addition, Himbaechel targets are now aligned with the rest in
how they are configured: instead of having all uarches enabled with
all of the devices disabled (the opposite of the rest of nextpnr),
uarches must be enabled explicitly but they come with all devices
enabled (except for Xilinx, which does not have a list of devices).
This commit is contained in:
Catherine 2025-01-15 16:20:21 +00:00
parent f5776a6d64
commit dcfb7d8c33
9 changed files with 187 additions and 139 deletions

View File

@ -7,7 +7,7 @@ function get_dependencies {
function build_nextpnr {
mkdir build
pushd build
cmake .. -DARCH=himbaechel -DHIMBAECHEL_EXAMPLE_DEVICES=example
cmake .. -DARCH=himbaechel -DHIMBAECHEL_UARCH=example -DHIMBAECHEL_EXAMPLE_DEVICES=example
make nextpnr-himbaechel chipdb-himbaechel-example -j`nproc`
popd
}

View File

@ -140,7 +140,7 @@ The himbaechel target allows running placement and routing for larger architectu
For Gowin support, install [Project Apicula](https://github.com/YosysHQ/apicula)
```
cmake . -DARCH="himbaechel" -DHIMBAECHEL_GOWIN_DEVICES="all"
cmake . -DARCH="himbaechel" -DHIMBAECHEL_UARCH="gowin"
make -j$(nproc)
sudo make install
```
@ -152,7 +152,7 @@ sudo make install
For NanoXplore NG-Ultra support, clone [Project Beyond DB](https://github.com/yosyshq-GmbH/prjbeyond-db) repo
```
cmake . -DARCH="himbaechel" -DHIMBAECHEL_PRJBEYOND_DB=/path/to/prjbeyond-db -DHIMBAECHEL_NGULTRA_DEVICES=ng-ultra
cmake . -DARCH="himbaechel" -DHIMBAECHEL_UARCH="ng-ultra" -DHIMBAECHEL_PRJBEYOND_DB=/path/to/prjbeyond-db -DHIMBAECHEL_NGULTRA_DEVICES=ng-ultra
make -j$(nproc)
sudo make install
```

View File

@ -39,12 +39,18 @@ function(add_bba_produce_command)
DEPENDS
${arg_EXECUTABLE}
${arg_INPUTS}
$ENV{SERIALIZE_BBA_PRODUCE_COMMAND}
$ENV{SERIALIZE_BBA_TARGET}
VERBATIM
)
if (BBASM_SERIALIZE)
set(ENV{SERIALIZE_BBA_PRODUCE_COMMAND} ${arg_OUTPUT})
# Have to insert a custom target in between two custom commands, else CMake will try to
# depend on the previous (in serialization order) command directly, which will fail if
# they're in different directories. Unfortunately this makes the terminal output uglier.
math(EXPR next_count "$ENV{SERIALIZE_BBA_COUNT} + 1")
add_custom_target(--bbasm-serialize-${next_count} DEPENDS ${arg_OUTPUT})
set(ENV{SERIALIZE_BBA_COUNT} ${next_count})
set(ENV{SERIALIZE_BBA_TARGET} --bbasm-serialize-${next_count})
endif()
endfunction()

View File

@ -1,2 +1,19 @@
# nextpnr-gowin only
find_program (GOWIN_BBA_EXECUTABLE gowin_bba)
message(STATUS "gowin_bba executable: ${GOWIN_BBA_EXECUTABLE}")
# nextpnr-himbaechel-gowin only
if (DEFINED ENV{APYCULA_INSTALL_PREFIX})
set(apycula_default_install_prefix $ENV{APYCULA_INSTALL_PREFIX})
endif()
set(APYCULA_INSTALL_PREFIX ${apycula_default_install_prefix} CACHE STRING
"Apycula install prefix (virtualenv directory)")
if (NOT APYCULA_INSTALL_PREFIX STREQUAL "")
message(STATUS "Apycula install prefix: ${APYCULA_INSTALL_PREFIX}")
set(apycula_Python3_EXECUTABLE ${APYCULA_INSTALL_PREFIX}/bin/python)
else()
message(STATUS "Apycula install prefix: (not set, using Python: ${Python3_EXECUTABLE})")
set(apycula_Python3_EXECUTABLE ${Python3_EXECUTABLE})
endif()

View File

@ -1,15 +1,27 @@
set(HIMBAECHEL_UARCHES "example;gowin;xilinx;ng-ultra")
set(HIMBAECHEL_UARCHES example gowin xilinx ng-ultra)
set(HIMBAECHEL_UARCH "${HIMBAECHEL_UARCHES}" CACHE STRING "Microarchitectures for nextpnr-himbaechel build")
set(HIMBAECHEL_UARCH "" CACHE STRING "Microarchitectures for nextpnr-himbaechel build")
set_property(CACHE HIMBAECHEL_UARCH PROPERTY STRINGS ${HIMBAECHEL_UARCHES})
foreach (item ${HIMBAECHEL_UARCH})
if (NOT item IN_LIST HIMBAECHEL_UARCHES)
message(FATAL_ERROR "Microarchitecture '${item}' not in list of supported architectures")
endif()
if (NOT HIMBAECHEL_UARCH)
message(STATUS "Microarchitecture needs to be set, set desired one with -DHIMBAECHEL_UARCH=xxx")
message(STATUS "Supported Himbaechel microarchitectures are :")
message(STATUS " all")
foreach (item ${HIMBAECHEL_UARCHES})
message(STATUS " ${item}")
endforeach()
message(FATAL_ERROR "Microarchitecture setting is mandatory")
endif()
if (HIMBAECHEL_UARCH STREQUAL "all")
set(HIMBAECHEL_UARCH ${HIMBAECHEL_UARCHES})
endif()
foreach (uarch ${HIMBAECHEL_UARCH})
if (NOT uarch IN_LIST HIMBAECHEL_UARCHES)
message(FATAL_ERROR "Microarchitecture ${uarch} is not a supported Himbaechel microarchitecture")
endif()
add_subdirectory(uarch/${uarch})
aux_source_directory(uarch/${uarch} HM_UARCH_FILES)
foreach (target ${family_targets})

View File

@ -1,32 +1,39 @@
message(STATUS "Configuring Himbaechel-Example uarch")
cmake_minimum_required(VERSION 3.5)
project(himbaechel-example-chipdb NONE)
add_custom_target(chipdb-himbaechel-example)
foreach (target ${family_targets})
add_dependencies(${target} chipdb-himbaechel-example)
endforeach()
set(ALL_HIMBAECHEL_EXAMPLE_DEVICES example)
set(HIMBAECHEL_EXAMPLE_DEVICES "" CACHE STRING
set(HIMBAECHEL_EXAMPLE_DEVICES ${ALL_HIMBAECHEL_EXAMPLE_DEVICES} CACHE STRING
"Include support for these Example devices (available: ${ALL_HIMBAECHEL_EXAMPLE_DEVICES})")
message(STATUS "Enabled Himbaechel-Example devices: ${HIMBAECHEL_EXAMPLE_DEVICES}")
set(chipdb_binaries)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/example)
foreach (device ${HIMBAECHEL_EXAMPLE_DEVICES})
set(device_bba ${CMAKE_BINARY_DIR}/share/himbaechel/example/chipdb-${device}.bba)
set(device_bin ${CMAKE_BINARY_DIR}/share/himbaechel/example/chipdb-${device}.bin)
add_custom_command(
OUTPUT ${device_bin}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example_arch_gen.py ${device_bba}
COMMAND bbasm ${BBASM_ENDIAN_FLAG} ${device_bba} ${device_bin}.new
# atomically update
COMMAND ${CMAKE_COMMAND} -E rename ${device_bin}.new ${device_bin}
DEPENDS
bbasm
if (NOT device IN_LIST ALL_HIMBAECHEL_EXAMPLE_DEVICES)
message(FATAL_ERROR "Device ${device} is not a supported Example device")
endif()
add_bba_produce_command(
COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/example_arch_gen.py
${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba.new
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba
INPUTS
${CMAKE_CURRENT_SOURCE_DIR}/example_arch_gen.py
${CMAKE_CURRENT_SOURCE_DIR}/constids.inc
${CMAKE_CURRENT_SOURCE_DIR}/gfxids.inc
VERBATIM)
list(APPEND chipdb_binaries ${device_bin})
)
add_bba_compile_command(
TARGET chipdb-himbaechel-example
OUTPUT ${CMAKE_BINARY_DIR}/share/himbaechel/example/chipdb-${device}.bin
INPUT ${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba
MODE binary
)
endforeach()
add_custom_target(chipdb-himbaechel-example ALL DEPENDS ${chipdb_binaries})
install(DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/example/ DESTINATION share/nextpnr/himbaechel/example
PATTERN "*.bba" EXCLUDE)
install(
DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/example
DESTINATION share/nextpnr/himbaechel/example
)

View File

@ -1,51 +1,44 @@
message(STATUS "Configuring Himbaechel-Gowin uarch")
cmake_minimum_required(VERSION 3.5)
project(himbaechel-gowin-chipdb NONE)
include(FindApycula)
add_custom_target(chipdb-himbaechel-gowin ALL)
foreach (target ${family_targets})
add_dependencies(${target} chipdb-himbaechel-gowin)
endforeach()
set(ALL_HIMBAECHEL_GOWIN_DEVICES GW1N-1 GW1NZ-1 GW1N-4 GW1N-9 GW1N-9C GW1NS-4 GW2A-18 GW2A-18C)
set(HIMBAECHEL_GOWIN_DEVICES "" CACHE STRING
set(HIMBAECHEL_GOWIN_DEVICES ${ALL_HIMBAECHEL_GOWIN_DEVICES} CACHE STRING
"Include support for these Gowin devices (available: ${ALL_HIMBAECHEL_GOWIN_DEVICES})")
if (HIMBAECHEL_GOWIN_DEVICES STREQUAL "all")
set(HIMBAECHEL_GOWIN_DEVICES ${ALL_HIMBAECHEL_GOWIN_DEVICES})
endif()
message(STATUS "Enabled Himbaechel-Gowin devices: ${HIMBAECHEL_GOWIN_DEVICES}")
if (DEFINED ENV{APYCULA_INSTALL_PREFIX})
set(apycula_default_install_prefix $ENV{APYCULA_INSTALL_PREFIX})
endif()
set(APYCULA_INSTALL_PREFIX ${apycula_default_install_prefix} CACHE STRING
"Apycula install prefix (virtualenv directory)")
if (NOT APYCULA_INSTALL_PREFIX STREQUAL "")
message(STATUS "Apycula install prefix: ${APYCULA_INSTALL_PREFIX}")
set(apycula_Python3_EXECUTABLE ${APYCULA_INSTALL_PREFIX}/bin/python)
else()
message(STATUS "Apycula install prefix: (using system Python)")
set(apycula_Python3_EXECUTABLE ${Python3_EXECUTABLE})
endif()
set(chipdb_binaries)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/gowin)
foreach (device ${HIMBAECHEL_GOWIN_DEVICES})
if (NOT device IN_LIST ALL_HIMBAECHEL_GOWIN_DEVICES)
message(FATAL_ERROR "Device ${device} is not a supported Gowin device")
endif()
set(device_bba ${CMAKE_BINARY_DIR}/share/himbaechel/gowin/chipdb-${device}.bba)
set(device_bin ${CMAKE_BINARY_DIR}/share/himbaechel/gowin/chipdb-${device}.bin)
add_custom_command(
OUTPUT ${device_bin}
COMMAND ${apycula_Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gowin_arch_gen.py -d ${device} -o ${device_bba}
COMMAND bbasm ${BBASM_ENDIAN_FLAG} ${device_bba} ${device_bin}.new
# atomically update
COMMAND ${CMAKE_COMMAND} -E rename ${device_bin}.new ${device_bin}
DEPENDS
bbasm
add_bba_produce_command(
COMMAND ${apycula_Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/gowin_arch_gen.py
-d ${device}
-o ${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba.new
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba
INPUTS
${CMAKE_CURRENT_SOURCE_DIR}/gowin_arch_gen.py
${CMAKE_CURRENT_SOURCE_DIR}/constids.inc
VERBATIM)
list(APPEND chipdb_binaries ${device_bin})
)
add_bba_compile_command(
TARGET chipdb-himbaechel-gowin
OUTPUT ${CMAKE_BINARY_DIR}/share/himbaechel/gowin/chipdb-${device}.bin
INPUT ${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba
MODE binary
)
endforeach()
add_custom_target(chipdb-himbaechel-gowin ALL DEPENDS ${chipdb_binaries})
install(DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/gowin/ DESTINATION share/nextpnr/himbaechel/gowin
PATTERN "*.bba" EXCLUDE)
install(
DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/gowin
DESTINATION share/nextpnr/himbaechel/gowin
)

View File

@ -1,38 +1,48 @@
message(STATUS "Configuring Himbaechel-NG-ULTRA uarch")
cmake_minimum_required(VERSION 3.5)
project(himbaechel-ng-ultra-chipdb NONE)
set(ALL_HIMBAECHEL_NGULTRA_DEVICES ng-ultra)
set(HIMBAECHEL_NGULTRA_DEVICES "" CACHE STRING
"Include support for these NG-Ultra devices (available: ${ALL_HIMBAECHEL_NGULTRA_DEVICES})")
message(STATUS "Enabled Himbaechel-NG-Ultra devices: ${HIMBAECHEL_NGULTRA_DEVICES}")
set(HIMBAECHEL_PRJBEYOND_DB "" CACHE STRING
"Path to a Project Beyond database")
set(chipdb_binaries)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/ng-ultra)
foreach (device ${HIMBAECHEL_NGULTRA_DEVICES})
if ("${HIMBAECHEL_PRJBEYOND_DB}" STREQUAL "")
message(SEND_ERROR "HIMBAECHEL_PRJBEYOND_DB must be set to a prjbeyond database checkout")
if (NOT HIMBAECHEL_PRJBEYOND_DB)
message(FATAL_ERROR "HIMBAECHEL_PRJBEYOND_DB must be set to a prjbeyond database checkout")
endif()
set(device_bba ${CMAKE_BINARY_DIR}/share/himbaechel/ng-ultra/chipdb-${device}.bba)
set(device_bin ${CMAKE_BINARY_DIR}/share/himbaechel/ng-ultra/chipdb-${device}.bin)
string(TOUPPER ${device} upcase_device)
add_custom_command(
OUTPUT ${device_bin}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen/arch_gen.py --db ${HIMBAECHEL_PRJBEYOND_DB} --device ${upcase_device} --bba ${device_bba}
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
VERBATIM)
list(APPEND chipdb_binaries ${device_bin})
add_custom_target(chipdb-himbaechel-ng-ultra)
foreach (target ${family_targets})
add_dependencies(${target} chipdb-himbaechel-ng-ultra)
endforeach()
add_custom_target(chipdb-himbaechel-ng-ultra ALL DEPENDS ${chipdb_binaries})
install(DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/ng-ultra/ DESTINATION share/nextpnr/himbaechel/ng-ultra
PATTERN "*.bba" EXCLUDE)
set(ALL_HIMBAECHEL_NGULTRA_DEVICES ng-ultra)
set(HIMBAECHEL_NGULTRA_DEVICES ${ALL_HIMBAECHEL_NGULTRA_DEVICES} CACHE STRING
"Include support for these NG-Ultra devices (available: ${ALL_HIMBAECHEL_NGULTRA_DEVICES})")
message(STATUS "Enabled Himbaechel-NG-Ultra devices: ${HIMBAECHEL_NGULTRA_DEVICES}")
foreach (device ${HIMBAECHEL_NGULTRA_DEVICES})
if (NOT device IN_LIST ALL_HIMBAECHEL_NGULTRA_DEVICES)
message(FATAL_ERROR "Device ${device} is not a supported NG-Ultra device")
endif()
string(TOUPPER ${device} upcase_device)
add_bba_produce_command(
COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/gen/arch_gen.py
--db ${HIMBAECHEL_PRJBEYOND_DB}
--device ${upcase_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
)
add_bba_compile_command(
TARGET chipdb-himbaechel-ng-ultra
OUTPUT ${CMAKE_BINARY_DIR}/share/himbaechel/ng-ultra/chipdb-${device}.bin
INPUT ${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba
MODE binary
)
endforeach()
install(
DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/ng-ultra
DESTINATION share/nextpnr/himbaechel/ng-ultra
)

View File

@ -1,37 +1,40 @@
message(STATUS "Configuring Xilinx uarch")
cmake_minimum_required(VERSION 3.5)
project(himbaechel-xilinx-chipdb NONE)
set(HIMBAECHEL_XILINX_DEVICES "" CACHE STRING
"Include support for these Xilinx devices via himbaechel")
set(HIMBAECHEL_PRJXRAY_DB "" CACHE STRING
"Path to a project x-ray database")
message(STATUS "Enabled Himbaechel-Xilinx devices: ${HIMBAECHEL_XILINX_DEVICES}")
set(chipdb_binaries)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/xilinx)
foreach (device ${HIMBAECHEL_XILINX_DEVICES})
if ("${HIMBAECHEL_PRJXRAY_DB}" STREQUAL "")
message(SEND_ERROR "HIMBAECHEL_PRJXRAY_DB must be set to a prjxray database checkout")
if (NOT HIMBAECHEL_PRJXRAY_DB)
message(FATAL_ERROR "HIMBAECHEL_PRJXRAY_DB must be set to a prjxray database checkout")
endif()
set(device_bba ${CMAKE_BINARY_DIR}/share/himbaechel/xilinx/chipdb-${device}.bba)
set(device_bin ${CMAKE_BINARY_DIR}/share/himbaechel/xilinx/chipdb-${device}.bin)
add_custom_command(
OUTPUT ${device_bin}
COMMAND pypy3 ${CMAKE_CURRENT_SOURCE_DIR}/gen/xilinx_gen.py --xray ${HIMBAECHEL_PRJXRAY_DB}/artix7 --device ${device} --bba ${device_bba}
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/xilinx_gen.py
${CMAKE_CURRENT_SOURCE_DIR}/constids.inc
VERBATIM)
list(APPEND chipdb_binaries ${device_bin})
add_custom_target(chipdb-himbaechel-xilinx)
foreach (target ${family_targets})
add_dependencies(${target} chipdb-himbaechel-xilinx)
endforeach()
add_custom_target(chipdb-himbaechel-xilinx ALL DEPENDS ${chipdb_binaries})
install(DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/xilinx/ DESTINATION share/nextpnr/himbaechel/xilinx
PATTERN "*.bba" EXCLUDE)
set(HIMBAECHEL_XILINX_DEVICES "" CACHE STRING
"Include support for these Xilinx devices")
message(STATUS "Enabled Himbaechel-Xilinx devices: ${HIMBAECHEL_XILINX_DEVICES}")
foreach (device ${HIMBAECHEL_XILINX_DEVICES})
add_bba_produce_command(
COMMAND /usr/bin/pypy3 ${CMAKE_CURRENT_SOURCE_DIR}/gen/xilinx_gen.py
--xray ${HIMBAECHEL_PRJXRAY_DB}/artix7
--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/xilinx_gen.py
${CMAKE_CURRENT_SOURCE_DIR}/constids.inc
)
add_bba_compile_command(
TARGET chipdb-himbaechel-xilinx
OUTPUT ${CMAKE_BINARY_DIR}/share/himbaechel/xilinx/chipdb-${device}.bin
INPUT ${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba
MODE binary
)
endforeach()
install(
DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/xilinx
DESTINATION share/nextpnr/himbaechel/xilinx
)