Repository navigation
asap7/chi_async_bridge: XiangShan's asynchronous CHI bridge, to replace mock-cpu - #4600
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the chi_async_bridge design, which models XiangShan's asynchronous CHI bridge between the core and network-on-chip clock domains. It includes SystemVerilog implementations for the queue source and sink, shadow buffers, reset generators, and synchronizers, along with SDC constraints and documentation. The review feedback recommends adding parameter validation assertions (initial assert) across several modules (async_queue_source, async_queue_sink, shadow_buffer, sync_shift_reg, and reset_gen) to guarantee that parameters like DEPTH, ENTRIES, and SYNC are valid (e.g., powers of two or at least 2), thereby preventing potential compilation errors or runtime functional failures.
A new test design with one concern: an asynchronous clock crossing, constrained without exceptions that hide a path, and implemented by the flow as constrained. It is XiangShan's CHI bridge between its tile and its network-on-chip, both halves in one block: six flit channels, each a rocket-chip async queue, with their link credits, handshakes and a reset synchroniser per domain, as readable parameterised SystemVerilog read by slang. constraint.sdc bounds every crossing with set_max_delay -ignore_clock_latency, budgets the ports per domain as the platform's constraints.sdc budgets a macro's, keeps synchroniser hops short, and checks the names it constrains against the synthesised netlist, stopping the flow if they are wrong. The core period, 300 ps, is where XiangShan's own bridge, elaborated from its Chisel and hardened alone through this flow, just fails at global route; this design fails there on the same path, within 1.5 %. README.md has the numbers. base is XiangShan's bridge as it is; FLOW_VARIANT=small|medium are faster rungs. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3a36af1 to
478cc0c
Compare
🔍 QoR checkMetrics reflect the PR merge build — i.e. what will land on the target branch. Commit 62 design(s) checked — 0 with regression(s), 0 without a comparable baseline. |
|
@precisionmoon pr-merge works so pr-head we can ignore |
|
I asked @maliberty to review this PR. |
|
Does the sv code come with a license file? |
Claude rewrote and stripped the generated verilog from XIangShan Chisel to SystemVerilog so that everything is human-readable. I don't think generated verilog is helpful for an idiomatic example of a clock crossing bridge. |
maliberty
left a comment
There was a problem hiding this comment.
From Claude (AI-generated review, posted at @maliberty's request)
Correctness issues in constraint.sdc:
-
Port budgets don't match the platform file they cite (
constraint.sdc:39-70). The comment says ports are budgeted "as$PLATFORM_DIR/constraints.sdcbudgets a single-clock macro's ... with that file's ratio", butflow/platforms/asap7/constraints.sdchas no ratio: it uses a fixed 80 ps for in2reg, reg2out and in2out. This file uses0.8 * period, i.e. 240 ps (core) and ~817 ps (NoC). Either match the platform file or fix the comment (and the README line that repeats it). -
No in2out budget, so port-to-port paths are unconstrained (
constraint.sdc:64-70).noc_tx_{req,rsp,dat}_readyreachesnoc_tx_*_flitvcombinationally (chi_async_bridge_sink.sv:assign tx_flitv = valid && tx_ready). The platform file covers this with its in2outset_max_delay; this file omits it. -
Nit: NoC clock comment (
constraint.sdc:11). "about half the core's frequency": 1021 ps vs 300 ps is ~0.29x, not half. -
Question: SYNC is hardcoded in the check (
constraint.sdc:95-101).DEPTHis parsed fromVERILOG_TOP_PARAMS, butsync_stagesis fixed at 3, so overridingSYNCvia params would trip the check. It fails explicitly, which is fine, but shouldSYNCbe parsed the same way? -
Nit: scope of the self-check (README, "fails the build when it stops being true").
SDC_FILEis only read at synthesis; after thatwrite_sdccanonicalizes it into1_synth.sdc. So the check guards against yosys renaming/restructuring, not against later resizer/hold-fix edits inside a synchroniser hop. Worth stating.
… platform's The comment and README said the ports are budgeted with $PLATFORM_DIR/constraints.sdc's ratio. That file has no ratio: it gives a single-clock macro a fixed 80 ps per port path. The budgets here are 80 % of each domain's period, a choice of this file; say so. The constraints themselves are unchanged, so the README's results stand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
noc_tx_{req,rsp,dat}_ready reach noc_tx_*_flitv through one gate
(chi_async_bridge_sink.sv: tx_flitv = valid && tx_ready), and nothing
constrained them: on the small variant's synthesised netlist they were
the only port-to-port paths, required INF. Give each domain an in2out
budget as the platform's constraints.sdc does, at the same 80 % of that
domain's period as its other port paths, and an in2out path group.
Now required 816.8 ps, met by 804 ps; every other path is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1021 ps against 300 ps is 0.29 times the frequency, not half. Only the comment changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
The synchroniser check parsed DEPTH from VERILOG_TOP_PARAMS but fixed the stage count at 3, so a flow that set SYNC stopped at synthesis: constraint.sdc: synchronisers: sink.asyncQSink_dat_flit.widx_gray.bit_[0] has 4 stages, not 3 Parse SYNC the same way, with the RTL's default. The small variant with SYNC 2, 3 and 4 now passes the check; with SYNC 4 it stopped before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
constraint.sdc is read once, by synth_odb.tcl against yosys's netlist; later stages read what write_sdc made of it, one set_max_delay per hop by cell name (172 on the small variant). So the check catches what synthesis does to a synchroniser, not a buffer that resizing or hold repair puts inside a hop afterwards, which the hop's budget still bounds. The README now says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
The SystemVerilog is rewritten from XiangShan's Chisel rather than generated from it, but it is still derived from that source and keeps its licenses. The async queue and synchroniser come from rocket-chip (Apache-2.0, LICENSE.SiFive); the bridge halves, shadow buffer, reset synchroniser and top-level wiring from XSCache, Utility and XiangShan (Mulan PSL v2). As picorv32 does: LICENSES/ holds both texts verbatim, SOURCE.md names each file's source, commit and license, and each file starts with its SPDX identifier, the upstream copyright lines and a note of what changed. The README points at them. No RTL changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
From Claude, at @oharboe's request Thanks, @maliberty, all five hold up; I checked each against the code before changing anything. Each is its own commit on top, so the review history is intact.
License (your question above) — 1923012. The SystemVerilog is rewritten from XiangShan's Chisel rather than generated, but it is still derived from it, so it keeps its licenses. Following picorv32's layout:
There are no RTL changes. |
|
Slack goes positive at grt. It would be good to slightly tighten the clock period so that optimization doesn't stop. 4_1_cts.json:31: "cts__timing__setup__ws": -0.41378, |
OPENROAD_HIERARCHICAL=1, the -hier mode that is to become the default. A flat netlist gives -hier nothing to link, so SYNTH_KEEP_MODULES keeps what a clock-crossing bridge is usually kept as: the two clock-domain halves, their asynchronous queues and their shadow buffers. The synchroniser check in constraint.sdc now finds the chains with get_cells -hierarchical; their names are the kept instances joined with '/', e.g. sink/asyncQSink_dat_flit/widx_gray.bit_[0].sync[1]. On the small variant all 172 hops are found and written back by name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
…n does An integration test: a timed asynchronous crossing, a self-checking constraint file, slang with SYNTH_KEEP_MODULES under -hier, instance names resolved through the hierarchy, three threshold voltages on a multi-clock design, and the top's parameters set from the flow. Checked against every config.mk and SDC under flow/designs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
… grt At 300 ps the worst slack reached +0.001 ps at global route (flat netlist), so repair stopped there. At 290 ps, linked hierarchically, the worst slack is -35.8 ps at CTS, -35.5 ps at global route and -30.1 ps at final, on the core half's async queue sink read, as in XiangShan. README.md's Results say so; the XiangShan calibration there is marked as measured on the flat netlist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
Thanks, agreed. The core clock is now 290 ps, so repair keeps working through global route instead of stopping at zero slack. Two more changes came with it: the design is now linked hierarchically ( Worst setup slack for the base variant, linked hierarchically, with only
With the hierarchy kept, 300 ps already stays negative at global route; 290 ps leaves more room for repair, and 280 ps buys nothing over it. At 290 ps the worst path at final is the core half's async queue sink read, the same path class XiangShan's own bridge fails on. These were measured outside CI, so CI's numbers may differ by a few picoseconds. |
|
fixed |
maliberty
left a comment
There was a problem hiding this comment.
@vvbandeira please add to the CI
@oharboe do you plan to remove mock-cpu?
Yes, but first it must be removed from CI. |
What
asap7/chi_async_bridgeis a new test design, replacing mock-cpu, with one concern: an asynchronous clock crossing, constrained the way the rest of a macro flow constrains its boundaries, and implemented by the flow as constrained.It is XiangShan's CHI bridge between its tile and its network-on-chip: six CHI flit channels, each a rocket-chip async queue (Gray-coded pointers, 3-flop synchronisers, the queue memory read by a mux on the far clock), their link credits and handshakes, and a reset synchroniser per domain. Both halves are in one block, so timing analysis sees both ends of every crossing.
REQ_W,RSP_W,DAT_W,SNP_W,DEPTH,SYNC), read by slang; each file cites the Chisel it modelsset_max_delay -ignore_clock_latencyat one period of its launching clock, no hold across; ports budgeted per domain as$PLATFORM_DIR/constraints.sdcbudgets a macro's; synchroniser hops kept shortconstraint.sdcverifies the names it constrains against the synthesised netlist and stops the flow if they are wrong, rather than letting OpenSTA drop the constraint with a warningFLOW_VARIANT=small|medium; base is XiangShan's bridge as it isResults
The core clock is 300 ps: given 420, 380 or 340 ps the flow closes, each time within a few picoseconds of the target; given 300 ps the worst path just fails. It is the core half's async queue sink, from the read pointer through the read-mux select, buffered out to every bit of a 385-bit data flit: the queue's own logic.
It reproduces XiangShan. XiangShan's own
CHIAsyncBridgeSourceandCHIAsyncBridgeSink, elaborated from its Chisel with its parameters and hardened alone, run through the same flow and constraints:Try this
cd flow make DESIGN_CONFIG=./designs/asap7/chi_async_bridge/config.mk make DESIGN_CONFIG=./designs/asap7/chi_async_bridge/config.mk FLOW_VARIANT=smallThe constraints check themselves. Rename the
syncregister insrc/chi_async_bridge/sync_shift_reg.sv, or put a gate between two of its flops, and synthesis stops:mock-cpu should be retired
asap7/mock-cpuwas meant to test this. Once CI's design list points atasap7/chi_async_bridge, mock-cpu anddesigns/src/fifocan be deleted in a follow-up. The list is not in this repository: nothing outside mock-cpu's own directory names it.What mock-cpu cannot show:
rdatais combinational from the FIFO memory to a port and declared a false path, which hides the data crossing it exists to test;1e+42;Appendix
A. Why: the boundary of a hardened core
XiangShan's tile is the block a XiangShan SoC hardens, and the CHI bridge is what sits immediately outside its pins:
XSTileWrapputs the tile half beside it on the core clock,XSNoCTopthe NoC half on the NoC clock. The bridge terminates every path the tile's CHI pins carry at a flop. That is why a block like the tile is constrained withset_max_delaybudgets on its ports rather than with input and output delays, and why only its register-to-register paths can fail timing closure. This design is the other side of that argument: the crossing itself, constrained without exceptions that hide a path, and checked.B. Names before and after synthesis
A constraint that names an instance is written against the RTL and read against the synthesised netlist. On this design the flattened name of a synchroniser flop gains yosys's cell type (
...ridx_gray.bit_[2].sync[1]$_DFF_PP0_); a flop takes the name of the net it drives, not of the variable that held it (async_ridx, notridx_gray); ODB escapes the brackets and timing analysis does not; and asap7's flop with asynchronous set and reset has only an inverted output, so each synchroniser step is flop, inverter, flop.constraint.sdccounts the chains it names (134), checks each step is exactly that and nothing else, and only then constrains them.C. How the period was found
The flow tracks its target: at 420, 380 and 340 ps both this design and XiangShan's bridge close, each landing within 4 ps of the target on the same path classes. At 300 ps both fail by a few picoseconds, on the same path. The NoC half is not calibrated: XiangShan's NoC link layer (link-state machines, credit managers), left out here as NoC-domain logic beyond the bridge, is in its NoC domain's worst path; both NoC domains keep more than 200 ps of slack at the 1021 ps NoC period.
The clock trees are OpenROAD CTS's H-trees, 261 ps deep on the core clock at final: an ordinary tree at a 1,000 ps period, not the mesh a 300 ps core would get. The crossing is timed without clock latency or hold, so the tree's depth does not enter what this design tests; it does move the same-clock paths and so the 300 ps, which is why XiangShan's bridge was measured through the same flow.
🤖 Generated with Claude Code