Skip to main content

ChiselBackend

Struct ChiselBackend 

Source
pub struct ChiselBackend;
Expand description

Code-generation backend for Chisel 3 / Chisel 5.

Implementations§

Source§

impl ChiselBackend

Source

pub fn new() -> Self

Create a new ChiselBackend.

Source

pub fn emit_type(&self, ty: &ChiselType) -> String

Emit the Chisel type string for a ChiselType.

Source

pub fn io_bundle(&self, ports: &[ChiselPort]) -> String

Emit the val io = IO(new Bundle { ... }) declaration for a port list.

Source

pub fn emit_module(&self, module: &ChiselModule) -> String

Emit a complete Chisel module class.

Source

pub fn when_stmt(&self, cond: &str, body: &str) -> String

Emit a when block: when(cond) { body }.

Source

pub fn when_otherwise( &self, cond: &str, when_body: &str, other_body: &str, ) -> String

Emit a when / otherwise block.

Source

pub fn reg_init(&self, name: &str, ty: &ChiselType, init: &str) -> String

Emit a register declaration: val r = RegInit(init_val).

Source

pub fn reg_no_reset(&self, name: &str, ty: &ChiselType) -> String

Emit a register declaration without reset: val r = Reg(gen).

Source

pub fn wire_decl(&self, name: &str, ty: &ChiselType) -> String

Emit a wire declaration: val w = Wire(gen).

Source

pub fn connect(&self, lhs: &str, rhs: &str) -> String

Emit a connection: lhs := rhs.

Source

pub fn printf(&self, fmt_str: &str, args: &[&str]) -> String

Emit a printf debug statement.

Source

pub fn assert_stmt(&self, cond: &str, msg: &str) -> String

Emit a assert statement.

Source

pub fn mux_expr(&self, sel: &str, t: &str, f: &str) -> String

Emit a Mux expression string.

Source

pub fn cat_expr(&self, parts: &[&str]) -> String

Emit a Cat expression string.

Source

pub fn fill_expr(&self, count: u32, value: &str) -> String

Emit a fill (replicate) expression.

Source

pub fn instantiate(&self, class: &str, inst_name: &str) -> String

Emit a submodule instantiation.

Source

pub fn emit_expr(&self, expr: &ChiselExpr) -> String

Emit a ChiselExpr as a string.

Source§

impl ChiselBackend

Source

pub fn dont_care(&self, signal: &str) -> String

Emit a DontCare assignment.

Source

pub fn irrevocable_port( &self, name: &str, data_type: &ChiselType, is_output: bool, ) -> String

Emit an Irrevocable (valid+ready, never de-asserts valid) port.

Source

pub fn comb_rom( &self, name: &str, _data_type: &ChiselType, values: &[&str], ) -> String

Emit a combinational ROM using a Vec[UInt] initialized from a list.

Source

pub fn mux1h(&self, _sel: &str, cases: &[(&str, &str)]) -> String

Emit a Mux1H (one-hot mux).

Source

pub fn log2_ceil(&self, n: u32) -> u32

Emit a log2Ceil computation.

Source

pub fn log2_floor(&self, n: u32) -> u32

Emit a log2Floor computation.

Source

pub fn is_pow2(&self, n: u32) -> bool

Check if n is a power of two.

Source

pub fn cover_stmt(&self, cond: &str, msg: &str) -> String

Emit a cover statement (Chisel formal verification).

Source

pub fn assume_stmt(&self, cond: &str) -> String

Emit an assume statement.

Source

pub fn sim_printf(&self, fmt_str: &str, args: &[&str]) -> String

Emit a ChiselSim-compatible printf for simulation only.

Source

pub fn fill(&self, n: u32, expr: &str) -> String

Emit a chisel3.util.Fill call (replicate a bit pattern).

Source

pub fn cat(&self, signals: &[&str]) -> String

Emit a Cat call (concatenate signals).

Source

pub fn popcount(&self, signal: &str) -> String

Emit a PopCount call.

Source

pub fn oh_to_uint(&self, one_hot: &str) -> String

Emit a priority encoder (OHToUInt).

Source

pub fn uint_to_oh(&self, n: &str, width: u32) -> String

Emit a UIntToOH call.

Source

pub fn reverse(&self, signal: &str) -> String

Emit a Reverse call (bit-reversal).

Source

pub fn mux_case(&self, default: &str, cases: &[(&str, &str)]) -> String

Emit a MuxCase expression.

Source

pub fn shift_register(&self, data: &str, n: u32, reset_val: &str) -> String

Emit a ShiftRegister instantiation.

Source

pub fn round_robin_arbiter( &self, name: &str, data_type: &ChiselType, n: u32, ) -> String

Emit an arbiter (RRArbiter) for n inputs of a given type.

Source

pub fn priority_arbiter( &self, name: &str, data_type: &ChiselType, n: u32, ) -> String

Emit a fixed-priority arbiter.

Source

pub fn queue_module( &self, name: &str, data_type: &ChiselType, depth: u32, ) -> String

Emit a Chisel FIFO queue module instantiation.

Source

pub fn when_chain( &self, cond_body: &[(&str, &str)], otherwise: Option<&str>, ) -> String

Emit a when/elsewhen/otherwise chain.

Source

pub fn counter(&self, name: &str, max_val: u32, enable: &str) -> String

Emit a counter that wraps at max_val.

Source

pub fn reset_sync(&self, name: &str, async_rst: &str) -> String

Emit a reset synchronizer (2-FF synchronizer for reset deassertion).

Source

pub fn cdc_handshake_comment(&self, from_clk: &str, to_clk: &str) -> String

Emit a clock domain crossing (CDC) handshake wrapper comment.

Source

pub fn blackbox_stub(&self, name: &str, params: &[(&str, &str)]) -> String

Emit a BlackBox module class stub.

Trait Implementations§

Source§

impl Clone for ChiselBackend

Source§

fn clone(&self) -> ChiselBackend

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChiselBackend

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChiselBackend

Source§

fn default() -> ChiselBackend

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.