misc fixes from using new fayalite version in cpu: improve UIntInRange's API, move FormalMode to testing and add to prelude, and fix inconsistent ordering of memories in vcd #42

Merged
programmerjake merged 4 commits from programmerjake/fayalite:misc_fixes_for_cpu into master 2025-10-24 08:48:50 +00:00
Showing only changes of commit 3e5b2f126a - Show all commits

View file

@ -304,6 +304,15 @@ macro_rules! define_uint_in_range_type {
$SerdeRange { start, end }.intern_sized(),
))
}
pub fn bit_width(self) -> usize {
self.value.width()
}
pub fn start(self) -> Start::SizeType {
self.range.get().start
}
pub fn end(self) -> End::SizeType {
self.range.get().end
}
}
impl<Start: Size, End: Size> fmt::Debug for $UIntInRangeType<Start, End> {
@ -477,18 +486,22 @@ macro_rules! define_uint_in_range_type {
}
}
impl<Start: Size, End: Size> ExprCastTo<UInt> for $UIntInRangeType<Start, End> {
fn cast_to(src: Expr<Self>, to_type: UInt) -> Expr<UInt> {
impl<Start: Size, End: Size, Width: Size> ExprCastTo<UIntType<Width>>
for $UIntInRangeType<Start, End>
{
fn cast_to(src: Expr<Self>, to_type: UIntType<Width>) -> Expr<UIntType<Width>> {
src.cast_to_bits().cast_to(to_type)
}
}
impl<Start: Size, End: Size> ExprCastTo<$UIntInRangeType<Start, End>> for UInt {
impl<Start: Size, End: Size, Width: Size> ExprCastTo<$UIntInRangeType<Start, End>>
for UIntType<Width>
{
fn cast_to(
src: Expr<Self>,
to_type: $UIntInRangeType<Start, End>,
) -> Expr<$UIntInRangeType<Start, End>> {
src.cast_bits_to(to_type)
src.cast_to(to_type.value).cast_bits_to(to_type)
}
}