Struct calyx_ir::Builder

source ·
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§

source§

impl<'a> Builder<'a>

source

pub fn new(component: &'a mut Component, lib: &'a LibrarySignatures) -> Self

Instantiate a new builder using for a component.

source

pub fn validate(self) -> Self

Enable the validation flag on a builder.

source

pub fn not_generated(self) -> Self

Disable the generated flag on the builder

source

pub fn add_continuous_assignments(&mut self, assigns: Vec<Assignment<Nothing>>)

source

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.

source

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.

source

pub fn add_comb_group<S>(&mut self, prefix: S) -> RRC<CombGroup>
where S: Into<Id> + ToString + Clone,

Construct a combinational group

source

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.

source

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]);
source

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()].

source

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.

source

pub fn build_assignment<T>( &self, dst: RRC<Port>, src: RRC<Port>, guard: Guard<T> ) -> Assignment<T>

Construct an assignment.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Builder<'a>

§

impl<'a> !Send for Builder<'a>

§

impl<'a> !Sync for Builder<'a>

§

impl<'a> Unpin for Builder<'a>

§

impl<'a> !UnwindSafe for Builder<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.