pub fn rom<T: Copy + 'static + Sized, S: Into<String>>(
g: &mut GateGraphBuilder,
read: GateIndex,
address: &[GateIndex],
data: &[T],
name: S,
) -> Vec<GateIndex>Expand description
Returns the output of a piece of addressable ROM filled with data.
If data is not long enough to fill the entire address space, it will be filled with OFF.
§Example
let address = WordInput::new(&mut g, 3, "address");
let out = rom(&mut g, ON, &address.bits(), &[3,9,1], "rom");
let output = g.output(&out, "result");
let ig = &mut g.init();
ig.run_until_stable(2);
assert_eq!(output.u8(ig), 3);
address.set_to(ig, 1);
ig.run_until_stable(2);
assert_eq!(output.u8(ig), 9);
address.set_to(ig, 2);
ig.run_until_stable(2);
assert_eq!(output.u8(ig), 1);
address.set_to(ig, 3);
ig.run_until_stable(2);
assert_eq!(output.u8(ig), 0);§Panics
Will panic if not enough address bits are provided to address every value in data.