From 9affda5626e8207952076b8b12d2981e4bc8533e Mon Sep 17 00:00:00 2001 From: David Shah Date: Thu, 15 Oct 2020 12:10:02 +0100 Subject: nexus: Build and embed chipdb automatically Signed-off-by: David Shah --- nexus/CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 nexus/CMakeLists.txt (limited to 'nexus/CMakeLists.txt') diff --git a/nexus/CMakeLists.txt b/nexus/CMakeLists.txt new file mode 100644 index 00000000..30796cfc --- /dev/null +++ b/nexus/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.5) +project(chipdb-nexus NONE) + +set(ALL_NEXUS_FAMILIES LIFCL) + +# NOTE: Unlike iCE40 and ECP5; one database can cover all densities of a given family + +set(NEXUS_FAMILIES ${ALL_NEXUS_FAMILIES} CACHE STRING + "Include support for these Nexus families (available: ${ALL_NEXUS_FAMILIES})") +message(STATUS "Enabled Nexus families: ${NEXUS_FAMILIES}") + +if(DEFINED NEXUS_CHIPDB) + add_custom_target(chipdb-nexus-bbas ALL) +else() + # shared among all families + set(OXIDE_ROOT "" CACHE STRING + "prjoxide root folder") + message(STATUS "prjoxide root folder: ${OXIDE_ROOT}") + + set(all_device_bbas) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chipdb) + foreach(subfamily ${NEXUS_FAMILIES}) + if(NOT subfamily IN_LIST ALL_NEXUS_FAMILIES) + message(FATAL_ERROR "${subfamily} is not a supported Nexus family") + endif() + + set(family_bba chipdb/chipdb-${subfamily}.bba) + set(BBA_TOOL ${OXIDE_ROOT}/libprjoxide/target/release/oxide_bbaexport) + add_custom_command( + OUTPUT ${family_bba} + COMMAND + ${BBA_TOOL} ${subfamily} ${CMAKE_CURRENT_SOURCE_DIR}/constids.inc ${family_bba}.new + # atomically update + COMMAND ${CMAKE_COMMAND} -E rename ${family_bba}.new ${family_bba} + DEPENDS + ${BBA_TOOL} + ${CMAKE_CURRENT_SOURCE_DIR}/constids.inc + ${CMAKE_CURRENT_SOURCE_DIR}/bba_version.inc + ${PREVIOUS_CHIPDB_TARGET} + VERBATIM) + list(APPEND all_device_bbas ${family_bba}) + if(SERIALIZE_CHIPDBS) + set(PREVIOUS_CHIPDB_TARGET ${CMAKE_CURRENT_BINARY_DIR}/${family_bba}) + endif() + endforeach() + + add_custom_target(chipdb-nexus-bbas ALL DEPENDS ${all_device_bbas}) + + get_directory_property(has_parent PARENT_DIRECTORY) + if(has_parent) + set(NEXUS_CHIPDB ${CMAKE_CURRENT_BINARY_DIR}/chipdb PARENT_SCOPE) + # serialize chipdb build across multiple architectures + set(PREVIOUS_CHIPDB_TARGET chipdb-nexus-bbas PARENT_SCOPE) + else() + message(STATUS "Build nextpnr with -DNEXUS_CHIPDB=${CMAKE_CURRENT_BINARY_DIR}/chipdb") + endif() +endif() -- cgit v1.2.3