prjunnamed_netlist

Enum Cell

Source
pub enum Cell {
Show 32 variants Buf(Value), Not(Value), And(Value, Value), Or(Value, Value), Xor(Value, Value), Mux(Net, Value, Value), Adc(Value, Value, Net), Eq(Value, Value), ULt(Value, Value), SLt(Value, Value), Shl(Value, Value, u32), UShr(Value, Value, u32), SShr(Value, Value, u32), XShr(Value, Value, u32), Mul(Value, Value), UDiv(Value, Value), UMod(Value, Value), SDivTrunc(Value, Value), SDivFloor(Value, Value), SModTrunc(Value, Value), SModFloor(Value, Value), Match(MatchCell), Assign(AssignCell), Dff(FlipFlop), Memory(Memory), IoBuf(IoBuffer), Target(TargetCell), Other(Instance), Input(String, usize), Output(String, Value), Name(String, Value), Debug(String, Value),
}
Expand description

A unit of logic.

Within a Design, each cell is identified by a range of indices, with each index corresponding to one of the output bits of the cell. As such, the cell itself only contains information about its inputs, with the outputs being implicit.

(do note that cells without any outputs, such as output or name, still get assigned an index)

Variants§

§

Buf(Value)

§

Not(Value)

§

And(Value, Value)

a & b.

Has short-circuiting behavior for inputs containing X — if the other bit is 0, the output is 0 and the X doesn’t propagate.

§

Or(Value, Value)

a | b.

Has short-circuiting behavior for inputs containing X — if the other bit is 1, the output is 1 and the X doesn’t propagate.

§

Xor(Value, Value)

§

Mux(Net, Value, Value)

a ? b : c.

Muxes are glitch free — if a is X, the bit positions that match between b and c still have a defined value. The X propagates only at the positions where b and c differ.

§

Adc(Value, Value, Net)

a + b + ci — add with carry.

Output is one bit wider than a and b — the most significant bit is the carry-out.

Xs in the input propagate only to the more significant bits, and do not affect the less significant bits.

§

Eq(Value, Value)

§

ULt(Value, Value)

§

SLt(Value, Value)

§

Shl(Value, Value, u32)

a << (b * c). The bottom bits are filled with zeros.

General notes for all shift cells:

  • output is the same width as a. If you need wider output, zero-extend or sign-extend your input first, as appropriate.
  • the shift count does not wrap. If you shift by more than a.len() - 1, you get the same result as if you made an equivalent sequence of 1-bit shifts (i.e. all zeros, all sign bits, or all X, as appropriate).
  • shift cells are one of the few cells which do not expect their inputs to be of the same width. In fact, that is the expected case.
§

UShr(Value, Value, u32)

a >> (b * c). The top bits are filled with zeros.

See also general notes above.

§

SShr(Value, Value, u32)

a >> (b * c). The top bits are filled with copies of the top bit of the input.

a must be at least one bit wide (as otherwise there would be no sign bit to propagate, and while there wouldn’t be anywhere to propagate it to, it’s an edge-case it doesn’t make sense to bother handling).

See also general notes above.

§

XShr(Value, Value, u32)

a >> (b * c). The top bits are filled with X.

See also general notes above.

§

Mul(Value, Value)

§

UDiv(Value, Value)

§

UMod(Value, Value)

§

SDivTrunc(Value, Value)

§

SDivFloor(Value, Value)

§

SModTrunc(Value, Value)

§

SModFloor(Value, Value)

§

Match(MatchCell)

§

Assign(AssignCell)

§

Dff(FlipFlop)

§

Memory(Memory)

§

IoBuf(IoBuffer)

§

Target(TargetCell)

§

Other(Instance)

§

Input(String, usize)

Design input of a given width.

If synthesizing for a specified target, and not in out-of-context mode, an input will be replaced with an IoBuffer and attached to a pin on the target device.

§

Output(String, Value)

Design output. Attaches a name to a given value.

If synthesizing for a specified target, and not in out-of-context mode, an output will be replaced with an IoBuffer and attached to a pin on the target device.

§

Name(String, Value)

Attaches a name to a given value for debugging.

Name keeps a given value alive during optimization and makes it easily available to be poked at during simulation.

Do note that the unname pass, which runs during target-dependent synthesis, replaces all Name cells with Debug cells.

§

Debug(String, Value)

Tentatively attaches a name to a given value.

Debug gives a name to a particular value, without insisting on keeping it alive during optimization. This helps correlate the output of synthesis with the corresponding input logic.

If at any point a value is being kept alive only by a Debug cell, it will be optimized out and the input to the Debug cell will be replaced with X.

See also: Name.

Implementations§

Source§

impl Cell

Source

pub fn validate(&self, design: &Design)

Source

pub fn slice(&self, range: impl RangeBounds<usize> + Clone) -> Option<Cell>

If possible, return a cell that computes only a slice of the outputs of this cell.

Source§

impl Cell

Source

pub fn output_len(&self) -> usize

Source

pub fn has_effects(&self, design: &Design) -> bool

Source

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

Source

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

Trait Implementations§

Source§

impl Clone for Cell

Source§

fn clone(&self) -> Cell

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 Cell

Source§

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

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

impl<'a> From<&'a Cell> for Cow<'a, Cell>

Source§

fn from(value: &'a Cell) -> Self

Converts to this type from the input type.
Source§

impl From<Cell> for Cow<'_, Cell>

Source§

fn from(value: Cell) -> Self

Converts to this type from the input type.
Source§

impl Hash for Cell

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 Cell

Source§

fn eq(&self, other: &Cell) -> 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 Cell

Source§

impl StructuralPartialEq for Cell

Auto Trait Implementations§

§

impl Freeze for Cell

§

impl RefUnwindSafe for Cell

§

impl Send for Cell

§

impl Sync for Cell

§

impl Unpin for Cell

§

impl UnwindSafe for Cell

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.