From 4a7dd26e7bee982dabbc3e18757a8b0cc80dd609 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Tue, 4 Apr 2023 17:41:49 -0700 Subject: [PATCH] write_path_spice Signed-off-by: James Cherry --- search/WritePathSpice.cc | 28 +++++++++++++++++++++------- tcl/Search.tcl | 24 ++++++++++++------------ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/search/WritePathSpice.cc b/search/WritePathSpice.cc index 538a3709..99ec69df 100644 --- a/search/WritePathSpice.cc +++ b/search/WritePathSpice.cc @@ -170,6 +170,8 @@ private: float slewAxisMinValue(TimingArc *arc); float pgPortVoltage(LibertyPgPort *pg_port); void writePrintStmt(); + float railToRailSlew(float slew, + const RiseFall *rf); // Stage "accessors". // @@ -408,11 +410,21 @@ WritePathSpice::maxTime() else { float end_slew = findSlew(path_); float arrival = delayAsFloat(path_->arrival(this)); - float max_time = input_slew + arrival + end_slew; + float max_time = railToRailSlew(input_slew, rf) + arrival + + railToRailSlew(end_slew, rf); return max_time; } } +float +WritePathSpice::railToRailSlew(float slew, + const RiseFall *rf) +{ + float lower = default_library_->slewLowerThreshold(rf); + float upper = default_library_->slewUpperThreshold(rf); + return slew / (upper - lower); +} + void WritePathSpice::writeStageInstances() { @@ -492,8 +504,11 @@ WritePathSpice::writeInputWaveform() const RiseFall *rf = input_path->transition(this); TimingArc *next_arc = stageGateArc(input_stage + 1); float slew0 = findSlew(input_path, rf, next_arc); - // Arbitrary offset. - float time0 = slew0; + + float threshold = default_library_->inputThreshold(rf); + float dt = railToRailSlew(slew0, rf); + float time0 = dt * threshold; + int volt_index = 1; const Pin *drvr_pin = stageDrvrPin(input_stage); const Pin *load_pin = stageLoadPin(input_stage); @@ -689,12 +704,11 @@ WritePathSpice::writeWaveformEdge(const RiseFall *rf, volt1 = gnd_voltage_; } float threshold = default_library_->inputThreshold(rf); - float lower = default_library_->slewLowerThreshold(rf); - float upper = default_library_->slewUpperThreshold(rf); - float dt = slew / (upper - lower); + float dt = railToRailSlew(slew, rf); float time0 = time - dt * threshold; float time1 = time0 + dt; - streamPrint(spice_stream_, "+%.3e %.3e\n", time0, volt0); + if (time0 > 0.0) + streamPrint(spice_stream_, "+%.3e %.3e\n", time0, volt0); streamPrint(spice_stream_, "+%.3e %.3e\n", time1, volt1); } diff --git a/tcl/Search.tcl b/tcl/Search.tcl index 69b8af13..7b2a40ea 100644 --- a/tcl/Search.tcl +++ b/tcl/Search.tcl @@ -249,7 +249,7 @@ proc report_delays_wrt_clk { vertex what clk clk_rf } { set rise_fmt [format_delays $rise] set fall_fmt [format_delays $fall] if {$clk != "NULL"} { - set clk_str " ([get_name $clk] [rise_fall_short_name $clk_rf])" + set clk_str " ([get_name $clk] [rf_short_name $clk_rf])" } else { set clk_str "" } @@ -281,7 +281,7 @@ proc report_wrt_clk { vertex what clk clk_rf } { set rise_fmt [format_times $rise $sta_report_default_digits] set fall_fmt [format_times $fall $sta_report_default_digits] if {$clk != "NULL"} { - set clk_str " ([get_name $clk] [rise_fall_short_name $clk_rf])" + set clk_str " ([get_name $clk] [rf_short_name $clk_rf])" } else { set clk_str "" } @@ -289,16 +289,6 @@ proc report_wrt_clk { vertex what clk clk_rf } { } } -proc rise_fall_short_name { rf } { - if { $rf == "rise" } { - return [rise_short_name] - } elseif { $rf == "fall" } { - return [fall_short_name] - } else { - error "unknown transition name $rf" - } -} - proc times_are_inf { times } { foreach time $times { if { $time < 1e+10 && $time > -1e+10 } { @@ -1164,6 +1154,16 @@ proc max_fanout_check_slack_limit {} { ################################################################ +proc rf_short_name { rf } { + if { [rf_is_rise $rf] } { + return [rise_short_name] + } elseif { [rf_is_fall $rf] } { + return [fall_short_name] + } else { + error "unknown transition name $rf" + } +} + proc opposite_rf { rf } { if { [rf_is_rise $rf] } { return "fall"