Skip to content

Commit 4b0ea42

Browse files
committed
vpr: base: interchange: netlist: add c-style init and fixed bug
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 54af79f commit 4b0ea42

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

vpr/src/base/read_interchange_netlist.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ struct NetlistReader {
168168
// TODO: export this to a library function to have generic parameter decoding
169169
if (entry.which() == LogicalNetlist::Netlist::PropertyMap::Entry::TEXT_VALUE) {
170170
const std::regex vhex_regex("[0-9]+'h([0-9A-Z]+)");
171-
const std::regex vbit_regex("[0-9]+'b([0-9A-Z]+)");
171+
const std::regex vbit_regex("[0-9]+'b([0-9]+)");
172+
const std::regex chex_regex("0x([0-9A-Za-z]+)");
173+
const std::regex cbit_regex("0b([0-9]+)");
172174
const std::regex bit_regex("[0-1]+");
173175
std::string init_str = str_list[entry.getTextValue()];
174176
std::smatch regex_matches;
@@ -180,9 +182,18 @@ struct NetlistReader {
180182
for (int bit = 3; bit >= 0; bit--)
181183
init.push_back((value >> bit) & 1);
182184
}
185+
else if (std::regex_match(init_str, regex_matches, chex_regex))
186+
for (const char& c : regex_matches[1].str()) {
187+
int value = std::stoi(std::string(1, c), 0, 16);
188+
for (int bit = 3; bit >= 0; bit--)
189+
init.push_back((value >> bit) & 1);
190+
}
183191
else if (std::regex_match(init_str, regex_matches, vbit_regex))
184192
for (const char& c : regex_matches[1].str())
185193
init.push_back((bool)std::stoi(std::string(1, c), 0, 2));
194+
else if (std::regex_match(init_str, regex_matches, cbit_regex))
195+
for (const char& c : regex_matches[1].str())
196+
init.push_back((bool)std::stoi(std::string(1, c), 0, 2));
186197
else if (std::regex_match(init_str, regex_matches, bit_regex))
187198
for (const char& c : init_str)
188199
init.push_back((bool)std::stoi(std::string(1, c), 0, 2));
@@ -260,6 +271,9 @@ struct NetlistReader {
260271

261272
int inum = 0;
262273
for (auto port : cell_lib.getPorts()) {
274+
if (port_net_map.find(port) == port_net_map.end())
275+
continue;
276+
263277
auto net_name = port_net_map.at(port);
264278
AtomNetId net_id = main_netlist_.create_net(net_name);
265279

0 commit comments

Comments
 (0)