From 21c73051ecd71151999af3c27a82bbe4a1abb7b2 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 18 Dec 2024 01:39:35 -0800 Subject: [PATCH] sim: add SimValue and reading/writing more than just a scalar --- crates/fayalite/src/bundle.rs | 125 +- crates/fayalite/src/sim.rs | 768 ++++++++++- crates/fayalite/tests/sim.rs | 39 +- crates/fayalite/tests/sim/expected/enums.txt | 1205 +++++++++++------- crates/fayalite/tests/sim/expected/enums.vcd | 42 +- 5 files changed, 1719 insertions(+), 460 deletions(-) diff --git a/crates/fayalite/src/bundle.rs b/crates/fayalite/src/bundle.rs index 843eb6c..995510e 100644 --- a/crates/fayalite/src/bundle.rs +++ b/crates/fayalite/src/bundle.rs @@ -4,12 +4,14 @@ use crate::{ expr::{ops::BundleLiteral, Expr, ToExpr}, intern::{Intern, Interned}, + sim::{SimValue, ToSimValue}, source_location::SourceLocation, ty::{ impl_match_variant_as_self, CanonicalType, MatchVariantWithoutScope, StaticType, Type, TypeProperties, TypeWithDeref, }, }; +use bitvec::vec::BitVec; use hashbrown::HashMap; use std::{fmt, marker::PhantomData}; @@ -323,7 +325,7 @@ macro_rules! impl_tuple_builder_fields { } macro_rules! impl_tuples { - ([$({#[num = $num:literal, field = $field:ident] $var:ident: $T:ident})*] []) => { + ([$({#[num = $num:literal, field = $field:ident, ty = $ty_var:ident: $Ty:ident] $var:ident: $T:ident})*] []) => { impl_tuple_builder_fields! { {} [$({ @@ -423,6 +425,79 @@ macro_rules! impl_tuples { BundleLiteral::new(ty, field_values[..].intern()).to_expr() } } + impl<$($T: ToSimValue,)*> ToSimValue for ($($T,)*) { + #[track_caller] + fn to_sim_value(&self, ty: CanonicalType) -> SimValue { + ToSimValue::::to_sim_value(self, Bundle::from_canonical(ty)).into_canonical() + } + #[track_caller] + fn into_sim_value(self, ty: CanonicalType) -> SimValue + { + ToSimValue::::into_sim_value(self, Bundle::from_canonical(ty)).into_canonical() + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: CanonicalType) -> SimValue { + ToSimValue::::box_into_sim_value(self, Bundle::from_canonical(ty)).into_canonical() + } + } + impl<$($T: ToSimValue,)*> ToSimValue for ($($T,)*) { + #[track_caller] + fn to_sim_value(&self, ty: Bundle) -> SimValue { + let ($($var,)*) = self; + let [$($ty_var,)*] = *ty.fields() else { + panic!("bundle has wrong number of fields"); + }; + $(let $var = $var.to_sim_value($ty_var.ty);)* + ToSimValue::into_sim_value(($($var,)*), ty) + } + #[track_caller] + fn into_sim_value(self, ty: Bundle) -> SimValue { + #![allow(unused_mut)] + #![allow(clippy::unused_unit)] + let ($($var,)*) = self; + let [$($ty_var,)*] = *ty.fields() else { + panic!("bundle has wrong number of fields"); + }; + let mut bits: Option = None; + $(let $var = $var.into_sim_value($ty_var.ty); + assert_eq!($var.ty(), $ty_var.ty); + if !$var.bits().is_empty() { + if let Some(bits) = &mut bits { + bits.extend_from_bitslice($var.bits()); + } else { + let mut $var = $var.into_bits(); + $var.reserve(ty.type_properties().bit_width - $var.len()); + bits = Some($var); + } + } + )* + bits.unwrap_or_else(BitVec::new).into_sim_value(ty) + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: Bundle) -> SimValue { + Self::into_sim_value(*self, ty) + } + } + impl<$($T: ToSimValue<$Ty>, $Ty: Type,)*> ToSimValue<($($Ty,)*)> for ($($T,)*) { + #[track_caller] + fn to_sim_value(&self, ty: ($($Ty,)*)) -> SimValue<($($Ty,)*)> { + let ($($var,)*) = self; + let ($($ty_var,)*) = ty; + $(let $var = $var.to_sim_value($ty_var).into_canonical();)* + SimValue::from_canonical(ToSimValue::into_sim_value(($($var,)*), ty.canonical())) + } + #[track_caller] + fn into_sim_value(self, ty: ($($Ty,)*)) -> SimValue<($($Ty,)*)> { + let ($($var,)*) = self; + let ($($ty_var,)*) = ty; + $(let $var = $var.into_sim_value($ty_var).into_canonical();)* + SimValue::from_canonical(ToSimValue::into_sim_value(($($var,)*), ty.canonical())) + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: ($($Ty,)*)) -> SimValue<($($Ty,)*)> { + Self::into_sim_value(*self, ty) + } + } }; ([$($lhs:tt)*] [$rhs_first:tt $($rhs:tt)*]) => { impl_tuples!([$($lhs)*] []); @@ -432,18 +507,18 @@ macro_rules! impl_tuples { impl_tuples! { [] [ - {#[num = 0, field = field_0] v0: T0} - {#[num = 1, field = field_1] v1: T1} - {#[num = 2, field = field_2] v2: T2} - {#[num = 3, field = field_3] v3: T3} - {#[num = 4, field = field_4] v4: T4} - {#[num = 5, field = field_5] v5: T5} - {#[num = 6, field = field_6] v6: T6} - {#[num = 7, field = field_7] v7: T7} - {#[num = 8, field = field_8] v8: T8} - {#[num = 9, field = field_9] v9: T9} - {#[num = 10, field = field_10] v10: T10} - {#[num = 11, field = field_11] v11: T11} + {#[num = 0, field = field_0, ty = ty0: Ty0] v0: T0} + {#[num = 1, field = field_1, ty = ty1: Ty1] v1: T1} + {#[num = 2, field = field_2, ty = ty2: Ty2] v2: T2} + {#[num = 3, field = field_3, ty = ty3: Ty3] v3: T3} + {#[num = 4, field = field_4, ty = ty4: Ty4] v4: T4} + {#[num = 5, field = field_5, ty = ty5: Ty5] v5: T5} + {#[num = 6, field = field_6, ty = ty6: Ty6] v6: T6} + {#[num = 7, field = field_7, ty = ty7: Ty7] v7: T7} + {#[num = 8, field = field_8, ty = ty8: Ty8] v8: T8} + {#[num = 9, field = field_9, ty = ty9: Ty9] v9: T9} + {#[num = 10, field = field_10, ty = ty10: Ty10] v10: T10} + {#[num = 11, field = field_11, ty = ty11: Ty11] v11: T11} ] } @@ -528,3 +603,27 @@ impl ToExpr for PhantomData { BundleLiteral::new(PhantomData, Interned::default()).to_expr() } } + +impl ToSimValue for PhantomData { + #[track_caller] + fn to_sim_value(&self, ty: Self) -> SimValue { + ToSimValue::into_sim_value(BitVec::new(), ty) + } +} + +impl ToSimValue for PhantomData { + #[track_caller] + fn to_sim_value(&self, ty: Bundle) -> SimValue { + assert!(ty.fields().is_empty()); + ToSimValue::into_sim_value(BitVec::new(), ty) + } +} + +impl ToSimValue for PhantomData { + #[track_caller] + fn to_sim_value(&self, ty: CanonicalType) -> SimValue { + let ty = Bundle::from_canonical(ty); + assert!(ty.fields().is_empty()); + ToSimValue::into_sim_value(BitVec::new(), ty).into_canonical() + } +} diff --git a/crates/fayalite/src/sim.rs b/crates/fayalite/src/sim.rs index a2b9648..10fbb92 100644 --- a/crates/fayalite/src/sim.rs +++ b/crates/fayalite/src/sim.rs @@ -14,7 +14,7 @@ use crate::{ }, ExprEnum, Flow, ToLiteralBits, }, - int::BoolOrIntType, + int::{BoolOrIntType, IntType, SIntValue, UIntValue}, intern::{Intern, Interned, Memoize}, memory::PortKind, module::{ @@ -42,7 +42,7 @@ use crate::{ use bitvec::{bits, order::Lsb0, slice::BitSlice, vec::BitVec, view::BitView}; use hashbrown::{HashMap, HashSet}; use num_bigint::BigInt; -use num_traits::{Signed, ToPrimitive, Zero}; +use num_traits::{Signed, Zero}; use petgraph::{ data::FromElements, visit::{ @@ -50,7 +50,9 @@ use petgraph::{ IntoNodeIdentifiers, IntoNodeReferences, NodeRef, VisitMap, Visitable, }, }; -use std::{borrow::Cow, collections::BTreeSet, fmt, marker::PhantomData, mem, ops::IndexMut}; +use std::{ + borrow::Cow, collections::BTreeSet, fmt, marker::PhantomData, mem, ops::IndexMut, sync::Arc, +}; mod interpreter; pub mod time; @@ -5806,6 +5808,624 @@ impl SimTraceKind { } } +#[derive(Clone, PartialEq, Eq, Hash, Debug)] +pub struct SimValue { + ty: T, + bits: BitVec, +} + +impl SimValue { + #[track_caller] + fn to_expr_impl(ty: CanonicalType, bits: &BitSlice) -> Expr { + match ty { + CanonicalType::UInt(_) => Expr::canonical(::bits_to_expr(Cow::Borrowed(bits))), + CanonicalType::SInt(_) => Expr::canonical(::bits_to_expr(Cow::Borrowed(bits))), + CanonicalType::Bool(_) => Expr::canonical(Bool::bits_to_expr(Cow::Borrowed(bits))), + CanonicalType::Array(ty) => { + let element_bit_width = ty.element().bit_width(); + Expr::::canonical( + crate::expr::ops::ArrayLiteral::new( + ty.element(), + (0..ty.len()) + .map(|array_index| { + let start = element_bit_width * array_index; + let end = start + element_bit_width; + Self::to_expr_impl(ty.element(), &bits[start..end]) + }) + .collect(), + ) + .to_expr(), + ) + } + CanonicalType::Enum(ty) => { + let discriminant_bit_width = ty.discriminant_bit_width(); + let mut variant_index = [0; mem::size_of::()]; + variant_index.view_bits_mut::()[0..discriminant_bit_width] + .clone_from_bitslice(&bits[..discriminant_bit_width]); + let variant_index = usize::from_le_bytes(variant_index); + if let Some(variant) = ty.variants().get(variant_index) { + let data_bit_width = variant.ty.map_or(0, CanonicalType::bit_width); + Expr::canonical( + crate::expr::ops::EnumLiteral::new_by_index( + ty, + variant_index, + variant.ty.map(|ty| { + Self::to_expr_impl( + ty, + &bits[discriminant_bit_width + ..discriminant_bit_width + data_bit_width], + ) + }), + ) + .to_expr(), + ) + } else { + Expr::canonical(::bits_to_expr(Cow::Borrowed(bits)).cast_bits_to(ty)) + } + } + CanonicalType::Bundle(ty) => Expr::canonical( + crate::expr::ops::BundleLiteral::new( + ty, + ty.fields() + .iter() + .zip(ty.field_offsets().iter()) + .map(|(field, &field_offset)| { + Self::to_expr_impl( + field.ty, + &bits[field_offset..field_offset + field.ty.bit_width()], + ) + }) + .collect(), + ) + .to_expr(), + ), + CanonicalType::AsyncReset(ty) => { + Expr::canonical(Bool::bits_to_expr(Cow::Borrowed(bits)).cast_to(ty)) + } + CanonicalType::SyncReset(ty) => { + Expr::canonical(Bool::bits_to_expr(Cow::Borrowed(bits)).cast_to(ty)) + } + CanonicalType::Reset(_) => panic!( + "can't convert SimValue to Expr -- \ + can't deduce whether reset value should be sync or async" + ), + CanonicalType::Clock(ty) => { + Expr::canonical(Bool::bits_to_expr(Cow::Borrowed(bits)).cast_to(ty)) + } + } + } +} + +impl ToExpr for SimValue { + type Type = T; + + #[track_caller] + fn to_expr(&self) -> Expr { + Expr::from_canonical(SimValue::to_expr_impl(self.ty.canonical(), &self.bits)) + } +} + +impl ToSimValue for SimValue { + #[track_caller] + fn to_sim_value(&self, ty: T) -> SimValue { + assert_eq!(self.ty, ty); + self.clone() + } + + #[track_caller] + fn into_sim_value(self, ty: T) -> SimValue { + assert_eq!(self.ty, ty); + self + } + + #[track_caller] + fn box_into_sim_value(self: Box, ty: T) -> SimValue { + assert_eq!(self.ty, ty); + *self + } +} + +impl ToSimValue for BitVec { + #[track_caller] + fn to_sim_value(&self, ty: T) -> SimValue { + self.clone().into_sim_value(ty) + } + + #[track_caller] + fn into_sim_value(self, ty: T) -> SimValue { + assert_eq!(ty.canonical().bit_width(), self.len()); + SimValue { ty, bits: self } + } + + #[track_caller] + fn box_into_sim_value(self: Box, ty: T) -> SimValue { + Self::into_sim_value(*self, ty) + } +} + +impl ToSimValue for bitvec::boxed::BitBox { + #[track_caller] + fn to_sim_value(&self, ty: T) -> SimValue { + self.clone().into_sim_value(ty) + } + + #[track_caller] + fn into_sim_value(self, ty: T) -> SimValue { + assert_eq!(ty.canonical().bit_width(), self.len()); + SimValue { + ty, + bits: self.into_bitvec(), + } + } + + #[track_caller] + fn box_into_sim_value(self: Box, ty: T) -> SimValue { + Self::into_sim_value(*self, ty) + } +} + +impl ToSimValue for BitSlice { + #[track_caller] + fn to_sim_value(&self, ty: T) -> SimValue { + assert_eq!(ty.canonical().bit_width(), self.len()); + SimValue { + ty, + bits: self.to_bitvec(), + } + } +} + +impl SimValue { + pub fn ty(&self) -> T { + self.ty + } + pub fn bits(&self) -> &BitSlice { + &self.bits + } + pub fn into_bits(self) -> BitVec { + self.bits + } + #[track_caller] + pub fn from_canonical(v: SimValue) -> Self { + Self { + ty: T::from_canonical(v.ty), + bits: v.bits, + } + } + pub fn into_canonical(self) -> SimValue { + SimValue { + ty: self.ty.canonical(), + bits: self.bits, + } + } + #[track_caller] + pub fn from_dyn_int(v: SimValue) -> Self + where + T: IntType, + { + Self { + ty: T::from_dyn_int(v.ty), + bits: v.bits, + } + } + pub fn into_dyn_int(self) -> SimValue + where + T: IntType, + { + SimValue { + ty: self.ty.as_dyn_int(), + bits: self.bits, + } + } + #[track_caller] + pub fn from_bundle(v: SimValue) -> Self + where + T: BundleType, + { + Self { + ty: T::from_canonical(CanonicalType::Bundle(v.ty)), + bits: v.bits, + } + } + pub fn into_bundle(self) -> SimValue + where + T: BundleType, + { + SimValue { + ty: Bundle::from_canonical(self.ty.canonical()), + bits: self.bits, + } + } + #[track_caller] + pub fn from_enum(v: SimValue) -> Self + where + T: EnumType, + { + Self { + ty: T::from_canonical(CanonicalType::Enum(v.ty)), + bits: v.bits, + } + } + pub fn into_enum(self) -> SimValue + where + T: EnumType, + { + SimValue { + ty: Enum::from_canonical(self.ty.canonical()), + bits: self.bits, + } + } +} + +pub trait ToSimValue { + #[track_caller] + fn to_sim_value(&self, ty: T) -> SimValue; + #[track_caller] + fn into_sim_value(self, ty: T) -> SimValue + where + Self: Sized, + { + self.to_sim_value(ty) + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: T) -> SimValue { + self.to_sim_value(ty) + } +} + +impl, T: Type> ToSimValue for &'_ This { + #[track_caller] + fn to_sim_value(&self, ty: T) -> SimValue { + This::to_sim_value(self, ty) + } +} + +impl, T: Type> ToSimValue for &'_ mut This { + #[track_caller] + fn to_sim_value(&self, ty: T) -> SimValue { + This::to_sim_value(self, ty) + } +} + +impl, T: Type> ToSimValue for Box { + #[track_caller] + fn to_sim_value(&self, ty: T) -> SimValue { + This::to_sim_value(self, ty) + } + #[track_caller] + fn into_sim_value(self, ty: T) -> SimValue { + This::box_into_sim_value(self, ty) + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: T) -> SimValue { + This::box_into_sim_value(*self, ty) + } +} + +impl + Send + Sync + 'static, T: Type> ToSimValue + for Interned +{ + #[track_caller] + fn to_sim_value(&self, ty: T) -> SimValue { + This::to_sim_value(self, ty) + } +} + +impl SimValue> { + #[track_caller] + pub fn from_array_elements< + I: IntoIterator, IntoIter: ExactSizeIterator>, + >( + elements: I, + ty: ArrayType, + ) -> Self { + let mut iter = elements.into_iter(); + assert_eq!(iter.len(), ty.len()); + let Some(first) = iter.next() else { + return SimValue { + ty, + bits: BitVec::new(), + }; + }; + let SimValue { + ty: element_ty, + mut bits, + } = first.into_sim_value(ty.element()); + assert_eq!(element_ty, ty.element()); + bits.reserve(ty.type_properties().bit_width - bits.len()); + for element in iter { + let SimValue { + ty: element_ty, + bits: element_bits, + } = element.into_sim_value(ty.element()); + assert_eq!(element_ty, ty.element()); + bits.extend_from_bitslice(&element_bits); + } + SimValue { ty, bits } + } +} + +impl, T: Type> ToSimValue> for [Element] { + #[track_caller] + fn to_sim_value(&self, ty: Array) -> SimValue> { + SimValue::from_array_elements(self, ty) + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: Array) -> SimValue> { + SimValue::from_array_elements(self, ty) + } +} + +impl> ToSimValue for [Element] { + #[track_caller] + fn to_sim_value(&self, ty: CanonicalType) -> SimValue { + SimValue::from_array_elements(self, ::from_canonical(ty)).into_canonical() + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: CanonicalType) -> SimValue { + SimValue::from_array_elements(self, ::from_canonical(ty)).into_canonical() + } +} + +impl, T: Type, const N: usize> ToSimValue> for [Element; N] +where + ConstUsize: KnownSize, +{ + #[track_caller] + fn to_sim_value(&self, ty: Array) -> SimValue> { + SimValue::from_array_elements(self, ty) + } + #[track_caller] + fn into_sim_value(self, ty: Array) -> SimValue> { + SimValue::from_array_elements(self, ty) + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: Array) -> SimValue> { + SimValue::from_array_elements( as From>>::from(self), ty) + } +} + +impl, T: Type, const N: usize> ToSimValue> for [Element; N] +where + ConstUsize: KnownSize, +{ + #[track_caller] + fn to_sim_value(&self, ty: Array) -> SimValue> { + SimValue::from_array_elements(self, ty) + } + #[track_caller] + fn into_sim_value(self, ty: Array) -> SimValue> { + SimValue::from_array_elements(self, ty) + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: Array) -> SimValue> { + SimValue::from_array_elements( as From>>::from(self), ty) + } +} + +impl, const N: usize> ToSimValue + for [Element; N] +{ + #[track_caller] + fn to_sim_value(&self, ty: CanonicalType) -> SimValue { + SimValue::from_array_elements(self, ::from_canonical(ty)).into_canonical() + } + #[track_caller] + fn into_sim_value(self, ty: CanonicalType) -> SimValue { + SimValue::from_array_elements(self, ::from_canonical(ty)).into_canonical() + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: CanonicalType) -> SimValue { + SimValue::from_array_elements( + as From>>::from(self), + ::from_canonical(ty), + ) + .into_canonical() + } +} + +impl, T: Type> ToSimValue> for Vec { + #[track_caller] + fn to_sim_value(&self, ty: Array) -> SimValue> { + SimValue::from_array_elements(self, ty) + } + #[track_caller] + fn into_sim_value(self, ty: Array) -> SimValue> { + SimValue::from_array_elements(self, ty) + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: Array) -> SimValue> { + SimValue::from_array_elements(*self, ty) + } +} + +impl> ToSimValue for Vec { + #[track_caller] + fn to_sim_value(&self, ty: CanonicalType) -> SimValue { + SimValue::from_array_elements(self, ::from_canonical(ty)).into_canonical() + } + #[track_caller] + fn into_sim_value(self, ty: CanonicalType) -> SimValue { + SimValue::from_array_elements(self, ::from_canonical(ty)).into_canonical() + } + #[track_caller] + fn box_into_sim_value(self: Box, ty: CanonicalType) -> SimValue { + SimValue::from_array_elements(*self, ::from_canonical(ty)).into_canonical() + } +} + +impl ToSimValue for Expr { + #[track_caller] + fn to_sim_value(&self, ty: T) -> SimValue { + assert_eq!(Expr::ty(*self), ty); + SimValue { + ty, + bits: self + .to_literal_bits() + .expect("must be a literal expression") + .to_bitvec(), + } + } +} + +macro_rules! impl_to_sim_value_for_bool_like { + ($ty:ident) => { + impl ToSimValue<$ty> for bool { + fn to_sim_value(&self, ty: $ty) -> SimValue<$ty> { + SimValue { + ty, + bits: BitVec::repeat(*self, 1), + } + } + } + }; +} + +impl_to_sim_value_for_bool_like!(Bool); +impl_to_sim_value_for_bool_like!(AsyncReset); +impl_to_sim_value_for_bool_like!(SyncReset); +impl_to_sim_value_for_bool_like!(Reset); +impl_to_sim_value_for_bool_like!(Clock); + +impl ToSimValue for bool { + #[track_caller] + fn to_sim_value(&self, ty: CanonicalType) -> SimValue { + match ty { + CanonicalType::UInt(_) + | CanonicalType::SInt(_) + | CanonicalType::Array(_) + | CanonicalType::Enum(_) + | CanonicalType::Bundle(_) => { + panic!("can't create SimValue from bool: expected value of type: {ty:?}"); + } + CanonicalType::Bool(_) + | CanonicalType::AsyncReset(_) + | CanonicalType::SyncReset(_) + | CanonicalType::Reset(_) + | CanonicalType::Clock(_) => SimValue { + ty, + bits: BitVec::repeat(*self, 1), + }, + } + } +} + +macro_rules! impl_to_sim_value_for_primitive_int { + ($prim:ident) => { + impl ToSimValue<<$prim as ToExpr>::Type> for $prim { + #[track_caller] + fn to_sim_value( + &self, + ty: <$prim as ToExpr>::Type, + ) -> SimValue<<$prim as ToExpr>::Type> { + SimValue { + ty, + bits: <<$prim as ToExpr>::Type as BoolOrIntType>::le_bytes_to_bits_wrapping( + &self.to_le_bytes(), + ty.width(), + ), + } + } + } + + impl ToSimValue<<<$prim as ToExpr>::Type as IntType>::Dyn> for $prim { + #[track_caller] + fn to_sim_value( + &self, + ty: <<$prim as ToExpr>::Type as IntType>::Dyn, + ) -> SimValue<<<$prim as ToExpr>::Type as IntType>::Dyn> { + SimValue { + ty, + bits: <<$prim as ToExpr>::Type as BoolOrIntType>::le_bytes_to_bits_wrapping( + &self.to_le_bytes(), + ty.width(), + ), + } + } + } + + impl ToSimValue for $prim { + #[track_caller] + fn to_sim_value(&self, ty: CanonicalType) -> SimValue { + let ty: <<$prim as ToExpr>::Type as IntType>::Dyn = Type::from_canonical(ty); + self.to_sim_value(ty).into_canonical() + } + } + }; +} + +impl_to_sim_value_for_primitive_int!(u8); +impl_to_sim_value_for_primitive_int!(u16); +impl_to_sim_value_for_primitive_int!(u32); +impl_to_sim_value_for_primitive_int!(u64); +impl_to_sim_value_for_primitive_int!(u128); +impl_to_sim_value_for_primitive_int!(usize); +impl_to_sim_value_for_primitive_int!(i8); +impl_to_sim_value_for_primitive_int!(i16); +impl_to_sim_value_for_primitive_int!(i32); +impl_to_sim_value_for_primitive_int!(i64); +impl_to_sim_value_for_primitive_int!(i128); +impl_to_sim_value_for_primitive_int!(isize); + +macro_rules! impl_to_sim_value_for_int_value { + ($IntValue:ident, $Int:ident, $IntType:ident) => { + impl ToSimValue<$IntType> for $IntValue { + fn to_sim_value(&self, ty: $IntType) -> SimValue<$IntType> { + self.bits().to_bitvec().into_sim_value(ty) + } + + fn into_sim_value(self, ty: $IntType) -> SimValue<$IntType> { + Arc::try_unwrap(self.into_bits()) + .unwrap_or_else(|v: Arc| v.to_bitvec()) + .into_sim_value(ty) + } + + fn box_into_sim_value( + self: Box, + ty: $IntType, + ) -> SimValue<$IntType> { + Self::into_sim_value(*self, ty) + } + } + + impl ToSimValue<$Int> for $IntValue { + fn to_sim_value(&self, ty: $Int) -> SimValue<$Int> { + self.bits().to_bitvec().into_sim_value(ty) + } + + fn into_sim_value(self, ty: $Int) -> SimValue<$Int> { + Arc::try_unwrap(self.into_bits()) + .unwrap_or_else(|v: Arc| v.to_bitvec()) + .into_sim_value(ty) + } + + fn box_into_sim_value(self: Box, ty: $Int) -> SimValue<$Int> { + Self::into_sim_value(*self, ty) + } + } + + impl ToSimValue for $IntValue { + #[track_caller] + fn to_sim_value(&self, ty: CanonicalType) -> SimValue { + ToSimValue::<$Int>::to_sim_value(self, $Int::from_canonical(ty)).into_canonical() + } + + #[track_caller] + fn into_sim_value(self, ty: CanonicalType) -> SimValue { + ToSimValue::<$Int>::into_sim_value(self, $Int::from_canonical(ty)).into_canonical() + } + + #[track_caller] + fn box_into_sim_value(self: Box, ty: CanonicalType) -> SimValue { + Self::into_sim_value(*self, ty) + } + } + }; +} + +impl_to_sim_value_for_int_value!(UIntValue, UInt, UIntType); +impl_to_sim_value_for_int_value!(SIntValue, SInt, SIntType); + struct SimulationImpl { state: interpreter::State, io: Expr, @@ -6263,8 +6883,11 @@ impl SimulationImpl { let value: BigInt = value.into(); match compiled_value.range.len() { TypeLen::A_SMALL_SLOT => { - self.state.small_slots[compiled_value.range.small_slots.start] = - value.to_u64().expect("value out of range"); + let mut small_value = value.iter_u64_digits().next().unwrap_or(0); + if value.is_negative() { + small_value = small_value.wrapping_neg(); + } + self.state.small_slots[compiled_value.range.small_slots.start] = small_value; } TypeLen::A_BIG_SLOT => { self.state.big_slots[compiled_value.range.big_slots.start] = value @@ -6272,6 +6895,130 @@ impl SimulationImpl { _ => unreachable!(), } } + #[track_caller] + fn read_write_sim_value_helper( + &mut self, + compiled_value: CompiledValue, + bits: &mut BitSlice, + read_write_big_scalar: impl Fn(bool, &mut BitSlice, &mut BigInt) + Copy, + read_write_small_scalar: impl Fn(bool, &mut BitSlice, &mut SmallUInt) + Copy, + ) { + match compiled_value.layout.body { + CompiledTypeLayoutBody::Scalar => { + let signed = match compiled_value.layout.ty { + CanonicalType::UInt(_) => false, + CanonicalType::SInt(_) => true, + CanonicalType::Bool(_) => false, + CanonicalType::Array(_) => unreachable!(), + CanonicalType::Enum(_) => false, + CanonicalType::Bundle(_) => unreachable!(), + CanonicalType::AsyncReset(_) => false, + CanonicalType::SyncReset(_) => false, + CanonicalType::Reset(_) => false, + CanonicalType::Clock(_) => false, + }; + match compiled_value.range.len() { + TypeLen::A_SMALL_SLOT => read_write_small_scalar( + signed, + bits, + &mut self.state.small_slots[compiled_value.range.small_slots.start], + ), + TypeLen::A_BIG_SLOT => read_write_big_scalar( + signed, + bits, + &mut self.state.big_slots[compiled_value.range.big_slots.start], + ), + _ => unreachable!(), + } + } + CompiledTypeLayoutBody::Array { element } => { + let ty = ::from_canonical(compiled_value.layout.ty); + let element_bit_width = ty.element().bit_width(); + for element_index in 0..ty.len() { + self.read_write_sim_value_helper( + CompiledValue { + layout: *element, + range: compiled_value + .range + .index_array(element.layout.len(), element_index), + write: None, + }, + &mut bits[element_index * element_bit_width..][..element_bit_width], + read_write_big_scalar, + read_write_small_scalar, + ); + } + } + CompiledTypeLayoutBody::Bundle { fields } => { + let ty = Bundle::from_canonical(compiled_value.layout.ty); + for ( + (field, offset), + CompiledBundleField { + offset: layout_offset, + ty: field_layout, + }, + ) in ty.fields().iter().zip(ty.field_offsets()).zip(fields) + { + self.read_write_sim_value_helper( + CompiledValue { + layout: field_layout, + range: compiled_value.range.slice(TypeIndexRange::new( + layout_offset, + field_layout.layout.len(), + )), + write: None, + }, + &mut bits[offset..][..field.ty.bit_width()], + read_write_big_scalar, + read_write_small_scalar, + ); + } + } + } + } + #[track_caller] + fn read(&mut self, io: Expr) -> SimValue { + let compiled_value = self.read_helper(io); + let mut bits = BitVec::repeat(false, compiled_value.layout.ty.bit_width()); + self.read_write_sim_value_helper( + compiled_value, + &mut bits, + |_signed, bits, value| ::copy_bits_from_bigint_wrapping(value, bits), + |_signed, bits, value| { + let bytes = value.to_le_bytes(); + let bitslice = BitSlice::::from_slice(&bytes); + bits.clone_from_bitslice(&bitslice[..bits.len()]); + }, + ); + SimValue { + ty: Expr::ty(io), + bits, + } + } + #[track_caller] + fn write(&mut self, io: Expr, value: SimValue) { + let compiled_value = self.write_helper(io); + assert_eq!(Expr::ty(io), value.ty()); + self.read_write_sim_value_helper( + compiled_value, + &mut value.into_bits(), + |signed, bits, value| { + if signed { + *value = SInt::bits_to_bigint(bits); + } else { + *value = UInt::bits_to_bigint(bits); + } + }, + |signed, bits, value| { + let mut small_value = [0; mem::size_of::()]; + if signed && bits.last().as_deref().copied() == Some(true) { + small_value.fill(u8::MAX); + } + small_value.view_bits_mut::()[0..bits.len()].clone_from_bitslice(bits); + *value = SmallUInt::from_le_bytes(small_value); + }, + ); + } fn close_all_trace_writers(&mut self) -> std::io::Result<()> { let trace_writers = mem::take(&mut self.trace_writers); let mut retval = Ok(()); @@ -6525,6 +7272,17 @@ impl Simulation { pub fn read_reset(&mut self, io: Expr) -> bool { self.sim_impl.read_bit(Expr::canonical(io)) } + #[track_caller] + pub fn read(&mut self, io: Expr) -> SimValue { + SimValue::from_canonical(self.sim_impl.read(Expr::canonical(io))) + } + #[track_caller] + pub fn write>(&mut self, io: Expr, value: V) { + self.sim_impl.write( + Expr::canonical(io), + value.into_sim_value(Expr::ty(io)).into_canonical(), + ); + } #[doc(hidden)] /// This is explicitly unstable and may be changed/removed at any time pub fn set_breakpoints_unstable(&mut self, pcs: HashSet, trace: bool) { diff --git a/crates/fayalite/tests/sim.rs b/crates/fayalite/tests/sim.rs index 008d792..bea7d93 100644 --- a/crates/fayalite/tests/sim.rs +++ b/crates/fayalite/tests/sim.rs @@ -5,7 +5,8 @@ use fayalite::{ int::UIntValue, prelude::*, reset::ResetType, - sim::{time::SimDuration, vcd::VcdWriterDecls, Simulation}, + sim::{time::SimDuration, vcd::VcdWriterDecls, Simulation, ToSimValue}, + ty::StaticType, util::RcWriter, }; use std::num::NonZeroUsize; @@ -309,6 +310,8 @@ pub fn enums() { let which_out: UInt<2> = m.output(); #[hdl] let data_out: UInt<4> = m.output(); + #[hdl] + let b_out: HdlOption<(UInt<1>, Bool)> = m.output(); #[hdl] struct MyStruct { @@ -348,6 +351,8 @@ pub fn enums() { } } + connect(b_out, HdlNone()); + #[hdl] match the_reg { MyEnum::A => { @@ -357,6 +362,7 @@ pub fn enums() { MyEnum::B(v) => { connect(which_out, 1_hdl_u2); connect_any(data_out, v.0 | (v.1.cast_to_static::>() << 1)); + connect(b_out, HdlSome(v)); } MyEnum::C(v) => { connect(which_out, 2_hdl_u2); @@ -382,13 +388,33 @@ fn test_enums() { sim.advance_time(SimDuration::from_nanos(100)); sim.write_reset(sim.io().cd.rst, false); sim.advance_time(SimDuration::from_nanos(900)); - #[derive(Debug, PartialEq, Eq)] + type BOutTy = HdlOption<(UInt<1>, Bool)>; + #[derive(Debug)] struct IO { en: bool, which_in: u8, data_in: u8, which_out: u8, data_out: u8, + b_out: Expr, + } + impl PartialEq for IO { + fn eq(&self, other: &Self) -> bool { + let Self { + en, + which_in, + data_in, + which_out, + data_out, + b_out, + } = *self; + en == other.en + && which_in == other.which_in + && data_in == other.data_in + && which_out == other.which_out + && data_out == other.data_out + && b_out.to_sim_value(BOutTy::TYPE) == other.b_out.to_sim_value(BOutTy::TYPE) + } } let io_cycles = [ IO { @@ -397,6 +423,7 @@ fn test_enums() { data_in: 0, which_out: 0, data_out: 0, + b_out: HdlNone(), }, IO { en: true, @@ -404,6 +431,7 @@ fn test_enums() { data_in: 0, which_out: 0, data_out: 0, + b_out: HdlNone(), }, IO { en: false, @@ -411,6 +439,7 @@ fn test_enums() { data_in: 0, which_out: 1, data_out: 0, + b_out: HdlSome((0_hdl_u1, false)), }, IO { en: true, @@ -418,6 +447,7 @@ fn test_enums() { data_in: 0xF, which_out: 1, data_out: 0, + b_out: HdlSome((0_hdl_u1, false)), }, IO { en: true, @@ -425,6 +455,7 @@ fn test_enums() { data_in: 0xF, which_out: 1, data_out: 0x3, + b_out: HdlSome((1_hdl_u1, true)), }, IO { en: true, @@ -432,6 +463,7 @@ fn test_enums() { data_in: 0xF, which_out: 1, data_out: 0x3, + b_out: HdlSome((1_hdl_u1, true)), }, IO { en: true, @@ -439,6 +471,7 @@ fn test_enums() { data_in: 0xF, which_out: 2, data_out: 0xF, + b_out: HdlNone(), }, ]; for ( @@ -449,6 +482,7 @@ fn test_enums() { data_in, which_out: _, data_out: _, + b_out: _, }, ) in io_cycles.into_iter().enumerate() { @@ -469,6 +503,7 @@ fn test_enums() { .to_bigint() .try_into() .expect("known to be in range"), + b_out: sim.read(sim.io().b_out).to_expr(), }; assert_eq!( expected, diff --git a/crates/fayalite/tests/sim/expected/enums.txt b/crates/fayalite/tests/sim/expected/enums.txt index ebdcf7e..ebfae3e 100644 --- a/crates/fayalite/tests/sim/expected/enums.txt +++ b/crates/fayalite/tests/sim/expected/enums.txt @@ -4,8 +4,15 @@ Simulation { state_layout: StateLayout { ty: TypeLayout { small_slots: StatePartLayout { - len: 5, + len: 6, debug_data: [ + SlotDebugData { + name: "", + ty: Enum { + HdlNone, + HdlSome, + }, + }, SlotDebugData { name: "", ty: Bool, @@ -34,7 +41,7 @@ Simulation { .. }, big_slots: StatePartLayout { - len: 82, + len: 103, debug_data: [ SlotDebugData { name: "InstantiatedModule(enums: enums).enums::cd.clk", @@ -64,6 +71,41 @@ Simulation { name: "InstantiatedModule(enums: enums).enums::data_out", ty: UInt<4>, }, + SlotDebugData { + name: "InstantiatedModule(enums: enums).enums::b_out", + ty: Enum { + HdlNone, + HdlSome(Bundle {0: UInt<1>, 1: Bool}), + }, + }, + SlotDebugData { + name: ".0", + ty: UInt<1>, + }, + SlotDebugData { + name: ".1", + ty: Bool, + }, + SlotDebugData { + name: "", + ty: UInt<3>, + }, + SlotDebugData { + name: "", + ty: UInt<2>, + }, + SlotDebugData { + name: "", + ty: UInt<1>, + }, + SlotDebugData { + name: "", + ty: UInt<1>, + }, + SlotDebugData { + name: "", + ty: Bool, + }, SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum { @@ -344,6 +386,17 @@ Simulation { C(Bundle {a: Array, 2>, b: SInt<2>}), }, }, + SlotDebugData { + name: "", + ty: UInt<3>, + }, + SlotDebugData { + name: "", + ty: Enum { + HdlNone, + HdlSome(Bundle {0: UInt<1>, 1: Bool}), + }, + }, SlotDebugData { name: "", ty: UInt<4>, @@ -364,6 +417,53 @@ Simulation { name: "", ty: UInt<4>, }, + SlotDebugData { + name: ".0", + ty: UInt<1>, + }, + SlotDebugData { + name: ".1.0", + ty: UInt<1>, + }, + SlotDebugData { + name: ".1.1", + ty: Bool, + }, + SlotDebugData { + name: "", + ty: UInt<1>, + }, + SlotDebugData { + name: "", + ty: UInt<1>, + }, + SlotDebugData { + name: "", + ty: UInt<2>, + }, + SlotDebugData { + name: "", + ty: UInt<2>, + }, + SlotDebugData { + name: "", + ty: UInt<3>, + }, + SlotDebugData { + name: "", + ty: UInt<3>, + }, + SlotDebugData { + name: "", + ty: UInt<3>, + }, + SlotDebugData { + name: "", + ty: Enum { + HdlNone, + HdlSome(Bundle {0: UInt<1>, 1: Bool}), + }, + }, SlotDebugData { name: "", ty: UInt<2>, @@ -398,490 +498,601 @@ Simulation { insns: [ // at: module-XXXXXXXXXX.rs:1:1 0: Const { - dest: StatePartIndex(72), // (0x0) SlotDebugData { name: "", ty: UInt<4> }, - value: 0x0, - }, - 1: SliceInt { - dest: StatePartIndex(61), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - src: StatePartIndex(4), // (0xf) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::data_in", ty: UInt<4> }, - start: 2, - len: 2, - }, - 2: CastToSInt { - dest: StatePartIndex(62), // (-0x1) SlotDebugData { name: "", ty: SInt<2> }, - src: StatePartIndex(61), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - dest_width: 2, - }, - 3: Const { - dest: StatePartIndex(54), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, - value: 0x2, - }, - 4: SliceInt { - dest: StatePartIndex(41), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - src: StatePartIndex(4), // (0xf) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::data_in", ty: UInt<4> }, - start: 1, - len: 1, - }, - 5: Copy { - dest: StatePartIndex(42), // (0x1) SlotDebugData { name: "", ty: Bool }, - src: StatePartIndex(41), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - }, - 6: Copy { - dest: StatePartIndex(60), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - src: StatePartIndex(42), // (0x1) SlotDebugData { name: "", ty: Bool }, - }, - 7: SliceInt { - dest: StatePartIndex(38), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - src: StatePartIndex(4), // (0xf) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::data_in", ty: UInt<4> }, - start: 0, - len: 1, - }, - 8: Copy { - dest: StatePartIndex(39), // (0x1) SlotDebugData { name: "", ty: Bool }, - src: StatePartIndex(38), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - }, - 9: Copy { - dest: StatePartIndex(40), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - src: StatePartIndex(39), // (0x1) SlotDebugData { name: "", ty: Bool }, - }, - 10: Copy { - dest: StatePartIndex(36), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, - src: StatePartIndex(40), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - }, - 11: Copy { - dest: StatePartIndex(37), // (0x1) SlotDebugData { name: ".1", ty: Bool }, - src: StatePartIndex(42), // (0x1) SlotDebugData { name: "", ty: Bool }, - }, - 12: Copy { - dest: StatePartIndex(58), // (0x1) SlotDebugData { name: "[0]", ty: UInt<1> }, - src: StatePartIndex(40), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - }, - 13: Copy { - dest: StatePartIndex(59), // (0x1) SlotDebugData { name: "[1]", ty: UInt<1> }, - src: StatePartIndex(60), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - }, - 14: Copy { - dest: StatePartIndex(55), // (0x1) SlotDebugData { name: ".a[0]", ty: UInt<1> }, - src: StatePartIndex(58), // (0x1) SlotDebugData { name: "[0]", ty: UInt<1> }, - }, - 15: Copy { - dest: StatePartIndex(56), // (0x1) SlotDebugData { name: ".a[1]", ty: UInt<1> }, - src: StatePartIndex(59), // (0x1) SlotDebugData { name: "[1]", ty: UInt<1> }, - }, - 16: Copy { - dest: StatePartIndex(57), // (-0x1) SlotDebugData { name: ".b", ty: SInt<2> }, - src: StatePartIndex(62), // (-0x1) SlotDebugData { name: "", ty: SInt<2> }, - }, - 17: Copy { - dest: StatePartIndex(50), // (0x2) SlotDebugData { name: ".0", ty: UInt<2> }, - src: StatePartIndex(54), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, - }, - 18: Copy { - dest: StatePartIndex(51), // (0x1) SlotDebugData { name: ".1.a[0]", ty: UInt<1> }, - src: StatePartIndex(55), // (0x1) SlotDebugData { name: ".a[0]", ty: UInt<1> }, - }, - 19: Copy { - dest: StatePartIndex(52), // (0x1) SlotDebugData { name: ".1.a[1]", ty: UInt<1> }, - src: StatePartIndex(56), // (0x1) SlotDebugData { name: ".a[1]", ty: UInt<1> }, - }, - 20: Copy { - dest: StatePartIndex(53), // (-0x1) SlotDebugData { name: ".1.b", ty: SInt<2> }, - src: StatePartIndex(57), // (-0x1) SlotDebugData { name: ".b", ty: SInt<2> }, - }, - 21: Shl { - dest: StatePartIndex(63), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, - lhs: StatePartIndex(52), // (0x1) SlotDebugData { name: ".1.a[1]", ty: UInt<1> }, - rhs: 1, - }, - 22: Or { - dest: StatePartIndex(64), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - lhs: StatePartIndex(51), // (0x1) SlotDebugData { name: ".1.a[0]", ty: UInt<1> }, - rhs: StatePartIndex(63), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, - }, - 23: CastToUInt { - dest: StatePartIndex(65), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - src: StatePartIndex(53), // (-0x1) SlotDebugData { name: ".1.b", ty: SInt<2> }, - dest_width: 2, - }, - 24: Shl { - dest: StatePartIndex(66), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, - lhs: StatePartIndex(65), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - rhs: 2, - }, - 25: Or { - dest: StatePartIndex(67), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, - lhs: StatePartIndex(64), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - rhs: StatePartIndex(66), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, - }, - 26: Shl { - dest: StatePartIndex(68), // (0x3c) SlotDebugData { name: "", ty: UInt<6> }, - lhs: StatePartIndex(67), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, - rhs: 2, - }, - 27: Or { - dest: StatePartIndex(69), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, - lhs: StatePartIndex(50), // (0x2) SlotDebugData { name: ".0", ty: UInt<2> }, - rhs: StatePartIndex(68), // (0x3c) SlotDebugData { name: "", ty: UInt<6> }, - }, - 28: CastToUInt { - dest: StatePartIndex(70), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, - src: StatePartIndex(69), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, - dest_width: 6, - }, - 29: Copy { - dest: StatePartIndex(71), // (0x3e) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - src: StatePartIndex(70), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, - }, - 30: Const { - dest: StatePartIndex(31), // (0x1) SlotDebugData { name: "", ty: UInt<2> }, + dest: StatePartIndex(90), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, value: 0x1, }, - 31: CmpEq { - dest: StatePartIndex(32), // (0x0) SlotDebugData { name: "", ty: Bool }, - lhs: StatePartIndex(3), // (0x2) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::which_in", ty: UInt<2> }, - rhs: StatePartIndex(31), // (0x1) SlotDebugData { name: "", ty: UInt<2> }, - }, - 32: Copy { - dest: StatePartIndex(33), // (0x1) SlotDebugData { name: ".0", ty: UInt<2> }, - src: StatePartIndex(31), // (0x1) SlotDebugData { name: "", ty: UInt<2> }, - }, - 33: Copy { - dest: StatePartIndex(34), // (0x1) SlotDebugData { name: ".1.0", ty: UInt<1> }, - src: StatePartIndex(36), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, - }, - 34: Copy { - dest: StatePartIndex(35), // (0x1) SlotDebugData { name: ".1.1", ty: Bool }, - src: StatePartIndex(37), // (0x1) SlotDebugData { name: ".1", ty: Bool }, - }, - 35: Copy { - dest: StatePartIndex(43), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - src: StatePartIndex(35), // (0x1) SlotDebugData { name: ".1.1", ty: Bool }, - }, - 36: Shl { - dest: StatePartIndex(44), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, - lhs: StatePartIndex(43), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - rhs: 1, - }, - 37: Or { - dest: StatePartIndex(45), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - lhs: StatePartIndex(34), // (0x1) SlotDebugData { name: ".1.0", ty: UInt<1> }, - rhs: StatePartIndex(44), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, - }, - 38: Shl { - dest: StatePartIndex(46), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, - lhs: StatePartIndex(45), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - rhs: 2, - }, - 39: Or { - dest: StatePartIndex(47), // (0xd) SlotDebugData { name: "", ty: UInt<4> }, - lhs: StatePartIndex(33), // (0x1) SlotDebugData { name: ".0", ty: UInt<2> }, - rhs: StatePartIndex(46), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, - }, - 40: CastToUInt { - dest: StatePartIndex(48), // (0xd) SlotDebugData { name: "", ty: UInt<6> }, - src: StatePartIndex(47), // (0xd) SlotDebugData { name: "", ty: UInt<4> }, - dest_width: 6, - }, - 41: Copy { - dest: StatePartIndex(49), // (0xd) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - src: StatePartIndex(48), // (0xd) SlotDebugData { name: "", ty: UInt<6> }, - }, - 42: Const { - dest: StatePartIndex(29), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, + 1: Const { + dest: StatePartIndex(82), // (0x0) SlotDebugData { name: "", ty: UInt<4> }, value: 0x0, }, - 43: CmpEq { - dest: StatePartIndex(30), // (0x0) SlotDebugData { name: "", ty: Bool }, - lhs: StatePartIndex(3), // (0x2) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::which_in", ty: UInt<2> }, - rhs: StatePartIndex(29), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, + 2: Const { + dest: StatePartIndex(80), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, + value: 0x0, }, - 44: Copy { - dest: StatePartIndex(13), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, - src: StatePartIndex(7), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + 3: Copy { + dest: StatePartIndex(81), // (0x0) SlotDebugData { name: "", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, + src: StatePartIndex(80), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, }, - 45: SliceInt { - dest: StatePartIndex(14), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - src: StatePartIndex(13), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, + // at: module-XXXXXXXXXX.rs:16:1 + 4: Copy { + dest: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::b_out", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, + src: StatePartIndex(81), // (0x0) SlotDebugData { name: "", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, + }, + // at: module-XXXXXXXXXX.rs:1:1 + 5: SliceInt { + dest: StatePartIndex(69), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + src: StatePartIndex(4), // (0xf) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::data_in", ty: UInt<4> }, start: 2, len: 2, }, - 46: SliceInt { - dest: StatePartIndex(15), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - src: StatePartIndex(14), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - start: 0, - len: 1, + 6: CastToSInt { + dest: StatePartIndex(70), // (-0x1) SlotDebugData { name: "", ty: SInt<2> }, + src: StatePartIndex(69), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + dest_width: 2, }, - 47: SliceInt { - dest: StatePartIndex(16), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - src: StatePartIndex(14), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + 7: Const { + dest: StatePartIndex(62), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + value: 0x2, + }, + 8: SliceInt { + dest: StatePartIndex(49), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(4), // (0xf) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::data_in", ty: UInt<4> }, start: 1, len: 1, }, - 48: Copy { - dest: StatePartIndex(17), // (0x1) SlotDebugData { name: "", ty: Bool }, - src: StatePartIndex(16), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + 9: Copy { + dest: StatePartIndex(50), // (0x1) SlotDebugData { name: "", ty: Bool }, + src: StatePartIndex(49), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, }, - 49: Copy { - dest: StatePartIndex(11), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, - src: StatePartIndex(15), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + 10: Copy { + dest: StatePartIndex(68), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(50), // (0x1) SlotDebugData { name: "", ty: Bool }, }, - 50: Copy { - dest: StatePartIndex(12), // (0x1) SlotDebugData { name: ".1", ty: Bool }, - src: StatePartIndex(17), // (0x1) SlotDebugData { name: "", ty: Bool }, + 11: SliceInt { + dest: StatePartIndex(46), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(4), // (0xf) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::data_in", ty: UInt<4> }, + start: 0, + len: 1, }, - 51: Copy { - dest: StatePartIndex(73), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - src: StatePartIndex(12), // (0x1) SlotDebugData { name: ".1", ty: Bool }, + 12: Copy { + dest: StatePartIndex(47), // (0x1) SlotDebugData { name: "", ty: Bool }, + src: StatePartIndex(46), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, }, - 52: Shl { - dest: StatePartIndex(74), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, - lhs: StatePartIndex(73), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + 13: Copy { + dest: StatePartIndex(48), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(47), // (0x1) SlotDebugData { name: "", ty: Bool }, + }, + 14: Copy { + dest: StatePartIndex(44), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, + src: StatePartIndex(48), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + }, + 15: Copy { + dest: StatePartIndex(45), // (0x1) SlotDebugData { name: ".1", ty: Bool }, + src: StatePartIndex(50), // (0x1) SlotDebugData { name: "", ty: Bool }, + }, + 16: Copy { + dest: StatePartIndex(66), // (0x1) SlotDebugData { name: "[0]", ty: UInt<1> }, + src: StatePartIndex(48), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + }, + 17: Copy { + dest: StatePartIndex(67), // (0x1) SlotDebugData { name: "[1]", ty: UInt<1> }, + src: StatePartIndex(68), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + }, + 18: Copy { + dest: StatePartIndex(63), // (0x1) SlotDebugData { name: ".a[0]", ty: UInt<1> }, + src: StatePartIndex(66), // (0x1) SlotDebugData { name: "[0]", ty: UInt<1> }, + }, + 19: Copy { + dest: StatePartIndex(64), // (0x1) SlotDebugData { name: ".a[1]", ty: UInt<1> }, + src: StatePartIndex(67), // (0x1) SlotDebugData { name: "[1]", ty: UInt<1> }, + }, + 20: Copy { + dest: StatePartIndex(65), // (-0x1) SlotDebugData { name: ".b", ty: SInt<2> }, + src: StatePartIndex(70), // (-0x1) SlotDebugData { name: "", ty: SInt<2> }, + }, + 21: Copy { + dest: StatePartIndex(58), // (0x2) SlotDebugData { name: ".0", ty: UInt<2> }, + src: StatePartIndex(62), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + }, + 22: Copy { + dest: StatePartIndex(59), // (0x1) SlotDebugData { name: ".1.a[0]", ty: UInt<1> }, + src: StatePartIndex(63), // (0x1) SlotDebugData { name: ".a[0]", ty: UInt<1> }, + }, + 23: Copy { + dest: StatePartIndex(60), // (0x1) SlotDebugData { name: ".1.a[1]", ty: UInt<1> }, + src: StatePartIndex(64), // (0x1) SlotDebugData { name: ".a[1]", ty: UInt<1> }, + }, + 24: Copy { + dest: StatePartIndex(61), // (-0x1) SlotDebugData { name: ".1.b", ty: SInt<2> }, + src: StatePartIndex(65), // (-0x1) SlotDebugData { name: ".b", ty: SInt<2> }, + }, + 25: Shl { + dest: StatePartIndex(71), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + lhs: StatePartIndex(60), // (0x1) SlotDebugData { name: ".1.a[1]", ty: UInt<1> }, rhs: 1, }, - 53: Or { - dest: StatePartIndex(75), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - lhs: StatePartIndex(11), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, - rhs: StatePartIndex(74), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + 26: Or { + dest: StatePartIndex(72), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + lhs: StatePartIndex(59), // (0x1) SlotDebugData { name: ".1.a[0]", ty: UInt<1> }, + rhs: StatePartIndex(71), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, }, - 54: CastToUInt { - dest: StatePartIndex(76), // (0x3) SlotDebugData { name: "", ty: UInt<4> }, - src: StatePartIndex(75), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + 27: CastToUInt { + dest: StatePartIndex(73), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + src: StatePartIndex(61), // (-0x1) SlotDebugData { name: ".1.b", ty: SInt<2> }, + dest_width: 2, + }, + 28: Shl { + dest: StatePartIndex(74), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, + lhs: StatePartIndex(73), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + rhs: 2, + }, + 29: Or { + dest: StatePartIndex(75), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, + lhs: StatePartIndex(72), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + rhs: StatePartIndex(74), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, + }, + 30: Shl { + dest: StatePartIndex(76), // (0x3c) SlotDebugData { name: "", ty: UInt<6> }, + lhs: StatePartIndex(75), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, + rhs: 2, + }, + 31: Or { + dest: StatePartIndex(77), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, + lhs: StatePartIndex(58), // (0x2) SlotDebugData { name: ".0", ty: UInt<2> }, + rhs: StatePartIndex(76), // (0x3c) SlotDebugData { name: "", ty: UInt<6> }, + }, + 32: CastToUInt { + dest: StatePartIndex(78), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, + src: StatePartIndex(77), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, + dest_width: 6, + }, + 33: Copy { + dest: StatePartIndex(79), // (0x3e) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + src: StatePartIndex(78), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, + }, + 34: Const { + dest: StatePartIndex(39), // (0x1) SlotDebugData { name: "", ty: UInt<2> }, + value: 0x1, + }, + 35: CmpEq { + dest: StatePartIndex(40), // (0x0) SlotDebugData { name: "", ty: Bool }, + lhs: StatePartIndex(3), // (0x2) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::which_in", ty: UInt<2> }, + rhs: StatePartIndex(39), // (0x1) SlotDebugData { name: "", ty: UInt<2> }, + }, + 36: Copy { + dest: StatePartIndex(41), // (0x1) SlotDebugData { name: ".0", ty: UInt<2> }, + src: StatePartIndex(39), // (0x1) SlotDebugData { name: "", ty: UInt<2> }, + }, + 37: Copy { + dest: StatePartIndex(42), // (0x1) SlotDebugData { name: ".1.0", ty: UInt<1> }, + src: StatePartIndex(44), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, + }, + 38: Copy { + dest: StatePartIndex(43), // (0x1) SlotDebugData { name: ".1.1", ty: Bool }, + src: StatePartIndex(45), // (0x1) SlotDebugData { name: ".1", ty: Bool }, + }, + 39: Copy { + dest: StatePartIndex(51), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(43), // (0x1) SlotDebugData { name: ".1.1", ty: Bool }, + }, + 40: Shl { + dest: StatePartIndex(52), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + lhs: StatePartIndex(51), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + rhs: 1, + }, + 41: Or { + dest: StatePartIndex(53), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + lhs: StatePartIndex(42), // (0x1) SlotDebugData { name: ".1.0", ty: UInt<1> }, + rhs: StatePartIndex(52), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + }, + 42: Shl { + dest: StatePartIndex(54), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, + lhs: StatePartIndex(53), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + rhs: 2, + }, + 43: Or { + dest: StatePartIndex(55), // (0xd) SlotDebugData { name: "", ty: UInt<4> }, + lhs: StatePartIndex(41), // (0x1) SlotDebugData { name: ".0", ty: UInt<2> }, + rhs: StatePartIndex(54), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, + }, + 44: CastToUInt { + dest: StatePartIndex(56), // (0xd) SlotDebugData { name: "", ty: UInt<6> }, + src: StatePartIndex(55), // (0xd) SlotDebugData { name: "", ty: UInt<4> }, + dest_width: 6, + }, + 45: Copy { + dest: StatePartIndex(57), // (0xd) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + src: StatePartIndex(56), // (0xd) SlotDebugData { name: "", ty: UInt<6> }, + }, + 46: Const { + dest: StatePartIndex(37), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, + value: 0x0, + }, + 47: CmpEq { + dest: StatePartIndex(38), // (0x0) SlotDebugData { name: "", ty: Bool }, + lhs: StatePartIndex(3), // (0x2) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::which_in", ty: UInt<2> }, + rhs: StatePartIndex(37), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, + }, + 48: Copy { + dest: StatePartIndex(21), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, + src: StatePartIndex(15), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + }, + 49: SliceInt { + dest: StatePartIndex(22), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + src: StatePartIndex(21), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, + start: 2, + len: 2, + }, + 50: SliceInt { + dest: StatePartIndex(23), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(22), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + start: 0, + len: 1, + }, + 51: SliceInt { + dest: StatePartIndex(24), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(22), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + start: 1, + len: 1, + }, + 52: Copy { + dest: StatePartIndex(25), // (0x1) SlotDebugData { name: "", ty: Bool }, + src: StatePartIndex(24), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + }, + 53: Copy { + dest: StatePartIndex(19), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, + src: StatePartIndex(23), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + }, + 54: Copy { + dest: StatePartIndex(20), // (0x1) SlotDebugData { name: ".1", ty: Bool }, + src: StatePartIndex(25), // (0x1) SlotDebugData { name: "", ty: Bool }, + }, + 55: Copy { + dest: StatePartIndex(83), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(20), // (0x1) SlotDebugData { name: ".1", ty: Bool }, + }, + 56: Shl { + dest: StatePartIndex(84), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + lhs: StatePartIndex(83), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + rhs: 1, + }, + 57: Or { + dest: StatePartIndex(85), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + lhs: StatePartIndex(19), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, + rhs: StatePartIndex(84), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + }, + 58: CastToUInt { + dest: StatePartIndex(86), // (0x3) SlotDebugData { name: "", ty: UInt<4> }, + src: StatePartIndex(85), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, dest_width: 4, }, - 55: SliceInt { - dest: StatePartIndex(23), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, - src: StatePartIndex(13), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, + 59: Copy { + dest: StatePartIndex(87), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, + src: StatePartIndex(90), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + }, + 60: Copy { + dest: StatePartIndex(88), // (0x1) SlotDebugData { name: ".1.0", ty: UInt<1> }, + src: StatePartIndex(19), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, + }, + 61: Copy { + dest: StatePartIndex(89), // (0x1) SlotDebugData { name: ".1.1", ty: Bool }, + src: StatePartIndex(20), // (0x1) SlotDebugData { name: ".1", ty: Bool }, + }, + 62: Copy { + dest: StatePartIndex(91), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(89), // (0x1) SlotDebugData { name: ".1.1", ty: Bool }, + }, + 63: Shl { + dest: StatePartIndex(92), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + lhs: StatePartIndex(91), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + rhs: 1, + }, + 64: Or { + dest: StatePartIndex(93), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + lhs: StatePartIndex(88), // (0x1) SlotDebugData { name: ".1.0", ty: UInt<1> }, + rhs: StatePartIndex(92), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + }, + 65: Shl { + dest: StatePartIndex(94), // (0x6) SlotDebugData { name: "", ty: UInt<3> }, + lhs: StatePartIndex(93), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + rhs: 1, + }, + 66: Or { + dest: StatePartIndex(95), // (0x7) SlotDebugData { name: "", ty: UInt<3> }, + lhs: StatePartIndex(87), // (0x1) SlotDebugData { name: ".0", ty: UInt<1> }, + rhs: StatePartIndex(94), // (0x6) SlotDebugData { name: "", ty: UInt<3> }, + }, + 67: CastToUInt { + dest: StatePartIndex(96), // (0x7) SlotDebugData { name: "", ty: UInt<3> }, + src: StatePartIndex(95), // (0x7) SlotDebugData { name: "", ty: UInt<3> }, + dest_width: 3, + }, + 68: Copy { + dest: StatePartIndex(97), // (0x7) SlotDebugData { name: "", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, + src: StatePartIndex(96), // (0x7) SlotDebugData { name: "", ty: UInt<3> }, + }, + 69: SliceInt { + dest: StatePartIndex(31), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, + src: StatePartIndex(21), // (0x3e) SlotDebugData { name: "", ty: UInt<6> }, start: 2, len: 4, }, - 56: SliceInt { - dest: StatePartIndex(24), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - src: StatePartIndex(23), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, + 70: SliceInt { + dest: StatePartIndex(32), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + src: StatePartIndex(31), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, start: 0, len: 2, }, - 57: SliceInt { - dest: StatePartIndex(25), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - src: StatePartIndex(24), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + 71: SliceInt { + dest: StatePartIndex(33), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(32), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, start: 0, len: 1, }, - 58: SliceInt { - dest: StatePartIndex(26), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, - src: StatePartIndex(24), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + 72: SliceInt { + dest: StatePartIndex(34), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(32), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, start: 1, len: 1, }, - 59: Copy { - dest: StatePartIndex(21), // (0x1) SlotDebugData { name: "[0]", ty: UInt<1> }, - src: StatePartIndex(25), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + 73: Copy { + dest: StatePartIndex(29), // (0x1) SlotDebugData { name: "[0]", ty: UInt<1> }, + src: StatePartIndex(33), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, }, - 60: Copy { - dest: StatePartIndex(22), // (0x1) SlotDebugData { name: "[1]", ty: UInt<1> }, - src: StatePartIndex(26), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, + 74: Copy { + dest: StatePartIndex(30), // (0x1) SlotDebugData { name: "[1]", ty: UInt<1> }, + src: StatePartIndex(34), // (0x1) SlotDebugData { name: "", ty: UInt<1> }, }, - 61: SliceInt { - dest: StatePartIndex(27), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - src: StatePartIndex(23), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, + 75: SliceInt { + dest: StatePartIndex(35), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + src: StatePartIndex(31), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, start: 2, len: 2, }, - 62: CastToSInt { - dest: StatePartIndex(28), // (-0x1) SlotDebugData { name: "", ty: SInt<2> }, - src: StatePartIndex(27), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + 76: CastToSInt { + dest: StatePartIndex(36), // (-0x1) SlotDebugData { name: "", ty: SInt<2> }, + src: StatePartIndex(35), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, dest_width: 2, }, - 63: Copy { - dest: StatePartIndex(18), // (0x1) SlotDebugData { name: ".a[0]", ty: UInt<1> }, - src: StatePartIndex(21), // (0x1) SlotDebugData { name: "[0]", ty: UInt<1> }, + 77: Copy { + dest: StatePartIndex(26), // (0x1) SlotDebugData { name: ".a[0]", ty: UInt<1> }, + src: StatePartIndex(29), // (0x1) SlotDebugData { name: "[0]", ty: UInt<1> }, }, - 64: Copy { - dest: StatePartIndex(19), // (0x1) SlotDebugData { name: ".a[1]", ty: UInt<1> }, - src: StatePartIndex(22), // (0x1) SlotDebugData { name: "[1]", ty: UInt<1> }, + 78: Copy { + dest: StatePartIndex(27), // (0x1) SlotDebugData { name: ".a[1]", ty: UInt<1> }, + src: StatePartIndex(30), // (0x1) SlotDebugData { name: "[1]", ty: UInt<1> }, }, - 65: Copy { - dest: StatePartIndex(20), // (-0x1) SlotDebugData { name: ".b", ty: SInt<2> }, - src: StatePartIndex(28), // (-0x1) SlotDebugData { name: "", ty: SInt<2> }, + 79: Copy { + dest: StatePartIndex(28), // (-0x1) SlotDebugData { name: ".b", ty: SInt<2> }, + src: StatePartIndex(36), // (-0x1) SlotDebugData { name: "", ty: SInt<2> }, }, - 66: Shl { - dest: StatePartIndex(77), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, - lhs: StatePartIndex(19), // (0x1) SlotDebugData { name: ".a[1]", ty: UInt<1> }, + 80: Shl { + dest: StatePartIndex(98), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + lhs: StatePartIndex(27), // (0x1) SlotDebugData { name: ".a[1]", ty: UInt<1> }, rhs: 1, }, - 67: Or { - dest: StatePartIndex(78), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - lhs: StatePartIndex(18), // (0x1) SlotDebugData { name: ".a[0]", ty: UInt<1> }, - rhs: StatePartIndex(77), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + 81: Or { + dest: StatePartIndex(99), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + lhs: StatePartIndex(26), // (0x1) SlotDebugData { name: ".a[0]", ty: UInt<1> }, + rhs: StatePartIndex(98), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, }, - 68: CastToUInt { - dest: StatePartIndex(79), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - src: StatePartIndex(20), // (-0x1) SlotDebugData { name: ".b", ty: SInt<2> }, + 82: CastToUInt { + dest: StatePartIndex(100), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + src: StatePartIndex(28), // (-0x1) SlotDebugData { name: ".b", ty: SInt<2> }, dest_width: 2, }, - 69: Shl { - dest: StatePartIndex(80), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, - lhs: StatePartIndex(79), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + 83: Shl { + dest: StatePartIndex(101), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, + lhs: StatePartIndex(100), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, rhs: 2, }, - 70: Or { - dest: StatePartIndex(81), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, - lhs: StatePartIndex(78), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, - rhs: StatePartIndex(80), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, + 84: Or { + dest: StatePartIndex(102), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, + lhs: StatePartIndex(99), // (0x3) SlotDebugData { name: "", ty: UInt<2> }, + rhs: StatePartIndex(101), // (0xc) SlotDebugData { name: "", ty: UInt<4> }, }, - // at: module-XXXXXXXXXX.rs:8:1 - 71: AndBigWithSmallImmediate { - dest: StatePartIndex(4), // (0x2 2) SlotDebugData { name: "", ty: Enum {A, B, C} }, - lhs: StatePartIndex(7), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + // at: module-XXXXXXXXXX.rs:9:1 + 85: AndBigWithSmallImmediate { + dest: StatePartIndex(5), // (0x2 2) SlotDebugData { name: "", ty: Enum {A, B, C} }, + lhs: StatePartIndex(15), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, rhs: 0x3, }, - // at: module-XXXXXXXXXX.rs:15:1 - 72: BranchIfSmallNeImmediate { - target: 75, - lhs: StatePartIndex(4), // (0x2 2) SlotDebugData { name: "", ty: Enum {A, B, C} }, + // at: module-XXXXXXXXXX.rs:17:1 + 86: BranchIfSmallNeImmediate { + target: 89, + lhs: StatePartIndex(5), // (0x2 2) SlotDebugData { name: "", ty: Enum {A, B, C} }, rhs: 0x0, }, - // at: module-XXXXXXXXXX.rs:16:1 - 73: Copy { - dest: StatePartIndex(5), // (0x2) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::which_out", ty: UInt<2> }, - src: StatePartIndex(29), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, - }, - // at: module-XXXXXXXXXX.rs:17:1 - 74: Copy { - dest: StatePartIndex(6), // (0xf) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::data_out", ty: UInt<4> }, - src: StatePartIndex(72), // (0x0) SlotDebugData { name: "", ty: UInt<4> }, - }, - // at: module-XXXXXXXXXX.rs:15:1 - 75: BranchIfSmallNeImmediate { - target: 78, - lhs: StatePartIndex(4), // (0x2 2) SlotDebugData { name: "", ty: Enum {A, B, C} }, - rhs: 0x1, - }, // at: module-XXXXXXXXXX.rs:18:1 - 76: Copy { + 87: Copy { dest: StatePartIndex(5), // (0x2) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::which_out", ty: UInt<2> }, - src: StatePartIndex(31), // (0x1) SlotDebugData { name: "", ty: UInt<2> }, + src: StatePartIndex(37), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, }, // at: module-XXXXXXXXXX.rs:19:1 - 77: Copy { + 88: Copy { dest: StatePartIndex(6), // (0xf) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::data_out", ty: UInt<4> }, - src: StatePartIndex(76), // (0x3) SlotDebugData { name: "", ty: UInt<4> }, + src: StatePartIndex(82), // (0x0) SlotDebugData { name: "", ty: UInt<4> }, }, - // at: module-XXXXXXXXXX.rs:15:1 - 78: BranchIfSmallNeImmediate { - target: 81, - lhs: StatePartIndex(4), // (0x2 2) SlotDebugData { name: "", ty: Enum {A, B, C} }, - rhs: 0x2, + // at: module-XXXXXXXXXX.rs:17:1 + 89: BranchIfSmallNeImmediate { + target: 93, + lhs: StatePartIndex(5), // (0x2 2) SlotDebugData { name: "", ty: Enum {A, B, C} }, + rhs: 0x1, }, // at: module-XXXXXXXXXX.rs:20:1 - 79: Copy { + 90: Copy { dest: StatePartIndex(5), // (0x2) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::which_out", ty: UInt<2> }, - src: StatePartIndex(54), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + src: StatePartIndex(39), // (0x1) SlotDebugData { name: "", ty: UInt<2> }, }, // at: module-XXXXXXXXXX.rs:21:1 - 80: Copy { + 91: Copy { dest: StatePartIndex(6), // (0xf) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::data_out", ty: UInt<4> }, - src: StatePartIndex(81), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, + src: StatePartIndex(86), // (0x3) SlotDebugData { name: "", ty: UInt<4> }, }, - // at: module-XXXXXXXXXX.rs:8:1 - 81: IsNonZeroDestIsSmall { - dest: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, + // at: module-XXXXXXXXXX.rs:22:1 + 92: Copy { + dest: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::b_out", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, + src: StatePartIndex(97), // (0x7) SlotDebugData { name: "", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, + }, + // at: module-XXXXXXXXXX.rs:17:1 + 93: BranchIfSmallNeImmediate { + target: 96, + lhs: StatePartIndex(5), // (0x2 2) SlotDebugData { name: "", ty: Enum {A, B, C} }, + rhs: 0x2, + }, + // at: module-XXXXXXXXXX.rs:23:1 + 94: Copy { + dest: StatePartIndex(5), // (0x2) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::which_out", ty: UInt<2> }, + src: StatePartIndex(62), // (0x2) SlotDebugData { name: "", ty: UInt<2> }, + }, + // at: module-XXXXXXXXXX.rs:24:1 + 95: Copy { + dest: StatePartIndex(6), // (0xf) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::data_out", ty: UInt<4> }, + src: StatePartIndex(102), // (0xf) SlotDebugData { name: "", ty: UInt<4> }, + }, + // at: module-XXXXXXXXXX.rs:9:1 + 96: IsNonZeroDestIsSmall { + dest: StatePartIndex(4), // (0x0 0) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(1), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::cd.rst", ty: SyncReset }, }, // at: module-XXXXXXXXXX.rs:1:1 - 82: Const { - dest: StatePartIndex(9), // (0x0) SlotDebugData { name: "", ty: UInt<6> }, + 97: Const { + dest: StatePartIndex(17), // (0x0) SlotDebugData { name: "", ty: UInt<6> }, value: 0x0, }, - 83: Copy { - dest: StatePartIndex(10), // (0x0) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - src: StatePartIndex(9), // (0x0) SlotDebugData { name: "", ty: UInt<6> }, + 98: Copy { + dest: StatePartIndex(18), // (0x0) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + src: StatePartIndex(17), // (0x0) SlotDebugData { name: "", ty: UInt<6> }, }, - // at: module-XXXXXXXXXX.rs:9:1 - 84: BranchIfZero { - target: 92, + // at: module-XXXXXXXXXX.rs:10:1 + 99: BranchIfZero { + target: 107, value: StatePartIndex(2), // (0x1) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::en", ty: Bool }, }, - // at: module-XXXXXXXXXX.rs:10:1 - 85: BranchIfZero { - target: 87, - value: StatePartIndex(30), // (0x0) SlotDebugData { name: "", ty: Bool }, + // at: module-XXXXXXXXXX.rs:11:1 + 100: BranchIfZero { + target: 102, + value: StatePartIndex(38), // (0x0) SlotDebugData { name: "", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:12:1 + 101: Copy { + dest: StatePartIndex(16), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + src: StatePartIndex(18), // (0x0) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, }, // at: module-XXXXXXXXXX.rs:11:1 - 86: Copy { - dest: StatePartIndex(8), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - src: StatePartIndex(10), // (0x0) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - }, - // at: module-XXXXXXXXXX.rs:10:1 - 87: BranchIfNonZero { - target: 92, - value: StatePartIndex(30), // (0x0) SlotDebugData { name: "", ty: Bool }, - }, - // at: module-XXXXXXXXXX.rs:12:1 - 88: BranchIfZero { - target: 90, - value: StatePartIndex(32), // (0x0) SlotDebugData { name: "", ty: Bool }, + 102: BranchIfNonZero { + target: 107, + value: StatePartIndex(38), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:13:1 - 89: Copy { - dest: StatePartIndex(8), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - src: StatePartIndex(49), // (0xd) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - }, - // at: module-XXXXXXXXXX.rs:12:1 - 90: BranchIfNonZero { - target: 92, - value: StatePartIndex(32), // (0x0) SlotDebugData { name: "", ty: Bool }, + 103: BranchIfZero { + target: 105, + value: StatePartIndex(40), // (0x0) SlotDebugData { name: "", ty: Bool }, }, // at: module-XXXXXXXXXX.rs:14:1 - 91: Copy { - dest: StatePartIndex(8), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - src: StatePartIndex(71), // (0x3e) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + 104: Copy { + dest: StatePartIndex(16), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + src: StatePartIndex(57), // (0xd) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, }, - // at: module-XXXXXXXXXX.rs:8:1 - 92: IsNonZeroDestIsSmall { - dest: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, + // at: module-XXXXXXXXXX.rs:13:1 + 105: BranchIfNonZero { + target: 107, + value: StatePartIndex(40), // (0x0) SlotDebugData { name: "", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:15:1 + 106: Copy { + dest: StatePartIndex(16), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + src: StatePartIndex(79), // (0x3e) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + }, + // at: module-XXXXXXXXXX.rs:9:1 + 107: IsNonZeroDestIsSmall { + dest: StatePartIndex(3), // (0x1 1) SlotDebugData { name: "", ty: Bool }, src: StatePartIndex(0), // (0x1) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::cd.clk", ty: Clock }, }, - 93: AndSmall { + 108: AndSmall { + dest: StatePartIndex(2), // (0x0 0) SlotDebugData { name: "", ty: Bool }, + lhs: StatePartIndex(3), // (0x1 1) SlotDebugData { name: "", ty: Bool }, + rhs: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:1:1 + 109: Copy { + dest: StatePartIndex(10), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, + src: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::b_out", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, + }, + 110: SliceInt { + dest: StatePartIndex(11), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, + src: StatePartIndex(10), // (0x0) SlotDebugData { name: "", ty: UInt<3> }, + start: 1, + len: 2, + }, + 111: SliceInt { + dest: StatePartIndex(12), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(11), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, + start: 0, + len: 1, + }, + 112: SliceInt { + dest: StatePartIndex(13), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, + src: StatePartIndex(11), // (0x0) SlotDebugData { name: "", ty: UInt<2> }, + start: 1, + len: 1, + }, + 113: Copy { + dest: StatePartIndex(14), // (0x0) SlotDebugData { name: "", ty: Bool }, + src: StatePartIndex(13), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, + }, + 114: Copy { + dest: StatePartIndex(8), // (0x0) SlotDebugData { name: ".0", ty: UInt<1> }, + src: StatePartIndex(12), // (0x0) SlotDebugData { name: "", ty: UInt<1> }, + }, + 115: Copy { + dest: StatePartIndex(9), // (0x0) SlotDebugData { name: ".1", ty: Bool }, + src: StatePartIndex(14), // (0x0) SlotDebugData { name: "", ty: Bool }, + }, + // at: module-XXXXXXXXXX.rs:8:1 + 116: AndBigWithSmallImmediate { + dest: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Enum {HdlNone, HdlSome} }, + lhs: StatePartIndex(7), // (0x0) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::b_out", ty: Enum {HdlNone, HdlSome(Bundle {0: UInt<1>, 1: Bool})} }, + rhs: 0x1, + }, + // at: module-XXXXXXXXXX.rs:9:1 + 117: BranchIfSmallZero { + target: 122, + value: StatePartIndex(2), // (0x0 0) SlotDebugData { name: "", ty: Bool }, + }, + 118: BranchIfSmallNonZero { + target: 121, + value: StatePartIndex(4), // (0x0 0) SlotDebugData { name: "", ty: Bool }, + }, + 119: Copy { + dest: StatePartIndex(15), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + src: StatePartIndex(16), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + }, + 120: Branch { + target: 122, + }, + 121: Copy { + dest: StatePartIndex(15), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + src: StatePartIndex(18), // (0x0) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, + }, + 122: XorSmallImmediate { dest: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, - lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, - rhs: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, - }, - 94: BranchIfSmallZero { - target: 99, - value: StatePartIndex(1), // (0x0 0) SlotDebugData { name: "", ty: Bool }, - }, - 95: BranchIfSmallNonZero { - target: 98, - value: StatePartIndex(3), // (0x0 0) SlotDebugData { name: "", ty: Bool }, - }, - 96: Copy { - dest: StatePartIndex(7), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - src: StatePartIndex(8), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg$next", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - }, - 97: Branch { - target: 99, - }, - 98: Copy { - dest: StatePartIndex(7), // (0x3e) SlotDebugData { name: "InstantiatedModule(enums: enums).enums::the_reg", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - src: StatePartIndex(10), // (0x0) SlotDebugData { name: "", ty: Enum {A, B(Bundle {0: UInt<1>, 1: Bool}), C(Bundle {a: Array, 2>, b: SInt<2>})} }, - }, - 99: XorSmallImmediate { - dest: StatePartIndex(0), // (0x0 0) SlotDebugData { name: "", ty: Bool }, - lhs: StatePartIndex(2), // (0x1 1) SlotDebugData { name: "", ty: Bool }, + lhs: StatePartIndex(3), // (0x1 1) SlotDebugData { name: "", ty: Bool }, rhs: 0x1, }, // at: module-XXXXXXXXXX.rs:1:1 - 100: Return, + 123: Return, ], .. }, - pc: 100, + pc: 123, memory_write_log: [], memories: StatePart { value: [], }, small_slots: StatePart { value: [ + 0, 0, 0, 1, @@ -898,6 +1109,14 @@ Simulation { 15, 2, 15, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 62, 62, 0, @@ -964,10 +1183,23 @@ Simulation { 62, 62, 0, + 0, + 0, 1, 2, 3, 3, + 1, + 1, + 1, + 1, + 1, + 2, + 3, + 6, + 7, + 7, + 7, 2, 3, 3, @@ -985,6 +1217,46 @@ Simulation { }, uninitialized_inputs: {}, io_targets: { + Instance { + name: ::enums, + instantiated: Module { + name: enums, + .. + }, + }.b_out: CompiledValue { + layout: CompiledTypeLayout { + ty: Enum { + HdlNone, + HdlSome(Bundle {0: UInt<1>, 1: Bool}), + }, + layout: TypeLayout { + small_slots: StatePartLayout { + len: 0, + debug_data: [], + .. + }, + big_slots: StatePartLayout { + len: 1, + debug_data: [ + SlotDebugData { + name: "InstantiatedModule(enums: enums).enums::b_out", + ty: Enum { + HdlNone, + HdlSome(Bundle {0: UInt<1>, 1: Bool}), + }, + }, + ], + .. + }, + }, + body: Scalar, + }, + range: TypeIndexRange { + small_slots: StatePartIndexRange { start: 0, len: 0 }, + big_slots: StatePartIndexRange { start: 7, len: 1 }, + }, + write: None, + }, Instance { name: ::enums, instantiated: Module { @@ -1415,23 +1687,22 @@ Simulation { ty: UInt<4>, flow: Sink, }, - TraceReg { - name: "the_reg", + TraceModuleIO { + name: "b_out", child: TraceEnumWithFields { - name: "the_reg", + name: "b_out", discriminant: TraceEnumDiscriminant { location: TraceScalarId(7), name: "$tag", ty: Enum { - A, - B(Bundle {0: UInt<1>, 1: Bool}), - C(Bundle {a: Array, 2>, b: SInt<2>}), + HdlNone, + HdlSome(Bundle {0: UInt<1>, 1: Bool}), }, - flow: Duplex, + flow: Sink, }, non_empty_fields: [ TraceBundle { - name: "B", + name: "HdlSome", fields: [ TraceUInt { location: TraceScalarId(8), @@ -1453,6 +1724,57 @@ Simulation { }, flow: Source, }, + ], + ty: Enum { + HdlNone, + HdlSome(Bundle {0: UInt<1>, 1: Bool}), + }, + flow: Sink, + }, + ty: Enum { + HdlNone, + HdlSome(Bundle {0: UInt<1>, 1: Bool}), + }, + flow: Sink, + }, + TraceReg { + name: "the_reg", + child: TraceEnumWithFields { + name: "the_reg", + discriminant: TraceEnumDiscriminant { + location: TraceScalarId(10), + name: "$tag", + ty: Enum { + A, + B(Bundle {0: UInt<1>, 1: Bool}), + C(Bundle {a: Array, 2>, b: SInt<2>}), + }, + flow: Duplex, + }, + non_empty_fields: [ + TraceBundle { + name: "B", + fields: [ + TraceUInt { + location: TraceScalarId(11), + name: "0", + ty: UInt<1>, + flow: Source, + }, + TraceBool { + location: TraceScalarId(12), + name: "1", + flow: Source, + }, + ], + ty: Bundle { + /* offset = 0 */ + 0: UInt<1>, + /* offset = 1 */ + 1: Bool, + }, + flow: Source, + }, TraceBundle { name: "C", fields: [ @@ -1460,13 +1782,13 @@ Simulation { name: "a", elements: [ TraceUInt { - location: TraceScalarId(10), + location: TraceScalarId(13), name: "[0]", ty: UInt<1>, flow: Source, }, TraceUInt { - location: TraceScalarId(11), + location: TraceScalarId(14), name: "[1]", ty: UInt<1>, flow: Source, @@ -1476,7 +1798,7 @@ Simulation { flow: Source, }, TraceSInt { - location: TraceScalarId(12), + location: TraceScalarId(15), name: "b", ty: SInt<2>, flow: Source, @@ -1570,7 +1892,36 @@ Simulation { SimTrace { id: TraceScalarId(7), kind: EnumDiscriminant { - index: StatePartIndex(4), + index: StatePartIndex(0), + ty: Enum { + HdlNone, + HdlSome(Bundle {0: UInt<1>, 1: Bool}), + }, + }, + state: 0x0, + last_state: 0x0, + }, + SimTrace { + id: TraceScalarId(8), + kind: BigUInt { + index: StatePartIndex(8), + ty: UInt<1>, + }, + state: 0x0, + last_state: 0x0, + }, + SimTrace { + id: TraceScalarId(9), + kind: BigBool { + index: StatePartIndex(9), + }, + state: 0x0, + last_state: 0x0, + }, + SimTrace { + id: TraceScalarId(10), + kind: EnumDiscriminant { + index: StatePartIndex(5), ty: Enum { A, B(Bundle {0: UInt<1>, 1: Bool}), @@ -1580,32 +1931,6 @@ Simulation { state: 0x2, last_state: 0x2, }, - SimTrace { - id: TraceScalarId(8), - kind: BigUInt { - index: StatePartIndex(11), - ty: UInt<1>, - }, - state: 0x1, - last_state: 0x1, - }, - SimTrace { - id: TraceScalarId(9), - kind: BigBool { - index: StatePartIndex(12), - }, - state: 0x1, - last_state: 0x1, - }, - SimTrace { - id: TraceScalarId(10), - kind: BigUInt { - index: StatePartIndex(18), - ty: UInt<1>, - }, - state: 0x1, - last_state: 0x1, - }, SimTrace { id: TraceScalarId(11), kind: BigUInt { @@ -1617,8 +1942,34 @@ Simulation { }, SimTrace { id: TraceScalarId(12), - kind: BigSInt { + kind: BigBool { index: StatePartIndex(20), + }, + state: 0x1, + last_state: 0x1, + }, + SimTrace { + id: TraceScalarId(13), + kind: BigUInt { + index: StatePartIndex(26), + ty: UInt<1>, + }, + state: 0x1, + last_state: 0x1, + }, + SimTrace { + id: TraceScalarId(14), + kind: BigUInt { + index: StatePartIndex(27), + ty: UInt<1>, + }, + state: 0x1, + last_state: 0x1, + }, + SimTrace { + id: TraceScalarId(15), + kind: BigSInt { + index: StatePartIndex(28), ty: SInt<2>, }, state: 0x3, @@ -1637,7 +1988,7 @@ Simulation { ], instant: 16 μs, clocks_triggered: [ - StatePartIndex(1), + StatePartIndex(2), ], .. } \ No newline at end of file diff --git a/crates/fayalite/tests/sim/expected/enums.vcd b/crates/fayalite/tests/sim/expected/enums.vcd index 48a493b..07cbd32 100644 --- a/crates/fayalite/tests/sim/expected/enums.vcd +++ b/crates/fayalite/tests/sim/expected/enums.vcd @@ -9,18 +9,25 @@ $var wire 2 $ which_in $end $var wire 4 % data_in $end $var wire 2 & which_out $end $var wire 4 ' data_out $end -$scope struct the_reg $end +$scope struct b_out $end $var string 1 ( \$tag $end +$scope struct HdlSome $end +$var wire 1 ) \0 $end +$var wire 1 * \1 $end +$upscope $end +$upscope $end +$scope struct the_reg $end +$var string 1 + \$tag $end $scope struct B $end -$var reg 1 ) \0 $end -$var reg 1 * \1 $end +$var reg 1 , \0 $end +$var reg 1 - \1 $end $upscope $end $scope struct C $end $scope struct a $end -$var reg 1 + \[0] $end -$var reg 1 , \[1] $end +$var reg 1 . \[0] $end +$var reg 1 / \[1] $end $upscope $end -$var reg 2 - b $end +$var reg 2 0 b $end $upscope $end $upscope $end $upscope $end @@ -33,12 +40,15 @@ b0 $ b0 % b0 & b0 ' -sA\x20(0) ( +sHdlNone\x20(0) ( 0) 0* -0+ +sA\x20(0) + 0, -b0 - +0- +0. +0/ +b0 0 $end #1000000 1! @@ -55,7 +65,8 @@ b1 $ #5000000 1! b1 & -sB\x20(1) ( +sHdlSome\x20(1) ( +sB\x20(1) + #6000000 0# b0 $ @@ -72,8 +83,10 @@ b1111 % b11 ' 1) 1* -1+ 1, +1- +1. +1/ #10000000 0! #11000000 @@ -85,8 +98,11 @@ b10 $ 1! b10 & b1111 ' -sC\x20(2) ( -b11 - +sHdlNone\x20(0) ( +0) +0* +sC\x20(2) + +b11 0 #14000000 0! #15000000