Skip to content

Commit 8d9b63f

Browse files
use same getReg/setReg in MinimalCSRs
1 parent 1f9c186 commit 8d9b63f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/riscv/Platform/MinimalCSRs.v

+7-6
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ Section Riscv.
5353
{ mach with pc := mach.(nextPc); nextPc ::= word.add (word.of_Z 4) }.
5454

5555
Definition getReg(regs: Registers)(reg: Z): word :=
56-
if Z.eq_dec reg 0 then word.of_Z 0
57-
else match map.get regs reg with
58-
| Some x => x
59-
| None => word.of_Z 0
60-
end.
56+
if ((0 <? reg) && (reg <? 32))%bool then
57+
match map.get regs reg with
58+
| Some x => x
59+
| None => word.of_Z 0
60+
end
61+
else word.of_Z 0.
6162

6263
Definition setReg(reg: Z)(v: word)(regs: Registers): Registers :=
63-
if Z.eq_dec reg Register0 then regs else map.put regs reg v.
64+
if ((0 <? reg) && (reg <? 32))%bool then map.put regs reg v else regs.
6465

6566
Definition run_primitive(a: riscv_primitive)(mach: State):
6667
(primitive_result a -> State -> Prop) -> (State -> Prop) -> Prop :=

0 commit comments

Comments
 (0)