Repository navigation
Fix the documented bit order of waveform groups, and paint large groups MSB-first - #707
Merged
Merged
Conversation
The group value treats the first net in the list as the most significant bit (WaveDataGroup::recalcData, intValue, WaveDataProviderGroup), but the docstring of add_waveform_group said it is the least significant one. Scripts that followed the docstring got every group value bit-mirrored. Fix the docstring in the header and the Python binding, and state the order of the pin group overloads: they take the pins in pin group order, so the pin at the start index is the most significant bit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WaveFormPainted::generateGroup composed the group value with the first child as the least significant bit, while WaveDataGroup::recalcData(), intValue() and WaveDataProviderGroup use it as the most significant one. The viewer uses generateGroup for groups whose waves exceed the loadable size, so such a group was drawn bit-mirrored relative to its cursor value and to get_value_at(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joern274
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The docstring of
add_waveform_group(name, nets)says the first net is the least significant bit. In the code it is the most significant bit:WaveDataGroup::recalcData()puts list element i at mask1 << (n-i-1).WaveDataGroup::intValue()andWaveDataProviderGroupuse the same order.A script that follows the docstring gets every group value bit-mirrored. Example: a group built as
[KEY(0), …, KEY(15)], withKEY(0)carrying bit 0 of0xABCD, showsB3D5. Built as[KEY(15), …, KEY(0)], it showsABCD.Groups built in the GUI are not affected: a net dropped onto a group goes in at the top, and the top row is the MSB.
There is one place that uses the opposite order.
WaveFormPainted::generateGroupcomposes the group value with the first child as the LSB. The viewer uses it for groups whose waves exceed the loadable size. Such a group is drawn bit-mirrored relative to its member waves and toget_value_at(). This applies to every group above the limit, whether a script, the GUI orload_waveform_groups()created it.Groups from pin groups
The pin-group overloads, and through them the groups that
load_waveform_groups()creates automatically, take the nets inget_pins()order.get_pins()honors the group's direction:So the pin at the start index is the MSB: the highest index for a descending group, index 0 for an ascending one. The value of these groups was consistent with that before this PR and is unchanged. Only their documentation was missing.
Changes
add_waveform_group(name, nets): the first net is the most significant bit.NetGroupoverload refers to the pin-group order.generateGroup: the first child is now the MSB, as everywhere else.I fixed the documentation rather than the value computation. Changing the computation would flip every existing group, including those restored from saved
waveform_viewer.jsonfiles.Testing
I ran a headless test on a 16-bit design.
get_value_at()andget_events()on groups built from net lists in both orders now match the documented order.Module pin groups match it as well:
generateGroup, in the viewer: I reproduced the bug onmastervia the GUI. A group above the limit shows the mirror of its member bits.Steps:
Don't compare it with the cursor value: for such a group the cursor value is read from the same painted values, so the two always agree.
Not changed
WaveDataGroup(WaveDataList*, const WaveData*)splits a multi-bit wave into child waves LSB-first, so it would produce mirrored groups. It has no callers, so I left it alone. It could be fixed or removed.🤖 Generated with Claude Code