-
Notifications
You must be signed in to change notification settings - Fork 0
Formalize LSC-1u XOR retained-boundary refinement #33
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # LSC-1u XOR retained-boundary refinement | ||
|
|
||
| ## Milestone and proven boundary | ||
|
|
||
| `lsc1u_xor_refinement.sby` proves a cycle-accurate lockstep relation between | ||
| the handwritten `lsc1u_core` RTL and a reduced retained-state model for one or | ||
| more complete XOR micro-ops. Every accepted idle command is assumed to be | ||
| XOR; this is an opcode-specific refinement lane, not an opcode-decoder proof. | ||
| All 32 payload bytes per command are otherwise arbitrary. | ||
|
|
||
| The environment may independently vary `rx_valid`, `tx_ready`, `ena`, and | ||
| `rst_n` on every cycle. Consequently the proof includes arbitrary finite or | ||
| infinite input/output backpressure, enable pauses, reset during any partial or | ||
| stalled operation, and back-to-back XOR transactions. It is a safety proof: | ||
| an environment that never supplies a beat or never accepts a result is not | ||
| assumed to make progress. Separate covers demonstrate concrete acceptance, | ||
| stalled-result retention, mid-operation reset, and final retirement traces. | ||
|
|
||
| ## Architectural state and relation | ||
|
|
||
| The reduced model retains exactly: | ||
|
|
||
| | Field | Meaning | RTL correspondence | | ||
| |---|---|---| | ||
| | `ref_phase` | idle, waiting for lane A, or waiting for lane B | `state` = `IDLE`, `XOR_A`, or `XOR_B` | | ||
| | `ref_lane` | result lane to retire, 0 through 15 | `byte_index` | | ||
| | `ref_a` | accepted first operand of the current lane | `saved_byte` | | ||
| | `ref_result` | retained result byte | `out_byte` | | ||
| | `ref_result_valid` | result is pending acceptance | `out_valid` | | ||
| | `ref_fault` | retained fault state (always clear on this lane) | `fault_reg` | | ||
| | `ref_retired` | one-cycle completion/retirement pulse | `done_reg` | | ||
|
|
||
| These conceptual RTL correspondences explain the abstraction; the mechanically | ||
| checked refinement relation is observational and equates `rx_ready`, | ||
| `tx_valid`, `tx_data`, `busy`, `fault`, and `done_pulse` to functions of the | ||
| reduced state on every post-initial clock boundary. Because those equalities | ||
| hold after every arbitrary input step, each retained field that can affect a | ||
| later XOR observation is exercised through the transition relation rather than | ||
| read through non-portable hierarchical references. The | ||
| multiplier is replaced by an unconstrained output because the XOR states never | ||
| read it; this is a conservative cone cut, not a result assumption. | ||
|
|
||
| ## Inductive invariants | ||
|
|
||
| - The lane index is always in `[0, 15]`. | ||
| - Waiting for B never overlaps a pending output. | ||
| - A pending output exists only in the A-wait phase, which prevents payload | ||
| acceptance until that exact retained byte is accepted. | ||
| - The retained result after accepting a pair is exactly `A XOR B`. | ||
| - Output data and validity remain unchanged through arbitrary `tx_ready = 0` | ||
| cycles and through `ena = 0` pauses. | ||
| - Retirement occurs only after acceptance of lane 15, returns to idle, clears | ||
| the pending result, and is a single enabled cycle. | ||
| - Reset restores all related retained state and cancels partial or stalled work. | ||
|
|
||
| ## Assumptions and residual gaps | ||
|
|
||
| The only functional assumption is `rx_data == 8'h01` when a command handshake | ||
| occurs in idle. There is no fairness, ready/valid scheduling, payload-value, | ||
| or reset-exclusion assumption. LSC-1u exposes reset and enable but has no | ||
| abort port, so abort refinement is outside this RTL interface rather than | ||
| silently excluded. | ||
|
|
||
| This tranche does not prove opcode decode/fault responses, SET, MUL arithmetic, | ||
| the Tiny Tapeout wrapper, packet LSC-1, Lean-to-RTL correspondence, liveness | ||
| under unfair backpressure, or RTL-to-netlist equivalence. It supplies one | ||
| compositional accepted-micro-op-to-arithmetic-result/retirement lane toward the | ||
| full controller relation. | ||
|
|
||
| Run: | ||
|
|
||
| ```sh | ||
| cd formal | ||
| sby -f lsc1u_xor_refinement.sby | ||
| cd .. | ||
| python3 formal/check_mutations.py | ||
| ``` |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| [tasks] | ||
| prove | ||
| cover | ||
|
|
||
| [options] | ||
| prove: mode prove | ||
| prove: depth 32 | ||
| cover: mode cover | ||
| cover: depth 80 | ||
| timeout 180 | ||
| vcd off | ||
|
|
||
| [engines] | ||
| prove: abc pdr | ||
| cover: btor btormc | ||
|
|
||
| [script] | ||
| read -formal -sv gf128_mul_boundary_formal.sv | ||
| read -formal -sv lsc1u_core.sv | ||
| prove: read -formal -sv lsc1u_xor_refinement_formal.sv | ||
| cover: read -formal -sv lsc1u_xor_refinement_cover.sv | ||
| prove: prep -top lsc1u_xor_refinement_formal | ||
| cover: prep -top lsc1u_xor_refinement_cover | ||
|
|
||
| [files] | ||
| gf128_mul_boundary_formal.sv | ||
| ../src/lsc1u_core.sv | ||
| lsc1u_xor_refinement_formal.sv | ||
| lsc1u_xor_refinement_cover.sv |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| `default_nettype none | ||
|
|
||
| // Deterministic composed witness: accept XOR, retain a stalled result, reset | ||
| // mid-operation, then restart and retire a complete 16-lane XOR transaction. | ||
| module lsc1u_xor_refinement_cover; | ||
| (* gclk *) reg clk; | ||
| reg [6:0] cycle = 0; | ||
| reg seen_accept = 0; | ||
| reg seen_stall = 0; | ||
| reg seen_reset_midop = 0; | ||
|
|
||
| wire rst_n = (cycle != 0) && (cycle != 4); | ||
| wire rx_valid = 1'b1; | ||
| wire [7:0] rx_data = 8'h01; | ||
| wire tx_ready = !(tx_valid && !seen_stall); | ||
| wire rx_ready, tx_valid, busy, done_pulse; | ||
|
|
||
| lsc1u_core dut ( | ||
| .clk(clk), .rst_n(rst_n), .ena(1'b1), | ||
| .rx_data(rx_data), .rx_valid(rx_valid), .rx_ready(rx_ready), | ||
| .tx_data(), .tx_valid(tx_valid), .tx_ready(tx_ready), | ||
| .busy(busy), .fault(), .done_pulse(done_pulse) | ||
| ); | ||
|
|
||
| always @(posedge clk) begin | ||
| cycle <= cycle + 1'b1; | ||
| if (rst_n && rx_valid && rx_ready) | ||
| seen_accept <= 1'b1; | ||
| if (rst_n && tx_valid && !tx_ready) | ||
| seen_stall <= 1'b1; | ||
| if (cycle == 4 && busy) | ||
| seen_reset_midop <= 1'b1; | ||
| cover(seen_accept && seen_stall && seen_reset_midop && done_pulse); | ||
| end | ||
| endmodule | ||
|
|
||
| `default_nettype wire |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a
--onlyvalue is misspelled or becomes stale after a mutation is renamed, this condition skips every entry, leavesfailuresempty, and exits successfully without running any proof. That can make a targeted mutation-validation command appear green while testing nothing; validate requested names againstMUTATIONSor fail when no mutation matches.Useful? React with 👍 / 👎.