Skip to content

Commit b4b4129

Browse files
committed
Remove pc_double_read constraints and clarify why in cpu.typ
1 parent 590809e commit b4b4129

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

spec/cpu.typ

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ so for performance reasons, we inline its memory interactions directly into the
6565
The timestamps are ensured to be disjoint for disjoint memory locations.
6666
One consequence of that is that `next_pc` is written at `timestamp + 1`
6767
to ensure the access is disjoint with the `pc` read into `rv1` as part of the `AUIPC` instruction.
68-
#rj[We can try to do a bit more, and move `double_pc_read` into decoding, so that `AUIPC` could set `read_register1 = 0`.]
68+
Constraints on `pc_double_read` corresponding to an `AUIPC` instruction are not necessary,
69+
as regardless of its value, the old timestamp is guaranteed smaller than the new timestamp,
70+
and the integrity of the memory argument therefor ensures the correctness of this bit.
71+
72+
#bold[Potential optimization: ] `double_pc_read` could be integrated into decoding, so that `AUIPC` could set `read_register1 = 0` and no extra MEMW access for `rv1` is needed at this point.
6973

7074
#render_constraint_table(chip, config, groups: "mem")
7175

spec/src/cpu.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,6 @@ tag = "MEMW"
703703
input = [0, ["cast", "res", "DWordWL"], ["cast", "arg2", ["Byte", 8]], ["+", "timestamp", ["cast", 1, "DWordWL"]], "memory_2bytes", "memory_4bytes", "memory_8bytes"]
704704
multiplicity = "STORE"
705705

706-
[[constraints.mem]]
707-
kind = "arith"
708-
constraint = "$#`pc_double_read` => #`rs1` = 255$"
709-
poly = ["*", "pc_double_read", ["-", "rs1", 255]]
710-
711706
[[constraints.mem]]
712707
kind = "template"
713708
tag = "IS_BIT"
@@ -718,11 +713,6 @@ kind = "template"
718713
tag = "IS_BIT"
719714
input = ["prev_pc_timestamp_borrow"]
720715

721-
[[constraints.mem]]
722-
kind = "arith"
723-
constraint = "$#`pc_double_read` => #`prev_pc_timestamp_borrow` = 0$"
724-
poly = ["*", "pc_double_read", "prev_pc_timestamp_borrow"]
725-
726716
[[constraints.mem]]
727717
kind = "interaction"
728718
tag = "memory"

0 commit comments

Comments
 (0)