diff options
author | David Shah <dave@ds0.me> | 2019-09-19 15:57:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-19 15:57:23 +0100 |
commit | f8719a5717e19511d57fa880ed7b623719b8af49 (patch) | |
tree | 81e4e35abbf666a5242af0af440aa9c368d80f44 | |
parent | c2299c8972e0cd22641d7d3b8e0bf7c19a42c3cb (diff) | |
parent | 2f9b04fd5642fcb1346b51d3a63367c09fc61486 (diff) | |
download | nextpnr-f8719a5717e19511d57fa880ed7b623719b8af49.tar.gz nextpnr-f8719a5717e19511d57fa880ed7b623719b8af49.tar.bz2 nextpnr-f8719a5717e19511d57fa880ed7b623719b8af49.zip |
Merge pull request #330 from zeldin/bba
bba: Default to native endian in bbasm
-rw-r--r-- | bba/bba.cmake | 8 | ||||
-rw-r--r-- | bba/main.cc | 9 | ||||
-rw-r--r-- | ecp5/family.cmake | 11 | ||||
-rw-r--r-- | ice40/family.cmake | 11 |
4 files changed, 28 insertions, 11 deletions
diff --git a/bba/bba.cmake b/bba/bba.cmake index 3e094277..a6995ca3 100644 --- a/bba/bba.cmake +++ b/bba/bba.cmake @@ -11,3 +11,11 @@ ENDIF(NOT CMAKE_CROSSCOMPILING) IF(NOT CMAKE_CROSSCOMPILING) EXPORT(TARGETS bbasm FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake ) ENDIF(NOT CMAKE_CROSSCOMPILING) + +include(TestBigEndian) +TEST_BIG_ENDIAN(IS_BIG_ENDIAN) +if(IS_BIG_ENDIAN) + set(BBASM_ENDIAN_FLAG "--be") +else() + set(BBASM_ENDIAN_FLAG "--le") +endif() diff --git a/bba/main.cc b/bba/main.cc index 32a68c63..d4d16e12 100644 --- a/bba/main.cc +++ b/bba/main.cc @@ -70,7 +70,7 @@ int main(int argc, char **argv) { bool debug = false; bool verbose = false; - bool bigEndian = false; + bool bigEndian; bool writeC = false; char buffer[512]; @@ -81,6 +81,7 @@ int main(int argc, char **argv) options.add_options()("verbose,v", "verbose output"); options.add_options()("debug,d", "debug output"); options.add_options()("be,b", "big endian"); + options.add_options()("le,l", "little 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); @@ -106,6 +107,12 @@ int main(int argc, char **argv) debug = true; if (vm.count("be")) bigEndian = true; + else if (vm.count("le")) + bigEndian = false; + else { + printf("Endian parameter is mandatory\n"); + exit(-1); + } if (vm.count("c")) writeC = true; diff --git a/ecp5/family.cmake b/ecp5/family.cmake index ec857569..a1043762 100644 --- a/ecp5/family.cmake +++ b/ecp5/family.cmake @@ -22,7 +22,8 @@ if (NOT EXTERNAL_CHIPDB) set(DB_PY ${CMAKE_CURRENT_SOURCE_DIR}/ecp5/trellis_import.py) file(MAKE_DIRECTORY ecp5/chipdbs/) - add_library(ecp5_chipdb OBJECT ecp5/chipdbs/) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ecp5/chipdbs/) + add_library(ecp5_chipdb OBJECT ${CMAKE_CURRENT_BINARY_DIR}/ecp5/chipdbs/) target_compile_definitions(ecp5_chipdb PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family}) target_include_directories(ecp5_chipdb PRIVATE ${family}/) @@ -37,7 +38,7 @@ if (NOT EXTERNAL_CHIPDB) 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_DB ${CMAKE_CURRENT_BINARY_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} @@ -45,7 +46,7 @@ if (NOT EXTERNAL_CHIPDB) DEPENDS ${DB_PY} ${PREV_DEV_CC_BBA_DB} ) add_custom_command(OUTPUT ${DEV_CC_DB} - COMMAND bbasm ${DEV_CC_BBA_DB} ${DEV_CC_DB} + COMMAND bbasm ${BBASM_ENDIAN_FLAG} ${DEV_CC_BBA_DB} ${DEV_CC_DB} DEPENDS bbasm ${DEV_CC_BBA_DB} ) if (SERIALIZE_CHIPDB) @@ -61,7 +62,7 @@ if (NOT EXTERNAL_CHIPDB) 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_DB ${CMAKE_CURRENT_BINARY_DIR}/ecp5/chipdbs/chipdb-${dev}.cc) 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} @@ -70,7 +71,7 @@ if (NOT EXTERNAL_CHIPDB) 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 bbasm --c ${BBASM_ENDIAN_FLAG} ${DEV_CC_BBA_DB} ${DEV_CC_DB}.new COMMAND mv ${DEV_CC_DB}.new ${DEV_CC_DB} DEPENDS bbasm ${DEV_CC_BBA_DB} ) diff --git a/ice40/family.cmake b/ice40/family.cmake index 6c46f459..8b2c4385 100644 --- a/ice40/family.cmake +++ b/ice40/family.cmake @@ -12,7 +12,8 @@ if (NOT EXTERNAL_CHIPDB) set(ICEBOX_ROOT "/usr/local/share/icebox" CACHE STRING "icebox location root") file(MAKE_DIRECTORY ice40/chipdbs/) - add_library(ice40_chipdb OBJECT ice40/chipdbs/) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ice40/chipdbs/) + add_library(ice40_chipdb OBJECT ${CMAKE_CURRENT_BINARY_DIR}/ice40/chipdbs/) target_compile_definitions(ice40_chipdb PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family}) target_include_directories(ice40_chipdb PRIVATE ${family}/) @@ -36,7 +37,7 @@ if (NOT EXTERNAL_CHIPDB) endif() set(DEV_TXT_DB ${ICEBOX_ROOT}/chipdb-${dev}.txt) set(DEV_CC_BBA_DB ${CMAKE_CURRENT_SOURCE_DIR}/ice40/chipdbs/chipdb-${dev}.bba) - set(DEV_CC_DB ${CMAKE_CURRENT_SOURCE_DIR}/ice40/chipdbs/chipdb-${dev}.bin) + set(DEV_CC_DB ${CMAKE_CURRENT_BINARY_DIR}/ice40/chipdbs/chipdb-${dev}.bin) 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} @@ -44,7 +45,7 @@ if (NOT EXTERNAL_CHIPDB) 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} + COMMAND bbasm ${BBASM_ENDIAN_FLAG} ${DEV_CC_BBA_DB} ${DEV_CC_DB} DEPENDS bbasm ${DEV_CC_BBA_DB} ) if (SERIALIZE_CHIPDB) @@ -75,7 +76,7 @@ if (NOT EXTERNAL_CHIPDB) endif() set(DEV_TXT_DB ${ICEBOX_ROOT}/chipdb-${dev}.txt) set(DEV_CC_BBA_DB ${CMAKE_CURRENT_SOURCE_DIR}/ice40/chipdbs/chipdb-${dev}.bba) - set(DEV_CC_DB ${CMAKE_CURRENT_SOURCE_DIR}/ice40/chipdbs/chipdb-${dev}.cc) + set(DEV_CC_DB ${CMAKE_CURRENT_BINARY_DIR}/ice40/chipdbs/chipdb-${dev}.cc) 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} @@ -84,7 +85,7 @@ if (NOT EXTERNAL_CHIPDB) 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 bbasm --c ${BBASM_ENDIAN_FLAG} ${DEV_CC_BBA_DB} ${DEV_CC_DB}.new COMMAND mv ${DEV_CC_DB}.new ${DEV_CC_DB} DEPENDS bbasm ${DEV_CC_BBA_DB} ) |