From 82ec1be31f2a13bca04cf1a6b69789c9cee0e535 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 23 Jun 2018 14:32:18 +0200 Subject: [PATCH] Added BUILD_GUI, BUILD_PYTHON and BUILD_TESTS cmake options, --- CMakeLists.txt | 160 +++++++++++++++++++++++++++-------------- common/emb.cc | 3 + common/handle_error.cc | 4 ++ common/pybindings.cc | 4 ++ dummy/main.cc | 29 ++++++-- dummy/pybindings.cc | 4 ++ gui/basewindow.cc | 5 ++ gui/designwidget.cc | 1 - gui/pythontab.cc | 3 + gui/pythontab.h | 3 + ice40/main.cc | 30 ++++++-- ice40/pybindings.cc | 4 ++ tests/ice40/hx1k.cc | 44 ++++++------ tests/ice40/hx8k.cc | 44 ++++++------ tests/ice40/lp1k.cc | 44 ++++++------ tests/ice40/lp384.cc | 44 ++++++------ tests/ice40/lp8k.cc | 44 ++++++------ tests/ice40/up5k.cc | 44 ++++++------ 18 files changed, 315 insertions(+), 199 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b05d296..5d41fcbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,11 @@ # TODO: sensible minimum CMake version cmake_minimum_required(VERSION 3.3) project(nextpnr) + +option(BUILD_GUI "Build GUI" ON) +option(BUILD_PYTHON "Build Python Integration" ON) +option(BUILD_TESTS "Build GUI" OFF) + # List of families to build set(FAMILIES dummy ice40) set(CMAKE_CXX_STANDARD 11) @@ -9,15 +14,24 @@ set(CMAKE_CXX_FLAGS_RELEASE "-Wall -fPIC -O3 -g") set(CMAKE_DEFIN) # List of Boost libraries to include set(boost_libs filesystem thread program_options) -# TODO: sensible minimum Python version -find_package(PythonInterp 3.5 REQUIRED) -find_package(PythonLibs 3.5 REQUIRED) + +if (BUILD_PYTHON) + # TODO: sensible minimum Python version + find_package(PythonInterp 3.5 REQUIRED) + find_package(PythonLibs 3.5 REQUIRED) +else() + add_definitions("-DNO_PYTHON") +endif() find_package(Boost REQUIRED COMPONENTS ${boost_libs}) -# Find the Qt5 libraries -find_package(Qt5 COMPONENTS Core Widgets OpenGL REQUIRED) -find_package(OpenGL REQUIRED) +if (BUILD_GUI) + # Find the Qt5 libraries + find_package(Qt5 COMPONENTS Core Widgets OpenGL REQUIRED) + find_package(OpenGL REQUIRED) +else() + add_definitions("-DNO_GUI") +endif() # Get the latest abbreviated commit hash of the working branch execute_process( @@ -27,57 +41,64 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -add_subdirectory(3rdparty/googletest/googletest generated/3rdparty/googletest EXCLUDE_FROM_ALL) -enable_testing() +if (BUILD_TESTS) + add_subdirectory(3rdparty/googletest/googletest generated/3rdparty/googletest EXCLUDE_FROM_ALL) + enable_testing() +endif() -add_subdirectory(3rdparty/QtPropertyBrowser generated/3rdparty/QtPropertyBrowser) +if (BUILD_GUI) + add_subdirectory(3rdparty/QtPropertyBrowser generated/3rdparty/QtPropertyBrowser) +endif() add_definitions("-DGIT_COMMIT_HASH=${GIT_COMMIT_HASH}") + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/common/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/generated/version.h ) -# Find Boost::Python of a suitable version in a cross-platform way -# Some distributions (Arch) call it libboost_python3, others such as Ubuntu -# call it libboost_python35. In the latter case we must consider all minor versions -# Original source: https://github.com/BVLC/caffe/blob/master/cmake/Dependencies.cmake#L148 -set(version ${PYTHONLIBS_VERSION_STRING}) - -STRING(REGEX REPLACE "[^0-9]" "" boost_py_version ${version}) -find_package(Boost COMPONENTS "python-py${boost_py_version}" ${boost_libs}) -set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND}) - -while (NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND) - STRING(REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version}) +if (BUILD_PYTHON) + # Find Boost::Python of a suitable version in a cross-platform way + # Some distributions (Arch) call it libboost_python3, others such as Ubuntu + # call it libboost_python35. In the latter case we must consider all minor versions + # Original source: https://github.com/BVLC/caffe/blob/master/cmake/Dependencies.cmake#L148 + set(version ${PYTHONLIBS_VERSION_STRING}) STRING(REGEX REPLACE "[^0-9]" "" boost_py_version ${version}) find_package(Boost COMPONENTS "python-py${boost_py_version}" ${boost_libs}) set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND}) - STRING(REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version}) - if ("${has_more_version}" STREQUAL "") - break() - endif () -endwhile () + while (NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND) + STRING(REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version}) -if (NOT Boost_PYTHON_FOUND) - find_package(Boost COMPONENTS python3 ${boost_libs}) - if ("${Boost_LIBRARIES}" MATCHES ".*(python|PYTHON).*" ) - set(Boost_PYTHON_FOUND TRUE) - endif () -endif () + STRING(REGEX REPLACE "[^0-9]" "" boost_py_version ${version}) + find_package(Boost COMPONENTS "python-py${boost_py_version}" ${boost_libs}) + set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND}) -if (NOT Boost_PYTHON_FOUND) - STRING(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" gentoo_version ${PYTHONLIBS_VERSION_STRING}) - find_package(Boost COMPONENTS python-${gentoo_version} ${boost_libs}) - if ("${Boost_LIBRARIES}" MATCHES ".*(python|PYTHON).*" ) - set(Boost_PYTHON_FOUND TRUE) - endif () -endif () + STRING(REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version}) + if ("${has_more_version}" STREQUAL "") + break() + endif () + endwhile () -if (NOT Boost_PYTHON_FOUND ) - message( FATAL_ERROR "No version of Boost::Python 3.x could be found.") -endif () + if (NOT Boost_PYTHON_FOUND) + find_package(Boost COMPONENTS python3 ${boost_libs}) + if ("${Boost_LIBRARIES}" MATCHES ".*(python|PYTHON).*" ) + set(Boost_PYTHON_FOUND TRUE) + endif () + endif () + + if (NOT Boost_PYTHON_FOUND) + STRING(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" gentoo_version ${PYTHONLIBS_VERSION_STRING}) + find_package(Boost COMPONENTS python-${gentoo_version} ${boost_libs}) + if ("${Boost_LIBRARIES}" MATCHES ".*(python|PYTHON).*" ) + set(Boost_PYTHON_FOUND TRUE) + endif () + endif () + + if (NOT Boost_PYTHON_FOUND ) + message( FATAL_ERROR "No version of Boost::Python 3.x could be found.") + endif () +endif() include_directories(common/ frontend/json ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}) aux_source_directory(common/ COMMON_SRC_FILES) @@ -91,33 +112,58 @@ endif(MINGW) foreach (family ${FAMILIES}) string(TOUPPER ${family} ufamily) - aux_source_directory(${family}/ ${ufamily}_FILES) - aux_source_directory(tests/${family}/ ${ufamily}_TEST_FILES) + aux_source_directory(${family}/ ${ufamily}_FILES) - add_subdirectory(gui generated/gui/${family}) + if (BUILD_GUI) + add_subdirectory(gui generated/gui/${family}) + endif() # Add the CLI binary target add_executable(nextpnr-${family} ${COMMON_FILES} ${${ufamily}_FILES} ) install(TARGETS nextpnr-${family} RUNTIME DESTINATION bin) target_compile_definitions(nextpnr-${family} PRIVATE MAIN_EXECUTABLE) - # Add the importable Python module target - PYTHON_ADD_MODULE(nextpnrpy_${family} EXCLUDE_FROM_ALL ${COMMON_FILES} ${${ufamily}_FILES}) - # Add any new per-architecture targets here + if (BUILD_PYTHON) + # Add the importable Python module target + PYTHON_ADD_MODULE(nextpnrpy_${family} EXCLUDE_FROM_ALL ${COMMON_FILES} ${${ufamily}_FILES}) + endif() - add_executable(nextpnr-${family}-test EXCLUDE_FROM_ALL ${${ufamily}_TEST_FILES} ${COMMON_FILES} ${${ufamily}_FILES}) - target_link_libraries(nextpnr-${family}-test PRIVATE gtest_main) - add_test(${family}-test ${CMAKE_CURRENT_BINARY_DIR}/nextpnr-${family}-test) + # Add any new per-architecture targets here + if (BUILD_TESTS) + aux_source_directory(tests/${family}/ ${ufamily}_TEST_FILES) + + add_executable(nextpnr-${family}-test ${${ufamily}_TEST_FILES} ${COMMON_FILES} ${${ufamily}_FILES}) + target_link_libraries(nextpnr-${family}-test PRIVATE gtest_main) + + add_test(${family}-test ${CMAKE_CURRENT_BINARY_DIR}/nextpnr-${family}-test) + endif() # Set ${family_targets} to the list of targets being build for this family - set(family_targets nextpnr-${family} nextpnrpy_${family} nextpnr-${family}-test) + set(family_targets nextpnr-${family}) + + if (BUILD_TESTS) + set(family_targets ${family_targets} nextpnr-${family}-test) + endif() + + if (BUILD_PYTHON) + set(family_targets ${family_targets} nextpnrpy_${family}) + endif() + # Include the family-specific CMakeFile include(${family}/family.cmake) foreach (target ${family_targets}) # Include family-specific source files to all family targets and set defines appropriately - target_include_directories(${target} PRIVATE ${family}/ generated/ gui/${family}/ gui/) - target_compile_definitions(${target} PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family} ARCH_${ufamily} ARCHNAME=${family} QT_NO_KEYWORDS) - target_link_libraries(${target} LINK_PUBLIC gui_${family} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${GUI_LIBRARY_FILES_${ufamily}}) + target_include_directories(${target} PRIVATE ${family}/ generated/) + target_compile_definitions(${target} PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family} ARCH_${ufamily} ARCHNAME=${family}) + target_link_libraries(${target} LINK_PUBLIC ${Boost_LIBRARIES}) + if (BUILD_PYTHON) + target_link_libraries(${target} LINK_PUBLIC ${PYTHON_LIBRARIES}) + endif() + if (BUILD_GUI) + target_include_directories(${target} PRIVATE gui/${family}/ gui/) + target_compile_definitions(${target} PRIVATE QT_NO_KEYWORDS) + target_link_libraries(${target} LINK_PUBLIC gui_${family} ${GUI_LIBRARY_FILES_${ufamily}}) + endif() endforeach (target) endforeach (family) @@ -133,3 +179,7 @@ add_custom_target( -i ${CLANGFORMAT_FILES} ) + +unset(BUILD_GUI CACHE) +unset(BUILD_PYTHON CACHE) +unset(BUILD_TESTS CACHE) diff --git a/common/emb.cc b/common/emb.cc index 2e3379d5..27c5d6e1 100644 --- a/common/emb.cc +++ b/common/emb.cc @@ -5,6 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // // Blog article: http://mateusz.loskot.net/?p=2819 +#ifndef NO_PYTHON #include "emb.h" #include @@ -136,3 +137,5 @@ void reset_stdout() void append_inittab() { PyImport_AppendInittab("emb", emb::PyInit_emb); } } // namespace emb + +#endif // NO_PYTHON \ No newline at end of file diff --git a/common/handle_error.cc b/common/handle_error.cc index 7076c188..a091f07e 100644 --- a/common/handle_error.cc +++ b/common/handle_error.cc @@ -1,3 +1,5 @@ +#ifndef NO_PYTHON + #include #include #include "nextpnr.h" @@ -61,3 +63,5 @@ std::string parse_python_exception() } NEXTPNR_NAMESPACE_END + +#endif // NO_PYTHON \ No newline at end of file diff --git a/common/pybindings.cc b/common/pybindings.cc index a9c32c1c..b67320a2 100644 --- a/common/pybindings.cc +++ b/common/pybindings.cc @@ -18,6 +18,8 @@ * */ +#ifndef NO_PYTHON + #include "pybindings.h" #include "emb.h" #include "jsonparse.h" @@ -186,3 +188,5 @@ void execute_python_file(const char *python_file) } NEXTPNR_NAMESPACE_END + +#endif // NO_PYTHON \ No newline at end of file diff --git a/dummy/main.cc b/dummy/main.cc index fa1259d4..6b4f9655 100644 --- a/dummy/main.cc +++ b/dummy/main.cc @@ -19,15 +19,20 @@ #ifdef MAIN_EXECUTABLE +#ifndef NO_GUI #include +#include "application.h" +#include "mainwindow.h" +#endif +#ifndef NO_PYTHON +#include "pybindings.h" +#endif #include #include -#include "application.h" #include "log.h" -#include "mainwindow.h" #include "nextpnr.h" -#include "pybindings.h" #include "version.h" +#include USING_NEXTPNR_NAMESPACE @@ -44,12 +49,17 @@ int main(int argc, char *argv[]) options.add_options()("help,h", "show help"); options.add_options()("verbose,v", "verbose output"); options.add_options()("force,f", "keep running after errors"); +#ifndef NO_GUI options.add_options()("gui", "start gui"); +#endif + + po::positional_options_description pos; +#ifndef NO_PYTHON options.add_options()("run", po::value>(), "python file to execute"); - options.add_options()("version,V", "show version"); - po::positional_options_description pos; pos.add("run", -1); +#endif + options.add_options()("version,V", "show version"); po::variables_map vm; try { @@ -85,8 +95,11 @@ int main(int argc, char *argv[]) } Context ctx(ArchArgs{}); + +#ifndef NO_PYTHON init_python(argv[0]); python_export_global("ctx", ctx); +#endif if (vm.count("verbose")) { ctx.verbose = true; @@ -100,13 +113,16 @@ int main(int argc, char *argv[]) ctx.rngseed(vm["seed"].as()); } +#ifndef NO_PYTHON if (vm.count("run")) { std::vector files = vm["run"].as>(); for (auto filename : files) execute_python_file(filename.c_str()); } +#endif +#ifndef NO_GUI if (vm.count("gui")) { Application a(argc, argv); MainWindow w(&ctx); @@ -114,7 +130,10 @@ int main(int argc, char *argv[]) rc = a.exec(); } +#endif +#ifndef NO_PYTHON deinit_python(); +#endif return rc; } catch (log_execution_error_exception) { #if defined(_MSC_VER) diff --git a/dummy/pybindings.cc b/dummy/pybindings.cc index 59bf402f..a2997456 100644 --- a/dummy/pybindings.cc +++ b/dummy/pybindings.cc @@ -18,6 +18,8 @@ * */ +#ifndef NO_PYTHON + #include "pybindings.h" #include "nextpnr.h" @@ -26,3 +28,5 @@ NEXTPNR_NAMESPACE_BEGIN void arch_wrap_python() { class_("ArchArgs"); } NEXTPNR_NAMESPACE_END + +#endif \ No newline at end of file diff --git a/gui/basewindow.cc b/gui/basewindow.cc index ac28e95f..9d99152c 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -27,7 +27,10 @@ #include "jsonparse.h" #include "log.h" #include "mainwindow.h" + +#ifndef NO_PYTHON #include "pythontab.h" +#endif static void initBasenameResource() { Q_INIT_RESOURCE(base); } @@ -70,7 +73,9 @@ BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent) SLOT(writeInfo(std::string))); tabWidget = new QTabWidget(); +#ifndef NO_PYTHON tabWidget->addTab(new PythonTab(), "Python"); +#endif info = new InfoTab(); tabWidget->addTab(info, "Info"); diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 95b76d81..6752b780 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -24,7 +24,6 @@ #include #include #include "fpgaviewwidget.h" -#include "pybindings.h" NEXTPNR_NAMESPACE_BEGIN diff --git a/gui/pythontab.cc b/gui/pythontab.cc index a11059b5..8e8b7be4 100644 --- a/gui/pythontab.cc +++ b/gui/pythontab.cc @@ -16,6 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ + #ifndef NO_PYTHON #include "pythontab.h" #include @@ -138,3 +139,5 @@ void PythonTab::showContextMenu(const QPoint &pt) void PythonTab::clearBuffer() { plainTextEdit->clear(); } NEXTPNR_NAMESPACE_END + +#endif \ No newline at end of file diff --git a/gui/pythontab.h b/gui/pythontab.h index f37381d7..40de0ebe 100644 --- a/gui/pythontab.h +++ b/gui/pythontab.h @@ -20,6 +20,8 @@ #ifndef PYTHONTAB_H #define PYTHONTAB_H +#ifndef NO_PYTHON + #include #include #include @@ -52,5 +54,6 @@ class PythonTab : public QWidget }; NEXTPNR_NAMESPACE_END +#endif // NO_PYTHON #endif // PYTHONTAB_H diff --git a/ice40/main.cc b/ice40/main.cc index e60ce442..00ed660f 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -19,23 +19,27 @@ #ifdef MAIN_EXECUTABLE +#ifndef NO_GUI #include -#include +#include "application.h" +#include "mainwindow.h" +#endif +#ifndef NO_PYTHON +#include "pybindings.h" +#endif + #include #include #include #include -#include "application.h" #include "bitstream.h" #include "design_utils.h" #include "jsonparse.h" #include "log.h" -#include "mainwindow.h" #include "nextpnr.h" #include "pack.h" #include "pcf.h" #include "place_sa.h" -#include "pybindings.h" #include "route.h" #include "timing.h" #include "version.h" @@ -76,13 +80,19 @@ int main(int argc, char *argv[]) options.add_options()("verbose,v", "verbose output"); options.add_options()("debug", "debug output"); options.add_options()("force,f", "keep running after errors"); +#ifndef NO_GUI options.add_options()("gui", "start gui"); +#endif options.add_options()("svg", "dump SVG file"); options.add_options()("pack-only", "pack design only without placement or routing"); + po::positional_options_description pos; +#ifndef NO_PYTHON options.add_options()("run", po::value>(), "python file to execute"); + pos.add("run", -1); +#endif options.add_options()("json", po::value(), "JSON design file to ingest"); options.add_options()("pcf", po::value(), @@ -104,8 +114,6 @@ int main(int argc, char *argv[]) options.add_options()("no-tmdriv", "disable timing-driven placement"); options.add_options()("package", po::value(), "set device package"); - po::positional_options_description pos; - pos.add("run", -1); po::variables_map vm; try { @@ -202,8 +210,11 @@ int main(int argc, char *argv[]) chipArgs.package = vm["package"].as(); Context ctx(chipArgs); + +#ifndef NO_PYTHON init_python(argv[0]); python_export_global("ctx", ctx); +#endif if (vm.count("verbose")) { ctx.verbose = true; @@ -326,13 +337,16 @@ int main(int argc, char *argv[]) write_asc(&ctx, f); } +#ifndef NO_PYTHON if (vm.count("run")) { std::vector files = vm["run"].as>(); for (auto filename : files) execute_python_file(filename.c_str()); } +#endif +#ifndef NO_GUI if (vm.count("gui")) { Application a(argc, argv); MainWindow w(&ctx); @@ -340,7 +354,11 @@ int main(int argc, char *argv[]) rc = a.exec(); } +#endif + +#ifndef NO_PYTHON deinit_python(); +#endif return rc; } catch (log_execution_error_exception) { #if defined(_MSC_VER) diff --git a/ice40/pybindings.cc b/ice40/pybindings.cc index 97eebd3e..2acc5258 100644 --- a/ice40/pybindings.cc +++ b/ice40/pybindings.cc @@ -18,6 +18,8 @@ * */ +#ifndef NO_PYTHON + #include "pybindings.h" #include "nextpnr.h" @@ -84,3 +86,5 @@ void arch_wrap_python() } NEXTPNR_NAMESPACE_END + +#endif // NO_PYTHON \ No newline at end of file diff --git a/tests/ice40/hx1k.cc b/tests/ice40/hx1k.cc index e1734fce..1d212f6a 100644 --- a/tests/ice40/hx1k.cc +++ b/tests/ice40/hx1k.cc @@ -9,23 +9,23 @@ class HX1KTest : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::HX1K; + chipArgs.type = ArchArgs::HX1K; chipArgs.package = "tq144"; - design = new Design(chipArgs); + ctx = new Context(chipArgs); } - virtual void TearDown() { delete design; } + virtual void TearDown() { delete ctx; } - ChipArgs chipArgs; - Design *design; + ArchArgs chipArgs; + Context *ctx; }; TEST_F(HX1KTest, bel_names) { int bel_count = 0; - for (auto bel : design->chip.getBels()) { - auto name = design->chip.getBelName(bel); - ASSERT_EQ(bel, design->chip.getBelByName(name)); + for (auto bel : ctx->getBels()) { + auto name = ctx->getBelName(bel); + ASSERT_EQ(bel, ctx->getBelByName(name)); bel_count++; } ASSERT_EQ(bel_count, 1416); @@ -34,9 +34,9 @@ TEST_F(HX1KTest, bel_names) TEST_F(HX1KTest, wire_names) { int wire_count = 0; - for (auto wire : design->chip.getWires()) { - auto name = design->chip.getWireName(wire); - assert(wire == design->chip.getWireByName(name)); + for (auto wire : ctx->getWires()) { + auto name = ctx->getWireName(wire); + assert(wire == ctx->getWireByName(name)); wire_count++; } ASSERT_EQ(wire_count, 27682); @@ -45,9 +45,9 @@ TEST_F(HX1KTest, wire_names) TEST_F(HX1KTest, pip_names) { int pip_count = 0; - for (auto pip : design->chip.getPips()) { - auto name = design->chip.getPipName(pip); - assert(pip == design->chip.getPipByName(name)); + for (auto pip : ctx->getPips()) { + auto name = ctx->getPipName(pip); + assert(pip == ctx->getPipByName(name)); pip_count++; } ASSERT_EQ(pip_count, 319904); @@ -55,11 +55,11 @@ TEST_F(HX1KTest, pip_names) TEST_F(HX1KTest, uphill_to_downhill) { - for (auto dst : design->chip.getWires()) { - for (auto uphill_pip : design->chip.getPipsUphill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto uphill_pip : ctx->getPipsUphill(dst)) { bool found_downhill = false; - for (auto downhill_pip : design->chip.getPipsDownhill( - design->chip.getPipSrcWire(uphill_pip))) { + for (auto downhill_pip : ctx->getPipsDownhill( + ctx->getPipSrcWire(uphill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_downhill); found_downhill = true; @@ -72,11 +72,11 @@ TEST_F(HX1KTest, uphill_to_downhill) TEST_F(HX1KTest, downhill_to_uphill) { - for (auto dst : design->chip.getWires()) { - for (auto downhill_pip : design->chip.getPipsDownhill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto downhill_pip : ctx->getPipsDownhill(dst)) { bool found_uphill = false; - for (auto uphill_pip : design->chip.getPipsUphill( - design->chip.getPipDstWire(downhill_pip))) { + for (auto uphill_pip : ctx->getPipsUphill( + ctx->getPipDstWire(downhill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_uphill); found_uphill = true; diff --git a/tests/ice40/hx8k.cc b/tests/ice40/hx8k.cc index 201dbdc2..eef5eb7c 100644 --- a/tests/ice40/hx8k.cc +++ b/tests/ice40/hx8k.cc @@ -9,23 +9,23 @@ class HX8KTest : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::HX8K; + chipArgs.type = ArchArgs::HX8K; chipArgs.package = "ct256"; - design = new Design(chipArgs); + ctx = new Context(chipArgs); } - virtual void TearDown() { delete design; } + virtual void TearDown() { delete ctx; } - ChipArgs chipArgs; - Design *design; + ArchArgs chipArgs; + Context *ctx; }; TEST_F(HX8KTest, bel_names) { int bel_count = 0; - for (auto bel : design->chip.getBels()) { - auto name = design->chip.getBelName(bel); - ASSERT_EQ(bel, design->chip.getBelByName(name)); + for (auto bel : ctx->getBels()) { + auto name = ctx->getBelName(bel); + ASSERT_EQ(bel, ctx->getBelByName(name)); bel_count++; } ASSERT_EQ(bel_count, 7968); @@ -34,9 +34,9 @@ TEST_F(HX8KTest, bel_names) TEST_F(HX8KTest, wire_names) { int wire_count = 0; - for (auto wire : design->chip.getWires()) { - auto name = design->chip.getWireName(wire); - assert(wire == design->chip.getWireByName(name)); + for (auto wire : ctx->getWires()) { + auto name = ctx->getWireName(wire); + assert(wire == ctx->getWireByName(name)); wire_count++; } ASSERT_EQ(wire_count, 135174); @@ -45,9 +45,9 @@ TEST_F(HX8KTest, wire_names) TEST_F(HX8KTest, pip_names) { int pip_count = 0; - for (auto pip : design->chip.getPips()) { - auto name = design->chip.getPipName(pip); - assert(pip == design->chip.getPipByName(name)); + for (auto pip : ctx->getPips()) { + auto name = ctx->getPipName(pip); + assert(pip == ctx->getPipByName(name)); pip_count++; } ASSERT_EQ(pip_count, 1652480); @@ -55,11 +55,11 @@ TEST_F(HX8KTest, pip_names) TEST_F(HX8KTest, uphill_to_downhill) { - for (auto dst : design->chip.getWires()) { - for (auto uphill_pip : design->chip.getPipsUphill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto uphill_pip : ctx->getPipsUphill(dst)) { bool found_downhill = false; - for (auto downhill_pip : design->chip.getPipsDownhill( - design->chip.getPipSrcWire(uphill_pip))) { + for (auto downhill_pip : ctx->getPipsDownhill( + ctx->getPipSrcWire(uphill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_downhill); found_downhill = true; @@ -72,11 +72,11 @@ TEST_F(HX8KTest, uphill_to_downhill) TEST_F(HX8KTest, downhill_to_uphill) { - for (auto dst : design->chip.getWires()) { - for (auto downhill_pip : design->chip.getPipsDownhill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto downhill_pip : ctx->getPipsDownhill(dst)) { bool found_uphill = false; - for (auto uphill_pip : design->chip.getPipsUphill( - design->chip.getPipDstWire(downhill_pip))) { + for (auto uphill_pip : ctx->getPipsUphill( + ctx->getPipDstWire(downhill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_uphill); found_uphill = true; diff --git a/tests/ice40/lp1k.cc b/tests/ice40/lp1k.cc index 6afc8c9e..392cf5c6 100644 --- a/tests/ice40/lp1k.cc +++ b/tests/ice40/lp1k.cc @@ -9,23 +9,23 @@ class LP1KTest : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::LP1K; + chipArgs.type = ArchArgs::LP1K; chipArgs.package = "tq144"; - design = new Design(chipArgs); + ctx = new Context(chipArgs); } - virtual void TearDown() { delete design; } + virtual void TearDown() { delete ctx; } - ChipArgs chipArgs; - Design *design; + ArchArgs chipArgs; + Context *ctx; }; TEST_F(LP1KTest, bel_names) { int bel_count = 0; - for (auto bel : design->chip.getBels()) { - auto name = design->chip.getBelName(bel); - ASSERT_EQ(bel, design->chip.getBelByName(name)); + for (auto bel : ctx->getBels()) { + auto name = ctx->getBelName(bel); + ASSERT_EQ(bel, ctx->getBelByName(name)); bel_count++; } ASSERT_EQ(bel_count, 1416); @@ -34,9 +34,9 @@ TEST_F(LP1KTest, bel_names) TEST_F(LP1KTest, wire_names) { int wire_count = 0; - for (auto wire : design->chip.getWires()) { - auto name = design->chip.getWireName(wire); - assert(wire == design->chip.getWireByName(name)); + for (auto wire : ctx->getWires()) { + auto name = ctx->getWireName(wire); + assert(wire == ctx->getWireByName(name)); wire_count++; } ASSERT_EQ(wire_count, 27682); @@ -45,9 +45,9 @@ TEST_F(LP1KTest, wire_names) TEST_F(LP1KTest, pip_names) { int pip_count = 0; - for (auto pip : design->chip.getPips()) { - auto name = design->chip.getPipName(pip); - assert(pip == design->chip.getPipByName(name)); + for (auto pip : ctx->getPips()) { + auto name = ctx->getPipName(pip); + assert(pip == ctx->getPipByName(name)); pip_count++; } ASSERT_EQ(pip_count, 319904); @@ -55,11 +55,11 @@ TEST_F(LP1KTest, pip_names) TEST_F(LP1KTest, uphill_to_downhill) { - for (auto dst : design->chip.getWires()) { - for (auto uphill_pip : design->chip.getPipsUphill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto uphill_pip : ctx->getPipsUphill(dst)) { bool found_downhill = false; - for (auto downhill_pip : design->chip.getPipsDownhill( - design->chip.getPipSrcWire(uphill_pip))) { + for (auto downhill_pip : ctx->getPipsDownhill( + ctx->getPipSrcWire(uphill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_downhill); found_downhill = true; @@ -72,11 +72,11 @@ TEST_F(LP1KTest, uphill_to_downhill) TEST_F(LP1KTest, downhill_to_uphill) { - for (auto dst : design->chip.getWires()) { - for (auto downhill_pip : design->chip.getPipsDownhill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto downhill_pip : ctx->getPipsDownhill(dst)) { bool found_uphill = false; - for (auto uphill_pip : design->chip.getPipsUphill( - design->chip.getPipDstWire(downhill_pip))) { + for (auto uphill_pip : ctx->getPipsUphill( + ctx->getPipDstWire(downhill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_uphill); found_uphill = true; diff --git a/tests/ice40/lp384.cc b/tests/ice40/lp384.cc index 77b82951..f54683f6 100644 --- a/tests/ice40/lp384.cc +++ b/tests/ice40/lp384.cc @@ -9,23 +9,23 @@ class LP384Test : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::LP384; + chipArgs.type = ArchArgs::LP384; chipArgs.package = "qn32"; - design = new Design(chipArgs); + ctx = new Context(chipArgs); } - virtual void TearDown() { delete design; } + virtual void TearDown() { delete ctx; } - ChipArgs chipArgs; - Design *design; + ArchArgs chipArgs; + Context *ctx; }; TEST_F(LP384Test, bel_names) { int bel_count = 0; - for (auto bel : design->chip.getBels()) { - auto name = design->chip.getBelName(bel); - ASSERT_EQ(bel, design->chip.getBelByName(name)); + for (auto bel : ctx->getBels()) { + auto name = ctx->getBelName(bel); + ASSERT_EQ(bel, ctx->getBelByName(name)); bel_count++; } ASSERT_EQ(bel_count, 440); @@ -34,9 +34,9 @@ TEST_F(LP384Test, bel_names) TEST_F(LP384Test, wire_names) { int wire_count = 0; - for (auto wire : design->chip.getWires()) { - auto name = design->chip.getWireName(wire); - assert(wire == design->chip.getWireByName(name)); + for (auto wire : ctx->getWires()) { + auto name = ctx->getWireName(wire); + assert(wire == ctx->getWireByName(name)); wire_count++; } ASSERT_EQ(wire_count, 8294); @@ -45,9 +45,9 @@ TEST_F(LP384Test, wire_names) TEST_F(LP384Test, pip_names) { int pip_count = 0; - for (auto pip : design->chip.getPips()) { - auto name = design->chip.getPipName(pip); - assert(pip == design->chip.getPipByName(name)); + for (auto pip : ctx->getPips()) { + auto name = ctx->getPipName(pip); + assert(pip == ctx->getPipByName(name)); pip_count++; } ASSERT_EQ(pip_count, 86864); @@ -55,11 +55,11 @@ TEST_F(LP384Test, pip_names) TEST_F(LP384Test, uphill_to_downhill) { - for (auto dst : design->chip.getWires()) { - for (auto uphill_pip : design->chip.getPipsUphill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto uphill_pip : ctx->getPipsUphill(dst)) { bool found_downhill = false; - for (auto downhill_pip : design->chip.getPipsDownhill( - design->chip.getPipSrcWire(uphill_pip))) { + for (auto downhill_pip : ctx->getPipsDownhill( + ctx->getPipSrcWire(uphill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_downhill); found_downhill = true; @@ -72,11 +72,11 @@ TEST_F(LP384Test, uphill_to_downhill) TEST_F(LP384Test, downhill_to_uphill) { - for (auto dst : design->chip.getWires()) { - for (auto downhill_pip : design->chip.getPipsDownhill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto downhill_pip : ctx->getPipsDownhill(dst)) { bool found_uphill = false; - for (auto uphill_pip : design->chip.getPipsUphill( - design->chip.getPipDstWire(downhill_pip))) { + for (auto uphill_pip : ctx->getPipsUphill( + ctx->getPipDstWire(downhill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_uphill); found_uphill = true; diff --git a/tests/ice40/lp8k.cc b/tests/ice40/lp8k.cc index 06543fd8..940e1c20 100644 --- a/tests/ice40/lp8k.cc +++ b/tests/ice40/lp8k.cc @@ -9,23 +9,23 @@ class LP8KTest : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::LP8K; + chipArgs.type = ArchArgs::LP8K; chipArgs.package = "ct256"; - design = new Design(chipArgs); + ctx = new Context(chipArgs); } - virtual void TearDown() { delete design; } + virtual void TearDown() { delete ctx; } - ChipArgs chipArgs; - Design *design; + ArchArgs chipArgs; + Context *ctx; }; TEST_F(LP8KTest, bel_names) { int bel_count = 0; - for (auto bel : design->chip.getBels()) { - auto name = design->chip.getBelName(bel); - ASSERT_EQ(bel, design->chip.getBelByName(name)); + for (auto bel : ctx->getBels()) { + auto name = ctx->getBelName(bel); + ASSERT_EQ(bel, ctx->getBelByName(name)); bel_count++; } ASSERT_EQ(bel_count, 7968); @@ -34,9 +34,9 @@ TEST_F(LP8KTest, bel_names) TEST_F(LP8KTest, wire_names) { int wire_count = 0; - for (auto wire : design->chip.getWires()) { - auto name = design->chip.getWireName(wire); - assert(wire == design->chip.getWireByName(name)); + for (auto wire : ctx->getWires()) { + auto name = ctx->getWireName(wire); + assert(wire == ctx->getWireByName(name)); wire_count++; } ASSERT_EQ(wire_count, 135174); @@ -45,9 +45,9 @@ TEST_F(LP8KTest, wire_names) TEST_F(LP8KTest, pip_names) { int pip_count = 0; - for (auto pip : design->chip.getPips()) { - auto name = design->chip.getPipName(pip); - assert(pip == design->chip.getPipByName(name)); + for (auto pip : ctx->getPips()) { + auto name = ctx->getPipName(pip); + assert(pip == ctx->getPipByName(name)); pip_count++; } ASSERT_EQ(pip_count, 1652480); @@ -55,11 +55,11 @@ TEST_F(LP8KTest, pip_names) TEST_F(LP8KTest, uphill_to_downhill) { - for (auto dst : design->chip.getWires()) { - for (auto uphill_pip : design->chip.getPipsUphill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto uphill_pip : ctx->getPipsUphill(dst)) { bool found_downhill = false; - for (auto downhill_pip : design->chip.getPipsDownhill( - design->chip.getPipSrcWire(uphill_pip))) { + for (auto downhill_pip : ctx->getPipsDownhill( + ctx->getPipSrcWire(uphill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_downhill); found_downhill = true; @@ -72,11 +72,11 @@ TEST_F(LP8KTest, uphill_to_downhill) TEST_F(LP8KTest, downhill_to_uphill) { - for (auto dst : design->chip.getWires()) { - for (auto downhill_pip : design->chip.getPipsDownhill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto downhill_pip : ctx->getPipsDownhill(dst)) { bool found_uphill = false; - for (auto uphill_pip : design->chip.getPipsUphill( - design->chip.getPipDstWire(downhill_pip))) { + for (auto uphill_pip : ctx->getPipsUphill( + ctx->getPipDstWire(downhill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_uphill); found_uphill = true; diff --git a/tests/ice40/up5k.cc b/tests/ice40/up5k.cc index 93d5f8a2..f6a58b3a 100644 --- a/tests/ice40/up5k.cc +++ b/tests/ice40/up5k.cc @@ -9,23 +9,23 @@ class UP5KTest : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::UP5K; + chipArgs.type = ArchArgs::UP5K; chipArgs.package = "sg48"; - design = new Design(chipArgs); + ctx = new Context(chipArgs); } - virtual void TearDown() { delete design; } + virtual void TearDown() { delete ctx; } - ChipArgs chipArgs; - Design *design; + ArchArgs chipArgs; + Context *ctx; }; TEST_F(UP5KTest, bel_names) { int bel_count = 0; - for (auto bel : design->chip.getBels()) { - auto name = design->chip.getBelName(bel); - ASSERT_EQ(bel, design->chip.getBelByName(name)); + for (auto bel : ctx->getBels()) { + auto name = ctx->getBelName(bel); + ASSERT_EQ(bel, ctx->getBelByName(name)); bel_count++; } ASSERT_EQ(bel_count, 5414); @@ -34,9 +34,9 @@ TEST_F(UP5KTest, bel_names) TEST_F(UP5KTest, wire_names) { int wire_count = 0; - for (auto wire : design->chip.getWires()) { - auto name = design->chip.getWireName(wire); - assert(wire == design->chip.getWireByName(name)); + for (auto wire : ctx->getWires()) { + auto name = ctx->getWireName(wire); + assert(wire == ctx->getWireByName(name)); wire_count++; } ASSERT_EQ(wire_count, 103383); @@ -45,9 +45,9 @@ TEST_F(UP5KTest, wire_names) TEST_F(UP5KTest, pip_names) { int pip_count = 0; - for (auto pip : design->chip.getPips()) { - auto name = design->chip.getPipName(pip); - assert(pip == design->chip.getPipByName(name)); + for (auto pip : ctx->getPips()) { + auto name = ctx->getPipName(pip); + assert(pip == ctx->getPipByName(name)); pip_count++; } ASSERT_EQ(pip_count, 1219104); @@ -55,11 +55,11 @@ TEST_F(UP5KTest, pip_names) TEST_F(UP5KTest, uphill_to_downhill) { - for (auto dst : design->chip.getWires()) { - for (auto uphill_pip : design->chip.getPipsUphill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto uphill_pip : ctx->getPipsUphill(dst)) { bool found_downhill = false; - for (auto downhill_pip : design->chip.getPipsDownhill( - design->chip.getPipSrcWire(uphill_pip))) { + for (auto downhill_pip : ctx->getPipsDownhill( + ctx->getPipSrcWire(uphill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_downhill); found_downhill = true; @@ -72,11 +72,11 @@ TEST_F(UP5KTest, uphill_to_downhill) TEST_F(UP5KTest, downhill_to_uphill) { - for (auto dst : design->chip.getWires()) { - for (auto downhill_pip : design->chip.getPipsDownhill(dst)) { + for (auto dst : ctx->getWires()) { + for (auto downhill_pip : ctx->getPipsDownhill(dst)) { bool found_uphill = false; - for (auto uphill_pip : design->chip.getPipsUphill( - design->chip.getPipDstWire(downhill_pip))) { + for (auto uphill_pip : ctx->getPipsUphill( + ctx->getPipDstWire(downhill_pip))) { if (uphill_pip == downhill_pip) { ASSERT_FALSE(found_uphill); found_uphill = true;