Skip to content

Allow visualizing delta cycles in VCD dumps #1232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2024

Conversation

whitequark
Copy link
Member

@whitequark whitequark commented Mar 23, 2024

This commit adds an option fs_per_delta= to Simulator.write_vcd(). Specifying a positive integer value for it causes the simulator to offset value change times by that many femtoseconds for each delta cycle after the last timeline advancement.

This option is only suitable for debugging. If the timeline is advanced by less than the combined duration of expanded delta cycles, an error will be raised like:

vcd.writer.VCDPhaseError: Out of order timestamp: 62490

Typically fs_per_delta=1 is best, since it allows thousands of delta cycles to be expanded without risking a VCD phase error, but bigger values can be used for an exaggerated visual effect.

Also, the VCD writer is changed to use 1 fs as the timebase instead of 1 ps. This change is largely invisible to designers, resulting only in slightly larger VCD files due to longer timestamps.

Since the fs_per_delta= option is per VCD writer, it is possible to simultaneously dump two VCDs, one with and one without delta cycle expansion:

with sim.write_vcd("sim.vcd"), sim.write_vcd("dsim.vcd", fs_per_delta=1):
    sim.run()

In GTKWave, it is possible to observe every intermediate value recorded by the VCD writer by selecting all signals and using left and right arrow keys to navigate. This works regardless of the value of fs_per_delta.

Screenshot


@whitequark whitequark marked this pull request as draft March 23, 2024 07:34
Copy link

codecov bot commented Mar 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.81%. Comparing base (0cb71f8) to head (4824a6a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1232      +/-   ##
==========================================
+ Coverage   89.80%   89.81%   +0.01%     
==========================================
  Files          43       43              
  Lines        9923     9928       +5     
  Branches     2400     2399       -1     
==========================================
+ Hits         8911     8917       +6     
+ Misses        821      820       -1     
  Partials      191      191              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This commit adds an option `fs_per_delta=` to `Simulator.write_vcd()`.
Specifying a positive integer value for it causes the simulator to
offset value change times by that many femtoseconds for each delta
cycle after the last timeline advancement.

This option is only suitable for debugging. If the timeline is advanced
by less than the combined duration of expanded delta cycles, an error
similar to the following will be raised:

    vcd.writer.VCDPhaseError: Out of order timestamp: 62490

Typically `fs_per_delta=1` is best, since it allows thousands of delta
cycles to be expanded without risking a VCD phase error, but bigger
values can be used for an exaggerated visual effect.

Also, the VCD writer is changed to use 1 fs as the timebase instead of
1 ps. This change is largely invisible to designers, resulting only in
slightly larger VCD files due to longer timestamps.

Since the `fs_per_delta=` option is per VCD writer, it is possible to
simultaneously dump two VCDs, one with and one without delta cycle
expansion:

    with sim.write_vcd("sim.vcd"), sim.write_vcd("sim.d.vcd", fs_per_delta=1):
        sim.run()
@whitequark whitequark marked this pull request as ready for review March 24, 2024 12:02
@whitequark whitequark enabled auto-merge March 24, 2024 12:02
@whitequark whitequark added this pull request to the merge queue Mar 24, 2024
Merged via the queue into amaranth-lang:main with commit 36fb903 Mar 24, 2024
@whitequark whitequark deleted the testbenchessss branch March 24, 2024 12:14
@whitequark whitequark added this to the 0.5 milestone Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant