Skip to content

Commit 3ad04b4

Browse files
committed
fasm: Handle tabs as whitespace in fasm metadata
Signed-off-by: Elms <[email protected]>
1 parent 4e823d1 commit 3ad04b4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

utils/fasm/src/fasm.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,18 @@ static LogicVec lut_outputs(const t_pb* atom_pb, size_t num_inputs, const t_pb_r
309309
return lut.table();
310310
}
311311

312+
static std::vector<std::string> split_fasm_entry(std::string entry,
313+
std::string delims,
314+
std::string ignore) {
315+
for (size_t ii=0; ii<entry.length(); ii++) {
316+
while (ignore.find(entry[ii]) != std::string::npos) {
317+
entry.erase(ii, 1);
318+
}
319+
}
320+
321+
return vtr::split(entry, delims);
322+
}
323+
312324
static const t_metadata_dict *get_fasm_type(const t_pb_graph_node* pb_graph_node, std::string target_type) {
313325
if(pb_graph_node == nullptr) {
314326
return nullptr;
@@ -361,7 +373,7 @@ const LutOutputDefinition* FasmWriterVisitor::find_lut(const t_pb_graph_node* pb
361373
if(meta != nullptr) {
362374
VTR_ASSERT(meta->has("fasm_lut"));
363375
std::string fasm_lut = meta->one("fasm_lut")->as_string();
364-
auto lut_parts = vtr::split(vtr::replace_all(fasm_lut, " ", ""), "\n");
376+
auto lut_parts = split_fasm_entry(fasm_lut, "\n", "\t ");
365377
if(__builtin_popcount(lut_parts.size()) != 1) {
366378
vpr_throw(VPR_ERROR_OTHER,
367379
__FILE__, __LINE__,
@@ -449,7 +461,7 @@ void FasmWriterVisitor::check_for_param(const t_pb *atom) {
449461
Parameters params;
450462
std::string fasm_params = meta->one("fasm_params")->as_string();
451463
for(const auto param : vtr::split(fasm_params, "\n")) {
452-
auto param_parts = vtr::split(vtr::replace_all(param, " ", ""), "=");
464+
auto param_parts = split_fasm_entry(param, "=", "\t ");
453465
if(param_parts.size() == 0) {
454466
continue;
455467
}
@@ -559,7 +571,7 @@ void FasmWriterVisitor::output_fasm_mux(std::string fasm_mux,
559571
auto pin_index = mux_input_pin->pin_number;
560572
auto mux_inputs = vtr::split(fasm_mux, "\n");
561573
for(const auto &mux_input : mux_inputs) {
562-
auto mux_parts = vtr::split(vtr::replace_all(mux_input, " ", ""), "=");
574+
auto mux_parts = split_fasm_entry(mux_input, "=", "\t ");
563575

564576
if(mux_parts.size() == 0) {
565577
// Swallow whitespace.

0 commit comments

Comments
 (0)