Skip to content

Commit

Permalink
Add the undef primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
EclecticGriffin committed Jul 15, 2024
1 parent 3d620d2 commit ec39d7e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions interp/src/flatten/flat_ir/cell_prototype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub enum PrimType1 {
UnsynSMult,
UnsynSDiv,
UnsynSMod,
Undef,
}

/// An enum for encoding FP primitives operator types
Expand Down Expand Up @@ -654,6 +655,14 @@ impl CellPrototype {
}
}

"undef" => {
get_params![params; width: "WIDTH"];
Self::SingleWidth {
op: PrimType1::Undef,
width: width.try_into().unwrap(),
}
}

_ => CellPrototype::Unknown(
name.to_string(),
param_binding.clone(),
Expand Down
1 change: 1 addition & 0 deletions interp/src/flatten/primitives/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub fn build_primitive(
PrimType1::UnsynSMod => {
Box::new(StdUnsynSmod::new(base_port, *width))
}
PrimType1::Undef => Box::new(StdUndef::new(base_port, *width)),
},
CellPrototype::FixedPoint {
op: _,
Expand Down
17 changes: 16 additions & 1 deletion interp/src/flatten/primitives/combinational.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Primitive for StdConst {
}

fn has_comb(&self) -> bool {
false
true
}

fn has_stateful(&self) -> bool {
Expand Down Expand Up @@ -548,3 +548,18 @@ comb_primitive!(StdUnsynSmod[WIDTH](left [0], right [1]) -> (out [2]) {
&left.as_signed(),
&right.as_signed()), WIDTH)))
});

pub struct StdUndef(GlobalPortIdx);

impl StdUndef {
pub fn new(base_port: GlobalPortIdx, _width: u32) -> Self {
Self(base_port)
}
}

impl Primitive for StdUndef {
fn exec_comb(&self, port_map: &mut PortMap) -> UpdateResult {
port_map.write_undef(self.0)?;
Ok(UpdateStatus::Unchanged)
}
}

0 comments on commit ec39d7e

Please sign in to comment.