Skip to content

Commit

Permalink
fix(simulation): standardize ngspice and spectre transient data forma…
Browse files Browse the repository at this point in the history
…ts (#327)
  • Loading branch information
rohanku authored Nov 26, 2023
1 parent 21f2437 commit 0aa42d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
27 changes: 3 additions & 24 deletions tools/ngspice/src/tran.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use rust_decimal::Decimal;
use scir::{NamedSliceOne, SliceOnePath};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::ops::Deref;
use std::sync::Arc;
use substrate::io::{NodePath, TerminalPath};
use substrate::schematic::conv::ConvertedNodePath;
Expand Down Expand Up @@ -65,34 +64,14 @@ impl Save<Ngspice, Tran, ()> for Output {
}
}

/// The time points of a transient simulation.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TranTime(pub(crate) Arc<Vec<f64>>);

impl Deref for TranTime {
type Target = Vec<f64>;
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl FromSaved<Ngspice, Tran> for TranTime {
impl FromSaved<Ngspice, Tran> for tran::Time {
type SavedKey = ();
fn from_saved(output: &<Tran as Analysis>::Output, _key: Self::SavedKey) -> Self {
TranTime(output.time.clone())
}
}

impl<T: ExportsNestedData> Save<Ngspice, Tran, &Cell<T>> for TranTime {
fn save(
_ctx: &SimulationContext<Ngspice>,
_to_save: &Cell<T>,
_opts: &mut <Ngspice as Simulator>::Options,
) -> Self::SavedKey {
tran::Time(output.time.clone())
}
}

impl Save<Ngspice, Tran, ()> for TranTime {
impl Save<Ngspice, Tran, ()> for tran::Time {
fn save(
_ctx: &SimulationContext<Ngspice>,
_to_save: (),
Expand Down
9 changes: 0 additions & 9 deletions tools/spectre/src/tran.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ impl FromSaved<Spectre, Tran> for tran::Time {
}
}

impl<T: ExportsNestedData> Save<Spectre, Tran, &Cell<T>> for tran::Time {
fn save(
_ctx: &SimulationContext<Spectre>,
_to_save: &Cell<T>,
_opts: &mut <Spectre as Simulator>::Options,
) -> Self::SavedKey {
}
}

impl Save<Spectre, Tran, ()> for tran::Time {
fn save(
_ctx: &SimulationContext<Spectre>,
Expand Down

0 comments on commit 0aa42d6

Please sign in to comment.