[][src]Function readmem::readmem

pub fn readmem<I>(
    content: &str,
    content_type: ContentType
) -> Result<Vec<I>, Error> where
    I: Integral + FromStr + Clone

Read a Verilog memory file from a string containing its contents into a Vec.

A memory file is composed of items, which are either numeric literals or @hh.. hex addresses to restart writing at. All instances of z and x are replaced with zeros. If an address directive @hh.. points past the end of the memory, the space between where we last wrote and the restart address will be filled with zeros.

Hex numbers support both upper- and lowercase digits. Both Verilog comment types /* ... */ and // ... are supported, and so are underscore separators in numeric literals.

Example:

use readmem::{readmem, ContentType};
assert_eq!(vec![0, 1, 2], readmem::<u8>("0 1\n2", ContentType::Hex).unwrap());
assert_eq!(vec![0, 1, 2], readmem::<u8>("z/* a */x1 1_0", ContentType::Binary).unwrap());