blob: 06543fd88e749ad015f29134a3ea01bbac7995f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#include <vector>
#include "gtest/gtest.h"
#include "nextpnr.h"
USING_NEXTPNR_NAMESPACE
class LP8KTest : public ::testing::Test
{
protected:
virtual void SetUp()
{
chipArgs.type = ChipArgs::LP8K;
chipArgs.package = "ct256";
design = new Design(chipArgs);
}
virtual void TearDown() { delete design; }
ChipArgs chipArgs;
Design *design;
};
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));
bel_count++;
}
ASSERT_EQ(bel_count, 7968);
}
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));
wire_count++;
}
ASSERT_EQ(wire_count, 135174);
}
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));
pip_count++;
}
ASSERT_EQ(pip_count, 1652480);
}
TEST_F(LP8KTest, 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(LP8KTest, 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);
}
}
}
|