Skip to content

Commit 1f9013a

Browse files
authored
Merge branch 'YosysHQ:main' into main
2 parents 3a93d1c + 7d82d80 commit 1f9013a

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

frontends/verilog/verilog_parser.y

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,15 +3289,19 @@ basic_expr:
32893289
$$ = AstNode::mkconst_str(@1, *$1);
32903290
SET_AST_NODE_LOC($$.get(), @1, @1);
32913291
} |
3292-
hierarchical_id attr {
3293-
// super sketchy! Orphaned pointer in non-owning extra->ast_stack
3294-
AstNode *node = new AstNode(@1, AST_FCALL);
3295-
node->str = *$1;
3296-
extra->ast_stack.push_back(node);
3297-
SET_AST_NODE_LOC(node, @1, @1);
3298-
append_attr(node, std::move($2));
3292+
hierarchical_id attr <ast_t>{
3293+
// Here we use "Typed Midrule Actions".
3294+
// https://www.gnu.org/software/bison/manual/html_node/Typed-Midrule-Actions.html
3295+
auto fcall = std::make_unique<AstNode>(@1, AST_FCALL);
3296+
AstNode *fcall_node = fcall.get();
3297+
fcall_node->str = *$1;
3298+
extra->ast_stack.push_back(fcall_node);
3299+
SET_AST_NODE_LOC(fcall_node, @1, @1);
3300+
append_attr(fcall_node, std::move($2));
3301+
$$ = std::move(fcall);
32993302
} TOK_LPAREN arg_list optional_comma TOK_RPAREN {
3300-
$$.reset(extra->ast_stack.back());
3303+
log_assert($3 != nullptr);
3304+
$$ = std::move($3);
33013305
extra->ast_stack.pop_back();
33023306
} |
33033307
TOK_TO_SIGNED attr TOK_LPAREN expr TOK_RPAREN {

passes/cmds/show.cc

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct ShowWorker
5959
RTLIL::Module *module;
6060
uint32_t currentColor;
6161
bool genWidthLabels;
62+
std::string wireshape;
6263
bool genSignedLabels;
6364
bool stretchIO;
6465
bool enumerateIds;
@@ -428,16 +429,19 @@ struct ShowWorker
428429

429430
std::map<std::string, std::string> wires_on_demand;
430431
for (auto wire : module->selected_wires()) {
431-
const char *shape = "diamond";
432+
std::string shape = wireshape;
432433
if (wire->port_input || wire->port_output)
433434
shape = "octagon";
435+
const bool is_borderless = (shape == "plaintext") || (shape == "plain") || (shape == "none");
434436
if (wire->name.isPublic()) {
435437
std::string src_href;
436438
if (href && wire->attributes.count(ID::src) > 0)
437439
src_href = stringf(", href=\"%s\" ", escape(wire->attributes.at(ID::src).decode_string()));
438-
fprintf(f, "n%d [ shape=%s, label=\"%s\", %s%s];\n",
439-
id2num(wire->name), shape, findLabel(wire->name.str()),
440-
nextColor(RTLIL::SigSpec(wire), "color=\"black\", fontcolor=\"black\"").c_str(),
440+
fprintf(f, "n%d [ shape=%s,%s label=\"%s\", %s%s];\n",
441+
id2num(wire->name), shape.c_str(), is_borderless? " margin=0, width=0" : "", findLabel(wire->name.str()),
442+
is_borderless
443+
? "color=\"none\", fontcolor=\"black\""
444+
: nextColor(RTLIL::SigSpec(wire), "color=\"black\", fontcolor=\"black\"").c_str(),
441445
src_href.c_str());
442446
if (wire->port_input)
443447
all_sources.insert(stringf("n%d", id2num(wire->name)));
@@ -616,10 +620,10 @@ struct ShowWorker
616620
}
617621

618622
ShowWorker(FILE *f, RTLIL::Design *design, std::vector<RTLIL::Design*> &libs, uint32_t colorSeed, bool genWidthLabels,
619-
bool genSignedLabels, bool stretchIO, bool enumerateIds, bool abbreviateIds, bool notitle, bool href,
623+
const std::string wireshape, bool genSignedLabels, bool stretchIO, bool enumerateIds, bool abbreviateIds, bool notitle, bool href,
620624
const std::vector<std::pair<std::string, RTLIL::Selection>> &color_selections,
621625
const std::vector<std::pair<std::string, RTLIL::Selection>> &label_selections, RTLIL::IdString colorattr) :
622-
f(f), design(design), currentColor(colorSeed), genWidthLabels(genWidthLabels),
626+
f(f), design(design), currentColor(colorSeed), genWidthLabels(genWidthLabels), wireshape(wireshape),
623627
genSignedLabels(genSignedLabels), stretchIO(stretchIO), enumerateIds(enumerateIds), abbreviateIds(abbreviateIds),
624628
notitle(notitle), href(href), color_selections(color_selections), label_selections(label_selections), colorattr(colorattr)
625629
{
@@ -712,6 +716,9 @@ struct ShowPass : public Pass {
712716
log(" Use the specified attribute to assign colors. A unique color is\n");
713717
log(" assigned to each unique value of this attribute.\n");
714718
log("\n");
719+
log(" -wireshape <graphviz_shape>\n");
720+
log(" Use the specified shape for wire nodes. E.g. plaintext.\n");
721+
log("\n");
715722
log(" -width\n");
716723
log(" annotate buses with a label indicating the width of the bus.\n");
717724
log("\n");
@@ -770,6 +777,7 @@ struct ShowPass : public Pass {
770777
std::string prefix = stringf("%s/.yosys_show", getenv("HOME") ? getenv("HOME") : ".");
771778
#endif
772779
std::string viewer_exe;
780+
std::string flag_wireshape = "diamond";
773781
std::vector<std::string> libfiles;
774782
std::vector<RTLIL::Design*> libs;
775783
uint32_t colorSeed = 0;
@@ -834,6 +842,10 @@ struct ShowPass : public Pass {
834842
format = args[++argidx];
835843
continue;
836844
}
845+
if (arg == "-wireshape" && argidx+1 < args.size()) {
846+
flag_wireshape = args[++argidx];
847+
continue;
848+
}
837849
if (arg == "-width") {
838850
flag_width= true;
839851
continue;
@@ -916,7 +928,7 @@ struct ShowPass : public Pass {
916928
delete lib;
917929
log_cmd_error("Can't open dot file `%s' for writing.\n", dot_file.c_str());
918930
}
919-
ShowWorker worker(f, design, libs, colorSeed, flag_width, flag_signed, flag_stretch, flag_enum, flag_abbreviate, flag_notitle, flag_href, color_selections, label_selections, colorattr);
931+
ShowWorker worker(f, design, libs, colorSeed, flag_width, flag_wireshape, flag_signed, flag_stretch, flag_enum, flag_abbreviate, flag_notitle, flag_href, color_selections, label_selections, colorattr);
920932
fclose(f);
921933

922934
for (auto lib : libs)

tests/cxxrtl/run-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -ex
55
run_subtest () {
66
local subtest=$1; shift
77

8-
${CC:-gcc} -std=c++11 -O2 -o cxxrtl-test-${subtest} -I../../backends/cxxrtl/runtime test_${subtest}.cc -lstdc++
8+
${CXX:-g++} -std=c++11 -O2 -o cxxrtl-test-${subtest} -I../../backends/cxxrtl/runtime test_${subtest}.cc -lstdc++
99
./cxxrtl-test-${subtest}
1010
}
1111

@@ -14,4 +14,4 @@ run_subtest value_fuzz
1414

1515
# Compile-only test.
1616
../../yosys -p "read_verilog test_unconnected_output.v; select =*; proc; clean; write_cxxrtl cxxrtl-test-unconnected_output.cc"
17-
${CC:-gcc} -std=c++11 -c -o cxxrtl-test-unconnected_output -I../../backends/cxxrtl/runtime cxxrtl-test-unconnected_output.cc
17+
${CXX:-g++} -std=c++11 -c -o cxxrtl-test-unconnected_output -I../../backends/cxxrtl/runtime cxxrtl-test-unconnected_output.cc

tests/fmt/run-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ test_cxxrtl () {
5151
local subtest=$1; shift
5252

5353
../../yosys -p "read_verilog ${subtest}.v; proc; clean; write_cxxrtl -print-output std::cerr yosys-${subtest}.cc"
54-
${CC:-gcc} -std=c++11 -o yosys-${subtest} -I../../backends/cxxrtl/runtime ${subtest}_tb.cc -lstdc++
54+
${CXX:-g++} -std=c++11 -o yosys-${subtest} -I../../backends/cxxrtl/runtime ${subtest}_tb.cc -lstdc++
5555
./yosys-${subtest} 2>yosys-${subtest}.log
5656
iverilog -o iverilog-${subtest} ${subtest}.v ${subtest}_tb.v
5757
./iverilog-${subtest} |grep -v '\$finish called' >iverilog-${subtest}.log
@@ -69,7 +69,7 @@ diff iverilog-always_full.log iverilog-always_full-1.log
6969

7070
../../yosys -p "read_verilog display_lm.v" >yosys-display_lm.log
7171
../../yosys -p "read_verilog display_lm.v; write_cxxrtl yosys-display_lm.cc"
72-
${CC:-gcc} -std=c++11 -o yosys-display_lm_cc -I../../backends/cxxrtl/runtime display_lm_tb.cc -lstdc++
72+
${CXX:-g++} -std=c++11 -o yosys-display_lm_cc -I../../backends/cxxrtl/runtime display_lm_tb.cc -lstdc++
7373
./yosys-display_lm_cc >yosys-display_lm_cc.log
7474
for log in yosys-display_lm.log yosys-display_lm_cc.log; do
7575
grep "^%l: \\\\bot\$" "$log"

tests/tools/autotest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ xfirrtl="../xfirrtl"
2626
abcprog="$toolsdir/../../yosys-abc"
2727

2828
if [ ! -f "$toolsdir/cmp_tbdata" -o "$toolsdir/cmp_tbdata.c" -nt "$toolsdir/cmp_tbdata" ]; then
29-
( set -ex; ${CC:-gcc} -Wall -o "$toolsdir/cmp_tbdata" "$toolsdir/cmp_tbdata.c"; ) || exit 1
29+
( set -ex; ${CXX:-g++} -Wall -o "$toolsdir/cmp_tbdata" "$toolsdir/cmp_tbdata.c"; ) || exit 1
3030
fi
3131

3232
while getopts xmGl:wkjvref:s:p:n:S:I:A:-: opt; do

0 commit comments

Comments
 (0)