pub struct CalyxBuilder { /* private fields */ }
Expand description
A builder for calyx IR optimized for generation from a higher-level AST or IR.
Implementations§
Source§impl CalyxBuilder
impl CalyxBuilder
Sourcepub fn new(
prelude: Option<PathBuf>,
lib_path: PathBuf,
entrypoint: Option<String>,
cell_name_prefix: String,
) -> Self
pub fn new( prelude: Option<PathBuf>, lib_path: PathBuf, entrypoint: Option<String>, cell_name_prefix: String, ) -> Self
Constructs a new calyx builder. See the documentation at
CalyxBuilder
for general usage information.
-
prelude
is an optional calyx file that will be parsed and inlined in additional to the standard library, which is useful for additional component definitions or imports. -
lib_path
should be the root of the calyx installation location, e.g., the folder generated from cloning the repository from GitHub. -
entrypoint
is the name of the entry component in the program. IfNone
is passed, it will default to"main"
. You can useCalyxBuilder::set_entrypoint
to update it. -
cell_name_prefix
is the non-empty prefix applied to all named cells (e.g., those requested via [CalyxComponent::named_reg
]) to guarantee no collisions with unnamed cells (e.g., those requested via [CalyxComponent::unnamed_cell
]). It must be non-empty.
Sourcepub fn register_component(&mut self, name: String, ports: Vec<PortDef<u64>>)
pub fn register_component(&mut self, name: String, ports: Vec<PortDef<u64>>)
Binds a component (named name
)’s signature to a list of ports
so it
can be constructed or instantiated by another component.
Sourcepub fn start_component<ComponentData: Default>(
&self,
name: String,
) -> CalyxComponent<'_, ComponentData>
pub fn start_component<ComponentData: Default>( &self, name: String, ) -> CalyxComponent<'_, ComponentData>
Returns a component wrapper for a registered component. Once you are
finished with the component builder, call [finish_component!
].
Requires: CalyxBuilder::register_component
has been issued for
name
.
Sourcepub fn _finish_component(&mut self, component: Component)
pub fn _finish_component(&mut self, component: Component)
Please use [finish_component!
] instead.
Sourcepub fn set_entrypoint(&mut self, entrypoint: String)
pub fn set_entrypoint(&mut self, entrypoint: String)
Updates the name of the program entrypoint.
Requires: CalyxBuilder::register_component
has been issued for
entrypoint
.
Sourcepub fn finalize(self) -> Context
pub fn finalize(self) -> Context
Yields a calyx_ir::Context
.
Requires: the entrypoint provided at CalyxBuilder::new
is the name
of a component added.
Auto Trait Implementations§
impl Freeze for CalyxBuilder
impl !RefUnwindSafe for CalyxBuilder
impl !Send for CalyxBuilder
impl !Sync for CalyxBuilder
impl Unpin for CalyxBuilder
impl !UnwindSafe for CalyxBuilder
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