Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronKutch committed Dec 12, 2023
1 parent d5485a5 commit 2a8fbb9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
14 changes: 5 additions & 9 deletions starlight/src/awi_structs/epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl EpochShared {
let lnode = lock.ensemble.lnodes.get(p_lnode).unwrap();
let p_driver = lnode.p_driver;
drop(lock);
Ensemble::calculate_value_with_lower_capability(&self, p_driver)?;
Ensemble::calculate_value_with_lower_capability(self, p_driver)?;
} else {
break
}
Expand All @@ -345,14 +345,10 @@ impl EpochShared {
let ensemble = &mut lock.ensemble;

let mut adv = ensemble.lnodes.advancer();
loop {
if let Some(p_lnode) = adv.advance(&ensemble.lnodes) {
let lnode = ensemble.lnodes.get(p_lnode).unwrap();
let p_driver = lnode.p_driver;
ensemble.calculate_value(p_driver)?;
} else {
break
}
while let Some(p_lnode) = adv.advance(&ensemble.lnodes) {
let lnode = ensemble.lnodes.get(p_lnode).unwrap();
let p_driver = lnode.p_driver;
ensemble.calculate_value(p_driver)?;
}
// second do all loopback changes
let mut adv = ensemble.lnodes.advancer();
Expand Down
29 changes: 27 additions & 2 deletions starlight/src/awi_structs/temporal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,33 @@ use crate::{epoch::get_current_epoch, lower::meta::selector};
/// value of the driver and use that to retroactively change the temporal value
/// of the loop.
///
/// The fundamental reason for temporal asymmetry is that there needs to be a
/// well defined root evaluation state and value.
/// ```
/// use starlight::{awi, dag::*, Epoch, EvalAwi, Loop};
/// let epoch = Epoch::new();
///
/// let looper = Loop::zero(bw(4));
/// // evaluate the value of `looper` at this point later
/// let val = EvalAwi::from(&looper);
/// let mut tmp = awi!(looper);
/// tmp.inc_(true);
/// // drive the `Loop` with itself incremented
/// looper.drive(&tmp).unwrap();
///
/// {
/// use awi::*;
/// for i in 0..16 {
/// // check that the evaluated value is equal to
/// // this loop iteration number
/// awi::assert_eq!(i, val.eval().unwrap().to_usize());
/// // every time `drive_loops` is called,
/// // the evaluated value increases by one
/// epoch.drive_loops().unwrap();
/// }
/// }
/// drop(epoch);
/// ```
// The fundamental reason for temporal asymmetry is that there needs to be a
// well defined root evaluation state and value.
#[derive(Debug)] // do not implement `Clone`, but maybe implement a `duplicate` function that
// explicitly duplicates drivers and loopbacks?
pub struct Loop {
Expand Down
4 changes: 1 addition & 3 deletions starlight/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
//! typical DSL (Domain Specific Language) approach, this allows RTL
//! descriptions in ordinary Rust code with all the features that Rust provides.
//!
//! This crate is still a WIP, but it currently can describe most combinational
//! logic. The temporal structs (`Loop` and `Net`) need more development before
//! they will work properly. Many optimizations are planned in the near future.
//! This crate still has a considerable amount of WIP stuff
//!
//! See the documentation of `awint`/`awint_dag` which is used as the backend
//! for this.
Expand Down

0 comments on commit 2a8fbb9

Please sign in to comment.