pub struct Builder<'a> {
pub component: &'a mut Component,
/* private fields */
}
Expand description
IR builder.
Uses internal references to the component to construct and validate
constructs when needed.
By default, assumes that the cells are being added by a pass and marks
them with the @generated
attribute.
In order to disable this behavior, call [ir::Builder::not_generated()].
Fields
component: &'a mut Component
Component for which this builder is constructing.
Implementations
sourceimpl<'a> Builder<'a>
impl<'a> Builder<'a>
sourcepub fn new(component: &'a mut Component, lib: &'a LibrarySignatures) -> Self
pub fn new(component: &'a mut Component, lib: &'a LibrarySignatures) -> Self
Instantiate a new builder using for a component.
sourcepub fn not_generated(self) -> Self
pub fn not_generated(self) -> Self
Disable the generated flag on the builder
pub fn add_continuous_assignments(&mut self, assigns: Vec<Assignment<Nothing>>)
sourcepub fn add_group<S>(&mut self, prefix: S) -> RRC<Group>where
S: Into<Id>,
pub fn add_group<S>(&mut self, prefix: S) -> RRC<Group>where
S: Into<Id>,
Construct a new group and add it to the Component.
The group is guaranteed to start with prefix
.
Returns a reference to the group.
sourcepub fn add_static_group<S>(&mut self, prefix: S, latency: u64) -> RRC<StaticGroup>where
S: Into<Id>,
pub fn add_static_group<S>(&mut self, prefix: S, latency: u64) -> RRC<StaticGroup>where
S: Into<Id>,
Construct a new static group and add it to the Component.
The group is guaranteed to start with prefix
.
Returns a reference to the group.
sourcepub fn add_comb_group<S>(&mut self, prefix: S) -> RRC<CombGroup>where
S: Into<Id> + ToString + Clone,
pub fn add_comb_group<S>(&mut self, prefix: S) -> RRC<CombGroup>where
S: Into<Id> + ToString + Clone,
Construct a combinational group
sourcepub fn add_constant(&mut self, val: u64, width: u64) -> RRC<Cell>
pub fn add_constant(&mut self, val: u64, width: u64) -> RRC<Cell>
Return reference for a constant cell associated with the (val, width) pair, building and adding it to the component if needed.. If the constant does not exist, it is added to the Context.
sourcepub fn add_primitive<Pre, Prim>(
&mut self,
prefix: Pre,
primitive: Prim,
param_values: &[u64]
) -> RRC<Cell>where
Pre: Into<Id> + ToString + Clone,
Prim: Into<Id>,
pub fn add_primitive<Pre, Prim>(
&mut self,
prefix: Pre,
primitive: Prim,
param_values: &[u64]
) -> RRC<Cell>where
Pre: Into<Id> + ToString + Clone,
Prim: Into<Id>,
Consturcts a primitive cell of type primitive
.
The name of the cell is guaranteed to start with prefix
.
Adds this cell to the underlying component and returns a reference
to the Cell.
For example:
// Construct a std_reg.
builder.add_primitive("fsm", "std_reg", vec![32]);
sourcepub fn try_add_primitive<Pre, Prim>(
&mut self,
prefix: Pre,
primitive: Prim,
param_values: &[u64]
) -> CalyxResult<RRC<Cell>>where
Pre: Into<Id> + ToString + Clone,
Prim: Into<Id>,
pub fn try_add_primitive<Pre, Prim>(
&mut self,
prefix: Pre,
primitive: Prim,
param_values: &[u64]
) -> CalyxResult<RRC<Cell>>where
Pre: Into<Id> + ToString + Clone,
Prim: Into<Id>,
Result variant of [ir::Builder::add_primitive()].
sourcepub fn add_component<Pre>(
&mut self,
prefix: Pre,
component: Pre,
sig: Vec<PortDef<u64>>
) -> RRC<Cell>where
Pre: Into<Id> + ToString + Clone,
pub fn add_component<Pre>(
&mut self,
prefix: Pre,
component: Pre,
sig: Vec<PortDef<u64>>
) -> RRC<Cell>where
Pre: Into<Id> + ToString + Clone,
Add a component instance to this component using its name and port signature.
sourcepub fn build_assignment<T>(
&self,
dst: RRC<Port>,
src: RRC<Port>,
guard: Guard<T>
) -> Assignment<T>
pub fn build_assignment<T>(
&self,
dst: RRC<Port>,
src: RRC<Port>,
guard: Guard<T>
) -> Assignment<T>
Construct an assignment.