1
0
Fork 0

Compare commits

..

4 commits

6 changed files with 2712 additions and 2837 deletions

View file

@ -21,9 +21,11 @@ use crate::{
CompiledValue,
},
interpreter::{
BreakAction, BreakpointsSet, RunResult, SmallUInt, State, StatePartIndex,
StatePartKindBigSlots, StatePartKindMemories, StatePartKindSmallSlots, TypeIndexRange,
TypeLen,
BreakAction, BreakpointsSet, RunResult, SmallUInt, State,
parts::{
StatePartIndex, StatePartKindBigSlots, StatePartKindMemories,
StatePartKindSmallSlots, TypeIndexRange, TypeLenSingle,
},
},
time::{SimDuration, SimInstant},
value::{DynSimOnlyValue, DynSimOnlyValueType, SimValue},
@ -1357,14 +1359,15 @@ impl MaybeNeedsSettleFn<&'_ mut interpreter::State> for ReadBitFn {
type Output = bool;
fn call(self, state: &mut interpreter::State) -> Self::Output {
match self.compiled_value.range.len() {
TypeLen::A_SMALL_SLOT => {
match self.compiled_value.range.len().as_single() {
Some(TypeLenSingle::SmallSlot) => {
state.small_slots[self.compiled_value.range.small_slots.start] != 0
}
TypeLen::A_BIG_SLOT => !state.big_slots[self.compiled_value.range.big_slots.start]
Some(TypeLenSingle::BigSlot) => !state.big_slots
[self.compiled_value.range.big_slots.start]
.clone()
.is_zero(),
_ => unreachable!(),
None => unreachable!(),
}
}
}
@ -1379,13 +1382,13 @@ impl<I: BoolOrIntType> MaybeNeedsSettleFn<&'_ mut interpreter::State> for ReadBo
fn call(self, state: &mut interpreter::State) -> Self::Output {
let Self { compiled_value, io } = self;
match compiled_value.range.len() {
TypeLen::A_SMALL_SLOT => Expr::ty(io)
match compiled_value.range.len().as_single() {
Some(TypeLenSingle::SmallSlot) => Expr::ty(io)
.value_from_int_wrapping(state.small_slots[compiled_value.range.small_slots.start]),
TypeLen::A_BIG_SLOT => Expr::ty(io).value_from_int_wrapping(
Some(TypeLenSingle::BigSlot) => Expr::ty(io).value_from_int_wrapping(
state.big_slots[compiled_value.range.big_slots.start].clone(),
),
_ => unreachable!(),
None => unreachable!(),
}
}
}
@ -2033,14 +2036,14 @@ impl SimulationImpl {
.get_module_mut(which_module)
.write_helper(io, which_module);
self.state_ready_to_run = true;
match compiled_value.range.len() {
TypeLen::A_SMALL_SLOT => {
match compiled_value.range.len().as_single() {
Some(TypeLenSingle::SmallSlot) => {
self.state.small_slots[compiled_value.range.small_slots.start] = value as _;
}
TypeLen::A_BIG_SLOT => {
Some(TypeLenSingle::BigSlot) => {
self.state.big_slots[compiled_value.range.big_slots.start] = value.into()
}
_ => unreachable!(),
None => unreachable!(),
}
}
#[track_caller]
@ -2066,18 +2069,18 @@ impl SimulationImpl {
.write_helper(Expr::canonical(io), which_module);
self.state_ready_to_run = true;
let value: BigInt = value.into();
match compiled_value.range.len() {
TypeLen::A_SMALL_SLOT => {
match compiled_value.range.len().as_single() {
Some(TypeLenSingle::SmallSlot) => {
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 => {
Some(TypeLenSingle::BigSlot) => {
self.state.big_slots[compiled_value.range.big_slots.start] = value
}
_ => unreachable!(),
None => unreachable!(),
}
}
#[track_caller]
@ -2107,20 +2110,20 @@ impl SimulationImpl {
};
let bit_indexes =
start_bit_index..start_bit_index + compiled_value.layout.ty.bit_width();
match compiled_value.range.len() {
TypeLen::A_SMALL_SLOT => read_write_small_scalar(
match compiled_value.range.len().as_single() {
Some(TypeLenSingle::SmallSlot) => read_write_small_scalar(
signed,
bit_indexes,
bits,
&mut state.small_slots[compiled_value.range.small_slots.start],
),
TypeLen::A_BIG_SLOT => read_write_big_scalar(
Some(TypeLenSingle::BigSlot) => read_write_big_scalar(
signed,
bit_indexes,
bits,
&mut state.big_slots[compiled_value.range.big_slots.start],
),
_ => unreachable!(),
None => unreachable!(),
}
}
CompiledTypeLayoutBody::Array { element } => {

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -33,6 +33,7 @@ pub use const_cmp::{
#[doc(inline)]
pub use scoped_ref::ScopedRef;
pub(crate) use misc::chain;
#[doc(inline)]
pub use misc::{
BitSliceWriteWithBase, DebugAsDisplay, DebugAsRawString, MakeMutSlice, RcWriter, interned_bit,

View file

@ -211,6 +211,21 @@ impl std::io::Write for RcWriter {
}
}
macro_rules! chain {
() => {
std::iter::empty()
};
($first:expr $(, $rest:expr)* $(,)?) => {
{
let retval = IntoIterator::into_iter($first);
$(let retval = Iterator::chain(retval, $rest);)*
retval
}
};
}
pub(crate) use chain;
pub fn try_slice_range<R: RangeBounds<usize>>(range: R, size: usize) -> Option<Range<usize>> {
let start = match range.start_bound() {
Bound::Included(start) => *start,