pub struct Memory { /* private fields */ }Expand description
A memory (see the module documentation).
Implementations§
Source§impl Memory
impl Memory
Sourcepub fn new(name: &str, addr: Width, cell: Width, endian: Endian) -> Memory
pub fn new(name: &str, addr: Width, cell: Width, endian: Endian) -> Memory
A memory named name (its unknown cells use unused symbols name.0, name.1, …)
from addresses of width addr to cells of width cell, all of it unknown.
Sourcepub fn zeroed(self) -> Memory
pub fn zeroed(self) -> Memory
Unknown cells read as zero instead (memory that starts cleared). Previously returned load expressions retain their original contents.
Sourcepub fn with_region(self, start: u128, cells: &[BitVec]) -> Result<Memory, Error>
pub fn with_region(self, start: u128, cells: &[BitVec]) -> Result<Memory, Error>
Known contents from address start on, one value per cell (for example a binary’s
read-only data). Regions must not overlap, including themselves when addresses wrap.
Previously returned load expressions retain their original contents.
Sourcepub fn with_bytes(self, start: u128, bytes: &[u8]) -> Result<Memory, Error>
pub fn with_bytes(self, start: u128, bytes: &[u8]) -> Result<Memory, Error>
Known contents of byte cells from address start on.
Sourcepub fn addr_width(&self) -> Width
pub fn addr_width(&self) -> Width
The address width.
Sourcepub fn cell_width(&self) -> Width
pub fn cell_width(&self) -> Width
The cell width.
Sourcepub fn store(
&mut self,
cx: &mut Context,
at: Version,
addr: Expr,
value: Expr,
) -> Result<Version, Error>
pub fn store( &mut self, cx: &mut Context, at: Version, addr: Expr, value: Expr, ) -> Result<Version, Error>
Stores value (a whole number of cells) at addr in version at: the new version.
Sourcepub fn load(
&mut self,
cx: &mut Context,
at: Version,
addr: Expr,
cells: u16,
) -> Result<Expr, Error>
pub fn load( &mut self, cx: &mut Context, at: Version, addr: Expr, cells: u16, ) -> Result<Expr, Error>
Loads cells consecutive cells at addr from version at, as one value.
Sourcepub fn reads(&self) -> &[(Expr, Expr)]
pub fn reads(&self) -> &[(Expr, Expr)]
The reads of unknown cells so far: each one’s address and symbol, in order.
Sourcepub fn bind(
&self,
cx: &mut Context,
env: &[(SymbolKey, BitVec)],
image: &dyn Fn(&BitVec) -> Option<BitVec>,
) -> Result<Vec<(SymbolKey, BitVec)>, Error>
pub fn bind( &self, cx: &mut Context, env: &[(SymbolKey, BitVec)], image: &dyn Fn(&BitVec) -> Option<BitVec>, ) -> Result<Vec<(SymbolKey, BitVec)>, Error>
Values for the symbols of the unknown cells read so far, from a memory image and the
values of the other symbols (a read’s address may depend on them, and on earlier reads):
each address is evaluated in turn and the image asked for its cell (None: 0).