pub fn run<M: FullMachine>(system: M) -> ExecResultExpand description
Executes machine-check with system environment arguments.
Is supposed to be used for simple systems that do not take arguments.
The system must implement Machine. The system structures and Input, State, and Machine
implementations must be enclosed within the machine_description macro, which processes them to enable
fast and efficient formal verification.
Examples found in repository?
More examples
examples/simple_risc.rs (line 147)
116fn main() {
117 let toy_program = [
118 // (0) set r0 to zero
119 Bitvector::new(0b0100_0000_0000),
120 // (1) set r1 to one
121 Bitvector::new(0b0101_0000_0001),
122 // (2) set r2 to zero
123 Bitvector::new(0b0110_0000_0000),
124 // --- main loop ---
125 // (3) store r1 content to data location 0
126 Bitvector::new(0b1100_0000_0000),
127 // (4) store r2 content to data location 1
128 Bitvector::new(0b1100_0000_0001),
129 // (5) read input location 0 to r3
130 Bitvector::new(0b0011_0100_0000),
131 // (6) jump to (3) if r3 bit 0 is set
132 Bitvector::new(0b0011_1000_0011),
133 // (7) increment r2
134 Bitvector::new(0b0010_0000_1001),
135 // (8) store r2 content to data location 1
136 Bitvector::new(0b1110_0000_0001),
137 // (9) jump to (3)
138 Bitvector::new(0b0001_1000_0011),
139 ];
140
141 // load toy program to program memory, filling unused locations with 0
142 let mut progmem = BitvectorArray::new_filled(Bitvector::new(0));
143 for (index, instruction) in toy_program.into_iter().enumerate() {
144 progmem[Bitvector::new(index as u64)] = instruction;
145 }
146 let system = machine_module::System { progmem };
147 machine_check::run(system);
148}