From e3709ce7767c0e23568cf89366fc049a47bdc5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Thu, 12 Jan 2023 19:10:00 +0100 Subject: [PATCH 1/9] passes: show: Fix portbox bit ranges in case of driven signals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the 'show' pass generates portboxes to detail the connection of cell ports to wires, it has special handling of signal chunk repetitions, but those repetitions are not accounted for in the displayed bit range in case of cell outputs. Fix that, and so bring it into consistence with the behavior on cell inputs. So, taking for example the following Verilog snippet, module DRIVER (Q); output [7:0] Q; assign Q = 8'b10101010; endmodule module main; wire w; DRIVER driver(.Q({8{w}})); endmodule make the show pass display '7:0 - 8x 0:0' in the driver-to-w portbox instead of '7:7 - 8x 0:0' which it displayed formerly. Signed-off-by: Martin Povišer --- passes/cmds/show.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index b186e5db2..850bd1889 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -272,7 +272,7 @@ struct ShowWorker std::string repinfo = rep > 1 ? stringf("%dx ", rep) : ""; if (driver) { log_assert(!net.empty()); - label_string += stringf(" %d:%d - %s%d:%d |", i, pos, pos-c.width+1, repinfo.c_str(), cl, cr); + label_string += stringf(" %d:%d - %s%d:%d |", i, pos, pos-rep*c.width+1, repinfo.c_str(), cl, cr); net_conn_map[net].in.insert({stringf("x%d:s%d", idx, i), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); } else From 13700e12e5ef62a9d462ddf8ec883ab19ba1d700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Thu, 12 Jan 2023 17:03:13 +0100 Subject: [PATCH 2/9] passes: show: s/idx/dot_idx/ for readability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Povišer --- passes/cmds/show.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index 850bd1889..bd9d1ef4e 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -239,9 +239,9 @@ struct ShowWorker std::string net = gen_signode_simple(sig); if (net.empty()) { + int dot_idx = single_idx_count++; std::string label_string; int pos = sig.size()-1; - int idx = single_idx_count++; for (int rep, i = int(sig.chunks().size())-1; i >= 0; i -= rep) { const RTLIL::SigChunk &c = sig.chunks().at(i); int cl, cr; @@ -273,7 +273,7 @@ struct ShowWorker if (driver) { log_assert(!net.empty()); label_string += stringf(" %d:%d - %s%d:%d |", i, pos, pos-rep*c.width+1, repinfo.c_str(), cl, cr); - net_conn_map[net].in.insert({stringf("x%d:s%d", idx, i), rep*c.width}); + net_conn_map[net].in.insert({stringf("x%d:s%d", dot_idx, i), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); } else if (net.empty()) { @@ -286,24 +286,24 @@ struct ShowWorker pos, pos-rep*c.width+1); } else { label_string += stringf(" %s%d:%d - %d:%d |", i, repinfo.c_str(), cl, cr, pos, pos-rep*c.width+1); - net_conn_map[net].out.insert({stringf("x%d:s%d", idx, i), rep*c.width}); + net_conn_map[net].out.insert({stringf("x%d:s%d", dot_idx, i), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); } pos -= rep * c.width; } if (label_string[label_string.size()-1] == '|') label_string = label_string.substr(0, label_string.size()-1); - code += stringf("x%d [ shape=record, style=rounded, label=\"%s\" ];\n", idx, label_string.c_str()); + code += stringf("x%d [ shape=record, style=rounded, label=\"%s\" ];\n", dot_idx, label_string.c_str()); if (!port.empty()) { currentColor = xorshift32(currentColor); log_warning("WIDTHLABEL %s %d\n", log_signal(sig), GetSize(sig)); if (driver) - code += stringf("%s:e -> x%d:w [arrowhead=odiamond, arrowtail=odiamond, dir=both, %s, %s];\n", port.c_str(), idx, nextColor(sig).c_str(), widthLabel(sig.size()).c_str()); + code += stringf("%s:e -> x%d:w [arrowhead=odiamond, arrowtail=odiamond, dir=both, %s, %s];\n", port.c_str(), dot_idx, nextColor(sig).c_str(), widthLabel(sig.size()).c_str()); else - code += stringf("x%d:e -> %s:w [arrowhead=odiamond, arrowtail=odiamond, dir=both, %s, %s];\n", idx, port.c_str(), nextColor(sig).c_str(), widthLabel(sig.size()).c_str()); + code += stringf("x%d:e -> %s:w [arrowhead=odiamond, arrowtail=odiamond, dir=both, %s, %s];\n", dot_idx, port.c_str(), nextColor(sig).c_str(), widthLabel(sig.size()).c_str()); } if (node != nullptr) - *node = stringf("x%d", idx); + *node = stringf("x%d", dot_idx); } else { From 58487908352621036aa360f6bed441fc46b1882e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Thu, 12 Jan 2023 17:06:31 +0100 Subject: [PATCH 3/9] passes: show: Label signed_suffix flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To make it easier to follow what's going on. Signed-off-by: Martin Povišer --- passes/cmds/show.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index bd9d1ef4e..ec89fe83a 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -431,10 +431,13 @@ struct ShowWorker std::string label_string = "{{"; - for (auto &p : in_ports) + for (auto &p : in_ports) { + bool signed_suffix = genSignedLabels && cell->hasParam(p.str() + "_SIGNED") + && cell->getParam(p.str() + "_SIGNED").as_bool(); + label_string += stringf(" %s%s|", id2num(p), escape(p.str()), - genSignedLabels && cell->hasParam(p.str() + "_SIGNED") && - cell->getParam(p.str() + "_SIGNED").as_bool() ? "*" : ""); + signed_suffix ? "*" : ""); + } if (label_string[label_string.size()-1] == '|') label_string = label_string.substr(0, label_string.size()-1); From ad149cc42aee9394ed5aa2783766fb039d23d2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Thu, 12 Jan 2023 17:09:53 +0100 Subject: [PATCH 4/9] passes: show: Factor out 'join_label_pieces' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In two places, we are joining label pieces by a '|' separator. We go about it by putting the separator behind each entry, then removing the trailing separator in a final fixup pass on the built string. For easier reading, replace those occurrences by a new factored-out 'join_label_pieces' function. Signed-off-by: Martin Povišer --- passes/cmds/show.cc | 55 ++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index ec89fe83a..c1a0c35ee 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -233,6 +233,22 @@ struct ShowWorker return std::string(); } + // Return the pieces of a label joined by a '|' separator + std::string join_label_pieces(std::vector pieces) + { + std::string ret = ""; + bool first_piece = true; + + for (auto &piece : pieces) { + if (!first_piece) + ret += "|"; + ret += piece; + first_piece = false; + } + + return ret; + } + std::string gen_portbox(std::string port, RTLIL::SigSpec sig, bool driver, std::string *node = nullptr) { std::string code; @@ -240,7 +256,7 @@ struct ShowWorker if (net.empty()) { int dot_idx = single_idx_count++; - std::string label_string; + std::vector label_pieces; int pos = sig.size()-1; for (int rep, i = int(sig.chunks().size())-1; i >= 0; i -= rep) { const RTLIL::SigChunk &c = sig.chunks().at(i); @@ -272,28 +288,29 @@ struct ShowWorker std::string repinfo = rep > 1 ? stringf("%dx ", rep) : ""; if (driver) { log_assert(!net.empty()); - label_string += stringf(" %d:%d - %s%d:%d |", i, pos, pos-rep*c.width+1, repinfo.c_str(), cl, cr); + label_pieces.push_back(stringf(" %d:%d - %s%d:%d ", i, pos, pos-rep*c.width+1, repinfo.c_str(), cl, cr)); net_conn_map[net].in.insert({stringf("x%d:s%d", dot_idx, i), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); } else if (net.empty()) { log_assert(rep == 1); - label_string += stringf("%c -> %d:%d |", + label_pieces.push_back(stringf("%c -> %d:%d ", c.data.front() == State::S0 ? '0' : c.data.front() == State::S1 ? '1' : c.data.front() == State::Sx ? 'X' : c.data.front() == State::Sz ? 'Z' : '?', - pos, pos-rep*c.width+1); + pos, pos-rep*c.width+1)); } else { - label_string += stringf(" %s%d:%d - %d:%d |", i, repinfo.c_str(), cl, cr, pos, pos-rep*c.width+1); + label_pieces.push_back(stringf(" %s%d:%d - %d:%d ", i, repinfo.c_str(), cl, cr, pos, pos-rep*c.width+1)); net_conn_map[net].out.insert({stringf("x%d:s%d", dot_idx, i), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); } pos -= rep * c.width; } - if (label_string[label_string.size()-1] == '|') - label_string = label_string.substr(0, label_string.size()-1); - code += stringf("x%d [ shape=record, style=rounded, label=\"%s\" ];\n", dot_idx, label_string.c_str()); + + code += stringf("x%d [ shape=record, style=rounded, label=\"", dot_idx) \ + + join_label_pieces(label_pieces) + "\" ];\n"; + if (!port.empty()) { currentColor = xorshift32(currentColor); log_warning("WIDTHLABEL %s %d\n", log_signal(sig), GetSize(sig)); @@ -418,6 +435,7 @@ struct ShowWorker for (auto cell : module->selected_cells()) { std::vector in_ports, out_ports; + std::vector in_label_pieces, out_label_pieces; for (auto &conn : cell->connections()) { if (!ct.cell_output(cell->type, conn.first)) @@ -429,26 +447,23 @@ struct ShowWorker std::sort(in_ports.begin(), in_ports.end(), RTLIL::sort_by_id_str()); std::sort(out_ports.begin(), out_ports.end(), RTLIL::sort_by_id_str()); - std::string label_string = "{{"; - for (auto &p : in_ports) { bool signed_suffix = genSignedLabels && cell->hasParam(p.str() + "_SIGNED") && cell->getParam(p.str() + "_SIGNED").as_bool(); - label_string += stringf(" %s%s|", id2num(p), escape(p.str()), - signed_suffix ? "*" : ""); + in_label_pieces.push_back(stringf(" %s%s", id2num(p), escape(p.str()), + signed_suffix ? "*" : "")); } - if (label_string[label_string.size()-1] == '|') - label_string = label_string.substr(0, label_string.size()-1); - - label_string += stringf("}|%s\\n%s|{", findLabel(cell->name.str()), escape(cell->type.str())); for (auto &p : out_ports) - label_string += stringf(" %s|", id2num(p), escape(p.str())); - if (label_string[label_string.size()-1] == '|') - label_string = label_string.substr(0, label_string.size()-1); + out_label_pieces.push_back(stringf(" %s", id2num(p), escape(p.str()))); - label_string += "}}"; + std::string in_label = join_label_pieces(in_label_pieces); + std::string out_label = join_label_pieces(out_label_pieces); + + std::string label_string = stringf("{{%s}|%s\\n%s|{%s}}", in_label.c_str(), + findLabel(cell->name.str()), escape(cell->type.str()), + out_label.c_str()); std::string code; for (auto &conn : cell->connections()) { From 8b1f5fba62e2d065d8bc31990927931fb67a4a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Thu, 12 Jan 2023 17:24:31 +0100 Subject: [PATCH 5/9] passes: show: Simplify wire bit range logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Povišer --- passes/cmds/show.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index c1a0c35ee..5739c79cd 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -261,18 +261,20 @@ struct ShowWorker for (int rep, i = int(sig.chunks().size())-1; i >= 0; i -= rep) { const RTLIL::SigChunk &c = sig.chunks().at(i); int cl, cr; - if (c.wire) { + + cl = c.offset + c.width - 1; + cr = c.offset; + + if (c.is_wire()) { if (c.wire->upto) { - cr = c.wire->start_offset + (c.wire->width - c.offset - 1); + cr = (c.wire->width - 1) - c.offset; cl = cr - (c.width - 1); - } else { - cr = c.wire->start_offset + c.offset; - cl = cr + c.width - 1; } - } else { - cl = c.offset + c.width - 1; - cr = c.offset; + + cl += c.wire->start_offset; + cr += c.wire->start_offset; } + if (!driver && c.wire == nullptr) { RTLIL::State s1 = c.data.front(); for (auto s2 : c.data) From 60318a5cd8ecea034ce82873a1fe49aae0d82374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Fri, 13 Jan 2023 16:17:03 +0100 Subject: [PATCH 6/9] passes: show: Label no_signode flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Label the flag and rearrange the control flow a bit. Signed-off-by: Martin Povišer --- passes/cmds/show.cc | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index 5739c79cd..ace9eec5b 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -275,17 +275,15 @@ struct ShowWorker cr += c.wire->start_offset; } - if (!driver && c.wire == nullptr) { - RTLIL::State s1 = c.data.front(); - for (auto s2 : c.data) - if (s1 != s2) - goto not_const_stream; - net.clear(); - } else { - not_const_stream: + // Is this chunk a constant filled with one kind of bit state? + bool no_signode = !driver && !c.is_wire() \ + && std::equal(c.data.begin() + 1, c.data.end(), c.data.begin()); + + if (!no_signode) { net = gen_signode_simple(c, false); log_assert(!net.empty()); } + for (rep = 1; i-rep >= 0 && c == sig.chunks().at(i-rep); rep++) {} std::string repinfo = rep > 1 ? stringf("%dx ", rep) : ""; if (driver) { @@ -293,19 +291,20 @@ struct ShowWorker label_pieces.push_back(stringf(" %d:%d - %s%d:%d ", i, pos, pos-rep*c.width+1, repinfo.c_str(), cl, cr)); net_conn_map[net].in.insert({stringf("x%d:s%d", dot_idx, i), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); - } else - if (net.empty()) { - log_assert(rep == 1); - label_pieces.push_back(stringf("%c -> %d:%d ", - c.data.front() == State::S0 ? '0' : - c.data.front() == State::S1 ? '1' : - c.data.front() == State::Sx ? 'X' : - c.data.front() == State::Sz ? 'Z' : '?', - pos, pos-rep*c.width+1)); } else { - label_pieces.push_back(stringf(" %s%d:%d - %d:%d ", i, repinfo.c_str(), cl, cr, pos, pos-rep*c.width+1)); - net_conn_map[net].out.insert({stringf("x%d:s%d", dot_idx, i), rep*c.width}); - net_conn_map[net].color = nextColor(c, net_conn_map[net].color); + if (no_signode) { + log_assert(rep == 1); + label_pieces.push_back(stringf("%c -> %d:%d ", + c.data.front() == State::S0 ? '0' : + c.data.front() == State::S1 ? '1' : + c.data.front() == State::Sx ? 'X' : + c.data.front() == State::Sz ? 'Z' : '?', + pos, pos-rep*c.width+1)); + } else { + label_pieces.push_back(stringf(" %s%d:%d - %d:%d ", i, repinfo.c_str(), cl, cr, pos, pos-rep*c.width+1)); + net_conn_map[net].out.insert({stringf("x%d:s%d", dot_idx, i), rep*c.width}); + net_conn_map[net].color = nextColor(c, net_conn_map[net].color); + } } pos -= rep * c.width; } From 61abca10a355b512a5f7d089aaf043d5df4d9ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Fri, 13 Jan 2023 16:10:20 +0100 Subject: [PATCH 7/9] passes: show: Touch chunk iteration in gen_portbox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Povišer --- passes/cmds/show.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index ace9eec5b..db428b329 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -258,10 +258,14 @@ struct ShowWorker int dot_idx = single_idx_count++; std::vector label_pieces; int pos = sig.size()-1; - for (int rep, i = int(sig.chunks().size())-1; i >= 0; i -= rep) { - const RTLIL::SigChunk &c = sig.chunks().at(i); - int cl, cr; + for (int rep, chunk_idx = ((int) sig.chunks().size()) - 1; chunk_idx >= 0; chunk_idx -= rep) { + const RTLIL::SigChunk &c = sig.chunks().at(chunk_idx); + + // Find the number of times this chunk is repeating + for (rep = 1; chunk_idx - rep >= 0 && c == sig.chunks().at(chunk_idx - rep); rep++); + + int cl, cr; cl = c.offset + c.width - 1; cr = c.offset; @@ -284,12 +288,11 @@ struct ShowWorker log_assert(!net.empty()); } - for (rep = 1; i-rep >= 0 && c == sig.chunks().at(i-rep); rep++) {} std::string repinfo = rep > 1 ? stringf("%dx ", rep) : ""; if (driver) { log_assert(!net.empty()); - label_pieces.push_back(stringf(" %d:%d - %s%d:%d ", i, pos, pos-rep*c.width+1, repinfo.c_str(), cl, cr)); - net_conn_map[net].in.insert({stringf("x%d:s%d", dot_idx, i), rep*c.width}); + label_pieces.push_back(stringf(" %d:%d - %s%d:%d ", chunk_idx, pos, pos-rep*c.width+1, repinfo.c_str(), cl, cr)); + net_conn_map[net].in.insert({stringf("x%d:s%d", dot_idx, chunk_idx), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); } else { if (no_signode) { @@ -301,8 +304,8 @@ struct ShowWorker c.data.front() == State::Sz ? 'Z' : '?', pos, pos-rep*c.width+1)); } else { - label_pieces.push_back(stringf(" %s%d:%d - %d:%d ", i, repinfo.c_str(), cl, cr, pos, pos-rep*c.width+1)); - net_conn_map[net].out.insert({stringf("x%d:s%d", dot_idx, i), rep*c.width}); + label_pieces.push_back(stringf(" %s%d:%d - %d:%d ", chunk_idx, repinfo.c_str(), cl, cr, pos, pos-rep*c.width+1)); + net_conn_map[net].out.insert({stringf("x%d:s%d", dot_idx, chunk_idx), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); } } From 314b8642051d8eb418a28e728cf5dcb788815307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Fri, 13 Jan 2023 16:25:02 +0100 Subject: [PATCH 8/9] passes: show: Reuse string parts in generation of portboxes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Povišer --- passes/cmds/show.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index db428b329..6e8ae6eda 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -289,9 +289,12 @@ struct ShowWorker } std::string repinfo = rep > 1 ? stringf("%dx ", rep) : ""; + std::string portside = stringf("%d:%d", pos, pos - rep*c.width + 1); + std::string remoteside = stringf("%s%d:%d", repinfo.c_str(), cl, cr); + if (driver) { log_assert(!net.empty()); - label_pieces.push_back(stringf(" %d:%d - %s%d:%d ", chunk_idx, pos, pos-rep*c.width+1, repinfo.c_str(), cl, cr)); + label_pieces.push_back(stringf(" %s - %s ", chunk_idx, portside.c_str(), remoteside.c_str())); net_conn_map[net].in.insert({stringf("x%d:s%d", dot_idx, chunk_idx), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); } else { @@ -304,7 +307,7 @@ struct ShowWorker c.data.front() == State::Sz ? 'Z' : '?', pos, pos-rep*c.width+1)); } else { - label_pieces.push_back(stringf(" %s%d:%d - %d:%d ", chunk_idx, repinfo.c_str(), cl, cr, pos, pos-rep*c.width+1)); + label_pieces.push_back(stringf(" %s - %s ", chunk_idx, remoteside.c_str(), portside.c_str())); net_conn_map[net].out.insert({stringf("x%d:s%d", dot_idx, chunk_idx), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); } From f9e30ee5e07745721b27b9f17749f095d57d2c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Fri, 13 Jan 2023 16:16:03 +0100 Subject: [PATCH 9/9] passes: show: s/pos/bitpos/ for readability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Povišer --- passes/cmds/show.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index 6e8ae6eda..614009585 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -257,7 +257,7 @@ struct ShowWorker { int dot_idx = single_idx_count++; std::vector label_pieces; - int pos = sig.size()-1; + int bitpos = sig.size()-1; for (int rep, chunk_idx = ((int) sig.chunks().size()) - 1; chunk_idx >= 0; chunk_idx -= rep) { const RTLIL::SigChunk &c = sig.chunks().at(chunk_idx); @@ -289,7 +289,7 @@ struct ShowWorker } std::string repinfo = rep > 1 ? stringf("%dx ", rep) : ""; - std::string portside = stringf("%d:%d", pos, pos - rep*c.width + 1); + std::string portside = stringf("%d:%d", bitpos, bitpos - rep*c.width + 1); std::string remoteside = stringf("%s%d:%d", repinfo.c_str(), cl, cr); if (driver) { @@ -305,14 +305,15 @@ struct ShowWorker c.data.front() == State::S1 ? '1' : c.data.front() == State::Sx ? 'X' : c.data.front() == State::Sz ? 'Z' : '?', - pos, pos-rep*c.width+1)); + bitpos, bitpos-rep*c.width+1)); } else { label_pieces.push_back(stringf(" %s - %s ", chunk_idx, remoteside.c_str(), portside.c_str())); net_conn_map[net].out.insert({stringf("x%d:s%d", dot_idx, chunk_idx), rep*c.width}); net_conn_map[net].color = nextColor(c, net_conn_map[net].color); } } - pos -= rep * c.width; + + bitpos -= rep * c.width; } code += stringf("x%d [ shape=record, style=rounded, label=\"", dot_idx) \