Skip to content

Commit

Permalink
set a minimum variable value for logic paths
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulk29 committed Oct 13, 2024
1 parent ad168b2 commit 22b2243
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions substrate/src/logic/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@ new_key_type! {
pub struct VarKey;
}

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LogicPath {
segments: Vec<Segment>,
variables: SlotMap<VarKey, VarState>,
min_var_value: f64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
impl Default for LogicPath {
fn default() -> Self {
Self {
segments: Vec::new(),
variables: Default::default(),
min_var_value: 1.,
}
}
}

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
struct VarState {
value: f64,
}
Expand Down Expand Up @@ -198,7 +209,7 @@ impl LogicPath {

#[inline]
pub fn value(&self, var: VarKey) -> f64 {
self.variables[var].value
f64::max(self.variables[var].value, self.min_var_value)
}

fn segment_delay_grad(&self, idx: usize, grad: &mut Gradient) -> f64 {
Expand Down

0 comments on commit 22b2243

Please sign in to comment.