Struct CalyxComponent

Source
pub struct CalyxComponent<'a, ComponentData: Default> { /* private fields */ }
Expand description

A wrapper for a calyx component that can only be created through [CalyxBuilder::build_component], where it must live no longer than the builder that created it.

The wrapper maintains cell and control manipulation. Cells can be created through methods such as [CalyxComponent::named_reg] or CalyxComponent::component_cell. It also contains unique per-component data initialized via ComponentData::default which can be accessed through appropriate getters.

Implementations§

Source§

impl<'a, ComponentData: Default> CalyxComponent<'a, ComponentData>

Source

pub fn user_data_ref(&self) -> &ComponentData

The user data associated with the component.

Source

pub fn user_data_mut(&mut self) -> &mut ComponentData

Source

pub fn signature(&mut self) -> CalyxCell

The input/output signature of this component as a cell.

Source

pub fn control(&mut self) -> &mut CalyxControl<Sequential>

The control of this component.

Source

pub fn with_calyx_builder<F, T>(&mut self, f: F) -> T
where F: FnOnce(&mut Builder<'_>) -> T,

Enables direct access to a calyx_ir::Builder for this component.

Source

pub fn new_reg(&mut self, name: String, width: usize) -> CalyxCell

A register cell bound to name.

Requires: name has not been bound.

Source

pub fn named_mem( &mut self, name: String, cell_size: usize, length: usize, address_bits: usize, ) -> CalyxCell

A memory cell bound to name.

Requires: name has not been bound.

Source

pub fn new_prim( &mut self, name: &str, prim: &str, params: Vec<u64>, ) -> CalyxCell

Creates a cell named name for a primitive prim with parameters params. Before using this function, see if [CalyxComponent::named_reg] or CalyxComponent::named_mem are more appropriate.

Requires: name has not been bound.

Source

pub fn component_cell( &mut self, prefix: String, component: String, instantiate_new: bool, ) -> (String, CalyxCell)

A cell for a component component whose name is guaranteed to begin with prefix. If instantiate_new, then a unique cell will be created. Both the cell and the actual cell name are returned.

Source

pub fn new_unnamed_cell(&mut self, kind: CalyxCellKind) -> CalyxCell

An unnamed cell of a given kind.

Source

pub fn constant(&mut self, value: i64, width: usize) -> CalyxCell

A constant cell, that is, a primitive "std_const".

Source

pub fn signal_out(&mut self) -> CalyxCell

Equivlane to constant(1, 1).

Source

pub fn alias_cell(&mut self, name: String, cell: CalyxCell)

Adds name as a named alias to refer to cell.

Requires: name has not been previously bound.

Source

pub fn find(&mut self, name: String) -> CalyxCell

Looks up a named cell previously bound to name.

Requires: name has been bound.

Source

pub fn begin_scope(&mut self)

Source

pub fn end_scope(&mut self) -> bool

Source

pub fn add_group(&mut self, prefix: &str) -> CalyxGroup

Creates a new group guaranteed to start with prefix.

Source

pub fn add_comb_group(&mut self, prefix: &str) -> CalyxCombGroup

Creates a new combinational group guaranteed to start with prefix.

Source

pub fn finalize(self) -> Component

Auto Trait Implementations§

§

impl<'a, ComponentData> Freeze for CalyxComponent<'a, ComponentData>
where ComponentData: Freeze,

§

impl<'a, ComponentData> !RefUnwindSafe for CalyxComponent<'a, ComponentData>

§

impl<'a, ComponentData> !Send for CalyxComponent<'a, ComponentData>

§

impl<'a, ComponentData> !Sync for CalyxComponent<'a, ComponentData>

§

impl<'a, ComponentData> Unpin for CalyxComponent<'a, ComponentData>
where ComponentData: Unpin,

§

impl<'a, ComponentData> !UnwindSafe for CalyxComponent<'a, ComponentData>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.