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/nextpnr.h b/common/nextpnr.h index 8cbead7d..2f3b5b14 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -81,77 +81,11 @@ struct IdString // --- deprecated old API --- - IdString(const std::string &s) __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - set(global_ctx, s); - } - - IdString(const char *s) __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - set(global_ctx, s); - } - const std::string &global_str() const __attribute__((deprecated)) { assert(global_ctx != nullptr); return str(global_ctx); } - - const std::string &str() const __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - return str(global_ctx); - } - - const char *c_str() const __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - return c_str(global_ctx); - } - - operator const char *() const __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - return c_str(global_ctx); - } - - operator const std::string &() const __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - return str(global_ctx); - } - - bool operator==(const std::string &s) const __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - return str(global_ctx) == s; - } - - bool operator==(const char *s) const __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - return str(global_ctx) == s; - } - - bool operator!=(const std::string &s) const __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - return str(global_ctx) != s; - } - - bool operator!=(const char *s) const __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - return str(global_ctx) != s; - } - - size_t size() const __attribute__((deprecated)) - { - assert(global_ctx != nullptr); - return str(global_ctx).size(); - } }; NEXTPNR_NAMESPACE_END 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 0f87f06c..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 @@ -116,8 +115,8 @@ DesignWidget::DesignWidget(Context *_ctx, QWidget *parent) QList bel_items; for (auto bel : ctx->getBels()) { auto name = ctx->getBelName(bel); - bel_items.append( - new BelTreeItem(name, ElementType::BEL, QString(name.c_str(ctx)))); + bel_items.append(new BelTreeItem(name, ElementType::BEL, + QString(name.c_str(ctx)))); } bel_root->addChildren(bel_items); @@ -140,8 +139,8 @@ DesignWidget::DesignWidget(Context *_ctx, QWidget *parent) treeWidget->insertTopLevelItem(0, pip_root); for (auto pip : ctx->getPips()) { auto name = ctx->getPipName(pip); - pip_items.append( - new PipTreeItem(name, ElementType::PIP, QString(name.c_str(ctx)))); + pip_items.append(new PipTreeItem(name, ElementType::PIP, + QString(name.c_str(ctx)))); } pip_root->addChildren(pip_items); diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index f9cfc900..71e74e19 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -173,6 +173,20 @@ bool LineShader::compile(void) program_->log().toStdString().c_str()); return false; } + + if (!vao_.create()) + log_abort(); + vao_.bind(); + + if (!buffers_.position.create()) + log_abort(); + if (!buffers_.normal.create()) + log_abort(); + if (!buffers_.miter.create()) + log_abort(); + if (!buffers_.index.create()) + log_abort(); + attributes_.position = program_->attributeLocation("position"); attributes_.normal = program_->attributeLocation("normal"); attributes_.miter = program_->attributeLocation("miter"); @@ -180,44 +194,84 @@ bool LineShader::compile(void) uniforms_.projection = program_->uniformLocation("projection"); uniforms_.color = program_->uniformLocation("color"); + vao_.release(); return true; } void LineShader::draw(const LineShaderData &line, const QMatrix4x4 &projection) { auto gl = QOpenGLContext::currentContext()->functions(); + vao_.bind(); program_->bind(); + buffers_.position.bind(); + buffers_.position.allocate(&line.vertices[0], + sizeof(Vertex2DPOD) * line.vertices.size()); + + buffers_.normal.bind(); + buffers_.normal.allocate(&line.normals[0], + sizeof(Vertex2DPOD) * line.normals.size()); + + buffers_.miter.bind(); + buffers_.miter.allocate(&line.miters[0], + sizeof(GLfloat) * line.miters.size()); + + buffers_.index.bind(); + buffers_.index.allocate(&line.indices[0], + sizeof(GLuint) * line.indices.size()); + program_->setUniformValue(uniforms_.projection, projection); program_->setUniformValue(uniforms_.thickness, line.thickness); program_->setUniformValue(uniforms_.color, line.color.r, line.color.g, line.color.b, line.color.a); + buffers_.position.bind(); + program_->enableAttributeArray("position"); gl->glVertexAttribPointer(attributes_.position, 2, GL_FLOAT, GL_FALSE, 0, - &line.vertices[0]); + (void *)0); + + buffers_.normal.bind(); + program_->enableAttributeArray("normal"); gl->glVertexAttribPointer(attributes_.normal, 2, GL_FLOAT, GL_FALSE, 0, - &line.normals[0]); + (void *)0); + + buffers_.miter.bind(); + program_->enableAttributeArray("miter"); gl->glVertexAttribPointer(attributes_.miter, 1, GL_FLOAT, GL_FALSE, 0, - &line.miters[0]); - - gl->glEnableVertexAttribArray(0); - gl->glEnableVertexAttribArray(1); - gl->glEnableVertexAttribArray(2); + (void *)0); + buffers_.index.bind(); gl->glDrawElements(GL_TRIANGLES, line.indices.size(), GL_UNSIGNED_INT, - &line.indices[0]); + (void *)0); + + program_->disableAttributeArray("miter"); + program_->disableAttributeArray("normal"); + program_->disableAttributeArray("position"); - gl->glDisableVertexAttribArray(2); - gl->glDisableVertexAttribArray(1); - gl->glDisableVertexAttribArray(0); program_->release(); + vao_.release(); } FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), moveX_(0), moveY_(0), zoom_(10.0f), lineShader_(this) { - ctx = qobject_cast(getMainWindow())->getContext(); + ctx_ = qobject_cast(getMainWindow())->getContext(); + auto fmt = format(); + fmt.setMajorVersion(3); + fmt.setMinorVersion(1); + setFormat(fmt); + + fmt = format(); + printf("FPGAViewWidget running on OpenGL %d.%d\n", fmt.majorVersion(), + fmt.minorVersion()); + if (fmt.majorVersion() < 3) { + printf("Could not get OpenGL 3.0 context. Aborting.\n"); + log_abort(); + } + if (fmt.minorVersion() < 1) { + printf("Could not get OpenGL 3.1 context - trying anyway...\n "); + } } QMainWindow *FPGAViewWidget::getMainWindow() @@ -320,15 +374,15 @@ void FPGAViewWidget::paintGL() // Draw Bels. auto bels = LineShaderData(0.02f, QColor("#b000ba")); - for (auto bel : ctx->getBels()) { - for (auto &el : ctx->getBelGraphics(bel)) + for (auto bel : ctx_->getBels()) { + for (auto &el : ctx_->getBelGraphics(bel)) drawElement(bels, el); } lineShader_.draw(bels, matrix); // Draw Frame Graphics. auto frames = LineShaderData(0.02f, QColor("#0066ba")); - for (auto &el : ctx->getFrameGraphics()) { + for (auto &el : ctx_->getFrameGraphics()) { drawElement(frames, el); } lineShader_.draw(frames, matrix); diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h index 0cfcbb3e..9f9dc024 100644 --- a/gui/fpgaviewwidget.h +++ b/gui/fpgaviewwidget.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -162,6 +163,15 @@ class LineShader GLuint miter; } attributes_; + // GL buffers + struct + { + QOpenGLBuffer position; + QOpenGLBuffer normal; + QOpenGLBuffer miter; + QOpenGLBuffer index; + } buffers_; + // GL uniform locations. struct { @@ -173,8 +183,23 @@ class LineShader GLuint color; } uniforms_; + QOpenGLVertexArrayObject vao_; + public: - LineShader(QObject *parent) : parent_(parent), program_(nullptr) {} + LineShader(QObject *parent) : parent_(parent), program_(nullptr) + { + buffers_.position = QOpenGLBuffer(QOpenGLBuffer::VertexBuffer); + buffers_.position.setUsagePattern(QOpenGLBuffer::StaticDraw); + + buffers_.normal = QOpenGLBuffer(QOpenGLBuffer::VertexBuffer); + buffers_.normal.setUsagePattern(QOpenGLBuffer::StaticDraw); + + buffers_.miter = QOpenGLBuffer(QOpenGLBuffer::VertexBuffer); + buffers_.miter.setUsagePattern(QOpenGLBuffer::StaticDraw); + + buffers_.index = QOpenGLBuffer(QOpenGLBuffer::IndexBuffer); + buffers_.index.setUsagePattern(QOpenGLBuffer::StaticDraw); + } static constexpr const char *vertexShaderSource_ = "attribute highp vec2 position;\n" @@ -238,7 +263,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions float startDragX_; float startDragY_; - Context *ctx; + Context *ctx_; }; NEXTPNR_NAMESPACE_END 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..7dd7bbe1 100644 --- a/tests/ice40/hx1k.cc +++ b/tests/ice40/hx1k.cc @@ -9,34 +9,35 @@ class HX1KTest : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::HX1K; + IdString::global_ctx = nullptr; + 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); + ASSERT_EQ(bel_count, 1418); } 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 +46,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 +56,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 +73,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..a8d0834e 100644 --- a/tests/ice40/hx8k.cc +++ b/tests/ice40/hx8k.cc @@ -9,34 +9,35 @@ class HX8KTest : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::HX8K; + IdString::global_ctx = nullptr; + 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); + ASSERT_EQ(bel_count, 7979); } 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 +46,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 +56,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 +73,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..c80d43f9 100644 --- a/tests/ice40/lp1k.cc +++ b/tests/ice40/lp1k.cc @@ -9,34 +9,35 @@ class LP1KTest : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::LP1K; + IdString::global_ctx = nullptr; + 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); + ASSERT_EQ(bel_count, 1418); } 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 +46,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 +56,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 +73,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..aedc3b6d 100644 --- a/tests/ice40/lp384.cc +++ b/tests/ice40/lp384.cc @@ -9,34 +9,35 @@ class LP384Test : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::LP384; + IdString::global_ctx = nullptr; + 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); + ASSERT_EQ(bel_count, 449); } 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 +46,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 +56,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 +73,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..e8e9cb0b 100644 --- a/tests/ice40/lp8k.cc +++ b/tests/ice40/lp8k.cc @@ -9,34 +9,35 @@ class LP8KTest : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::LP8K; + IdString::global_ctx = nullptr; + 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); + ASSERT_EQ(bel_count, 7979); } 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 +46,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 +56,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 +73,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..c7de5269 100644 --- a/tests/ice40/up5k.cc +++ b/tests/ice40/up5k.cc @@ -9,34 +9,35 @@ class UP5KTest : public ::testing::Test protected: virtual void SetUp() { - chipArgs.type = ChipArgs::UP5K; + IdString::global_ctx = nullptr; + 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); + ASSERT_EQ(bel_count, 5438); } 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 +46,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 +56,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 +73,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;