|
| 1 | +module READ-SYMBOLIC-INDEX-VALUE |
| 2 | + imports RISCV |
| 3 | + |
| 4 | + claim [id]: |
| 5 | + <instrs> #CHECK_HALT => #HALT </instrs> |
| 6 | + <regs> |
| 7 | + // read from #bytes |
| 8 | + 1 |-> (readBytes(4, 4, |
| 9 | + #WB(true, I1, V0, 2, |
| 10 | + #WB(true, I1, V1, 4, |
| 11 | + #WB(true, I0, V2, 4, |
| 12 | + #WB(true, I2, V3, 4, |
| 13 | + #bytes (b"\x00\x00\x00\x00" +Bytes Int2Bytes(4, V4, LE) +Bytes b"\x00\x00\x00\x00\x00\x00\x00\x00") .SparseBytes))))) |
| 14 | + => V4) |
| 15 | + // read I2 with same number of bytes |
| 16 | + 2 |-> (readBytes(I2, 4, |
| 17 | + #WB(true, I1, V0, 2, |
| 18 | + #WB(true, I1, V1, 4, |
| 19 | + #WB(true, I0, V2, 4, |
| 20 | + #WB(true, I2, V3, 4, |
| 21 | + #bytes (Int2Bytes(4, V4, LE) +Bytes b"\x00\x00\x00\x00\x00\x00\x00\x00") .SparseBytes))))) |
| 22 | + => V3) |
| 23 | + // read I2 with smaller number of bytes |
| 24 | + 3 |-> (readBytes(I2, 2, |
| 25 | + #WB(true, I1, V0, 2, |
| 26 | + #WB(true, I1, V1, 4, |
| 27 | + #WB(true, I0, V2, 4, |
| 28 | + #WB(true, I2, V3, 4, |
| 29 | + #bytes (Int2Bytes(4, V4, LE) +Bytes b"\x00\x00\x00\x00\x00\x00\x00\x00") .SparseBytes))))) |
| 30 | + => V3 &Int 65535) |
| 31 | + // DISALLOWED: read with more number of bytes (8 bytes, but only 4 stored) |
| 32 | + // read I1 with 2 bytes |
| 33 | + 4 |-> (readBytes(I1, 2, |
| 34 | + #WB(true, I1, V0, 2, |
| 35 | + #WB(true, I1, V1, 4, |
| 36 | + #WB(true, I0, V2, 4, |
| 37 | + #WB(true, I2, V3, 4, |
| 38 | + #bytes (Int2Bytes(4, V4, LE) +Bytes b"\x00\x00\x00\x00\x00\x00\x00\x00") .SparseBytes))))) |
| 39 | + => V0 &Int 65535) |
| 40 | + // read I1 with 4 bytes |
| 41 | + 5 |-> (readBytes(I1, 4, |
| 42 | + #WB(true, I1, V0, 2, |
| 43 | + #WB(true, I1, V1, 4, |
| 44 | + #WB(true, I0, V2, 4, |
| 45 | + #WB(true, I2, V3, 4, |
| 46 | + #bytes (Int2Bytes(4, V4, LE) +Bytes b"\x00\x00\x00\x00\x00\x00\x00\x00") .SparseBytes))))) |
| 47 | + => Bytes2Int(Int2Bytes(2, V0, LE) +Bytes Int2Bytes(2, V1 >>Int 16, LE), LE, Unsigned)) |
| 48 | + </regs> |
| 49 | + <pc> 0 </pc> |
| 50 | + <haltCond> ADDRESS ( 0 ) </haltCond> |
| 51 | + // index not equal to 0 |
| 52 | + requires 4 =/=Int I0 andBool 4 =/=Int I1 andBool 4 =/=Int I2 |
| 53 | + // different indices |
| 54 | + andBool I0 =/=Int I1 andBool I0 =/=Int I2 andBool I1 =/=Int I2 |
| 55 | + // values are within range |
| 56 | + andBool 0 <=Int V0 andBool V0 <=Int 65535 |
| 57 | + andBool 0 <=Int V1 andBool V1 <=Int 4294967295 |
| 58 | + andBool 0 <=Int V2 andBool V2 <=Int 4294967295 |
| 59 | + andBool 0 <=Int V3 andBool V3 <=Int 4294967295 |
| 60 | + andBool 0 <=Int V4 andBool V4 <=Int 4294967295 |
| 61 | +endmodule |
| 62 | + |
0 commit comments