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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
* nextpnr -- Next Generation Place and Route
*
* Copyright (C) 2018 Clifford Wolf <clifford@symbioticeda.com>
* Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#include <vector>
#include "gtest/gtest.h"
#include "nextpnr.h"
USING_NEXTPNR_NAMESPACE
class UP5KTest : public ::testing::Test
{
protected:
virtual void SetUp()
{
chipArgs.type = ArchArgs::UP5K;
chipArgs.package = "sg48";
ctx = new Context(chipArgs);
}
virtual void TearDown() { delete ctx; }
ArchArgs chipArgs;
Context *ctx;
};
TEST_F(UP5KTest, bel_names)
{
int bel_count = 0;
for (auto bel : ctx->getBels()) {
auto name = ctx->getBelName(bel);
ASSERT_EQ(bel, ctx->getBelByName(name));
bel_count++;
}
ASSERT_EQ(bel_count, 5438);
}
TEST_F(UP5KTest, wire_names)
{
int wire_count = 0;
for (auto wire : ctx->getWires()) {
auto name = ctx->getWireName(wire);
assert(wire == ctx->getWireByName(name));
wire_count++;
}
ASSERT_EQ(wire_count, 124503);
}
TEST_F(UP5KTest, pip_names)
{
int pip_count = 0;
for (auto pip : ctx->getPips()) {
auto name = ctx->getPipName(pip);
assert(pip == ctx->getPipByName(name));
pip_count++;
}
ASSERT_EQ(pip_count, 1324704);
}
TEST_F(UP5KTest, uphill_to_downhill)
{
for (auto dst : ctx->getWires()) {
for (auto uphill_pip : ctx->getPipsUphill(dst)) {
bool found_downhill = false;
for (auto downhill_pip : ctx->getPipsDownhill(ctx->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 : ctx->getWires()) {
for (auto downhill_pip : ctx->getPipsDownhill(dst)) {
bool found_uphill = false;
for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) {
if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_uphill);
found_uphill = true;
}
}
ASSERT_TRUE(found_uphill);
}
}
}
|