Repository navigation
Description
register_alias() writes (2, 2) as the size of an alias for a four-bit compound variable. The original declaration correctly uses 4.
Reproduced with CPython 3.12.3 on PyVCD 0.5.1.dev0 installed from acfdd0b5a5a3b89f1587d8b4488e766f18197002 and the PyPI 0.5.0 wheel.
Reproduction
Save this as repro-alias.py:
import io
from vcd import VCDWriter
output = io.StringIO()
writer = VCDWriter(output, timescale="1 ns", date="")
var = writer.register_var("top", "original", "reg", size=(2, 2), init=(1, 2))
writer.register_alias("top", "copy", var)
writer.change(var, 1, (3, 1))
writer.close()
print(output.getvalue(), end="")In a fresh directory with Python 3.12.3, run in Bash:
python3 -m venv .venv
.venv/bin/python -m pip install --only-binary=:all: pyvcd==0.5.0
.venv/bin/python repro-alias.pyTo check the source pin in the same environment:
git clone https://github.com/SanDisk-Open-Source/pyvcd.git pyvcd-src
git -C pyvcd-src checkout --detach acfdd0b5a5a3b89f1587d8b4488e766f18197002
.venv/bin/python -m pip install ./pyvcd-src
.venv/bin/python repro-alias.pyExpected and observed
Tuple widths are documented by register_var(), writer.py:142. register_alias(), writer.py:266 documents the same identifier, type and size for both names. IEEE 1800-2023 §21.7.2.1, Syntax 21-20 and IEEE 1364-2005 §18.2.3.7, Syntax 18-15 require a decimal bit width in this four-state VCD declaration.
Expected:
$timescale 1 ns $end
$scope module top $end
$var reg 4 ! original $end
$var reg 4 ! copy $end
$upscope $end
$enddefinitions $end
#0
$dumpvars
b110 !
$end
#1
b1101 !
Both installations produce the same text except for the alias declaration:
$var reg (2, 2) ! copy $end
Initial registration, writer.py:198 sums the tuple for the declaration. Alias registration, writer.py:291 writes var.size directly. The alias declaration should use the total width while retaining the tuple for compound-value packing.
Scope
Verification covered tuple widths (2, 2), (1, 3) and (3, 5, 8), with aliases in the same scope and a child scope, on both installations. Integer-width aliases and compound variables without aliases passed. All 694 upstream tests and 14 conformance controls passed on each installation.
A headless GTKWave 4.0.0-prealpha (132a086) VCD/FST roundtrip returned $var reg 1 " ! copy $end for the actual fixture and $var reg 4 ! copy $end for the expected fixture. In this conversion, the intended four-bit alias became a separate one-bit variable. The original signal remained present. Other consumers were not exhaustively tested. No fix or formal proof was tested. A read-only upstream check found current master still equals the tested pin.
The small reproducer is provided under CC0.
Found by ChipLab's AI verification agents and independently reproduced.
ChipLab ref: CLAB-2026-586
Activity