Skip to content

Commit 9f7b716

Browse files
committed
vpr: tests: improve interchange tests
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent b17d4ef commit 9f7b716

File tree

2 files changed

+121
-1
lines changed

2 files changed

+121
-1
lines changed

vpr/test/test_interchange_device.cpp

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ TEST_CASE("read_interchange_models", "[vpr]") {
1818

1919
FPGAInterchangeReadArch(kArchFile, /*timing_enabled=*/true, &arch, physical_tile_types, logical_block_types);
2020

21-
std::unordered_set<std::string> models = {"IB", "OB", "LUT", "DFF", "GND", "VCC"};
21+
std::unordered_set<std::string> models = {"IB", "OB", "DFF", "GND", "VCC"};
2222

2323
// Check that there are exactly the expected models
2424
for (auto* model = arch.models; model != nullptr; model = model->next) {
@@ -67,4 +67,124 @@ TEST_CASE("read_interchange_layout", "[vpr]") {
6767
}
6868
}
6969

70+
TEST_CASE("read_interchange_luts", "[vpr]") {
71+
t_arch arch;
72+
std::vector<t_physical_tile_type> physical_tile_types;
73+
std::vector<t_logical_block_type> logical_block_types;
74+
75+
FPGAInterchangeReadArch(kArchFile, /*timing_enabled=*/true, &arch, physical_tile_types, logical_block_types);
76+
77+
std::unordered_set<std::string> lut_cell_pins = {"A0", "A1", "A2", "A3"};
78+
std::unordered_set<std::string> lut_bel_pins = {"I0", "I1", "I2", "I3"};
79+
80+
REQUIRE(arch.lut_cells.size() == 1);
81+
REQUIRE(arch.lut_bels.size() == 1);
82+
83+
auto lut_cell = arch.lut_cells[0];
84+
REQUIRE(lut_cell.name == std::string("LUT"));
85+
REQUIRE(lut_cell.init_param == std::string("INIT"));
86+
for (auto lut_pin : lut_cell_pins)
87+
CHECK(std::find(lut_cell.inputs.begin(), lut_cell.inputs.end(), lut_pin) != lut_cell.inputs.end());
88+
89+
auto lut_bel = arch.lut_bels[0];
90+
REQUIRE(lut_bel.name == std::string("LUT"));
91+
REQUIRE(lut_bel.output_pin == std::string("O"));
92+
for (auto lut_pin : lut_bel_pins)
93+
CHECK(std::find(lut_bel.input_pins.begin(), lut_bel.input_pins.end(), lut_pin) != lut_bel.input_pins.end());
94+
}
95+
96+
TEST_CASE("read_interchange_pin_packages", "[vpr]") {
97+
t_arch arch;
98+
std::vector<t_physical_tile_type> physical_tile_types;
99+
std::vector<t_logical_block_type> logical_block_types;
100+
101+
FPGAInterchangeReadArch(kArchFile, /*timing_enabled=*/true, &arch, physical_tile_types, logical_block_types);
102+
103+
// The device architecture file contains 35 perimetral PADs
104+
REQUIRE(arch.pad_bels.size() == 35);
105+
106+
int ipad = 0;
107+
for (auto pad_bel : arch.pad_bels) {
108+
REQUIRE(pad_bel.name == std::string("A") + std::to_string(ipad++));
109+
REQUIRE(pad_bel.bel_name == std::string("PAD"));
110+
}
111+
}
112+
113+
TEST_CASE("read_interchange_tiles", "[vpr]") {
114+
t_arch arch;
115+
std::vector<t_physical_tile_type> physical_tile_types;
116+
std::vector<t_logical_block_type> logical_block_types;
117+
118+
FPGAInterchangeReadArch(kArchFile, /*timing_enabled=*/true, &arch, physical_tile_types, logical_block_types);
119+
120+
std::unordered_set<std::string> ptypes = {"NULL", "IOB", "PWR", "CLB"};
121+
122+
// Check that there are exactly the expected models
123+
for (auto ptype : physical_tile_types) {
124+
std::string name = ptype.name;
125+
REQUIRE(ptypes.find(name) != ptypes.end());
126+
ptypes.erase(name);
127+
128+
if (name == std::string("IOB")) {
129+
CHECK(ptype.is_input_type);
130+
CHECK(ptype.is_output_type);
131+
}
132+
}
133+
134+
REQUIRE(ptypes.size() == 0);
135+
}
136+
137+
TEST_CASE("read_interchange_pb_types", "[vpr]") {
138+
t_arch arch;
139+
std::vector<t_physical_tile_type> physical_tile_types;
140+
std::vector<t_logical_block_type> logical_block_types;
141+
142+
FPGAInterchangeReadArch(kArchFile, /*timing_enabled=*/true, &arch, physical_tile_types, logical_block_types);
143+
144+
std::unordered_set<std::string> ltypes = {"NULL", "IOPAD", "SLICE", "POWER"};
145+
146+
std::unordered_map<std::string, PORTS> slice_ports = {
147+
{"L0", PORTS::IN_PORT},
148+
{"L1", PORTS::IN_PORT},
149+
{"L2", PORTS::IN_PORT},
150+
{"L3", PORTS::IN_PORT},
151+
{"R", PORTS::IN_PORT},
152+
{"C", PORTS::IN_PORT},
153+
{"D", PORTS::IN_PORT},
154+
{"O", PORTS::OUT_PORT},
155+
{"Q", PORTS::OUT_PORT}};
156+
157+
// Check that there are exactly the expected models
158+
for (auto ltype : logical_block_types) {
159+
std::string name = ltype.name;
160+
REQUIRE(ltypes.find(name) != ltypes.end());
161+
ltypes.erase(name);
162+
163+
if (ltype.pb_type == nullptr) {
164+
REQUIRE(name == std::string("NULL"));
165+
continue;
166+
}
167+
168+
bool check_pb_type = name == std::string("SLICE");
169+
size_t num_visited = 0;
170+
for (auto iport = 0; iport < ltype.pb_type->num_ports; iport++) {
171+
auto port = ltype.pb_type->ports[iport];
172+
173+
REQUIRE(port.name != nullptr);
174+
175+
if (!check_pb_type)
176+
continue;
177+
178+
auto res = slice_ports.find(std::string(port.name));
179+
REQUIRE(res != slice_ports.end());
180+
REQUIRE(res->second == port.type);
181+
num_visited++;
182+
}
183+
184+
REQUIRE((num_visited == slice_ports.size() || !check_pb_type));
185+
}
186+
187+
REQUIRE(ltypes.size() == 0);
188+
}
189+
70190
} // namespace

vpr/test/testarch.device

1.65 KB
Binary file not shown.

0 commit comments

Comments
 (0)