forked from libre-chip/fayalite
Compare commits
4 commits
9b12ff54e6
...
c8ab70d32f
| Author | SHA1 | Date | |
|---|---|---|---|
| c8ab70d32f | |||
| 1fde884e48 | |||
| 9055713ff2 | |||
| fc7ab51620 |
6 changed files with 2712 additions and 2837 deletions
|
|
@ -21,9 +21,11 @@ use crate::{
|
||||||
CompiledValue,
|
CompiledValue,
|
||||||
},
|
},
|
||||||
interpreter::{
|
interpreter::{
|
||||||
BreakAction, BreakpointsSet, RunResult, SmallUInt, State, StatePartIndex,
|
BreakAction, BreakpointsSet, RunResult, SmallUInt, State,
|
||||||
StatePartKindBigSlots, StatePartKindMemories, StatePartKindSmallSlots, TypeIndexRange,
|
parts::{
|
||||||
TypeLen,
|
StatePartIndex, StatePartKindBigSlots, StatePartKindMemories,
|
||||||
|
StatePartKindSmallSlots, TypeIndexRange, TypeLenSingle,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
time::{SimDuration, SimInstant},
|
time::{SimDuration, SimInstant},
|
||||||
value::{DynSimOnlyValue, DynSimOnlyValueType, SimValue},
|
value::{DynSimOnlyValue, DynSimOnlyValueType, SimValue},
|
||||||
|
|
@ -1357,14 +1359,15 @@ impl MaybeNeedsSettleFn<&'_ mut interpreter::State> for ReadBitFn {
|
||||||
type Output = bool;
|
type Output = bool;
|
||||||
|
|
||||||
fn call(self, state: &mut interpreter::State) -> Self::Output {
|
fn call(self, state: &mut interpreter::State) -> Self::Output {
|
||||||
match self.compiled_value.range.len() {
|
match self.compiled_value.range.len().as_single() {
|
||||||
TypeLen::A_SMALL_SLOT => {
|
Some(TypeLenSingle::SmallSlot) => {
|
||||||
state.small_slots[self.compiled_value.range.small_slots.start] != 0
|
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()
|
.clone()
|
||||||
.is_zero(),
|
.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 {
|
fn call(self, state: &mut interpreter::State) -> Self::Output {
|
||||||
let Self { compiled_value, io } = self;
|
let Self { compiled_value, io } = self;
|
||||||
match compiled_value.range.len() {
|
match compiled_value.range.len().as_single() {
|
||||||
TypeLen::A_SMALL_SLOT => Expr::ty(io)
|
Some(TypeLenSingle::SmallSlot) => Expr::ty(io)
|
||||||
.value_from_int_wrapping(state.small_slots[compiled_value.range.small_slots.start]),
|
.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(),
|
state.big_slots[compiled_value.range.big_slots.start].clone(),
|
||||||
),
|
),
|
||||||
_ => unreachable!(),
|
None => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2033,14 +2036,14 @@ impl SimulationImpl {
|
||||||
.get_module_mut(which_module)
|
.get_module_mut(which_module)
|
||||||
.write_helper(io, which_module);
|
.write_helper(io, which_module);
|
||||||
self.state_ready_to_run = true;
|
self.state_ready_to_run = true;
|
||||||
match compiled_value.range.len() {
|
match compiled_value.range.len().as_single() {
|
||||||
TypeLen::A_SMALL_SLOT => {
|
Some(TypeLenSingle::SmallSlot) => {
|
||||||
self.state.small_slots[compiled_value.range.small_slots.start] = value as _;
|
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()
|
self.state.big_slots[compiled_value.range.big_slots.start] = value.into()
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
None => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
|
@ -2066,18 +2069,18 @@ impl SimulationImpl {
|
||||||
.write_helper(Expr::canonical(io), which_module);
|
.write_helper(Expr::canonical(io), which_module);
|
||||||
self.state_ready_to_run = true;
|
self.state_ready_to_run = true;
|
||||||
let value: BigInt = value.into();
|
let value: BigInt = value.into();
|
||||||
match compiled_value.range.len() {
|
match compiled_value.range.len().as_single() {
|
||||||
TypeLen::A_SMALL_SLOT => {
|
Some(TypeLenSingle::SmallSlot) => {
|
||||||
let mut small_value = value.iter_u64_digits().next().unwrap_or(0);
|
let mut small_value = value.iter_u64_digits().next().unwrap_or(0);
|
||||||
if value.is_negative() {
|
if value.is_negative() {
|
||||||
small_value = small_value.wrapping_neg();
|
small_value = small_value.wrapping_neg();
|
||||||
}
|
}
|
||||||
self.state.small_slots[compiled_value.range.small_slots.start] = small_value;
|
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
|
self.state.big_slots[compiled_value.range.big_slots.start] = value
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
None => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
|
@ -2107,20 +2110,20 @@ impl SimulationImpl {
|
||||||
};
|
};
|
||||||
let bit_indexes =
|
let bit_indexes =
|
||||||
start_bit_index..start_bit_index + compiled_value.layout.ty.bit_width();
|
start_bit_index..start_bit_index + compiled_value.layout.ty.bit_width();
|
||||||
match compiled_value.range.len() {
|
match compiled_value.range.len().as_single() {
|
||||||
TypeLen::A_SMALL_SLOT => read_write_small_scalar(
|
Some(TypeLenSingle::SmallSlot) => read_write_small_scalar(
|
||||||
signed,
|
signed,
|
||||||
bit_indexes,
|
bit_indexes,
|
||||||
bits,
|
bits,
|
||||||
&mut state.small_slots[compiled_value.range.small_slots.start],
|
&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,
|
signed,
|
||||||
bit_indexes,
|
bit_indexes,
|
||||||
bits,
|
bits,
|
||||||
&mut state.big_slots[compiled_value.range.big_slots.start],
|
&mut state.big_slots[compiled_value.range.big_slots.start],
|
||||||
),
|
),
|
||||||
_ => unreachable!(),
|
None => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CompiledTypeLayoutBody::Array { element } => {
|
CompiledTypeLayoutBody::Array { element } => {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
1012
crates/fayalite/src/sim/interpreter/parts.rs
Normal file
1012
crates/fayalite/src/sim/interpreter/parts.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -33,6 +33,7 @@ pub use const_cmp::{
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use scoped_ref::ScopedRef;
|
pub use scoped_ref::ScopedRef;
|
||||||
|
|
||||||
|
pub(crate) use misc::chain;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use misc::{
|
pub use misc::{
|
||||||
BitSliceWriteWithBase, DebugAsDisplay, DebugAsRawString, MakeMutSlice, RcWriter, interned_bit,
|
BitSliceWriteWithBase, DebugAsDisplay, DebugAsRawString, MakeMutSlice, RcWriter, interned_bit,
|
||||||
|
|
|
||||||
|
|
@ -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>> {
|
pub fn try_slice_range<R: RangeBounds<usize>>(range: R, size: usize) -> Option<Range<usize>> {
|
||||||
let start = match range.start_bound() {
|
let start = match range.start_bound() {
|
||||||
Bound::Included(start) => *start,
|
Bound::Included(start) => *start,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue