2018-06-13 02:44:05 +08:00
|
|
|
#include <vector>
|
2018-06-13 02:39:20 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "nextpnr.h"
|
|
|
|
|
|
|
|
USING_NEXTPNR_NAMESPACE
|
|
|
|
|
2018-06-13 02:44:05 +08:00
|
|
|
class HX8KTest : public ::testing::Test
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2018-06-23 20:56:30 +08:00
|
|
|
IdString::global_ctx = nullptr;
|
2018-06-23 20:32:18 +08:00
|
|
|
chipArgs.type = ArchArgs::HX8K;
|
2018-06-13 21:16:38 +08:00
|
|
|
chipArgs.package = "ct256";
|
2018-06-23 20:32:18 +08:00
|
|
|
ctx = new Context(chipArgs);
|
2018-06-13 02:44:05 +08:00
|
|
|
}
|
|
|
|
|
2018-06-23 20:32:18 +08:00
|
|
|
virtual void TearDown() { delete ctx; }
|
2018-06-13 02:39:20 +08:00
|
|
|
|
2018-06-23 20:32:18 +08:00
|
|
|
ArchArgs chipArgs;
|
|
|
|
Context *ctx;
|
2018-06-13 02:39:20 +08:00
|
|
|
};
|
|
|
|
|
2018-06-13 02:44:05 +08:00
|
|
|
TEST_F(HX8KTest, bel_names)
|
2018-06-13 02:39:20 +08:00
|
|
|
{
|
2018-06-13 02:44:05 +08:00
|
|
|
int bel_count = 0;
|
2018-06-23 20:32:18 +08:00
|
|
|
for (auto bel : ctx->getBels()) {
|
|
|
|
auto name = ctx->getBelName(bel);
|
|
|
|
ASSERT_EQ(bel, ctx->getBelByName(name));
|
2018-06-13 02:44:05 +08:00
|
|
|
bel_count++;
|
|
|
|
}
|
2018-06-23 20:56:30 +08:00
|
|
|
ASSERT_EQ(bel_count, 7979);
|
2018-06-13 02:39:20 +08:00
|
|
|
}
|
|
|
|
|
2018-06-13 02:44:05 +08:00
|
|
|
TEST_F(HX8KTest, wire_names)
|
2018-06-13 02:39:20 +08:00
|
|
|
{
|
2018-06-13 02:44:05 +08:00
|
|
|
int wire_count = 0;
|
2018-06-23 20:32:18 +08:00
|
|
|
for (auto wire : ctx->getWires()) {
|
|
|
|
auto name = ctx->getWireName(wire);
|
|
|
|
assert(wire == ctx->getWireByName(name));
|
2018-06-13 02:44:05 +08:00
|
|
|
wire_count++;
|
|
|
|
}
|
|
|
|
ASSERT_EQ(wire_count, 135174);
|
2018-06-13 02:39:20 +08:00
|
|
|
}
|
|
|
|
|
2018-06-13 02:44:05 +08:00
|
|
|
TEST_F(HX8KTest, pip_names)
|
2018-06-13 02:39:20 +08:00
|
|
|
{
|
2018-06-13 02:44:05 +08:00
|
|
|
int pip_count = 0;
|
2018-06-23 20:32:18 +08:00
|
|
|
for (auto pip : ctx->getPips()) {
|
|
|
|
auto name = ctx->getPipName(pip);
|
|
|
|
assert(pip == ctx->getPipByName(name));
|
2018-06-13 02:44:05 +08:00
|
|
|
pip_count++;
|
|
|
|
}
|
|
|
|
ASSERT_EQ(pip_count, 1652480);
|
2018-06-13 02:39:20 +08:00
|
|
|
}
|
|
|
|
|
2018-06-13 02:44:05 +08:00
|
|
|
TEST_F(HX8KTest, uphill_to_downhill)
|
2018-06-13 02:39:20 +08:00
|
|
|
{
|
2018-06-23 20:32:18 +08:00
|
|
|
for (auto dst : ctx->getWires()) {
|
|
|
|
for (auto uphill_pip : ctx->getPipsUphill(dst)) {
|
2018-06-13 02:44:05 +08:00
|
|
|
bool found_downhill = false;
|
2018-06-23 20:32:18 +08:00
|
|
|
for (auto downhill_pip : ctx->getPipsDownhill(
|
|
|
|
ctx->getPipSrcWire(uphill_pip))) {
|
2018-06-13 02:44:05 +08:00
|
|
|
if (uphill_pip == downhill_pip) {
|
|
|
|
ASSERT_FALSE(found_downhill);
|
|
|
|
found_downhill = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ASSERT_TRUE(found_downhill);
|
|
|
|
}
|
|
|
|
}
|
2018-06-13 02:39:20 +08:00
|
|
|
}
|
|
|
|
|
2018-06-13 02:44:05 +08:00
|
|
|
TEST_F(HX8KTest, downhill_to_uphill)
|
2018-06-13 02:39:20 +08:00
|
|
|
{
|
2018-06-23 20:32:18 +08:00
|
|
|
for (auto dst : ctx->getWires()) {
|
|
|
|
for (auto downhill_pip : ctx->getPipsDownhill(dst)) {
|
2018-06-13 02:44:05 +08:00
|
|
|
bool found_uphill = false;
|
2018-06-23 20:32:18 +08:00
|
|
|
for (auto uphill_pip : ctx->getPipsUphill(
|
|
|
|
ctx->getPipDstWire(downhill_pip))) {
|
2018-06-13 02:44:05 +08:00
|
|
|
if (uphill_pip == downhill_pip) {
|
|
|
|
ASSERT_FALSE(found_uphill);
|
|
|
|
found_uphill = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ASSERT_TRUE(found_uphill);
|
|
|
|
}
|
|
|
|
}
|
2018-06-13 02:39:20 +08:00
|
|
|
}
|