Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Himbaechel Gowin build system improvements #1204

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion himbaechel/uarch/gowin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,24 @@ find_package(Python3 3.5 REQUIRED COMPONENTS Interpreter)
set(ALL_HIMBAECHEL_GOWIN_DEVICES GW1N-1 GW1NZ-1 GW1NS-2 GW1N-4 GW1N-9 GW1N-9C GW1NS-4 GW2A-18 GW2A-18C)
set(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_CURRENT_BINARY_DIR}/chipdb)
foreach(device ${HIMBAECHEL_GOWIN_DEVICES})
Expand All @@ -19,7 +35,7 @@ foreach(device ${HIMBAECHEL_GOWIN_DEVICES})
set(device_bin chipdb/chipdb-${device}.bin)
add_custom_command(
OUTPUT ${device_bin}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gowin_arch_gen.py -d ${device} -o ${device_bba}
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}
Expand Down