Added BUILD_GUI, BUILD_PYTHON and BUILD_TESTS cmake options,

This commit is contained in:
Miodrag Milanovic 2018-06-23 14:32:18 +02:00
parent b63fdfbeab
commit 82ec1be31f
18 changed files with 315 additions and 199 deletions

View File

@ -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)
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})
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,16 +41,22 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (BUILD_TESTS)
add_subdirectory(3rdparty/googletest/googletest generated/3rdparty/googletest EXCLUDE_FROM_ALL)
enable_testing()
endif()
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
)
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
@ -78,6 +98,7 @@ 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)
@ -92,32 +113,57 @@ endif(MINGW)
foreach (family ${FAMILIES})
string(TOUPPER ${family} ufamily)
aux_source_directory(${family}/ ${ufamily}_FILES)
aux_source_directory(tests/${family}/ ${ufamily}_TEST_FILES)
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)
if (BUILD_PYTHON)
# 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
endif()
add_executable(nextpnr-${family}-test EXCLUDE_FROM_ALL ${${ufamily}_TEST_FILES} ${COMMON_FILES} ${${ufamily}_FILES})
# 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)

View File

@ -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 <Python.h>
@ -136,3 +137,5 @@ void reset_stdout()
void append_inittab() { PyImport_AppendInittab("emb", emb::PyInit_emb); }
} // namespace emb
#endif // NO_PYTHON

View File

@ -1,3 +1,5 @@
#ifndef NO_PYTHON
#include <Python.h>
#include <boost/python.hpp>
#include "nextpnr.h"
@ -61,3 +63,5 @@ std::string parse_python_exception()
}
NEXTPNR_NAMESPACE_END
#endif // NO_PYTHON

View File

@ -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

View File

@ -19,15 +19,20 @@
#ifdef MAIN_EXECUTABLE
#ifndef NO_GUI
#include <QApplication>
#include "application.h"
#include "mainwindow.h"
#endif
#ifndef NO_PYTHON
#include "pybindings.h"
#endif
#include <boost/filesystem/convenience.hpp>
#include <boost/program_options.hpp>
#include "application.h"
#include "log.h"
#include "mainwindow.h"
#include "nextpnr.h"
#include "pybindings.h"
#include "version.h"
#include <iostream>
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<std::vector<std::string>>(),
"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<int>());
}
#ifndef NO_PYTHON
if (vm.count("run")) {
std::vector<std::string> files =
vm["run"].as<std::vector<std::string>>();
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)

View File

@ -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>("ArchArgs"); }
NEXTPNR_NAMESPACE_END
#endif

View File

@ -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");

View File

@ -24,7 +24,6 @@
#include <QSplitter>
#include <QTreeWidgetItem>
#include "fpgaviewwidget.h"
#include "pybindings.h"
NEXTPNR_NAMESPACE_BEGIN

View File

@ -16,6 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#ifndef NO_PYTHON
#include "pythontab.h"
#include <QGridLayout>
@ -138,3 +139,5 @@ void PythonTab::showContextMenu(const QPoint &pt)
void PythonTab::clearBuffer() { plainTextEdit->clear(); }
NEXTPNR_NAMESPACE_END
#endif

View File

@ -20,6 +20,8 @@
#ifndef PYTHONTAB_H
#define PYTHONTAB_H
#ifndef NO_PYTHON
#include <QLineEdit>
#include <QMenu>
#include <QPlainTextEdit>
@ -52,5 +54,6 @@ class PythonTab : public QWidget
};
NEXTPNR_NAMESPACE_END
#endif // NO_PYTHON
#endif // PYTHONTAB_H

View File

@ -19,23 +19,27 @@
#ifdef MAIN_EXECUTABLE
#ifndef NO_GUI
#include <QApplication>
#include <QSurfaceFormat>
#include "application.h"
#include "mainwindow.h"
#endif
#ifndef NO_PYTHON
#include "pybindings.h"
#endif
#include <boost/filesystem/convenience.hpp>
#include <boost/program_options.hpp>
#include <fstream>
#include <iostream>
#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<std::vector<std::string>>(),
"python file to execute");
pos.add("run", -1);
#endif
options.add_options()("json", po::value<std::string>(),
"JSON design file to ingest");
options.add_options()("pcf", po::value<std::string>(),
@ -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<std::string>(),
"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<std::string>();
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<std::string> files =
vm["run"].as<std::vector<std::string>>();
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)

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;