Skip to content

Bugfix for dumping xz values incorrectly - #12

Open
johnjohnlin wants to merge 2 commits into
gtkwave:mainfrom
johnjohnlin:main
Open

johnjohnlin wants to merge 2 commits into
gtkwave:mainfrom
johnjohnlin:main

Conversation

@johnjohnlin

Copy link
Copy Markdown
Contributor

@rfuest

rfuest commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

I've merged #11, please check if there are additional changes in this PR that should get merged.

@johnjohnlin
johnjohnlin force-pushed the main branch 6 times, most recently from 058401d to fbe1292 Compare September 13, 2026 17:41
Comment thread .github/workflows/regression.yml Outdated
uses: veryl-lang/setup-verilator@v1
with:
version: '5.050'
version: '5.044'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to revert to 5.044 since I always got http 404 recently...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A proper solution would be to build Verilator from source or to use the official Verilator docker image, instead of relying on some third party GH action.

Comment thread fstcpp/fstcpp.h
static const char* kEncodedBitToCharTable = (
"01" // Binary
"zxhu" // Verilog
"xzhu" // Verilog

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think xz is more reasonable than zx (see the case encoding below)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intentionally changed in #11 to match the encoding defined in the VPI standard to match the internal encoding used by the new 4 state support in Verilator.

case 2: delta_time_index = (delta_time_index<<4) | (1<<1) | 1; break; // 'Z'
case 3: delta_time_index = (delta_time_index<<4) | (0<<1) | 1; break; // 'X'
case 2: delta_time_index = (delta_time_index<<4) | (0<<1) | 1; break; // 'X'
case 3: delta_time_index = (delta_time_index<<4) | (1<<1) | 1; break; // 'Z'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the zxhu mapping results in 0123 -> 0110 mapping, which is not very reasonable. With xzhu, it becomes 0101

@johnjohnlin johnjohnlin left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments here explain my changes

@johnjohnlin

Copy link
Copy Markdown
Contributor Author

The most important change here is to add an bit-true, hand-crafted integration test for xz. The existing implementation cannot pass the added integration test. The PR aims to fix the issue. I will fix the verilator docker image later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this test for? At the moment it doesn't use libfstwriter at all. Do you intend to also add a libfstwriter writer version and compare the outputs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests under integration test build against fstapi.c (wrapper for libfstwriter) and the original fstapi.c, comparing the bit-trueness. My previous README does not mention this, so I clarify this by updating the README.

Comment thread fstcpp/fstcpp_writer.cpp Outdated
Comment on lines +323 to +324
} else if (c == 'h' || c == 'H') {
b1 |= 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there an encoding for 'H' but not for 'L'?

@rfuest

rfuest commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

The most important change here is to add an bit-true, hand-crafted integration test for xz. The existing implementation cannot pass the added integration test. The PR aims to fix the issue. I will fix the verilator docker image later.

I agree, that the CI change was outside the scope of this PR. But I noticed that you already changed CI to use the docker image. Thanks for taking care of that so quickly.

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.

2 participants