Allow splitting nextpnr-himbaechel per microarchitecture.
This is added primarily for YoWASP.
This commit is contained in:
parent
cd7f7c12f1
commit
dbba1328bf
@ -241,7 +241,18 @@ add_subdirectory(rust)
|
|||||||
add_subdirectory(tests/gui)
|
add_subdirectory(tests/gui)
|
||||||
|
|
||||||
function(add_nextpnr_architecture target)
|
function(add_nextpnr_architecture target)
|
||||||
cmake_parse_arguments(arg "" "MAIN_SOURCE" "CORE_SOURCES;TEST_SOURCES" ${ARGN})
|
cmake_parse_arguments(arg "" "MAIN_SOURCE" "CORE_SOURCES;TEST_SOURCES;CURRENT_SOURCE_DIR;CURRENT_BINARY_DIR" ${ARGN})
|
||||||
|
|
||||||
|
if (NOT arg_CURRENT_SOURCE_DIR)
|
||||||
|
set(arg_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
endif()
|
||||||
|
if (NOT arg_CURRENT_BINARY_DIR)
|
||||||
|
set(arg_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(arg_MAIN_SOURCE "${arg_CURRENT_SOURCE_DIR}/${arg_MAIN_SOURCE}")
|
||||||
|
list(TRANSFORM arg_CORE_SOURCES PREPEND ${arg_CURRENT_SOURCE_DIR}/)
|
||||||
|
list(TRANSFORM arg_TEST_SOURCES PREPEND ${arg_CURRENT_SOURCE_DIR}/)
|
||||||
|
|
||||||
# Defs library: used by everything
|
# Defs library: used by everything
|
||||||
#
|
#
|
||||||
@ -251,7 +262,7 @@ function(add_nextpnr_architecture target)
|
|||||||
|
|
||||||
target_include_directories(nextpnr-${target}-defs INTERFACE
|
target_include_directories(nextpnr-${target}-defs INTERFACE
|
||||||
${CMAKE_SOURCE_DIR}/common/kernel
|
${CMAKE_SOURCE_DIR}/common/kernel
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${arg_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
string(TOUPPER ${family} family_upper)
|
string(TOUPPER ${family} family_upper)
|
||||||
@ -290,7 +301,7 @@ function(add_nextpnr_architecture target)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_GUI)
|
if (BUILD_GUI)
|
||||||
add_subdirectory(${CMAKE_SOURCE_DIR}/gui ${CMAKE_CURRENT_BINARY_DIR}/gui)
|
add_subdirectory(${CMAKE_SOURCE_DIR}/gui ${arg_CURRENT_BINARY_DIR}/gui)
|
||||||
|
|
||||||
# Upsettingly, there is a cyclic dependency between `common/kernel` and `gui`, so these
|
# Upsettingly, there is a cyclic dependency between `common/kernel` and `gui`, so these
|
||||||
# two libraries have to be added separately to all executable targets.
|
# two libraries have to be added separately to all executable targets.
|
||||||
|
12
README.md
12
README.md
@ -181,6 +181,18 @@ sudo make install
|
|||||||
|
|
||||||
To build every available stable architecture, use `-DARCH=all`. To include experimental arches (currently nexus), use `-DARCH=all+alpha`.
|
To build every available stable architecture, use `-DARCH=all`. To include experimental arches (currently nexus), use `-DARCH=all+alpha`.
|
||||||
|
|
||||||
|
### Per-microarchitecture Himbächel
|
||||||
|
|
||||||
|
To build a single nextpnr-himbachel executable for each of the supported microarchitectures, use `-DHIMBAECHEL_SPLIT`.
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake . -DARCH="himbaechel" -DHIMBAECHEL_UARCH="gowin;ng-ultra"
|
||||||
|
make -j$(nproc)
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
In such a build, instead of a single `nextpnr-himbaechel` binary, two binaries `nextpnr-himbaechel-gowin` and `nextpnr-himbaechel-ng-ultra` are built. Although they are installed together, each microarchitecture is completely independent of the other, and only needs its corresponding `.../share/himbaechel/<microarchitecture>/` chip database directory to run. Split build reduces the size of individual distributed artifacts (although the total size increases), and allows co-installation of artifacts of different versions.
|
||||||
|
|
||||||
Cross-compilation
|
Cross-compilation
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
set(SOURCES
|
option(HIMBAECHEL_SPLIT "Whether to build one executable per Himbächel microarchitecture" OFF)
|
||||||
|
|
||||||
|
set(HIMBAECHEL_SOURCES
|
||||||
arch.cc
|
arch.cc
|
||||||
archdefs.h
|
archdefs.h
|
||||||
arch.h
|
arch.h
|
||||||
@ -13,8 +15,32 @@ set(SOURCES
|
|||||||
himbaechel_helpers.h
|
himbaechel_helpers.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_nextpnr_architecture(${family}
|
if (HIMBAECHEL_SPLIT)
|
||||||
CORE_SOURCES ${SOURCES}
|
|
||||||
|
function(add_nextpnr_himbaechel_microarchitecture microtarget)
|
||||||
|
cmake_parse_arguments(arg "" "" "CORE_SOURCES;TEST_SOURCES" ${ARGN})
|
||||||
|
|
||||||
|
list(TRANSFORM arg_CORE_SOURCES PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||||
|
list(TRANSFORM arg_TEST_SOURCES PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||||
|
|
||||||
|
add_nextpnr_architecture(himbaechel-${microtarget}
|
||||||
|
CORE_SOURCES ${HIMBAECHEL_SOURCES}
|
||||||
|
MAIN_SOURCE main.cc
|
||||||
|
CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/himbaechel
|
||||||
|
CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(nextpnr-himbaechel-${microtarget}-core INTERFACE ${arg_CORE_SOURCES})
|
||||||
|
|
||||||
|
if (BUILD_TESTS)
|
||||||
|
target_sources(nextpnr-himbaechel-${microtarget}-test PRIVATE ${arg_TEST_SOURCES})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
add_nextpnr_architecture(himbaechel
|
||||||
|
CORE_SOURCES ${HIMBAECHEL_SOURCES}
|
||||||
MAIN_SOURCE main.cc
|
MAIN_SOURCE main.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,6 +58,8 @@ function(add_nextpnr_himbaechel_microarchitecture microtarget)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
set(HIMBAECHEL_UARCHES example gowin xilinx ng-ultra)
|
set(HIMBAECHEL_UARCHES example gowin xilinx ng-ultra)
|
||||||
|
|
||||||
set(HIMBAECHEL_UARCH "" CACHE STRING "Microarchitectures for nextpnr-himbaechel build")
|
set(HIMBAECHEL_UARCH "" CACHE STRING "Microarchitectures for nextpnr-himbaechel build")
|
||||||
|
Loading…
Reference in New Issue
Block a user