Skip to content

Commit 1a54e8d

Browse files
authored
Merge pull request #4379 from QuantamHD/fix_verific
frontend: Fixes verific import around range order
2 parents bdce7fa + 82a4a87 commit 1a54e8d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

frontends/verific/verific.cc

+10-2
Original file line numberDiff line numberDiff line change
@@ -2156,8 +2156,16 @@ void VerificImporter::import_netlist(RTLIL::Design *design, Netlist *nl, std::ma
21562156
int port_offset = 0;
21572157
if (pr->GetPort()->Bus()) {
21582158
port_name = pr->GetPort()->Bus()->Name();
2159-
port_offset = pr->GetPort()->Bus()->IndexOf(pr->GetPort()) -
2160-
min(pr->GetPort()->Bus()->LeftIndex(), pr->GetPort()->Bus()->RightIndex());
2159+
int msb_index = pr->GetPort()->Bus()->LeftIndex();
2160+
int lsb_index = pr->GetPort()->Bus()->RightIndex();
2161+
int index_of_port = pr->GetPort()->Bus()->IndexOf(pr->GetPort());
2162+
port_offset = index_of_port - min(msb_index, lsb_index);
2163+
// In cases where the msb order is flipped we need to make sure
2164+
// that the indicies match LSB = 0 order to match the std::vector
2165+
// to SigSpec LSB = 0 precondition.
2166+
if (lsb_index > msb_index) {
2167+
port_offset = abs(port_offset - (lsb_index - min(msb_index, lsb_index)));
2168+
}
21612169
}
21622170
IdString port_name_id = RTLIL::escape_id(port_name);
21632171
auto &sigvec = cell_port_conns[port_name_id];

0 commit comments

Comments
 (0)