Compare commits

..

No commits in common. "929e9f8b16861acd72b0965c01a9b429cbb00338" and "25aa90ec603acdc49a984588e75ba62d7f16b5c4" have entirely different histories.

8 changed files with 145 additions and 427 deletions

View file

@ -15,4 +15,3 @@ jobs:
with:
save-if: ${{ github.ref == 'refs/heads/master' }}
- run: cargo test
- run: cargo doc

View file

@ -4,7 +4,7 @@ use crate::{
array::ArrayType,
bundle::{BundleType, BundleValue, DynBundle, DynBundleType, FieldType},
enum_::{DynEnumType, EnumType, EnumValue},
int::{DynSIntType, DynUInt, DynUIntType, FixedOrDynIntType, IntValue, UInt, UIntType},
int::{DynSIntType, DynUIntType, FixedOrDynIntType, IntValue, UInt, UIntType},
intern::{Intern, Interned, InternedCompare, PtrEqWithTypeId, SupportsPtrEqWithTypeId},
memory::{DynPortType, MemPort, PortType},
module::{
@ -288,12 +288,7 @@ impl<T> Hash for Expr<T> {
impl<T> Expr<IntValue<T>>
where
T: FixedOrDynIntType<
1,
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
T: FixedOrDynIntType<1, Signed = ConstBool<false>>,
{
pub fn as_bool(self) -> Expr<UInt<1>> {
assert_eq!(self.canonical_type().width, 1);

View file

@ -10,8 +10,8 @@ use crate::{
TargetPathDynArrayElement, TargetPathElement, ToExpr,
},
int::{
DynInt, DynIntType, DynSInt, DynSIntType, DynUInt, DynUIntType, FixedOrDynIntType, Int,
IntCmp, IntTypeTrait, IntValue, UInt, UIntType,
DynIntType, DynSInt, DynSIntType, DynUInt, DynUIntType, FixedOrDynIntType, Int, IntCmp,
IntTypeTrait, IntValue, UInt, UIntType,
},
intern::{Intern, Interned},
reset::{
@ -242,7 +242,7 @@ unary_op! {
#[method = not]
impl<T> Not for _
where (
T: IntTypeTrait<CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>>,
T: IntTypeTrait,
)
{
fn expr_enum(&self) -> _ {
@ -262,7 +262,7 @@ unary_op! {
#[method = neg]
impl<T> Neg for _
where (
T: IntTypeTrait<Signed = ConstBool<true>, CanonicalType = DynSIntType, CanonicalValue = DynSInt>,
T: IntTypeTrait<Signed = ConstBool<true>>,
)
{
fn expr_enum(&self) -> _ {
@ -361,48 +361,48 @@ binary_op! {
#[method = bitand, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = BitAndU, expr_enum_s = BitAndS]
impl<L, R> BitAnd for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait,
R: IntTypeTrait<Signed = L::Signed>,
}
binary_op! {
#[method = bitor, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = BitOrU, expr_enum_s = BitOrS]
impl<L, R> BitOr for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait,
R: IntTypeTrait<Signed = L::Signed>,
}
binary_op! {
#[method = bitxor, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = BitXorU, expr_enum_s = BitXorS]
impl<L, R> BitXor for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait,
R: IntTypeTrait<Signed = L::Signed>,
}
binary_op! {
#[method = add, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = AddU, expr_enum_s = AddS]
impl<L, R> Add for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait,
R: IntTypeTrait<Signed = L::Signed>,
}
binary_op! {
#[method = sub, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = SubU, expr_enum_s = SubS]
impl<L, R> Sub for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait,
R: IntTypeTrait<Signed = L::Signed>,
}
binary_op! {
#[method = mul, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = MulU, expr_enum_s = MulS]
impl<L, R> Mul for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait,
R: IntTypeTrait<Signed = L::Signed>,
}
macro_rules! dyn_shift_op {
@ -413,7 +413,7 @@ macro_rules! dyn_shift_op {
fixed_ary_op! {
pub struct $DynOp<LhsType,>
where (
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
LhsType: IntTypeTrait,
)
{
pub lhs: Expr<LhsType::CanonicalValue>,
@ -458,8 +458,8 @@ macro_rules! dyn_shift_op {
impl<Lhs: Value<Type = LhsType>, LhsType, RhsType, Rhs: Value<Type = RhsType>> ops::$Op<Expr<Rhs>> for Expr<Lhs>
where
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
RhsType: IntTypeTrait<Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>,
LhsType: IntTypeTrait,
RhsType: IntTypeTrait<Signed = ConstBool<false>>,
{
type Output = Expr<<<Valueless<LhsType> as ops::$Op<Valueless<RhsType>>>::Output as ValuelessTr>::Value>;
@ -470,8 +470,8 @@ macro_rules! dyn_shift_op {
impl<LhsType, RhsType, Rhs: Value<Type = RhsType>> ops::$Op<Expr<Rhs>> for IntValue<LhsType>
where
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
RhsType: IntTypeTrait<Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>,
LhsType: IntTypeTrait,
RhsType: IntTypeTrait<Signed = ConstBool<false>>,
{
type Output = Expr<<<Valueless<LhsType> as ops::$Op<Valueless<RhsType>>>::Output as ValuelessTr>::Value>;
@ -490,7 +490,7 @@ macro_rules! fixed_shift_op {
fixed_ary_op! {
pub struct $FixedOp<LhsType,>
where (
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
LhsType: IntTypeTrait,
)
{
pub lhs: Expr<LhsType::CanonicalValue>,
@ -532,7 +532,7 @@ macro_rules! fixed_shift_op {
impl<Lhs: Value<Type = LhsType>, LhsType> ops::$Op<usize> for Expr<Lhs>
where
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
LhsType: IntTypeTrait,
{
type Output = Expr<<<Valueless<LhsType> as ops::$Op<usize>>::Output as ValuelessTr>::Value>;
@ -568,9 +568,9 @@ macro_rules! cmp_op {
$(fixed_ary_op! {
pub struct $CmpOp<LhsType, RhsType, Output,>
where (
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>,
Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>,
LhsType: IntTypeTrait,
RhsType: IntTypeTrait<Signed = LhsType::Signed>,
Output: FixedOrDynIntType<1, Signed = ConstBool<false>>,
)
{
pub lhs: Expr<LhsType::CanonicalValue>,
@ -612,7 +612,7 @@ macro_rules! cmp_op {
}
})*
impl<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Rhs: Value<Type = RhsType>, Lhs: Value<Type = LhsType>> IntCmp<Expr<Rhs>> for Expr<Lhs> {
impl<LhsType: IntTypeTrait, RhsType: IntTypeTrait<Signed = LhsType::Signed>, Rhs: Value<Type = RhsType>, Lhs: Value<Type = LhsType>> IntCmp<Expr<Rhs>> for Expr<Lhs> {
type Output = Expr<UInt<1>>;
$(fn $fn(self, rhs: Expr<Rhs>) -> Self::Output {
@ -620,7 +620,7 @@ macro_rules! cmp_op {
})*
}
impl<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Rhs: Value<Type = RhsType>, Lhs: Value<Type = LhsType>> IntCmp<Rhs> for Expr<Lhs> {
impl<LhsType: IntTypeTrait, RhsType: IntTypeTrait<Signed = LhsType::Signed>, Rhs: Value<Type = RhsType>, Lhs: Value<Type = LhsType>> IntCmp<Rhs> for Expr<Lhs> {
type Output = Expr<UInt<1>>;
$(fn $fn(self, rhs: Rhs) -> Self::Output {
@ -628,7 +628,7 @@ macro_rules! cmp_op {
})*
}
impl<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Rhs: Value<Type = RhsType>> IntCmp<Expr<Rhs>> for IntValue<LhsType> {
impl<LhsType: IntTypeTrait, RhsType: IntTypeTrait<Signed = LhsType::Signed>, Rhs: Value<Type = RhsType>> IntCmp<Expr<Rhs>> for IntValue<LhsType> {
type Output = Expr<UInt<1>>;
$(fn $fn(self, rhs: Expr<Rhs>) -> Self::Output {
@ -658,8 +658,8 @@ cmp_op! {
fixed_ary_op! {
pub struct CastInt<FromType, ToType,>
where (
FromType: IntTypeTrait<CanonicalType = DynIntType<<FromType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<FromType as IntTypeTrait>::Signed>>,
ToType: IntTypeTrait<CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>,
FromType: IntTypeTrait,
ToType: IntTypeTrait,
)
{
pub value: Expr<FromType::CanonicalValue>,
@ -705,18 +705,9 @@ fixed_ary_op! {
}
}
impl<
FromType: IntTypeTrait<
CanonicalType = DynIntType<<FromType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<FromType as IntTypeTrait>::Signed>,
>,
> Expr<IntValue<FromType>>
{
impl<FromType: IntTypeTrait> Expr<IntValue<FromType>> {
pub fn cast<
ToType: IntTypeTrait<
CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>,
>,
ToType: IntTypeTrait<CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>>,
>(
self,
ty: ToType,
@ -740,7 +731,7 @@ impl<
fixed_ary_op! {
pub struct Slice<Base,>
where (
Base: IntTypeTrait<CanonicalType = DynIntType<<Base as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<Base as IntTypeTrait>::Signed>>,
Base: IntTypeTrait,
)
{
pub base: Expr<Base::CanonicalValue>,
@ -774,13 +765,7 @@ fixed_ary_op! {
}
}
impl<
T: IntTypeTrait<
CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>,
>,
> Expr<IntValue<T>>
{
impl<T: IntTypeTrait> Expr<IntValue<T>> {
pub fn slice<I: RangeBounds<usize>>(self, index: I) -> Expr<DynUInt> {
Slice::<T>::new_unchecked(
self.canonical(),
@ -856,14 +841,7 @@ impl_built_in_range!(<T> std::ops::RangeInclusive<T>);
impl_built_in_range!(<T> std::ops::RangeTo<T>);
impl_built_in_range!(<T> std::ops::RangeToInclusive<T>);
impl<
T: IntTypeTrait<
CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>,
>,
I: BuiltInRange<usize>,
> ExprIndex<I> for IntValue<T>
{
impl<T: IntTypeTrait, I: BuiltInRange<usize>> ExprIndex<I> for IntValue<T> {
type OutputValue = DynUInt;
fn expr_index(this: Expr<Self>, index: I) -> Expr<Self::OutputValue> {
@ -871,13 +849,7 @@ impl<
}
}
impl<
T: IntTypeTrait<
CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>,
>,
> ExprIndex<usize> for IntValue<T>
{
impl<T: IntTypeTrait> ExprIndex<usize> for IntValue<T> {
type OutputValue = UInt<1>;
fn expr_index(this: Expr<Self>, index: usize) -> Expr<Self::OutputValue> {
@ -890,7 +862,7 @@ macro_rules! reduce_bit_op {
fixed_ary_op! {
pub struct $name<Output,>
where (
Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>,
Output: FixedOrDynIntType<1, Signed = ConstBool<false>>,
)
{
pub arg: Expr<DynUInt>,
@ -920,14 +892,7 @@ reduce_bit_op!(ReduceBitAnd; |bits| bits.all());
reduce_bit_op!(ReduceBitOr; |bits| bits.any());
reduce_bit_op!(ReduceBitXor; |bits| bits.count_ones() % 2 == 1);
impl<
T: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
> Expr<IntValue<T>>
{
impl<T: IntTypeTrait<Signed = ConstBool<false>>> Expr<IntValue<T>> {
pub fn reduce_bitand(self) -> Expr<UInt<1>> {
ReduceBitAnd::<UIntType<1>>::new_unchecked(self.canonical()).to_expr()
}
@ -974,9 +939,7 @@ fixed_ary_op! {
},
#[target]
target: Option<Interned<Target>> = base.target().map(|base| {
Intern::intern_sized(base.join(
TargetPathElement::intern_sized(TargetPathBundleField{ name: field.name }.into()),
))
Intern::intern_sized(base.join(TargetPathElement::intern_sized(TargetPathBundleField{name:field.name}.into())))
}),
fn simulate(&self, sim_state: &mut SimState) -> _ {
todo!()
@ -1022,9 +985,9 @@ fixed_ary_op! {
#[cache]
base_ty: DynEnumType = base.canonical_type(),
#[type]
ty: VariantTy = VariantTy::from_dyn_canonical_type(
base_ty.variants()[variant_index].ty.unwrap_or_else(|| ().canonical_dyn()),
),
ty: VariantTy = VariantTy::from_dyn_canonical_type(base_ty.variants()[variant_index].ty.unwrap_or_else(
|| ().canonical_dyn(),
)),
#[cache]
literal_bits: Result<Interned<BitSlice>, ()> = {
base.to_literal_bits().map(|base| {
@ -1123,9 +1086,7 @@ fixed_ary_op! {
}
fn expr_enum(&self) -> _ {
ExprEnum::CastBitsTo(
CastBitsTo::new_unchecked(self.value, self.ty.canonical_dyn()).intern_sized(),
)
ExprEnum::CastBitsTo(CastBitsTo::new_unchecked(self.value, self.ty.canonical_dyn()).intern_sized())
}
fn to_literal_bits(&self) -> Result<Interned<BitSlice>, ()> {
@ -1144,14 +1105,7 @@ where
}
}
impl<
T: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
> Expr<IntValue<T>>
{
impl<T: IntTypeTrait<Signed = ConstBool<false>>> Expr<IntValue<T>> {
pub fn cast_bits_to<U: Value>(self, ty: U::Type) -> Expr<U>
where
U::Type: Type<Value = U>,
@ -1161,11 +1115,11 @@ impl<
}
macro_rules! cast_bit_to_typed_bit {
(pub struct $Op:ident$(<$T:ident: $Bound:path>)?; $FromType:ty => $ToType:ty) => {
(pub struct $Op:ident$(<$T:ident: $Bound:ident<$BoundArg:tt>>)?; $FromType:ty => $ToType:ty) => {
fixed_ary_op! {
pub struct $Op<$($T,)?>
where (
$($T: $Bound,)?
$($T: $Bound<$BoundArg>,)?
)
{
pub value: Expr<<$FromType as Type>::Value>,
@ -1290,7 +1244,7 @@ where
}
}
cast_bit_to_typed_bit!(pub struct CastClockToBit<ToType: FixedOrDynIntType<1, CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>>; ClockType => ToType);
cast_bit_to_typed_bit!(pub struct CastClockToBit<ToType: FixedOrDynIntType<1>>; ClockType => ToType);
impl ToBit for Clock {
fn to_bit(v: Expr<Self>) -> Expr<UInt<1>> {
@ -1298,7 +1252,7 @@ impl ToBit for Clock {
}
}
cast_bit_to_typed_bit!(pub struct CastSyncResetToBit<ToType: FixedOrDynIntType<1, CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>>; SyncResetType => ToType);
cast_bit_to_typed_bit!(pub struct CastSyncResetToBit<ToType: FixedOrDynIntType<1>>; SyncResetType => ToType);
impl ToBit for SyncReset {
fn to_bit(v: Expr<Self>) -> Expr<UInt<1>> {
@ -1306,7 +1260,7 @@ impl ToBit for SyncReset {
}
}
cast_bit_to_typed_bit!(pub struct CastAsyncResetToBit<ToType: FixedOrDynIntType<1, CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>>; AsyncResetType => ToType);
cast_bit_to_typed_bit!(pub struct CastAsyncResetToBit<ToType: FixedOrDynIntType<1>>; AsyncResetType => ToType);
impl ToBit for AsyncReset {
fn to_bit(v: Expr<Self>) -> Expr<UInt<1>> {
@ -1314,7 +1268,7 @@ impl ToBit for AsyncReset {
}
}
cast_bit_to_typed_bit!(pub struct CastResetToBit<ToType: FixedOrDynIntType<1, CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>>; ResetType => ToType);
cast_bit_to_typed_bit!(pub struct CastResetToBit<ToType: FixedOrDynIntType<1>>; ResetType => ToType);
impl ToBit for Reset {
fn to_bit(v: Expr<Self>) -> Expr<UInt<1>> {
@ -1401,9 +1355,7 @@ fixed_ary_op! {
},
#[target]
target: Option<Interned<Target>> = base.target().map(|base| {
Intern::intern_sized(base.join(
TargetPathElement::ArrayElement(TargetPathArrayElement { index }).intern(),
))
Intern::intern_sized(base.join(TargetPathElement::ArrayElement(TargetPathArrayElement { index }).intern()))
}),
fn simulate(&self, sim_state: &mut SimState) -> _ {
todo!()
@ -1446,28 +1398,21 @@ fixed_ary_op! {
let base_ty = base.ty();
let element_bit_width = base_ty.element().bit_width();
base.to_literal_bits().ok().zip(index.to_literal_bits().ok()).and_then(|(base, index)| {
let start = DynUInt::from_bit_slice(&index)
.uint_value()
.to_usize()?
.checked_mul(element_bit_width)?;
let start = DynUInt::from_bit_slice(&index).uint_value().to_usize()?.checked_mul(element_bit_width)?;
let end = start.checked_add(element_bit_width)?;
Some(base.get(start..end)?.intern())
}).ok_or(())
},
#[target]
target: Option<Interned<Target>> = base.target().map(|base| {
Intern::intern_sized(base.join(
TargetPathElement::DynArrayElement(TargetPathDynArrayElement {}).intern(),
))
Intern::intern_sized(base.join(TargetPathElement::DynArrayElement(TargetPathDynArrayElement {}).intern()))
}),
fn simulate(&self, sim_state: &mut SimState) -> _ {
todo!()
}
fn expr_enum(&self) -> _ {
ExprEnum::DynArrayIndex(
DynArrayIndex::new_unchecked(self.base, self.index).intern_sized(),
)
ExprEnum::DynArrayIndex(DynArrayIndex::new_unchecked(self.base, self.index).intern_sized())
}
fn to_literal_bits(&self) -> Result<Interned<BitSlice>, ()> {
@ -1487,11 +1432,7 @@ impl<ElementType: Type> DynArrayIndex<ElementType> {
impl<
VA: ?Sized + ValueArrayOrSlice,
Idx: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
Idx: IntTypeTrait<Signed = ConstBool<false>, CanonicalType = DynUIntType>,
> ExprIndex<IntValue<Idx>> for Array<VA>
{
type OutputValue = VA::Element;
@ -1504,11 +1445,7 @@ impl<
impl<
VA: ?Sized + ValueArrayOrSlice,
Idx: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
Idx: IntTypeTrait<Signed = ConstBool<false>, CanonicalType = DynUIntType>,
> ExprIndex<Expr<IntValue<Idx>>> for Array<VA>
{
type OutputValue = VA::Element;
@ -1618,8 +1555,7 @@ fixed_ary_op! {
ty
},
#[cache]
literal_bits: Result<Interned<BitSlice>, ()> =
ty.variant_to_bits(variant_index, variant_value.as_ref()),
literal_bits: Result<Interned<BitSlice>, ()> = ty.variant_to_bits(variant_index, variant_value.as_ref()),
fn simulate(&self, sim_state: &mut SimState) -> _ {
todo!()
}

View file

@ -35,13 +35,7 @@ pub type Int<Signed, const WIDTH: usize> = IntValue<IntType<Signed, WIDTH>>;
pub type UInt<const WIDTH: usize> = Int<ConstBool<false>, WIDTH>;
pub type SInt<const WIDTH: usize> = Int<ConstBool<true>, WIDTH>;
impl<
T: IntTypeTrait<
CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>,
>,
> ToExpr for IntValue<T>
{
impl<T: IntTypeTrait> ToExpr for IntValue<T> {
type Type = T;
fn ty(&self) -> Self::Type {
@ -53,25 +47,13 @@ impl<
}
}
impl<
T: IntTypeTrait<
CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>,
>,
> fmt::Display for IntValue<T>
{
impl<T: IntTypeTrait> fmt::Display for IntValue<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self.to_canonical(), f)
}
}
impl<
T: IntTypeTrait<
CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>,
>,
> fmt::Debug for IntValue<T>
{
impl<T: IntTypeTrait> fmt::Debug for IntValue<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let neg;
let (sign, magnitude) = if self.is_negative() {
@ -111,13 +93,7 @@ impl<Signed: GenericConstBool> DynInt<Signed> {
}
}
impl<
T: IntTypeTrait<
CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>,
>,
> IntValue<T>
{
impl<T: IntTypeTrait> IntValue<T> {
pub fn with_type<I: Into<BigInt>>(ty: T, value: I) -> Self {
let int_type = ty.canonical();
let mut value: BigInt = value.into();
@ -196,30 +172,14 @@ impl<
let width = self.ty.width();
T::Signed::VALUE && width > 0 && self.uint_value.bit((width - 1).try_into().unwrap())
}
pub fn into_cast<
NewType: IntTypeTrait<
CanonicalType = DynIntType<<NewType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<NewType as IntTypeTrait>::Signed>,
>,
>(
self,
new_type: NewType,
) -> IntValue<NewType> {
pub fn into_cast<NewType: IntTypeTrait>(self, new_type: NewType) -> IntValue<NewType> {
if new_type.width() > self.ty.width() && self.is_negative() {
IntValue::with_type(new_type, self.into_value())
} else {
IntValue::with_type(new_type, self.into_uint_value())
}
}
pub fn cast<
NewType: IntTypeTrait<
CanonicalType = DynIntType<<NewType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<NewType as IntTypeTrait>::Signed>,
>,
>(
&self,
new_type: NewType,
) -> IntValue<NewType> {
pub fn cast<NewType: IntTypeTrait>(&self, new_type: NewType) -> IntValue<NewType> {
if new_type.width() > self.ty.width() && self.is_negative() {
IntValue::with_type(new_type, self.value())
} else {
@ -261,14 +221,7 @@ impl<
assert!(index < self.ty.width(), "bit index out of range");
self.uint_value.set_bit(index.try_into().unwrap(), value)
}
pub fn set_slice<
I: RangeBounds<usize>,
RhsType: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
>(
pub fn set_slice<I: RangeBounds<usize>, RhsType: IntTypeTrait<Signed = ConstBool<false>>>(
&mut self,
index: I,
value: impl Into<IntValue<RhsType>>,
@ -287,11 +240,7 @@ impl<
}
pub fn with_replaced_slice<
I: RangeBounds<usize>,
RhsType: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
RhsType: IntTypeTrait<Signed = ConstBool<false>>,
>(
mut self,
index: I,
@ -300,12 +249,7 @@ impl<
self.set_slice(index, value);
self
}
pub fn concat<
HighType: IntTypeTrait<
CanonicalType = DynIntType<<HighType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<HighType as IntTypeTrait>::Signed>,
>,
>(
pub fn concat<HighType: IntTypeTrait>(
&self,
high_part: IntValue<HighType>,
) -> IntValue<DynIntType<HighType::Signed>> {
@ -335,13 +279,7 @@ impl<
}
}
impl<
Ty: IntTypeTrait<
CanonicalType = DynIntType<<Ty as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<Ty as IntTypeTrait>::Signed>,
>,
> Value for IntValue<Ty>
{
impl<Ty: IntTypeTrait> Value for IntValue<Ty> {
fn to_canonical(&self) -> <Self::Type as Type>::CanonicalValue {
IntValue {
ty: self.ty.canonical(),
@ -357,13 +295,7 @@ impl<
}
}
impl<T> Copy for ToBitsMemoize<T> {}
impl<
Ty: IntTypeTrait<
CanonicalType = DynIntType<<Ty as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<Ty as IntTypeTrait>::Signed>,
>,
> Memoize for ToBitsMemoize<IntValue<Ty>>
{
impl<Ty: IntTypeTrait> Memoize for ToBitsMemoize<IntValue<Ty>> {
type Input = IntValue<Ty>;
type InputOwned = IntValue<Ty>;
type Output = Interned<BitSlice>;
@ -389,15 +321,8 @@ macro_rules! impl_add_sub {
($Op:ident::$op:ident) => {
impl<LhsType, RhsType> $Op<IntValue<RhsType>> for IntValue<LhsType>
where
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = <LhsType as IntTypeTrait>::Signed,
CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>,
>,
LhsType: IntTypeTrait,
RhsType: IntTypeTrait<Signed = <LhsType as IntTypeTrait>::Signed>,
{
type Output = IntValue<DynIntType<LhsType::Signed>>;
@ -409,15 +334,8 @@ macro_rules! impl_add_sub {
impl<LhsType, RhsType> $Op<Valueless<RhsType>> for Valueless<LhsType>
where
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = <LhsType as IntTypeTrait>::Signed,
CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>,
>,
LhsType: IntTypeTrait,
RhsType: IntTypeTrait<Signed = <LhsType as IntTypeTrait>::Signed>,
{
type Output = Valueless<DynIntType<LhsType::Signed>>;
@ -439,16 +357,8 @@ macro_rules! impl_bitwise {
($Op:ident::$op:ident) => {
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>,
>,
LhsType: IntTypeTrait<Signed = Signed>,
RhsType: IntTypeTrait<Signed = Signed>,
> $Op<IntValue<RhsType>> for IntValue<LhsType>
{
type Output = IntValue<DynIntType<Signed>>;
@ -461,16 +371,8 @@ macro_rules! impl_bitwise {
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>,
>,
LhsType: IntTypeTrait<Signed = Signed>,
RhsType: IntTypeTrait<Signed = Signed>,
> $Op<Valueless<RhsType>> for Valueless<LhsType>
{
type Output = Valueless<DynIntType<Signed>>;
@ -488,16 +390,8 @@ impl_add_sub!(Sub::sub);
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>,
>,
LhsType: IntTypeTrait<Signed = Signed>,
RhsType: IntTypeTrait<Signed = Signed>,
> Mul<IntValue<RhsType>> for IntValue<LhsType>
{
type Output = IntValue<DynIntType<Signed>>;
@ -509,16 +403,8 @@ impl<
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>,
>,
LhsType: IntTypeTrait<Signed = Signed>,
RhsType: IntTypeTrait<Signed = Signed>,
> Mul<Valueless<RhsType>> for Valueless<LhsType>
{
type Output = Valueless<DynIntType<Signed>>;
@ -539,16 +425,8 @@ impl_bitwise!(BitXor::bitxor);
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
LhsType: IntTypeTrait<Signed = Signed>,
RhsType: IntTypeTrait<Signed = ConstBool<false>>,
> Shl<IntValue<RhsType>> for IntValue<LhsType>
{
type Output = IntValue<DynIntType<Signed>>;
@ -569,16 +447,8 @@ impl<
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
LhsType: IntTypeTrait<Signed = Signed>,
RhsType: IntTypeTrait<Signed = ConstBool<false>>,
> Shl<Valueless<RhsType>> for Valueless<LhsType>
{
type Output = Valueless<DynIntType<Signed>>;
@ -599,16 +469,8 @@ impl<
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
LhsType: IntTypeTrait<Signed = Signed>,
RhsType: IntTypeTrait<Signed = ConstBool<false>>,
> Shr<IntValue<RhsType>> for IntValue<LhsType>
{
type Output = IntValue<DynIntType<Signed>>;
@ -626,12 +488,8 @@ impl<
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<Signed = Signed, CanonicalType = DynIntType<Signed>>,
RhsType: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
LhsType: IntTypeTrait<Signed = Signed>,
RhsType: IntTypeTrait<Signed = ConstBool<false>>,
> Shr<Valueless<RhsType>> for Valueless<LhsType>
{
type Output = Valueless<DynIntType<Signed>>;
@ -643,14 +501,8 @@ impl<
}
}
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
> Shl<usize> for IntValue<LhsType>
impl<Signed: GenericConstBool, LhsType: IntTypeTrait<Signed = Signed>> Shl<usize>
for IntValue<LhsType>
{
type Output = IntValue<DynIntType<Signed>>;
@ -660,14 +512,8 @@ impl<
}
}
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
> Shl<usize> for Valueless<LhsType>
impl<Signed: GenericConstBool, LhsType: IntTypeTrait<Signed = Signed>> Shl<usize>
for Valueless<LhsType>
{
type Output = Valueless<DynIntType<Signed>>;
@ -682,14 +528,8 @@ impl<
}
}
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
> Shr<usize> for IntValue<LhsType>
impl<Signed: GenericConstBool, LhsType: IntTypeTrait<Signed = Signed>> Shr<usize>
for IntValue<LhsType>
{
type Output = IntValue<DynIntType<Signed>>;
@ -701,14 +541,8 @@ impl<
}
}
impl<
Signed: GenericConstBool,
LhsType: IntTypeTrait<
Signed = Signed,
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
> Shr<usize> for Valueless<LhsType>
impl<Signed: GenericConstBool, LhsType: IntTypeTrait<Signed = Signed>> Shr<usize>
for Valueless<LhsType>
{
type Output = Valueless<DynIntType<Signed>>;
@ -718,14 +552,7 @@ impl<
}
}
impl<
T: IntTypeTrait<
Signed = ConstBool<true>,
CanonicalType = DynSIntType,
CanonicalValue = DynSInt,
>,
> Neg for IntValue<T>
{
impl<T: IntTypeTrait<Signed = ConstBool<true>>> Neg for IntValue<T> {
type Output = IntValue<DynSIntType>;
fn neg(self) -> Self::Output {
let ty = self.valueless().neg().ty;
@ -733,14 +560,7 @@ impl<
}
}
impl<
T: IntTypeTrait<
Signed = ConstBool<true>,
CanonicalType = DynSIntType,
CanonicalValue = DynSInt,
>,
> Neg for Valueless<T>
{
impl<T: IntTypeTrait<Signed = ConstBool<true>>> Neg for Valueless<T> {
type Output = Valueless<DynSIntType>;
fn neg(self) -> Self::Output {
let ty = DynIntType::new(
@ -753,26 +573,14 @@ impl<
}
}
impl<
T: IntTypeTrait<
CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>,
>,
> Not for IntValue<T>
{
impl<T: IntTypeTrait> Not for IntValue<T> {
type Output = IntValue<T>;
fn not(self) -> Self::Output {
IntValue::with_type(self.valueless().not().ty, Not::not(self.into_value()))
}
}
impl<
T: IntTypeTrait<
CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>,
>,
> Not for Valueless<T>
{
impl<T: IntTypeTrait> Not for Valueless<T> {
type Output = Valueless<T>;
fn not(self) -> Self::Output {
self
@ -818,15 +626,7 @@ impl_int!(i32, true);
impl_int!(i64, true);
impl_int!(i128, true);
impl<
T: FixedOrDynIntType<
1,
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
> From<bool> for IntValue<T>
{
impl<T: FixedOrDynIntType<1, Signed = ConstBool<false>>> From<bool> for IntValue<T> {
fn from(v: bool) -> Self {
IntValue::with_type(T::new(), v)
}
@ -865,7 +665,11 @@ pub trait IntTypeTrait:
+ Eq
+ Hash
+ fmt::Debug
+ Type<Value = IntValue<Self>>
+ Type<
Value = IntValue<Self>,
CanonicalType = DynIntType<<Self as IntTypeTrait>::Signed>,
CanonicalValue = IntValue<DynIntType<<Self as IntTypeTrait>::Signed>>,
>
+ Connect<Self>
+ Connect<DynIntType<<Self as IntTypeTrait>::Signed>>
{
@ -874,15 +678,11 @@ pub trait IntTypeTrait:
Signed = ConstBool<false>,
SameWidthUInt = Self::SameWidthUInt,
SameWidthSInt = Self::SameWidthSInt,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>;
type SameWidthSInt: IntTypeTrait<
Signed = ConstBool<true>,
SameWidthUInt = Self::SameWidthUInt,
SameWidthSInt = Self::SameWidthSInt,
CanonicalType = DynSIntType,
CanonicalValue = DynSInt,
>;
fn from_width_unchecked(width: usize) -> Self;
fn width(self) -> usize;
@ -935,12 +735,12 @@ pub trait IntTypeTrait:
start..end
}
fn slice_and_shift<I: RangeBounds<usize>>(self, index: I) -> (DynUIntType, usize) {
let range = self.slice_index_to_range(index);
let range = self.canonical().slice_index_to_range(index);
let width = range.end - range.start;
(DynUIntType::new(width), range.start)
}
fn slice<I: RangeBounds<usize>>(self, index: I) -> DynUIntType {
self.slice_and_shift(index).0
self.canonical().slice_and_shift(index).0
}
}

View file

@ -11,7 +11,7 @@ use crate::{
ops::VariantAccess, Expr, Flow, Target, TargetBase, TargetPathArrayElement,
TargetPathBundleField, TargetPathElement, ToExpr,
},
int::{DynUInt, DynUIntType, FixedOrDynIntType, UInt},
int::{FixedOrDynIntType, UInt},
intern::{Intern, Interned},
memory::{Mem, MemBuilder, MemBuilderTarget, PortName},
reg::Reg,
@ -2254,12 +2254,7 @@ where
#[track_caller]
pub fn if_<Ty>(&mut self, cond: impl ToExpr<Type = Ty>) -> IfScope
where
Ty: FixedOrDynIntType<
1,
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
Ty: FixedOrDynIntType<1, Signed = ConstBool<false>>,
{
self.if_with_loc(cond, SourceLocation::caller())
}
@ -2269,12 +2264,7 @@ where
source_location: SourceLocation,
) -> IfScope
where
Ty: FixedOrDynIntType<
1,
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
Ty: FixedOrDynIntType<1, Signed = ConstBool<false>>,
{
let cond = cond.to_expr().as_bool();
let outer_block = self.block_stack.top();

View file

@ -11,10 +11,7 @@ use crate::{
ops, Expr, ExprEnum, Literal, Target, TargetBase, TargetChild, TargetPathArrayElement,
TargetPathBundleField, TargetPathDynArrayElement, TargetPathElement, ToExpr,
},
int::{
DynInt, DynIntType, DynSInt, DynSIntType, DynUInt, DynUIntType, FixedOrDynIntType, IntType,
IntTypeTrait,
},
int::{DynInt, DynIntType, FixedOrDynIntType, IntType, IntTypeTrait},
intern::{Intern, Interned},
memory::{Mem, MemPort, PortKind, PortName, PortType, ReadUnderWrite},
module::{

View file

@ -68,9 +68,10 @@ impl<T: IntTypeTrait> Valueless<T> {
&self,
high_part: Valueless<HighType>,
) -> Valueless<DynIntType<HighType::Signed>> {
let self_type = self.ty.canonical();
let ty = DynIntType::new(
self.ty
.width()
self_type
.width
.checked_add(high_part.ty.width())
.expect("result has too many bits"),
);

View file

@ -376,7 +376,7 @@
"$constructor": "ops::Not::new_unchecked",
"arg": "Visible"
},
"generics": "<T: IntTypeTrait<CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>>>"
"generics": "<T: IntTypeTrait>"
},
"ops::Neg": {
"data": {
@ -384,7 +384,7 @@
"$constructor": "ops::Neg::new_unchecked",
"arg": "Visible"
},
"generics": "<T: IntTypeTrait<Signed = ConstBool<true>, CanonicalType = DynSIntType, CanonicalValue = DynSInt>>"
"generics": "<T: IntTypeTrait<Signed = ConstBool<true>>>"
},
"ops::BitAnd": {
"data": {
@ -395,7 +395,7 @@
},
"generics": {
"generics": "<L, R>",
"where": "L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>, R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>"
"where": "L: IntTypeTrait, R: IntTypeTrait<Signed = L::Signed>"
}
},
"ops::BitOr": {
@ -407,7 +407,7 @@
},
"generics": {
"generics": "<L, R>",
"where": "L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>, R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>"
"where": "L: IntTypeTrait, R: IntTypeTrait<Signed = L::Signed>"
}
},
"ops::BitXor": {
@ -419,7 +419,7 @@
},
"generics": {
"generics": "<L, R>",
"where": "L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>, R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>"
"where": "L: IntTypeTrait, R: IntTypeTrait<Signed = L::Signed>"
}
},
"ops::Add": {
@ -431,7 +431,7 @@
},
"generics": {
"generics": "<L, R>",
"where": "L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>, R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>"
"where": "L: IntTypeTrait, R: IntTypeTrait<Signed = L::Signed>"
}
},
"ops::Sub": {
@ -443,7 +443,7 @@
},
"generics": {
"generics": "<L, R>",
"where": "L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>, R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>"
"where": "L: IntTypeTrait, R: IntTypeTrait<Signed = L::Signed>"
}
},
"ops::Mul": {
@ -455,7 +455,7 @@
},
"generics": {
"generics": "<L, R>",
"where": "L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>, R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>"
"where": "L: IntTypeTrait, R: IntTypeTrait<Signed = L::Signed>"
}
},
"ops::DynShl": {
@ -465,7 +465,7 @@
"lhs": "Visible",
"rhs": "Visible"
},
"generics": "<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>>"
"generics": "<LhsType: IntTypeTrait>"
},
"ops::DynShr": {
"data": {
@ -474,7 +474,7 @@
"lhs": "Visible",
"rhs": "Visible"
},
"generics": "<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>>"
"generics": "<LhsType: IntTypeTrait>"
},
"ops::FixedShl": {
"data": {
@ -483,7 +483,7 @@
"lhs": "Visible",
"rhs": "Visible"
},
"generics": "<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>>"
"generics": "<LhsType: IntTypeTrait>"
},
"ops::FixedShr": {
"data": {
@ -492,7 +492,7 @@
"lhs": "Visible",
"rhs": "Visible"
},
"generics": "<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>>"
"generics": "<LhsType: IntTypeTrait>"
},
"ops::CmpLt": {
"data": {
@ -501,7 +501,7 @@
"lhs": "Visible",
"rhs": "Visible"
},
"generics": "<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>>"
"generics": "<LhsType: IntTypeTrait, RhsType: IntTypeTrait<Signed = LhsType::Signed>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>>>"
},
"ops::CmpLe": {
"data": {
@ -510,7 +510,7 @@
"lhs": "Visible",
"rhs": "Visible"
},
"generics": "<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>>"
"generics": "<LhsType: IntTypeTrait, RhsType: IntTypeTrait<Signed = LhsType::Signed>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>>>"
},
"ops::CmpGt": {
"data": {
@ -519,7 +519,7 @@
"lhs": "Visible",
"rhs": "Visible"
},
"generics": "<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>>"
"generics": "<LhsType: IntTypeTrait, RhsType: IntTypeTrait<Signed = LhsType::Signed>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>>>"
},
"ops::CmpGe": {
"data": {
@ -528,7 +528,7 @@
"lhs": "Visible",
"rhs": "Visible"
},
"generics": "<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>>"
"generics": "<LhsType: IntTypeTrait, RhsType: IntTypeTrait<Signed = LhsType::Signed>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>>>"
},
"ops::CmpEq": {
"data": {
@ -537,7 +537,7 @@
"lhs": "Visible",
"rhs": "Visible"
},
"generics": "<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>>"
"generics": "<LhsType: IntTypeTrait, RhsType: IntTypeTrait<Signed = LhsType::Signed>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>>>"
},
"ops::CmpNe": {
"data": {
@ -546,7 +546,7 @@
"lhs": "Visible",
"rhs": "Visible"
},
"generics": "<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>>"
"generics": "<LhsType: IntTypeTrait, RhsType: IntTypeTrait<Signed = LhsType::Signed>, Output: FixedOrDynIntType<1, Signed = ConstBool<false>>>"
},
"ops::CastInt": {
"data": {
@ -555,7 +555,7 @@
"value": "Visible",
"ty()": "Visible"
},
"generics": "<FromType: IntTypeTrait<CanonicalType = DynIntType<<FromType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<FromType as IntTypeTrait>::Signed>>, ToType: IntTypeTrait<CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>>",
"generics": "<FromType: IntTypeTrait, ToType: IntTypeTrait>",
"fold_where": "ToType: Fold<State>",
"visit_where": "ToType: Visit<State>"
},
@ -566,7 +566,7 @@
"base": "Visible",
"range": "Opaque"
},
"generics": "<Base: IntTypeTrait<CanonicalType = DynIntType<<Base as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<Base as IntTypeTrait>::Signed>>>"
"generics": "<Base: IntTypeTrait>"
},
"ops::ReduceBitAnd": {
"data": {
@ -574,7 +574,7 @@
"$constructor": "ops::ReduceBitAnd::new_unchecked",
"arg": "Visible"
},
"generics": "<Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>>"
"generics": "<Output: FixedOrDynIntType<1, Signed = ConstBool<false>>>"
},
"ops::ReduceBitOr": {
"data": {
@ -582,7 +582,7 @@
"$constructor": "ops::ReduceBitOr::new_unchecked",
"arg": "Visible"
},
"generics": "<Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>>"
"generics": "<Output: FixedOrDynIntType<1, Signed = ConstBool<false>>>"
},
"ops::ReduceBitXor": {
"data": {
@ -590,7 +590,7 @@
"$constructor": "ops::ReduceBitXor::new_unchecked",
"arg": "Visible"
},
"generics": "<Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>>"
"generics": "<Output: FixedOrDynIntType<1, Signed = ConstBool<false>>>"
},
"ops::FieldAccess": {
"data": {
@ -696,7 +696,7 @@
"$constructor": "ops::CastClockToBit::new_unchecked",
"value": "Visible"
},
"generics": "<ToType: FixedOrDynIntType<1, CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>>"
"generics": "<ToType: FixedOrDynIntType<1>>"
},
"ops::CastSyncResetToBit": {
"data": {
@ -704,7 +704,7 @@
"$constructor": "ops::CastSyncResetToBit::new_unchecked",
"value": "Visible"
},
"generics": "<ToType: FixedOrDynIntType<1, CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>>"
"generics": "<ToType: FixedOrDynIntType<1>>"
},
"ops::CastAsyncResetToBit": {
"data": {
@ -712,7 +712,7 @@
"$constructor": "ops::CastAsyncResetToBit::new_unchecked",
"value": "Visible"
},
"generics": "<ToType: FixedOrDynIntType<1, CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>>"
"generics": "<ToType: FixedOrDynIntType<1>>"
},
"ops::CastResetToBit": {
"data": {
@ -720,7 +720,7 @@
"$constructor": "ops::CastResetToBit::new_unchecked",
"value": "Visible"
},
"generics": "<ToType: FixedOrDynIntType<1, CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>>"
"generics": "<ToType: FixedOrDynIntType<1>>"
},
"BlockId": {
"data": {