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>
impl<'a, ComponentData: Default> CalyxComponent<'a, ComponentData>
Sourcepub fn user_data_ref(&self) -> &ComponentData
pub fn user_data_ref(&self) -> &ComponentData
The user data associated with the component.
Sourcepub fn user_data_mut(&mut self) -> &mut ComponentData
pub fn user_data_mut(&mut self) -> &mut ComponentData
Sourcepub fn signature(&mut self) -> CalyxCell
pub fn signature(&mut self) -> CalyxCell
The input/output signature of this component as a cell.
Sourcepub fn control(&mut self) -> &mut CalyxControl<Sequential>
pub fn control(&mut self) -> &mut CalyxControl<Sequential>
The control of this component.
Sourcepub fn with_calyx_builder<F, T>(&mut self, f: F) -> T
pub fn with_calyx_builder<F, T>(&mut self, f: F) -> T
Enables direct access to a calyx_ir::Builder
for this component.
Sourcepub fn new_reg(&mut self, name: String, width: usize) -> CalyxCell
pub fn new_reg(&mut self, name: String, width: usize) -> CalyxCell
A register cell bound to name
.
Requires: name
has not been bound.
Sourcepub fn named_mem(
&mut self,
name: String,
cell_size: usize,
length: usize,
address_bits: usize,
) -> CalyxCell
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.
Sourcepub fn new_prim(
&mut self,
name: &str,
prim: &str,
params: Vec<u64>,
) -> CalyxCell
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.
Sourcepub fn component_cell(
&mut self,
prefix: String,
component: String,
instantiate_new: bool,
) -> (String, CalyxCell)
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.
Sourcepub fn new_unnamed_cell(&mut self, kind: CalyxCellKind) -> CalyxCell
pub fn new_unnamed_cell(&mut self, kind: CalyxCellKind) -> CalyxCell
An unnamed cell of a given kind
.
Sourcepub fn constant(&mut self, value: i64, width: usize) -> CalyxCell
pub fn constant(&mut self, value: i64, width: usize) -> CalyxCell
A constant cell, that is, a primitive "std_const"
.
Sourcepub fn signal_out(&mut self) -> CalyxCell
pub fn signal_out(&mut self) -> CalyxCell
Equivlane to constant(1, 1)
.
Sourcepub fn alias_cell(&mut self, name: String, cell: CalyxCell)
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.
Sourcepub fn find(&mut self, name: String) -> CalyxCell
pub fn find(&mut self, name: String) -> CalyxCell
Looks up a named cell previously bound to name
.
Requires: name
has been bound.
Sourcepub fn begin_scope(&mut self)
pub fn begin_scope(&mut self)
See Environment::push
.
Sourcepub fn end_scope(&mut self) -> bool
pub fn end_scope(&mut self) -> bool
See Environment::pop
.
Sourcepub fn add_group(&mut self, prefix: &str) -> CalyxGroup
pub fn add_group(&mut self, prefix: &str) -> CalyxGroup
Creates a new group guaranteed to start with prefix
.
Sourcepub fn add_comb_group(&mut self, prefix: &str) -> CalyxCombGroup
pub fn add_comb_group(&mut self, prefix: &str) -> CalyxCombGroup
Creates a new combinational group guaranteed to start with prefix
.
Sourcepub fn finalize(self) -> Component
pub fn finalize(self) -> Component
Yields a calyx_ir::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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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