diff options
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | bba/main.cc | 29 | ||||
-rw-r--r-- | ecp5/family.cmake | 20 | ||||
-rw-r--r-- | ice40/family.cmake | 50 | ||||
-rw-r--r-- | ice40/pcf.cc | 5 |
5 files changed, 70 insertions, 43 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ade76d60..9ec078e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ option(USE_OPENMP "Use OpenMP to accelerate analytic placer" OFF) option(COVERAGE "Add code coverage info" OFF) option(STATIC_BUILD "Create static build" OFF) option(EXTERNAL_CHIPDB "Create build with pre-built chipdb binaries" OFF) +option(SERIALIZE_CHIPDB "Never build chipdb in parallel to reduce peak memory use" ON) set(link_param "") if (STATIC_BUILD) @@ -209,7 +210,7 @@ include(bba/bba.cmake) foreach (family ${ARCH}) message(STATUS "Configuring architecture : ${family}") string(TOUPPER ${family} ufamily) - aux_source_directory(${family}/ ${ufamily}_FILES) + aux_source_directory(${family}/ ${ufamily}_FILES) if (BUILD_GUI) add_subdirectory(gui ${CMAKE_CURRENT_BINARY_DIR}/generated/gui/${family} EXCLUDE_FROM_ALL) @@ -219,14 +220,14 @@ foreach (family ${ARCH}) add_executable(nextpnr-${family} ${COMMON_FILES} ${${ufamily}_FILES}) install(TARGETS nextpnr-${family} RUNTIME DESTINATION bin) target_compile_definitions(nextpnr-${family} PRIVATE MAIN_EXECUTABLE) - + # Add any new per-architecture targets here if (BUILD_TESTS) if (COVERAGE) APPEND_COVERAGE_COMPILER_FLAGS() set(COVERAGE_LCOV_EXCLUDES '/usr/include/*' '3rdparty/*' 'generated/*' 'bba/*' 'tests/*') SETUP_TARGET_FOR_COVERAGE_LCOV( - NAME ${family}-coverage + NAME ${family}-coverage EXECUTABLE nextpnr-${family}-test DEPENDENCIES nextpnr-${family}-test ) @@ -247,7 +248,7 @@ foreach (family ${ARCH}) # Set ${family_targets} to the list of targets being build for this family set(family_targets nextpnr-${family}) - + if (BUILD_TESTS) set(family_targets ${family_targets} nextpnr-${family}-test) endif() diff --git a/bba/main.cc b/bba/main.cc index 263cf39e..d3c81445 100644 --- a/bba/main.cc +++ b/bba/main.cc @@ -77,10 +77,11 @@ int main(int argc, char **argv) namespace po = boost::program_options; po::positional_options_description pos; po::options_description options("Allowed options"); - options.add_options()("v", "verbose output"); - options.add_options()("d", "debug output"); - options.add_options()("b", "big endian"); - options.add_options()("c", "write c strings"); + options.add_options()("help,h", "verbose output"); + options.add_options()("verbose,v", "verbose output"); + options.add_options()("debug,d", "debug output"); + options.add_options()("be,b", "big endian"); + options.add_options()("c,c", "write c strings"); options.add_options()("files", po::value<std::vector<std::string>>(), "file parameters"); pos.add("files", -1); @@ -95,11 +96,15 @@ int main(int argc, char **argv) std::cout << e.what() << "\n"; return 1; } - if (vm.count("v")) + if (vm.count("help")) { + std::cout << options; + return 0; + } + if (vm.count("verbose")) verbose = true; - if (vm.count("d")) + if (vm.count("debug")) debug = true; - if (vm.count("b")) + if (vm.count("be")) bigEndian = true; if (vm.count("c")) writeC = true; @@ -181,10 +186,12 @@ int main(int argc, char **argv) if (cmd == "str") { const char *value = skipWhitespace(strtok(nullptr, "\r\n")); - char terminator[2] = {*value, 0}; - assert(terminator[0] != 0); - value = strtok((char *)value + 1, terminator); - const char *comment = skipWhitespace(strtok(nullptr, "\r\n")); + assert(*value != 0); + char *end = strchr((char *)value + 1, *value); + assert(end != nullptr); + *end = 0; + value += 1; + const char *comment = skipWhitespace(strtok(end+1, "\r\n")); std::string label = std::string("str:") + value; Stream &s = streams.at(streamStack.back()); if (labelIndex.count(label) == 0) { diff --git a/ecp5/family.cmake b/ecp5/family.cmake index ca7dc9e9..596f0924 100644 --- a/ecp5/family.cmake +++ b/ecp5/family.cmake @@ -35,26 +35,31 @@ if (NOT EXTERNAL_CHIPDB) if (MSVC) target_sources(ecp5_chipdb PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ecp5/resource/embed.cc) set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ecp5/resources/chipdb.rc PROPERTIES LANGUAGE RC) + set(PREV_DEV_CC_BBA_DB) foreach (dev ${devices}) set(DEV_CC_DB ${CMAKE_CURRENT_SOURCE_DIR}/ecp5/chipdbs/chipdb-${dev}.bin) set(DEV_CC_BBA_DB ${CMAKE_CURRENT_SOURCE_DIR}/ecp5/chipdbs/chipdb-${dev}.bba) set(DEV_CONSTIDS_INC ${CMAKE_CURRENT_SOURCE_DIR}/ecp5/constids.inc) add_custom_command(OUTPUT ${DEV_CC_BBA_DB} COMMAND ${ENV_CMD} python3 ${DB_PY} -p ${DEV_CONSTIDS_INC} ${dev} > ${DEV_CC_BBA_DB} - DEPENDS ${DB_PY} + DEPENDS ${DB_PY} ${PREV_DEV_CC_BBA_DB} ) add_custom_command(OUTPUT ${DEV_CC_DB} COMMAND bbasm ${DEV_CC_BBA_DB} ${DEV_CC_DB} DEPENDS bbasm ${DEV_CC_BBA_DB} ) + if (SERIALIZE_CHIPDB) + set(PREV_DEV_CC_BBA_DB ${DEV_CC_BBA_DB}) + endif() target_sources(ecp5_chipdb PRIVATE ${DEV_CC_DB}) set_source_files_properties(${DEV_CC_DB} PROPERTIES HEADER_FILE_ONLY TRUE) foreach (target ${family_targets}) target_sources(${target} PRIVATE $<TARGET_OBJECTS:ecp5_chipdb> ${CMAKE_CURRENT_SOURCE_DIR}/ecp5/resource/chipdb.rc) - endforeach (target) - endforeach (dev) + endforeach() + endforeach() else() target_compile_options(ecp5_chipdb PRIVATE -g0 -O0 -w) + set(PREV_DEV_CC_BBA_DB) foreach (dev ${devices}) set(DEV_CC_DB ${CMAKE_CURRENT_SOURCE_DIR}/ecp5/chipdbs/chipdb-${dev}.cc) set(DEV_CC_BBA_DB ${CMAKE_CURRENT_SOURCE_DIR}/ecp5/chipdbs/chipdb-${dev}.bba) @@ -62,17 +67,20 @@ if (NOT EXTERNAL_CHIPDB) add_custom_command(OUTPUT ${DEV_CC_BBA_DB} COMMAND ${ENV_CMD} python3 ${DB_PY} -p ${DEV_CONSTIDS_INC} ${dev} > ${DEV_CC_BBA_DB}.new COMMAND mv ${DEV_CC_BBA_DB}.new ${DEV_CC_BBA_DB} - DEPENDS ${DB_PY} + DEPENDS ${DB_PY} ${PREV_DEV_CC_BBA_DB} ) add_custom_command(OUTPUT ${DEV_CC_DB} COMMAND bbasm --c ${DEV_CC_BBA_DB} ${DEV_CC_DB}.new COMMAND mv ${DEV_CC_DB}.new ${DEV_CC_DB} DEPENDS bbasm ${DEV_CC_BBA_DB} ) + if (SERIALIZE_CHIPDB) + set(PREV_DEV_CC_BBA_DB ${DEV_CC_BBA_DB}) + endif() target_sources(ecp5_chipdb PRIVATE ${DEV_CC_DB}) foreach (target ${family_targets}) target_sources(${target} PRIVATE $<TARGET_OBJECTS:ecp5_chipdb>) - endforeach (target) - endforeach (dev) + endforeach() + endforeach() endif() endif() diff --git a/ice40/family.cmake b/ice40/family.cmake index e1fcec16..6c46f459 100644 --- a/ice40/family.cmake +++ b/ice40/family.cmake @@ -1,5 +1,5 @@ if (NOT EXTERNAL_CHIPDB) - if(ICE40_HX1K_ONLY) + if (ICE40_HX1K_ONLY) set(devices 1k) foreach (target ${family_targets}) target_compile_definitions(${target} PRIVATE ICE40_HX1K_ONLY=1) @@ -19,6 +19,7 @@ if (NOT EXTERNAL_CHIPDB) if (MSVC) target_sources(ice40_chipdb PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ice40/resource/embed.cc) set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ice40/resources/chipdb.rc PROPERTIES LANGUAGE RC) + set(PREV_DEV_CC_BBA_DB) foreach (dev ${devices}) if (dev STREQUAL "5k") set(OPT_FAST "") @@ -26,7 +27,7 @@ if (NOT EXTERNAL_CHIPDB) elseif (dev STREQUAL "u4k") set(OPT_FAST "") set(OPT_SLOW --slow ${ICEBOX_ROOT}/timings_u4k.txt) - elseif(dev STREQUAL "384") + elseif (dev STREQUAL "384") set(OPT_FAST "") set(OPT_SLOW --slow ${ICEBOX_ROOT}/timings_lp384.txt) else() @@ -39,21 +40,25 @@ if (NOT EXTERNAL_CHIPDB) set(DEV_CONSTIDS_INC ${CMAKE_CURRENT_SOURCE_DIR}/ice40/constids.inc) set(DEV_GFXH ${CMAKE_CURRENT_SOURCE_DIR}/ice40/gfx.h) add_custom_command(OUTPUT ${DEV_CC_BBA_DB} - COMMAND ${PYTHON_EXECUTABLE} ${DB_PY} -p ${DEV_CONSTIDS_INC} -g ${DEV_GFXH} ${OPT_FAST} ${OPT_SLOW} ${DEV_TXT_DB} > ${DEV_CC_BBA_DB} - DEPENDS ${DEV_CONSTIDS_INC} ${DEV_GFXH} ${DEV_TXT_DB} ${DB_PY} - ) + COMMAND ${PYTHON_EXECUTABLE} ${DB_PY} -p ${DEV_CONSTIDS_INC} -g ${DEV_GFXH} ${OPT_FAST} ${OPT_SLOW} ${DEV_TXT_DB} > ${DEV_CC_BBA_DB} + DEPENDS ${DEV_CONSTIDS_INC} ${DEV_GFXH} ${DEV_TXT_DB} ${DB_PY} ${PREV_DEV_CC_BBA_DB} + ) add_custom_command(OUTPUT ${DEV_CC_DB} - COMMAND bbasm ${DEV_CC_BBA_DB} ${DEV_CC_DB} - DEPENDS bbasm ${DEV_CC_BBA_DB} - ) + COMMAND bbasm ${DEV_CC_BBA_DB} ${DEV_CC_DB} + DEPENDS bbasm ${DEV_CC_BBA_DB} + ) + if (SERIALIZE_CHIPDB) + set(PREV_DEV_CC_BBA_DB ${DEV_CC_BBA_DB}) + endif() target_sources(ice40_chipdb PRIVATE ${DEV_CC_DB}) set_source_files_properties(${DEV_CC_DB} PROPERTIES HEADER_FILE_ONLY TRUE) foreach (target ${family_targets}) target_sources(${target} PRIVATE $<TARGET_OBJECTS:ice40_chipdb> ${CMAKE_CURRENT_SOURCE_DIR}/ice40/resource/chipdb.rc) - endforeach (target) - endforeach (dev) + endforeach() + endforeach() else() target_compile_options(ice40_chipdb PRIVATE -g0 -O0 -w) + set(PREV_DEV_CC_BBA_DB) foreach (dev ${devices}) if (dev STREQUAL "5k") set(OPT_FAST "") @@ -61,7 +66,7 @@ if (NOT EXTERNAL_CHIPDB) elseif (dev STREQUAL "u4k") set(OPT_FAST "") set(OPT_SLOW --slow ${ICEBOX_ROOT}/timings_u4k.txt) - elseif(dev STREQUAL "384") + elseif (dev STREQUAL "384") set(OPT_FAST "") set(OPT_SLOW --slow ${ICEBOX_ROOT}/timings_lp384.txt) else() @@ -74,19 +79,22 @@ if (NOT EXTERNAL_CHIPDB) set(DEV_CONSTIDS_INC ${CMAKE_CURRENT_SOURCE_DIR}/ice40/constids.inc) set(DEV_GFXH ${CMAKE_CURRENT_SOURCE_DIR}/ice40/gfx.h) add_custom_command(OUTPUT ${DEV_CC_BBA_DB} - COMMAND ${PYTHON_EXECUTABLE} ${DB_PY} -p ${DEV_CONSTIDS_INC} -g ${DEV_GFXH} ${OPT_FAST} ${OPT_SLOW} ${DEV_TXT_DB} > ${DEV_CC_BBA_DB}.new - COMMAND mv ${DEV_CC_BBA_DB}.new ${DEV_CC_BBA_DB} - DEPENDS ${DEV_CONSTIDS_INC} ${DEV_GFXH} ${DEV_TXT_DB} ${DB_PY} - ) + COMMAND ${PYTHON_EXECUTABLE} ${DB_PY} -p ${DEV_CONSTIDS_INC} -g ${DEV_GFXH} ${OPT_FAST} ${OPT_SLOW} ${DEV_TXT_DB} > ${DEV_CC_BBA_DB}.new + COMMAND mv ${DEV_CC_BBA_DB}.new ${DEV_CC_BBA_DB} + DEPENDS ${DEV_CONSTIDS_INC} ${DEV_GFXH} ${DEV_TXT_DB} ${DB_PY} ${PREV_DEV_CC_BBA_DB} + ) add_custom_command(OUTPUT ${DEV_CC_DB} - COMMAND bbasm --c ${DEV_CC_BBA_DB} ${DEV_CC_DB}.new - COMMAND mv ${DEV_CC_DB}.new ${DEV_CC_DB} - DEPENDS bbasm ${DEV_CC_BBA_DB} - ) + COMMAND bbasm --c ${DEV_CC_BBA_DB} ${DEV_CC_DB}.new + COMMAND mv ${DEV_CC_DB}.new ${DEV_CC_DB} + DEPENDS bbasm ${DEV_CC_BBA_DB} + ) + if (SERIALIZE_CHIPDB) + set(PREV_DEV_CC_BBA_DB ${DEV_CC_BBA_DB}) + endif() target_sources(ice40_chipdb PRIVATE ${DEV_CC_DB}) foreach (target ${family_targets}) target_sources(${target} PRIVATE $<TARGET_OBJECTS:ice40_chipdb>) - endforeach (target) - endforeach (dev) + endforeach() + endforeach() endif() endif() diff --git a/ice40/pcf.cc b/ice40/pcf.cc index 91935bee..a854a780 100644 --- a/ice40/pcf.cc +++ b/ice40/pcf.cc @@ -77,8 +77,11 @@ bool apply_pcf(Context *ctx, std::string filename, std::istream &in) } args_end++; } - if (args_end >= words.size() - 1) + if (args_end > words.size() - 2) log_error("expected PCF syntax 'set_io cell pin' (on line %d)\n", lineno); + else if (args_end < words.size() - 2 && !nowarn) + log_warning("Ignoring trailing PCF settings (on line %d)\n", lineno); + std::string cell = words.at(args_end); std::string pin = words.at(args_end + 1); auto fnd_cell = ctx->cells.find(ctx->id(cell)); |