Skip to content

Commit 1570b83

Browse files
committed
Added reading LUT elements from FPGA interchange
Signed-off-by: Maciej Kurc <[email protected]>
1 parent 0067842 commit 1570b83

File tree

2 files changed

+50
-23
lines changed

2 files changed

+50
-23
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,24 @@ struct t_lut_bel {
17431743

17441744
std::vector<std::string> input_pins;
17451745
std::string output_pin;
1746+
1747+
bool operator == (const t_lut_bel& other) const {
1748+
return name == other.name &&
1749+
input_pins == other.input_pins &&
1750+
output_pin == other.output_pin;
1751+
}
1752+
};
1753+
1754+
struct t_lut_element {
1755+
std::string site_type;
1756+
int width;
1757+
std::vector<t_lut_bel> lut_bels;
1758+
1759+
bool operator == (const t_lut_element& other) const {
1760+
return site_type == other.site_type &&
1761+
width == other.width &&
1762+
lut_bels == other.lut_bels;
1763+
}
17461764
};
17471765

17481766
/* Detailed routing architecture */
@@ -1780,7 +1798,7 @@ struct t_arch {
17801798

17811799
// Luts
17821800
std::vector<t_lut_cell> lut_cells;
1783-
std::vector<t_lut_bel> lut_bels;
1801+
std::vector<t_lut_element> lut_elements;
17841802

17851803
//The name of the switch used for the input connection block (i.e. to
17861804
//connect routing tracks to block pins).

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,12 @@ struct ArchReader {
290290
if (cell.name == name)
291291
return true;
292292

293-
for (auto bel : arch_->lut_bels)
294-
if (bel.name == name)
295-
return true;
293+
for (const auto& lut_element : arch_->lut_elements) {
294+
for (const auto& lut_bel : lut_element.lut_bels) {
295+
if (lut_bel.name == name)
296+
return true;
297+
}
298+
}
296299

297300
return false;
298301
}
@@ -454,27 +457,26 @@ struct ArchReader {
454457

455458
for (auto lut_elem : lut_def.getLutElements()) {
456459
for (auto lut : lut_elem.getLuts()) {
457-
for (auto bel : lut.getBels()) {
458-
t_lut_bel lut_bel;
459-
460-
std::string name = bel.getName().cStr();
461-
lut_bel.name = name;
462460

463-
// Check for duplicates
464-
auto is_duplicate = [name](t_lut_bel l) { return l.name == name; };
465-
auto res = std::find_if(arch_->lut_bels.begin(), arch_->lut_bels.end(), is_duplicate);
466-
if (res != arch_->lut_bels.end())
467-
continue;
461+
t_lut_element element;
462+
element.site_type = lut_elem.getSite().cStr();
463+
element.width = lut.getWidth();
468464

465+
for (auto bel : lut.getBels()) {
466+
t_lut_bel lut_bel;
467+
lut_bel.name = bel.getName().cStr();
469468
std::vector<std::string> ipins;
469+
470470
for (auto pin : bel.getInputPins())
471471
ipins.push_back(pin.cStr());
472472

473473
lut_bel.input_pins = ipins;
474474
lut_bel.output_pin = bel.getOutputPin().cStr();
475475

476-
arch_->lut_bels.push_back(lut_bel);
476+
element.lut_bels.push_back(lut_bel);
477477
}
478+
479+
arch_->lut_elements.push_back(element);
478480
}
479481
}
480482
}
@@ -737,10 +739,17 @@ struct ArchReader {
737739

738740
// Check for duplicates
739741
std::string lut_name = lut->name;
742+
t_lut_bel* lut_bel = nullptr;
743+
740744
auto find_lut = [lut_name](t_lut_bel l) { return l.name == lut_name; };
741-
auto res = std::find_if(arch_->lut_bels.begin(), arch_->lut_bels.end(), find_lut);
742-
VTR_ASSERT(res != arch_->lut_bels.end());
743-
auto lut_bel = *res;
745+
for (auto& lut_element : arch_->lut_elements) {
746+
auto res = std::find_if(lut_element.lut_bels.begin(), lut_element.lut_bels.end(), find_lut);
747+
if(res != lut_element.lut_bels.end()) {
748+
lut_bel = &*res;
749+
break;
750+
}
751+
}
752+
VTR_ASSERT(lut_bel != nullptr);
744753

745754
auto mode = &lut->modes[0];
746755
mode->name = vtr::strdup("lut");
@@ -760,7 +769,7 @@ struct ArchReader {
760769
new_leaf->blif_model = vtr::strdup(MODEL_NAMES);
761770
new_leaf->model = get_model(arch_, std::string(MODEL_NAMES));
762771

763-
auto in_size = lut_bel.input_pins.size();
772+
auto in_size = lut_bel->input_pins.size();
764773
new_leaf->ports[0] = get_generic_port(arch_, new_leaf, IN_PORT, "in", MODEL_NAMES, in_size);
765774
new_leaf->ports[1] = get_generic_port(arch_, new_leaf, OUT_PORT, "out", MODEL_NAMES);
766775

@@ -781,13 +790,13 @@ struct ArchReader {
781790
std::string output_string;
782791

783792
if (i < num_pins - 1) {
784-
istr << lut_bel.input_pins[i];
793+
istr << lut_bel->input_pins[i];
785794
ostr << "in[" << i << "]";
786795
input_string = std::string(lut->name) + std::string(".") + istr.str();
787796
output_string = std::string(new_leaf->name) + std::string(".") + ostr.str();
788797
} else {
789798
istr << "out";
790-
ostr << lut_bel.output_pin;
799+
ostr << lut_bel->output_pin;
791800
input_string = std::string(new_leaf->name) + std::string(".") + istr.str();
792801
output_string = std::string(lut->name) + std::string(".") + ostr.str();
793802
}
@@ -1533,10 +1542,10 @@ struct ArchReader {
15331542
// the RR graph generation is correct.
15341543
// This can be removed once the RR graph reader from the interchange
15351544
// device is ready and functional.
1536-
int num_seg = 1; //wire_names.size();
1545+
size_t num_seg = 1; //wire_names.size();
15371546

15381547
arch_->Segments.resize(num_seg);
1539-
uint32_t index = 0;
1548+
size_t index = 0;
15401549
for (auto i : wire_names) {
15411550
if (index >= num_seg) break;
15421551

0 commit comments

Comments
 (0)