Repository navigation
feat(sv): support both edges of one clock or reset - #1384
Merged
Merged
Conversation
An event domain whose variable no path names, such as a hidden copy of a clock, has no name to list in named_events, as named_signals, the hierarchy, and VCD descriptions already omit such variables.
A variable carries one domain kind, so always_ff processes sensing one signal at both edges, or as a clock and as an asynchronous reset, were rejected. The frontend now senses the signal on itself at one kind (rising clock first) and at every other kind on a hidden one-bit whole-variable copy, which clock-domain unification keeps in the signal's domain when the edges agree and otherwise runs as a clock derived from the signal. Designs that sense one kind per signal are unchanged. Closes #443. Closes #471.
Both edges of a divided clock, of a child clock port, and one register as an asynchronous reset at both edges and as a clock at both edges. Verified against Verilator and Icarus with no mismatches.
Simulation::step of counters at the rising edge only, half at each edge of one clock, and half at the falling edge of a whole copy of the clock.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
Merge Queue Status
This pull request spent 39 minutes 53 seconds in the queue, including 35 minutes 52 seconds running CI. Required conditions to merge
|
38 of 66 tasks
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.
Closes #443. Closes #471.
The SystemVerilog frontend rejected a signal sensed at both edges in different
always_ffprocesses, a reset sensed at both edges, and a signal used as a clock in one process and an asynchronous reset in another. It now accepts all of them.How
A variable carries one domain kind, so
lower_ff_processeskeeps one edge and role on the signal itself. The order is fixed: rising clock, falling clock, active-high reset, active-low reset. Every other combination is sensed on a hidden 1-bit copy (clk@negedge,rst@reset_high, …) driven bycopy = signal. Since #1373, a whole-variable copy sensed at the opposite edge is cut from its source's domain and becomes a derived clock, which fires at the signal's other edge.@cannot appear in an SystemVerilog identifier, and the copy is not module-scoped. It stays out ofsignal(), named signals, the hierarchy, VCD, VPI and the NAPI layout.named_events()listed every event address. It now lists only events that a path names (fix(sim): list only named events).Limitations
Simulator,tick(clk)is the rising edge only, so there is no way to drive a falling edge until the explicit edge API lands. Processes on the falling edge run on the timedSimulation. On theSimulatorthey run only where a derived clock that a tick reaches drives them. A follow-up after the edge API addsSimulatortests and shared-suite cases that drive the falling edge directly.@(posedge clk or negedge clk)inside one process is still rejected; it needs edge-typed triggers.Tests
crates/celox/tests/both_clock_edges.rs(timedSimulation):assigncopiessv/cases/procedural.vtest, 0 mismatches against Verilator and Icarus.review_regressions.rs: the rejection cases are replaced by a run of the accepted designs.cargo nextest run --workspace --features celox/systemverilog: 13818 passed. fmt and clippy are clean.Performance
The before and after builds were run alternately, pinned with taskset, on a noisy machine (ms).
simulator_tick_x10000(Veryl)simulation_step_x20000assign c = clk+negedge cposedge clk+negedge clkA design that senses each signal at one edge lowers exactly as before. The Veryl benches do not reach the changed code, so their differences are noise. A design that uses both edges costs the same as the hand-written copy: only the derived falling-edge domain pays.