prjunnamed_netlist

Struct Memory

Source
pub struct Memory {
    pub depth: usize,
    pub width: usize,
    pub init_value: Const,
    pub write_ports: Vec<MemoryWritePort>,
    pub read_ports: Vec<MemoryReadPort>,
}
Expand description

An all-in-one random-access memory cell.

A memory is made of depth rows, each of them width bits wide. While a memory row is considered to be the basic access unit, we support the notion of “wide ports”, which access a (naturally aligned) power-of-two number of memory rows at once.

While any number and combination of read and write ports is considered valid in the netlist, the rules for what memories can actually be realized in hardware depend on the target, and can be quite byzantine.

There are no priority rules among write ports. If more than one port writes to the same memory bit at the same time, the value written is undefined.

The output of the memory cell consists of the read data from all the read ports, concatenated in order.

Fields§

§depth: usize

The number of rows in the memory.

For every port on the memory, depth must be evenly divisible by port.data_len / memory.width. This ensures that, for wide ports, every access is either completely in-bounds, or completely out-of-bounds.

§width: usize

The width of single memory row.

§init_value: Const

Initial value for the memory, with all the rows concatenated in order. Must have a length equal to depth * width.

§write_ports: Vec<MemoryWritePort>§read_ports: Vec<MemoryReadPort>

Implementations§

Source§

impl Memory

Source

pub fn output_len(&self) -> usize

Source

pub fn visit(&self, f: impl FnMut(Net))

Source

pub fn visit_mut(&mut self, f: impl FnMut(&mut Net))

Source

pub fn read_port_output_slice(&self, port_index: usize) -> Range<usize>

Trait Implementations§

Source§

impl Clone for Memory

Source§

fn clone(&self) -> Memory

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Memory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Memory

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Memory

Source§

fn eq(&self, other: &Memory) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Memory

Source§

impl StructuralPartialEq for Memory

Auto Trait Implementations§

§

impl Freeze for Memory

§

impl RefUnwindSafe for Memory

§

impl Send for Memory

§

impl Sync for Memory

§

impl Unpin for Memory

§

impl UnwindSafe for Memory

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.