mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-04-20 03:03:25 -04:00
Fixes #844 This PR adds a new machine to the STD: `WriteOnceMemory`. This can be used in our RISC-V machine for bootloader inputs (#1203). Most of the issues mentioned in the issue were fixed in the meantime or had a simple workaround (like defining `let LATCH = 1`). The only remaining issues were in the machine detection, which I fixed here. I also re-factor two existing tests.
20 lines
830 B
NASM
20 lines
830 B
NASM
// Very simple write-once memory that let's you store any field element at
|
|
// an address from 0 to N-1. Any value can be written only once, writing two
|
|
// different values to the same address fails. If an uninitialized cell is
|
|
// read, the returned values is unconstrained.
|
|
// A typical use-case would be to pass the `value` column as an "external"
|
|
// witness. This way the prover can provide some input vector and the program
|
|
// can read the same input multiple times.
|
|
machine WriteOnceMemory(LATCH, _) {
|
|
|
|
// Accesses the memory cell at the given address. This can be used
|
|
// both for reading and writing, e.g.:
|
|
// instr mload X -> Y = memory.access X, Y ->;
|
|
// instr mstore X, Y -> = memory.access X, Y ->;
|
|
operation access ADDR, value ->;
|
|
|
|
let LATCH = 1;
|
|
|
|
let ADDR: col = |i| i;
|
|
let value;
|
|
} |