Skip to content

fix(readers): apply two's complement when load_waveform(signed=True) - #27

Merged
cxzzzz merged 1 commit into
mainfrom
fix/signed-twos-complement
Oct 15, 2026
Merged

cxzzzz merged 1 commit into
mainfrom
fix/signed-twos-complement

Conversation

@cxzzzz

@cxzzzz cxzzzz commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Summary

load_waveform(signed=True) set the signed flag but never applied the two's-complement conversion, so the raw unsigned bit patterns were only labelled as signed. The readers now build the Waveform as unsigned and call as_signed() when signed=True, so the result matches load_waveform(...).as_signed(). The change is in the shared _value_change_to_waveform in readers/base.py, so it applies to all readers.

Reported in #26.

Tests

  • Added test_vcd_load_waveform_signed_values, which compares signed=True against .as_signed() on a 4-bit counter. It fails without the fix.
  • Full suite: 395 passed, 65 skipped. The skipped tests are the FSDB ones, which I could not run in this environment, so the FSDB path is untested here.

@cxzzzz
cxzzzz merged commit 4d74883 into main Oct 15, 2026
20 checks passed
@cxzzzz
cxzzzz deleted the fix/signed-twos-complement branch October 15, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant