Add nesting test.

This commit is contained in:
nella 2026-07-31 10:29:49 +02:00 committed by nella
parent 250a467518
commit 4baff94575
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
trap 'echo "ERROR in const_cmdline_nested.sh" >&2; exit 1' ERR
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
cat > "$tmp/design.v" <<'EOT'
module top(output [7:0] o);
assign o = 8'hAA;
endmodule
EOT
printf "setattr -set foo 2'd7 t:*\n" > "$tmp/inner.ys"
cat > "$tmp/outer.ys" <<EOT
read_verilog $tmp/design.v
prep -top top
script $tmp/inner.ys
setattr -set bar 3'd15 t:*
EOT
# nesting + revert
out=$(${YOSYS} -q "$tmp/outer.ys" 2>&1)
echo "$out" | grep -E "inner\.ys:1: Warning: While parsing constant \`2'd7'" > /dev/null
echo "$out" | grep -E "outer\.ys:[0-9]+: Warning: While parsing constant \`3'd15'" > /dev/null
# cmd fallback - no source location prefix
out=$(${YOSYS} -q -p "read_verilog $tmp/design.v; prep -top top; setattr -set foo 2'd7 t:*" 2>&1)
echo "$out" | grep -E "^Warning: While parsing constant \`2'd7'" > /dev/null