spec: DVRM chip#220
Conversation
00e559a to
eecb0bb
Compare
Greptile OverviewGreptile SummaryThis PR introduces the Key Changes
Technical ImplementationThe DVRM chip correctly implements ISA requirements through:
The overflow detection uses a clever zero-sum check that requires exactly 20 bits (max sum = 458,746 < 2^19), justifying the ZERO lookup expansion. Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| spec/dvrm.typ | New comprehensive specification for DVRM chip implementing DIV/REM operations with signed/unsigned support and proper edge case handling |
| spec/src/dvrm.toml | Complete DVRM chip configuration with variables, constraints, and ISA requirement implementations |
Sequence Diagram
sequenceDiagram
participant CPU as CPU Chip
participant DVRM as DVRM Chip
participant MUL as MUL Chip
participant SUB as SUB Chip
participant BITWISE as BITWISE Chip
participant LT as LT Chip
CPU->>DVRM: DIV/REM request (n, d, signed)
Note over DVRM: Compute sign flags
DVRM->>BITWISE: SIGN<n[3], signed> → sign_n
DVRM->>BITWISE: SIGN<d[3], signed> → sign_d
DVRM->>BITWISE: SIGN<r[3], signed> → sign_r
Note over DVRM: Check edge cases
DVRM->>BITWISE: ZERO[d] → div_by_zero
DVRM->>BITWISE: ZERO[overflow_sum] → overflow
Note over DVRM: Compute absolute values
alt sign_r = 1
DVRM->>SUB: SUB<0, r> → abs_r
end
alt sign_d = 1
DVRM->>SUB: SUB<0, d> → abs_d
end
Note over DVRM: Verify |r| < |d|
DVRM->>LT: LT<abs_r, abs_d, 0> → !div_by_zero
Note over DVRM: Verify n = qd + r
DVRM->>SUB: SUB<n, r> → n_sub_r
DVRM->>MUL: MUL<d, signed, q, sign_q, 0> → n_sub_r[lower]
DVRM->>MUL: MUL<d, signed, q, sign_q, 1> → n_sub_r[upper]
DVRM-->>CPU: Return (q, r)
RobinJadoul
left a comment
There was a problem hiding this comment.
I will definitely suggest a manual rebase -i and merge here, rather than a full squash, to keep #280 its own commit if it gets merged in here.
I'm slating #280 to merge into this as a "chained" PR; this PR should be merged first, after which #280 will update to be based against spec/main. The reason I'm pointing #280 against this, is that I can use some of things here in there. |
|
Seems like #280 landed before this one to stay as separate history against spec/main :) |
|
|
||
| [[variables.virtual]] | ||
| name = "extension_n_sub_r" | ||
| type = "DWordHL" |
There was a problem hiding this comment.
Nitpick: this could just be a single Half, or even integrated into extended_n_sub_r like we do for extended_n and extended_r
There was a problem hiding this comment.
the reason it exists separately, is that we need it inside the second MUL lookup. And slicing was not going to be an option, really.
yeah.. my bad |
2821e1f to
62ac9ba
Compare
|
This was manually merged into |
|
No reviewable files after applying ignore patterns. |
62ac9ba to
aba4542
Compare
This PR introduces the
DVRMchip.Note: this PR additionally widens the
ZEROlookup from 16 to 20 bits. (see 582bc35)