From 0c07003c413751ad8e02b96181d34f65552e9025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20L=C3=A4ufer?= Date: Tue, 12 Dec 2023 15:47:13 -0500 Subject: [PATCH] synth: clear synthesis variables --- synth/src/main.rs | 3 +++ synth/src/repair.rs | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/synth/src/main.rs b/synth/src/main.rs index 0030790..e9a3d94 100644 --- a/synth/src/main.rs +++ b/synth/src/main.rs @@ -133,6 +133,9 @@ fn main() { tb.define_inputs(InitKind::Random(1)); } } + // set all synthesis variables to zero + synth_vars.clear_in_sim(&mut sim); + // remember the starting state let start_state = sim.take_snapshot(); diff --git a/synth/src/repair.rs b/synth/src/repair.rs index f62a0ed..13a3085 100644 --- a/synth/src/repair.rs +++ b/synth/src/repair.rs @@ -153,6 +153,15 @@ impl RepairVars { } } + pub fn clear_in_sim(&self, sim: &mut impl Simulator) { + for sym in self.change.iter() { + sim.set(*sym, &Value::from_u64(0)); + } + for sym in self.free.iter() { + sim.set(*sym, &Value::from_u64(0)); + } + } + pub fn to_json(&self, ctx: &Context, assignment: &RepairAssignment) -> serde_json::Value { //let mut out = IndexMap::with_capacity(self.change.len() + self.free.len()); let mut out = serde_json::Map::with_capacity(self.change.len() + self.free.len());