Skip to content

Commit

Permalink
Implement delay unit for ImmediateValue.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhartman committed Dec 17, 2024
1 parent 93293c3 commit f520d63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions crates/circuit/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ pub enum DelayUnit {
DT,
}

unsafe impl ::bytemuck::CheckedBitPattern for DelayUnit {
type Bits = u8;

fn is_valid_bit_pattern(bits: &Self::Bits) -> bool {
*bits < 6
}
}
unsafe impl ::bytemuck::NoUninit for DelayUnit {}

impl fmt::Display for DelayUnit {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
Expand Down
2 changes: 1 addition & 1 deletion crates/circuit/src/packed_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl ImmediateValue {

#[inline]
fn delay_unit(&self) -> DelayUnit {
todo!()
::bytemuck::checked::cast(self.0 as u8)
}

#[inline]
Expand Down

0 comments on commit f520d63

Please sign in to comment.