diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2018-06-12 20:39:20 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2018-06-12 20:39:20 +0200 |
commit | b7c747f15bcad48f4e1b82704bc9d00c28b9d62d (patch) | |
tree | c8113d93b00d5661b76096e7a2859f5af8605ebc /tests/ice40/up5k.cc | |
parent | 9953012154f18ea51ff9216529089715ba79fb41 (diff) | |
download | nextpnr-b7c747f15bcad48f4e1b82704bc9d00c28b9d62d.tar.gz nextpnr-b7c747f15bcad48f4e1b82704bc9d00c28b9d62d.tar.bz2 nextpnr-b7c747f15bcad48f4e1b82704bc9d00c28b9d62d.zip |
Write tests to replace -test option from main
Diffstat (limited to 'tests/ice40/up5k.cc')
-rw-r--r-- | tests/ice40/up5k.cc | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/ice40/up5k.cc b/tests/ice40/up5k.cc new file mode 100644 index 00000000..eb6dd732 --- /dev/null +++ b/tests/ice40/up5k.cc @@ -0,0 +1,88 @@ +#include "gtest/gtest.h" +#include "nextpnr.h" +#include <vector> + +USING_NEXTPNR_NAMESPACE + +class UP5KTest : public ::testing::Test { + protected: + virtual void SetUp() + { + chipArgs.type = ChipArgs::UP5K; + design = new Design(chipArgs); + } + + virtual void TearDown() { + delete design; + } + + ChipArgs chipArgs; + Design *design; +}; + +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)); + bel_count++; + } + ASSERT_EQ(bel_count,5414); +} + +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)); + wire_count++; + } + ASSERT_EQ(wire_count,103383); +} + +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)); + pip_count++; + } + ASSERT_EQ(pip_count,1219104); +} + +TEST_F(UP5KTest, uphill_to_downhill) +{ + for (auto dst : design->chip.getWires()) { + for (auto uphill_pip : design->chip.getPipsUphill(dst)) { + bool found_downhill = false; + for (auto downhill_pip : design->chip.getPipsDownhill( + design->chip.getPipSrcWire(uphill_pip))) { + if (uphill_pip == downhill_pip) { + ASSERT_FALSE(found_downhill); + found_downhill = true; + } + } + ASSERT_TRUE(found_downhill); + } + } +} + +TEST_F(UP5KTest, downhill_to_uphill) +{ + for (auto dst : design->chip.getWires()) { + for (auto downhill_pip : design->chip.getPipsDownhill(dst)) { + bool found_uphill = false; + for (auto uphill_pip : design->chip.getPipsUphill( + design->chip.getPipDstWire(downhill_pip))) { + if (uphill_pip == downhill_pip) { + ASSERT_FALSE(found_uphill); + found_uphill = true; + } + } + ASSERT_TRUE(found_uphill); + } + } +} |