diff --git a/dcalc/ArnoldiDelayCalc.cc b/dcalc/ArnoldiDelayCalc.cc index 97866a79..2523686e 100644 --- a/dcalc/ArnoldiDelayCalc.cc +++ b/dcalc/ArnoldiDelayCalc.cc @@ -236,7 +236,6 @@ private: int pin_n_; ArnoldiReduce *reduce_; delay_work *delay_work_; - std::vector unsaved_parasitics_; }; ArcDelayCalc * @@ -247,6 +246,7 @@ makeArnoldiDelayCalc(StaState *sta) ArnoldiDelayCalc::ArnoldiDelayCalc(StaState *sta) : LumpedCapDelayCalc(sta), + rcmodel_(nullptr), reduce_(new ArnoldiReduce(sta)), delay_work_(delay_work_create()) { @@ -267,6 +267,7 @@ ArnoldiDelayCalc::~ArnoldiDelayCalc() free(_delayV); free(_slewV); delete reduce_; + delete rcmodel_; } Parasitic * @@ -297,12 +298,11 @@ ArnoldiDelayCalc::findParasitic(const Pin *drvr_pin, } if (parasitic_network) { - rcmodel *rcmodel = reduce_->reduceToArnoldi(parasitic_network, drvr_pin, - parasitics->couplingCapFactor(), - drvr_rf, scene, min_max); + rcmodel_ = reduce_->reduceToArnoldi(parasitic_network, drvr_pin, + parasitics->couplingCapFactor(), + drvr_rf, scene, min_max); // Arnoldi parasitics are their own class that are not saved in the parasitic db. - unsaved_parasitics_.push_back(rcmodel); - parasitic = rcmodel; + parasitic = rcmodel_; } return parasitic; } @@ -321,9 +321,8 @@ ArnoldiDelayCalc::reduceParasitic(const Parasitic *, void ArnoldiDelayCalc::finishDrvrPin() { - for (auto parasitic : unsaved_parasitics_) - delete parasitic; - unsaved_parasitics_.clear(); + delete rcmodel_; + rcmodel_ = nullptr; } ArcDcalcResult diff --git a/dcalc/CcsCeffDelayCalc.cc b/dcalc/CcsCeffDelayCalc.cc index 6ca9cb96..fec6f032 100644 --- a/dcalc/CcsCeffDelayCalc.cc +++ b/dcalc/CcsCeffDelayCalc.cc @@ -445,14 +445,13 @@ CcsCeffDelayCalc::findVlTime(double v, { double t_init = region_ramp_times_[0]; double t_final = region_ramp_times_[region_count_]; - bool root_fail = false; - double time = findRoot( - [&](double t, double &y, double &dy) { - vl(t, elmore, y, dy); - y -= v; - }, - t_init, t_final + elmore * 3.0, .001, 20, root_fail); - vl_fail_ |= root_fail; + auto [time, failed] = + findRoot([&](double t, double &y, double &dy) { + vl(t, elmore, y, dy); + y -= v; + }, + t_init, t_final + elmore * 3.0, .001, 20); + vl_fail_ |= failed; return time; } diff --git a/dcalc/DmpCeff.cc b/dcalc/DmpCeff.cc index 6828aa67..108bf798 100644 --- a/dcalc/DmpCeff.cc +++ b/dcalc/DmpCeff.cc @@ -33,9 +33,12 @@ #include "DmpCeff.hh" #include +#include #include -#include +#include #include +#include +#include #include "Format.hh" #include "Report.hh" @@ -52,15 +55,6 @@ namespace sta { -// Tolerance (as a scale of value) for driver parameters (Ceff, delta t, t0). -static const double driver_param_tol = .01; -// Waveform threshold crossing time tolerance (1.0 = 100%). -static const double vth_time_tol = .01; -// A small number used by luDecomp. -static const double tiny_double = 1.0e-20; -// Max iterations for findRoot. -static const int find_root_max_iter = 20; - // Indices of Newton-Raphson parameter vector. enum DmpParam { t0, dt, ceff }; @@ -92,30 +86,6 @@ gateModelRd(const LibertyCell *cell, double c2, double c1, const Pvt *pvt); -static void -newtonRaphson(const int max_iter, - double x[], - const int n, - const double x_tol, - // eval(state) is called to fill fvec and fjac. - std::function eval, - // Temporaries supplied by caller. - double *fvec, - double **fjac, - int *index, - double *p, - double *scale); -static void -luSolve(double **a, - const int size, - const int *index, - double b[]); -static void -luDecomp(double **a, - const int size, - int *index, - double *scale); - //////////////////////////////////////////////////////////////// // Base class for Dartu/Menezes/Pileggi algorithm. @@ -138,51 +108,32 @@ public: double c2, double rpi, double c1); - virtual void gateDelaySlew(// Return values. - double &delay, - double &slew) = 0; - virtual void loadDelaySlew(const Pin *load_pin, - double elmore, - // Return values. - double &delay, - double &slew); + virtual std::pair gateDelaySlew() = 0; + virtual std::pair loadDelaySlew(const Pin *load_pin, + double elmore); double ceff() { return ceff_; } // Given x_ as a vector of input parameters, fill fvec_ with the // equations evaluated at x_ and fjac_ with the jabobian evaluated at x_. virtual void evalDmpEqns() = 0; - // Output response to vs(t) ramp driving pi model load. - void Vo(double t, - // Return values. - double &vo, - double &dol_dt); - // Load response to driver waveform. - void Vl(double t, - // Return values. - double &vl, - double &dvl_dt); + // Output response to vs(t) ramp driving pi model load (vo, dvo_dt). + std::pair Vo(double t); + // Load response to driver waveform (vl, dvl/dt). + std::pair Vl(double t); protected: + void luDecomp(); + void luSolve(); + void newtonRaphson(); // Find driver parameters t0, delta_t, Ceff. void findDriverParams(double ceff); - void gateCapDelaySlew(double cl, - // Return values. - double &delay, - double &slew); - void gateDelays(double ceff, - // Return values. - double &t_vth, - double &t_vl, - double &slew); - // Partial derivatives of y(t) (jacobian). - void dy(double t, - double t0, - double dt, - double cl, - // Return values. - double &dydt0, - double &dyddt, - double &dydcl); + std::pair gateCapDelaySlew(double cl); + std::tuple gateDelays(double ceff); + // Partial derivatives of y(t) jacobian (dydt0, dyddt, dydcl). + std::tuple dy(double t, + double t0, + double dt, + double cl); double y0dt(double t, double cl); double y0dcl(double t, @@ -190,9 +141,7 @@ protected: void showX(); void showFvec(); void showJacobian(); - void findDriverDelaySlew( // Return values. - double &delay, - double &slew); + std::pair findDriverDelaySlew(); double findVoCrossing(double vth, double lower_bound, double upper_bound); @@ -203,26 +152,22 @@ protected: void showVl(); void fail(std::string_view reason); - // Output response to vs(t) ramp driving capacitive load. - double y(double t, - double t0, - double dt, - double cl); + // Output response to vs(t) ramp driving capacitive load (y, t1). + std::pair y(double t, + double t0, + double dt, + double cl); // Output response to unit ramp driving capacitive load. double y0(double t, double cl); // Output response to unit ramp driving pi model load. - virtual void V0(double t, - // Return values. - double &vo, - double &dvo_dt) = 0; + // Unit ramp output at pi load (vo, dvo_dt). + virtual std::pair V0(double t) = 0; // Upper bound on time that vo crosses vh. virtual double voCrossingUpperBound() = 0; // Load responce to driver unit ramp. - virtual void Vl0(double t, - // Return values. - double &vl, - double &dvl_dt) = 0; + // Unit ramp load response (vl, dvl_dt). + virtual std::pair Vl0(double t) = 0; // Upper bound on time that vl crosses vh. double vlCrossingUpperBound(); @@ -257,13 +202,12 @@ protected: static constexpr int max_nr_order_ = 3; - double x_[max_nr_order_]; - double fvec_[max_nr_order_]; - double fjac_storage_[max_nr_order_ * max_nr_order_]; - double *fjac_[max_nr_order_]; - double scale_[max_nr_order_]; - double p_[max_nr_order_]; - int index_[max_nr_order_]; + std::array x_; + std::array fvec_; + std::array, max_nr_order_> fjac_; + std::array scale_; + std::array p_; + std::array index_; // Driver slew used to check load delay. double drvr_slew_; @@ -273,6 +217,16 @@ protected: // Load rspf elmore delay. double elmore_; double p3_; + + // Tolerance (as a scale of value) for driver parameters (Ceff, delta t, t0). + static constexpr double driver_param_tol_ = .01; + // Waveform threshold crossing time tolerance (1.0 = 100%). + static constexpr double vth_time_tol_ = .01; + // Max iterations for findRoot. + static constexpr int find_root_max_iter_ = 20; + static inline int newton_raphson_max_iter_ = 100; + // A small number used by luDecomp. + static constexpr double tiny_double_ = 1.0e-20; }; DmpAlg::DmpAlg(int nr_order, @@ -283,9 +237,6 @@ DmpAlg::DmpAlg(int nr_order, c1_(0.0), nr_order_(nr_order) { - for (int i = 0; i < nr_order_; i++) - // Only use the upper left block of the matrix - fjac_[i] = fjac_storage_ + i * max_nr_order_; } void @@ -323,16 +274,13 @@ DmpAlg::findDriverParams(double ceff) { if (nr_order_ == 3) x_[DmpParam::ceff] = ceff; - double t_vth, t_vl, slew; - gateDelays(ceff, t_vth, t_vl, slew); + auto [t_vth, t_vl, slew] = gateDelays(ceff); // Scale slew to 0-100% double dt = slew / (vh_ - vl_); double t0 = t_vth + std::log(1.0 - vth_) * rd_ * ceff - vth_ * dt; x_[DmpParam::dt] = dt; x_[DmpParam::t0] = t0; - newtonRaphson( - 100, x_, nr_order_, driver_param_tol, [this]() { evalDmpEqns(); }, fvec_, - fjac_, index_, p_, scale_); + newtonRaphson(); t0_ = x_[DmpParam::t0]; dt_ = x_[DmpParam::dt]; debugPrint(debug_, "dmp_ceff", 3, " t0 = {} dt = {} ceff = {}", @@ -342,45 +290,43 @@ DmpAlg::findDriverParams(double ceff) showVo(); } -void -DmpAlg::gateCapDelaySlew(double ceff, - // Return values. - double &delay, - double &slew) +std::pair +DmpAlg::gateCapDelaySlew(double ceff) { float model_delay, model_slew; gate_model_->gateDelay(pvt_, in_slew_, ceff, model_delay, model_slew); - delay = model_delay; - slew = model_slew; + double delay = model_delay; + double slew = model_slew; + return {delay, slew}; } -void -DmpAlg::gateDelays(double ceff, - // Return values. - double &t_vth, - double &t_vl, - double &slew) +std::tuple +DmpAlg::gateDelays(double ceff) { - double table_slew; - gateCapDelaySlew(ceff, t_vth, table_slew); + auto [t_vth, table_slew] = gateCapDelaySlew(ceff); // Convert reported/table slew to measured slew. - slew = table_slew * slew_derate_; - t_vl = t_vth - slew * (vth_ - vl_) / (vh_ - vl_); + double slew = table_slew * slew_derate_; + double t_vl = t_vth - slew * (vth_ - vl_) / (vh_ - vl_); + return {t_vth, t_vl, slew}; } -double +std::pair DmpAlg::y(double t, double t0, double dt, double cl) { double t1 = t - t0; - if (t1 <= 0.0) - return 0.0; - else if (t1 <= dt) - return y0(t1, cl) / dt; - else - return (y0(t1, cl) - y0(t1 - dt, cl)) / dt; + if (t1 <= 0.0) { + double y = 0.0; + return {y, t1}; + } + if (t1 <= dt) { + double y = y0(t1, cl) / dt; + return {y, t1}; + } + double y = (y0(t1, cl) - y0(t1 - dt, cl)) / dt; + return {y, t1}; } double @@ -390,29 +336,29 @@ DmpAlg::y0(double t, return t - rd_ * cl * (1.0 - exp2(-t / (rd_ * cl))); } -void +std::tuple DmpAlg::dy(double t, double t0, double dt, - double cl, - // Return values. - double &dydt0, - double &dyddt, - double &dydcl) + double cl) { double t1 = t - t0; - if (t1 <= 0.0) - dydt0 = dyddt = dydcl = 0.0; - else if (t1 <= dt) { - dydt0 = -y0dt(t1, cl) / dt; - dyddt = -y0(t1, cl) / (dt * dt); - dydcl = y0dcl(t1, cl) / dt; + if (t1 <= 0.0) { + double dydt0 = 0.0; + double dyddt = 0.0; + double dydcl = 0.0; + return {dydt0, dyddt, dydcl}; } - else { - dydt0 = -(y0dt(t1, cl) - y0dt(t1 - dt, cl)) / dt; - dyddt = -(y0(t1, cl) + y0(t1 - dt, cl)) / (dt * dt) + y0dt(t1 - dt, cl) / dt; - dydcl = (y0dcl(t1, cl) - y0dcl(t1 - dt, cl)) / dt; + if (t1 <= dt) { + double dydt0 = -y0dt(t1, cl) / dt; + double dyddt = -y0(t1, cl) / (dt * dt); + double dydcl = y0dcl(t1, cl) / dt; + return {dydt0, dyddt, dydcl}; } + double dydt0 = -(y0dt(t1, cl) - y0dt(t1 - dt, cl)) / dt; + double dyddt = -(y0(t1, cl) + y0(t1 - dt, cl)) / (dt * dt) + y0dt(t1 - dt, cl) / dt; + double dydcl = (y0dcl(t1, cl) - y0dcl(t1 - dt, cl)) / dt; + return {dydt0, dyddt, dydcl}; } double @@ -459,17 +405,16 @@ DmpAlg::showJacobian() } } -void -DmpAlg::findDriverDelaySlew( // Return values. - double &delay, - double &slew) +std::pair +DmpAlg::findDriverDelaySlew() { double t_upper = voCrossingUpperBound(); - delay = findVoCrossing(vth_, t0_, t_upper); + double delay = findVoCrossing(vth_, t0_, t_upper); double tl = findVoCrossing(vl_, t0_, delay); double th = findVoCrossing(vh_, delay, t_upper); // Convert measured slew to table slew. - slew = (th - tl) / slew_derate_; + double slew = (th - tl) / slew_derate_; + return {delay, slew}; } // Find t such that vo(t)=v. @@ -479,47 +424,40 @@ DmpAlg::findVoCrossing(double vth, double t_upper) { FindRootFunc vo_func = [&](double t, double &y, double &dy) { - double vo, vo_dt; - Vo(t, vo, vo_dt); + auto [vo, dvo_dt] = Vo(t); y = vo - vth; - dy = vo_dt; + dy = dvo_dt; }; - bool fail; - double t_vth = - findRoot(vo_func, t_lower, t_upper, vth_time_tol, find_root_max_iter, fail); - if (fail) + auto [t_vth, failed] = findRoot(vo_func, t_lower, t_upper, vth_time_tol_, + find_root_max_iter_); + if (failed) throw DmpError("find Vo crossing failed"); return t_vth; } -void -DmpAlg::Vo(double t, - // Return values. - double &vo, - double &dvo_dt) +std::pair +DmpAlg::Vo(double t) { double t1 = t - t0_; if (t1 <= 0.0) { - vo = 0.0; - dvo_dt = 0.0; + double vo = 0.0; + double dvo_dt = 0.0; + return {vo, dvo_dt}; } - else if (t1 <= dt_) { - double v0, dv0_dt; - V0(t1, v0, dv0_dt); + if (t1 <= dt_) { + auto [v0, dv0_dt] = V0(t1); - vo = v0 / dt_; - dvo_dt = dv0_dt / dt_; + double vo = v0 / dt_; + double dvo_dt = dv0_dt / dt_; + return {vo, dvo_dt}; } - else { - double v0, dv0_dt; - V0(t1, v0, dv0_dt); + auto [v0, dv0_dt] = V0(t1); - double v0_dt, dv0_dt_dt; - V0(t1 - dt_, v0_dt, dv0_dt_dt); + auto [v0_dt, dv0_dt_dt] = V0(t1 - dt_); - vo = (v0 - v0_dt) / dt_; - dvo_dt = (dv0_dt - dv0_dt_dt) / dt_; - } + double vo = (v0 - v0_dt) / dt_; + double dvo_dt = (dv0_dt - dv0_dt_dt) / dt_; + return {vo, dvo_dt}; } void @@ -527,63 +465,57 @@ DmpAlg::showVo() { report_->report(" t vo(t)"); double ub = voCrossingUpperBound(); - for (double t = t0_; t < t0_ + ub; t += dt_ / 10.0) { - double vo, dvo_dt; - Vo(t, vo, dvo_dt); - report_->report(" {:g} {:g}", t, vo); - } + for (double t = t0_; t < t0_ + ub; t += dt_ / 10.0) + report_->report(" {:g} {:g}", t, Vo(t).first); } -void +std::pair DmpAlg::loadDelaySlew(const Pin *, - double elmore, - double &delay, - double &slew) + double elmore) { if (!driver_valid_ || elmore == 0.0 // Elmore delay is small compared to driver slew. || elmore < drvr_slew_ * 1e-3) { - delay = elmore; - slew = drvr_slew_; + double delay = elmore; + double slew = drvr_slew_; + return {delay, slew}; } - else { - // Use the driver thresholds and rely on thresholdAdjust to - // convert the delay and slew to the load's thresholds. - try { - elmore_ = elmore; - p3_ = 1.0 / elmore; - if (debug_->check("dmp_ceff", 4)) - showVl(); - double t_lower = t0_; - double t_upper = vlCrossingUpperBound(); - double load_delay = findVlCrossing(vth_, t_lower, t_upper); - double tl = findVlCrossing(vl_, t_lower, load_delay); - double th = findVlCrossing(vh_, load_delay, t_upper); - // Measure delay from Vo, the load dependent source excitation. - double delay1 = load_delay - vo_delay_; - // Convert measured slew to reported/table slew. - double slew1 = (th - tl) / slew_derate_; - if (delay1 < 0.0) { - // Only report a problem if the difference is significant. - if (-delay1 > vth_time_tol * vo_delay_) - fail("load delay less than zero"); - // Use elmore delay. - delay1 = elmore; - } - if (slew1 < drvr_slew_) { - // Only report a problem if the difference is significant. - if ((drvr_slew_ - slew1) > vth_time_tol * drvr_slew_) - fail("load slew less than driver slew"); - slew1 = drvr_slew_; - } - delay = delay1; - slew = slew1; - } catch (DmpError &error) { - fail(error.what()); - delay = elmore_; + // Use the driver thresholds and rely on thresholdAdjust to + // convert the delay and slew to the load's thresholds. + try { + elmore_ = elmore; + p3_ = 1.0 / elmore; + if (debug_->check("dmp_ceff", 4)) + showVl(); + double t_lower = t0_; + double t_upper = vlCrossingUpperBound(); + double load_delay = findVlCrossing(vth_, t_lower, t_upper); + double tl = findVlCrossing(vl_, t_lower, load_delay); + double th = findVlCrossing(vh_, load_delay, t_upper); + // Measure delay from Vo, the load dependent source excitation. + double delay = load_delay - vo_delay_; + // Convert measured slew to reported/table slew. + double slew = (th - tl) / slew_derate_; + if (delay < 0.0) { + // Only report a problem if the difference is significant. + if (-delay > vth_time_tol_ * vo_delay_) + fail("load delay less than zero"); + // Use elmore delay. + delay = elmore; + } + if (slew < drvr_slew_) { + // Only report a problem if the difference is significant. + if ((drvr_slew_ - slew) > vth_time_tol_ * drvr_slew_) + fail("load slew less than driver slew"); slew = drvr_slew_; } + return {delay, slew}; + } catch (DmpError &error) { + fail(error.what()); + double delay = elmore_; + double slew = drvr_slew_; + return {delay, slew}; } } @@ -594,15 +526,13 @@ DmpAlg::findVlCrossing(double vth, double t_upper) { FindRootFunc vl_func = [&](double t, double &y, double &dy) { - double vl, vl_dt; - Vl(t, vl, vl_dt); + auto [vl, vl_dt] = Vl(t); y = vl - vth; dy = vl_dt; }; - bool fail; - double t_vth = - findRoot(vl_func, t_lower, t_upper, vth_time_tol, find_root_max_iter, fail); - if (fail) + auto [t_vth, failed] = findRoot(vl_func, t_lower, t_upper, vth_time_tol_, + find_root_max_iter_); + if (failed) throw DmpError("find Vl crossing failed"); return t_vth; } @@ -613,33 +543,23 @@ DmpAlg::vlCrossingUpperBound() return voCrossingUpperBound() + elmore_ * 2.0; } -void -DmpAlg::Vl(double t, - // Return values. - double &vl, - double &dvl_dt) +std::pair +DmpAlg::Vl(double t) { double t1 = t - t0_; - if (t1 <= 0.0) { - vl = 0.0; - dvl_dt = 0.0; + if (t1 <= 0.0) + return {0.0, 0.0}; + if (t1 <= dt_) { + auto [vl0, dvl0_dt] = Vl0(t1); + return {vl0 / dt_, dvl0_dt / dt_}; } - else if (t1 <= dt_) { - double vl0, dvl0_dt; - Vl0(t1, vl0, dvl0_dt); - vl = vl0 / dt_; - dvl_dt = dvl0_dt / dt_; - } - else { - double vl0, dvl0_dt; - Vl0(t1, vl0, dvl0_dt); + auto [vl0, dvl0_dt] = Vl0(t1); - double vl0_dt, dvl0_dt_dt; - Vl0(t1 - dt_, vl0_dt, dvl0_dt_dt); + auto [vl0_dt, dvl0_dt_dt] = Vl0(t1 - dt_); - vl = (vl0 - vl0_dt) / dt_; - dvl_dt = (dvl0_dt - dvl0_dt_dt) / dt_; - } + double vl = (vl0 - vl0_dt) / dt_; + double dvl_dt = (dvl0_dt - dvl0_dt_dt) / dt_; + return {vl, dvl_dt}; } void @@ -647,11 +567,8 @@ DmpAlg::showVl() { report_->report(" t vl(t)"); double ub = vlCrossingUpperBound(); - for (double t = t0_; t < t0_ + ub * 2.0; t += ub / 10.0) { - double vl, dvl_dt; - Vl(t, vl, dvl_dt); - report_->report(" {:g} {:g}", t, vl); - } + for (double t = t0_; t < t0_ + ub * 2.0; t += ub / 10.0) + report_->report(" {:g} {:g}", t, Vl(t).first); } void @@ -684,26 +601,15 @@ public: double c2, double rpi, double c1) override; - void gateDelaySlew(// Return values. - double &delay, - double &slew) override; - void loadDelaySlew(const Pin *, - double elmore, - // Return values. - double &delay, - double &slew) override; + std::pair gateDelaySlew() override; + std::pair loadDelaySlew(const Pin *, + double elmore) override; void evalDmpEqns() override; double voCrossingUpperBound() override; private: - void V0(double t, - // Return values. - double &vo, - double &dvo_dt) override; - void Vl0(double t, - // Return values. - double &vl, - double &dvl_dt) override; + std::pair V0(double t) override; + std::pair Vl0(double t) override; }; DmpCap::DmpCap(StaState *sta) : @@ -730,25 +636,23 @@ DmpCap::init(const LibertyLibrary *drvr_library, ceff_ = c1 + c2; } -void -DmpCap::gateDelaySlew(// Return values. - double &delay, - double &slew) +std::pair +DmpCap::gateDelaySlew() { debugPrint(debug_, "dmp_ceff", 3, " ceff = {}", units_->capacitanceUnit()->asString(ceff_)); - gateCapDelaySlew(ceff_, delay, slew); + auto [delay, slew] = gateCapDelaySlew(ceff_); drvr_slew_ = slew; + return {delay, slew}; } -void +std::pair DmpCap::loadDelaySlew(const Pin *, - double elmore, - double &delay, - double &slew) + double elmore) { - delay = elmore; - slew = drvr_slew_; + double delay = elmore; + double slew = drvr_slew_; + return {delay, slew}; } void @@ -756,14 +660,12 @@ DmpCap::evalDmpEqns() { } -void -DmpCap::V0(double, - // Return values. - double &vo, - double &dvo_dt) +std::pair +DmpCap::V0(double) { - vo = 0.0; - dvo_dt = 0.0; + double vo = 0.0; + double dvo_dt = 0.0; + return {vo, dvo_dt}; } double @@ -772,14 +674,12 @@ DmpCap::voCrossingUpperBound() return 0.0; } -void -DmpCap::Vl0(double, - // Return values. - double &vl, - double &dvl_dt) +std::pair +DmpCap::Vl0(double) { - vl = 0.0; - dvl_dt = 0.0; + double vl = 0.0; + double dvl_dt = 0.0; + return {vl, dvl_dt}; } //////////////////////////////////////////////////////////////// @@ -800,9 +700,7 @@ public: double c2, double rpi, double c1) override; - void gateDelaySlew(// Return values. - double &delay, - double &slew) override; + std::pair gateDelaySlew() override; void evalDmpEqns() override; double voCrossingUpperBound() override; @@ -812,14 +710,8 @@ private: double dt, double ceff_time, double ceff); - void V0(double t, - // Return values. - double &vo, - double &dvo_dt) override; - void Vl0(double t, - // Return values. - double &vl, - double &dvl_dt) override; + std::pair V0(double t) override; + std::pair Vl0(double t) override; // Poles/zero. double p1_; @@ -891,22 +783,20 @@ DmpPi::init(const LibertyLibrary *drvr_library, D_ = (z_ - p2_) / (p2_ * (p2_ - p1_)); } -void -DmpPi::gateDelaySlew(// Return values. - double &delay, - double &slew) +std::pair +DmpPi::gateDelaySlew() { driver_valid_ = false; + double delay = 0.0; + double slew = 0.0; try { findDriverParamsPi(); ceff_ = x_[DmpParam::ceff]; - double table_delay, table_slew; - gateCapDelaySlew(ceff_, table_delay, table_slew); + auto [table_delay, table_slew] = gateCapDelaySlew(ceff_); delay = table_delay; // slew = table_slew; try { - double vo_delay, vo_slew; - findDriverDelaySlew(vo_delay, vo_slew); + auto [vo_delay, vo_slew] = findDriverDelaySlew(); driver_valid_ = true; // Save Vo delay to measure load wire delay waveform. vo_delay_ = vo_delay; @@ -921,9 +811,10 @@ DmpPi::gateDelaySlew(// Return values. fail(error.what()); // Driver calculation failed - use Ceff=c1+c2. ceff_ = c1_ + c2_; - gateCapDelaySlew(ceff_, delay, slew); + std::tie(delay, slew) = gateCapDelaySlew(ceff_); } drvr_slew_ = slew; + return {delay, slew}; } void @@ -950,8 +841,7 @@ DmpPi::evalDmpEqns() if (ceff > (c1_ + c2_)) throw DmpError("eqn eval failed: ceff > c2 + c1"); - double t_vth, t_vl, slew; - gateDelays(ceff, t_vth, t_vl, slew); + auto [t_vth, t_vl, slew] = gateDelays(ceff); if (slew == 0.0) throw DmpError("eqn eval failed: slew = 0"); @@ -966,9 +856,9 @@ DmpPi::evalDmpEqns() double exp_p2_dt = exp2(-p2_ * dt); double exp_dt_rd_ceff = exp2(-dt / (rd_ * ceff)); - double y50 = y(t_vth, t0, dt, ceff); + double y50 = y(t_vth, t0, dt, ceff).first; // Match Vl. - double y20 = y(t_vl, t0, dt, ceff); + double y20 = y(t_vl, t0, dt, ceff).first; fvec_[DmpFunc::ipi] = ipiIceff(t0, dt, ceff_time, ceff); fvec_[DmpFunc::y50] = y50 - vth_; fvec_[DmpFunc::y20] = y20 - vl_; @@ -983,11 +873,13 @@ DmpPi::evalDmpEqns() (2 * rd_ * ceff - dt - (2 * rd_ * ceff + dt) * exp2(-dt / (rd_ * ceff))) / (dt * dt); - dy(t_vl, t0, dt, ceff, fjac_[DmpFunc::y20][DmpParam::t0], - fjac_[DmpFunc::y20][DmpParam::dt], fjac_[DmpFunc::y20][DmpParam::ceff]); + std::tie(fjac_[DmpFunc::y20][DmpParam::t0], + fjac_[DmpFunc::y20][DmpParam::dt], + fjac_[DmpFunc::y20][DmpParam::ceff]) = dy(t_vl, t0, dt, ceff); - dy(t_vth, t0, dt, ceff, fjac_[DmpFunc::y50][DmpParam::t0], - fjac_[DmpFunc::y50][DmpParam::dt], fjac_[DmpFunc::y50][DmpParam::ceff]); + std::tie(fjac_[DmpFunc::y50][DmpParam::t0], + fjac_[DmpFunc::y50][DmpParam::dt], + fjac_[DmpFunc::y50][DmpParam::ceff]) = dy(t_vth, t0, dt, ceff); if (debug_->check("dmp_ceff", 4)) { showX(); @@ -1016,23 +908,18 @@ DmpPi::ipiIceff(double, return ipi - iceff; } -void -DmpPi::V0(double t, - // Return values. - double &vo, - double &dvo_dt) +std::pair +DmpPi::V0(double t) { double exp_p1 = exp2(-p1_ * t); double exp_p2 = exp2(-p2_ * t); - vo = k0_ * (k1_ + k2_ * t + k3_ * exp_p1 + k4_ * exp_p2); - dvo_dt = k0_ * (k2_ - k3_ * p1_ * exp_p1 - k4_ * p2_ * exp_p2); + double vo = k0_ * (k1_ + k2_ * t + k3_ * exp_p1 + k4_ * exp_p2); + double dvo_dt = k0_ * (k2_ - k3_ * p1_ * exp_p1 - k4_ * p2_ * exp_p2); + return {vo, dvo_dt}; } -void -DmpPi::Vl0(double t, - // Return values. - double &vl, - double &dvl_dt) +std::pair +DmpPi::Vl0(double t) { double D1 = k0_ * (k1_ - k2_ / p3_); double D3 = -p3_ * k0_ * k3_ / (p1_ - p3_); @@ -1042,8 +929,9 @@ DmpPi::Vl0(double t, double exp_p1 = exp2(-p1_ * t); double exp_p2 = exp2(-p2_ * t); double exp_p3 = exp2(-p3_ * t); - vl = D1 + t + D3 * exp_p1 + D4 * exp_p2 + D5 * exp_p3; - dvl_dt = 1.0 - D3 * p1_ * exp_p1 - D4 * p2_ * exp_p2 - D5 * p3_ * exp_p3; + double vl = D1 + t + D3 * exp_p1 + D4 * exp_p2 + D5 * exp_p3; + double dvl_dt = 1.0 - D3 * p1_ * exp_p1 - D4 * p2_ * exp_p2 - D5 * p3_ * exp_p3; + return {vl, dvl_dt}; } double @@ -1076,25 +964,27 @@ DmpOnePole::evalDmpEqns() double t0 = x_[DmpParam::t0]; double dt = x_[DmpParam::dt]; - double t_vth, t_vl, ignore1, ignore2; - gateDelays(ceff_, t_vth, t_vl, ignore1); + auto [t_vth, t_vl, ignore1] = gateDelays(ceff_); + double ignore2; if (dt <= 0.0) dt = x_[DmpParam::dt] = (t_vl - t_vth) / 100; - fvec_[DmpFunc::y50] = y(t_vth, t0, dt, ceff_) - vth_; - fvec_[DmpFunc::y20] = y(t_vl, t0, dt, ceff_) - vl_; + fvec_[DmpFunc::y50] = y(t_vth, t0, dt, ceff_).first - vth_; + fvec_[DmpFunc::y20] = y(t_vl, t0, dt, ceff_).first - vl_; if (debug_->check("dmp_ceff", 4)) { showX(); showFvec(); } - dy(t_vl, t0, dt, ceff_, fjac_[DmpFunc::y20][DmpParam::t0], - fjac_[DmpFunc::y20][DmpParam::dt], ignore2); + std::tie(fjac_[DmpFunc::y20][DmpParam::t0], + fjac_[DmpFunc::y20][DmpParam::dt], + ignore2) = dy(t_vl, t0, dt, ceff_); - dy(t_vth, t0, dt, ceff_, fjac_[DmpFunc::y50][DmpParam::t0], - fjac_[DmpFunc::y50][DmpParam::dt], ignore2); + std::tie(fjac_[DmpFunc::y50][DmpParam::t0], + fjac_[DmpFunc::y50][DmpParam::dt], + ignore2) = dy(t_vth, t0, dt, ceff_); if (debug_->check("dmp_ceff", 4)) { showJacobian(); @@ -1126,19 +1016,11 @@ public: double c2, double rpi, double c1) override; - void gateDelaySlew(// Return values. - double &delay, - double &slew) override; + std::pair gateDelaySlew() override; private: - void V0(double t, - // Return values. - double &vo, - double &dvo_dt) override; - void Vl0(double t, - // Return values. - double &vl, - double &dvl_dt) override; + std::pair V0(double t) override; + std::pair Vl0(double t) override; double voCrossingUpperBound() override; // Pole/zero. @@ -1188,51 +1070,49 @@ DmpZeroC2::init(const LibertyLibrary *drvr_library, k3_ = -k1_; } -void -DmpZeroC2::gateDelaySlew(// Return values. - double &delay, - double &slew) +std::pair +DmpZeroC2::gateDelaySlew() { + double delay = 0.0; + double slew = 0.0; try { findDriverParams(c1_); ceff_ = c1_; - findDriverDelaySlew(delay, slew); + std::tie(delay, slew) = findDriverDelaySlew(); driver_valid_ = true; vo_delay_ = delay; - } catch (DmpError &error) { + } + catch (DmpError &error) { fail(error.what()); // Fall back to table slew. driver_valid_ = false; ceff_ = c1_; - gateCapDelaySlew(ceff_, delay, slew); + std::tie(delay, slew) = gateCapDelaySlew(ceff_); } drvr_slew_ = slew; + return {delay, slew}; } -void -DmpZeroC2::V0(double t, - // Return values. - double &vo, - double &dvo_dt) +std::pair +DmpZeroC2::V0(double t) { double exp_p1 = exp2(-p1_ * t); - vo = k0_ * (k1_ + k2_ * t + k3_ * exp_p1); - dvo_dt = k0_ * (k2_ - k3_ * p1_ * exp_p1); + double vo = k0_ * (k1_ + k2_ * t + k3_ * exp_p1); + double dvo_dt = k0_ * (k2_ - k3_ * p1_ * exp_p1); + return {vo, dvo_dt}; } -void -DmpZeroC2::Vl0(double t, - // Return values. - double &vl, - double &dvl_dt) +std::pair +DmpZeroC2::Vl0(double t) { double D1 = k0_ * (k1_ - k2_ / p3_); double D3 = -p3_ * k0_ * k3_ / (p1_ - p3_); double D5 = k0_ * (k2_ / p3_ - k1_ + p3_ * k3_ / (p1_ - p3_)); double exp_p1 = exp2(-p1_ * t); double exp_p3 = exp2(-p3_ * t); - vl = D1 + t + D3 * exp_p1 + D5 * exp_p3; - dvl_dt = 1.0 - D3 * p1_ * exp_p1 - D5 * p3_ * exp_p3; + double vl = D1 + t + D3 * exp_p1 + D5 * exp_p3; + double dvl_dt = 1.0 - D3 * p1_ * exp_p1 - D5 * p3_ * exp_p3; + return {vl, dvl_dt}; } double @@ -1244,38 +1124,27 @@ DmpZeroC2::voCrossingUpperBound() //////////////////////////////////////////////////////////////// // Newton-Raphson iteration to find zeros of a function. -// x_tol is percentage that all changes in x must be less than (1.0 = 100%). -// Eval(state) is called to fill fvec and fjac (returns false if fails). -// Return error msg on failure. -static void -newtonRaphson(const int max_iter, - double x[], - const int size, - const double x_tol, - std::function eval, - // Temporaries supplied by caller. - double *fvec, - double **fjac, - int *index, - double *p, - double *scale) +// driver_param_tol_ is the scale that all changes in x must be under (1.0 = 100%). +// evalDmpEqns() fills fvec_ and fjac_. +void +DmpAlg::newtonRaphson() { - for (int k = 0; k < max_iter; k++) { - eval(); - for (int i = 0; i < size; i++) + for (int k = 0; k < newton_raphson_max_iter_; k++) { + evalDmpEqns(); + for (int i = 0; i < nr_order_; i++) // Right-hand side of linear equations. - p[i] = -fvec[i]; - luDecomp(fjac, size, index, scale); - luSolve(fjac, size, index, p); + p_[i] = -fvec_[i]; + luDecomp(); + luSolve(); bool all_under_x_tol = true; - for (int i = 0; i < size; i++) { - if (std::abs(p[i]) > std::abs(x[i]) * x_tol) + for (int i = 0; i < nr_order_; i++) { + if (std::abs(p_[i]) > std::abs(x_[i]) * driver_param_tol_) all_under_x_tol = false; - x[i] += p[i]; + x_[i] += p_[i]; } if (all_under_x_tol) { - eval(); + evalDmpEqns(); return; } } @@ -1287,41 +1156,37 @@ newtonRaphson(const int max_iter, // ftp://ftp.mcc.ac.uk/pub/matclass/libmat.tar.Z // Crout's Method of LU decomposition of square matrix, with implicit -// partial pivoting. A is overwritten. U is explicit in the upper +// partial pivoting. fjac_ is overwritten. U is explicit in the upper // triangle and L is in multiplier form in the subdiagionals i.e. subdiag // a[i,j] is the multiplier used to eliminate the [i,j] term. // -// Replaces a[0..size-1][0..size-1] by the LU decomposition. -// index[0..size-1] is an output vector of the row permutations. -// Return error msg on failure. +// Replaces fjac_[0..nr_order_-1][*] by the LU decomposition. +// index_[0..nr_order_-1] is an output vector of the row permutations. void -luDecomp(double **a, - const int size, - int *index, - // Temporary supplied by caller. - // scale stores the implicit scaling of each row. - double *scale) +DmpAlg::luDecomp() { + const int size = nr_order_; + // Find implicit scaling factors. for (int i = 0; i < size; i++) { double big = 0.0; for (int j = 0; j < size; j++) { - double temp = std::abs(a[i][j]); + double temp = std::abs(fjac_[i][j]); if (temp > big) big = temp; } if (big == 0.0) throw DmpError("LU decomposition: no non-zero row element"); - scale[i] = 1.0 / big; + scale_[i] = 1.0 / big; } int size_1 = size - 1; for (int j = 0; j < size; j++) { // Run down jth column from top to diag, to form the elements of U. for (int i = 0; i < j; i++) { - double sum = a[i][j]; + double sum = fjac_[i][j]; for (int k = 0; k < i; k++) - sum -= a[i][k] * a[k][j]; - a[i][j] = sum; + sum -= fjac_[i][k] * fjac_[k][j]; + fjac_[i][j] = sum; } // Run down jth subdiag to form the residuals after the elimination // of the first j-1 subdiags. These residuals diviyded by the @@ -1331,11 +1196,11 @@ luDecomp(double **a, double big = 0.0; int imax = 0; for (int i = j; i < size; i++) { - double sum = a[i][j]; + double sum = fjac_[i][j]; for (int k = 0; k < j; k++) - sum -= a[i][k] * a[k][j]; - a[i][j] = sum; - double dum = scale[i] * std::abs(sum); + sum -= fjac_[i][k] * fjac_[k][j]; + fjac_[i][j] = sum; + double dum = scale_[i] * std::abs(sum); if (dum >= big) { big = dum; imax = i; @@ -1345,100 +1210,56 @@ luDecomp(double **a, if (j != imax) { // Yes, do so... for (int k = 0; k < size; k++) { - double dum = a[imax][k]; - a[imax][k] = a[j][k]; - a[j][k] = dum; + double dum = fjac_[imax][k]; + fjac_[imax][k] = fjac_[j][k]; + fjac_[j][k] = dum; } - scale[imax] = scale[j]; + scale_[imax] = scale_[j]; } - index[j] = imax; + index_[j] = imax; // If diag term is not zero divide subdiag to form multipliers. - if (a[j][j] == 0.0) - a[j][j] = tiny_double; + if (fjac_[j][j] == 0.0) + fjac_[j][j] = tiny_double_; if (j != size_1) { - double pivot = 1.0 / a[j][j]; + double pivot = 1.0 / fjac_[j][j]; for (int i = j + 1; i < size; i++) - a[i][j] *= pivot; + fjac_[i][j] *= pivot; } } } -// Solves the set of size linear equations a*x=b, assuming A is LU form -// but assume b has not been transformed. -// a[0..size-1] is LU decomposition -// Returns the solution vector x in b. -// a and index are not modified. +// Solves fjac_ * x = p_ for x, assuming fjac_ is LU form from luDecomp. +// Solution overwrites p_. void -luSolve(double **a, - const int size, - const int *index, - double b[]) +DmpAlg::luSolve() { - // Transform b allowing for leading zeros. + const int size = nr_order_; + + // Transform p_ allowing for leading zeros. int non_zero = -1; for (int i = 0; i < size; i++) { - int iperm = index[i]; - double sum = b[iperm]; - b[iperm] = b[i]; + int iperm = index_[i]; + double sum = p_[iperm]; + p_[iperm] = p_[i]; if (non_zero != -1) { for (int j = non_zero; j <= i - 1; j++) - sum -= a[i][j] * b[j]; + sum -= fjac_[i][j] * p_[j]; } else { if (sum != 0.0) non_zero = i; } - b[i] = sum; + p_[i] = sum; } // Backsubstitution. for (int i = size - 1; i >= 0; i--) { - double sum = b[i]; + double sum = p_[i]; for (int j = i + 1; j < size; j++) - sum -= a[i][j] * b[j]; - b[i] = sum / a[i][i]; + sum -= fjac_[i][j] * p_[j]; + p_[i] = sum / fjac_[i][i]; } } -#if 0 -// Solve: -// x + y = 5 -// x - y = 1 -// x = 3 -// y = 2 -void -testLuDecomp1() -{ - double a0[2] = {1, 1}; - double a1[2] = {1, -1}; - double *a[2] = {a0, a1}; - int index[2]; - double b[2] = {5, 1}; - double scale[2]; - luDecomp(a, 2, index, scale); - luSolve(a, 2, index, b); - printf("x = %f y= %f\n", b[0], b[1]); -} - -// Solve -// x + 2y = 3 -// 3x - 4y = 19 -// x = 5 -// y = -1 -void -testLuDecomp2() -{ - double a0[2] = {1, 2}; - double a1[2] = {3, -4}; - double *a[2] = {a0, a1}; - int index[2]; - double b[2] = {3, 19}; - double scale[2]; - luDecomp(a, 2, index, scale); - luSolve(a, 2, index, b); - printf("x = %f y= %f\n", b[0], b[1]); -} -#endif - //////////////////////////////////////////////////////////////// bool DmpCeffDelayCalc::unsuppored_model_warned_ = false; @@ -1484,8 +1305,7 @@ DmpCeffDelayCalc::gateDelay(const Pin *drvr_pin, const Pvt *pvt = pinPvt(drvr_pin, scene, min_max); setCeffAlgorithm(drvr_library, drvr_cell, pvt, table_model, rf, in_slew1, c2, rpi, c1); - double gate_delay, drvr_slew; - gateDelaySlew(gate_delay, drvr_slew); + auto [gate_delay, drvr_slew] = gateDelaySlew(); // Fill in pocv parameters. double ceff = dmp_alg_->ceff(); @@ -1640,22 +1460,19 @@ gateModelRd(const LibertyCell *cell, return rd; } -void -DmpCeffDelayCalc::gateDelaySlew( // Return values. - double &delay, - double &slew) +std::pair +DmpCeffDelayCalc::gateDelaySlew() { - dmp_alg_->gateDelaySlew(delay, slew); + return dmp_alg_->gateDelaySlew(); } -void +std::optional> DmpCeffDelayCalc::loadDelaySlewElmore(const Pin *load_pin, - double elmore, - double &delay, - double &slew) + double elmore) { if (dmp_alg_) - dmp_alg_->loadDelaySlew(load_pin, elmore, delay, slew); + return dmp_alg_->loadDelaySlew(load_pin, elmore); + return std::nullopt; } // Notify algorithm components. diff --git a/dcalc/DmpCeff.hh b/dcalc/DmpCeff.hh index 4d3b7fd5..065a0026 100644 --- a/dcalc/DmpCeff.hh +++ b/dcalc/DmpCeff.hh @@ -24,6 +24,9 @@ #pragma once +#include +#include + #include "LibertyClass.hh" #include "LumpedCapDelayCalc.hh" @@ -71,13 +74,10 @@ protected: // Return values. double &wire_delay, double &load_slew) = 0; - void gateDelaySlew(// Return values. - double &delay, - double &slew); - void loadDelaySlewElmore(const Pin *load_pin, - double elmore, - double &delay, - double &slew); + std::pair gateDelaySlew(); + std::optional> + loadDelaySlewElmore(const Pin *load_pin, + double elmore); // Select the appropriate special case Dartu/Menezes/Pileggi algorithm. void setCeffAlgorithm(const LibertyLibrary *library, const LibertyCell *cell, diff --git a/dcalc/DmpDelayCalc.cc b/dcalc/DmpDelayCalc.cc index 3fefc53b..d89b319d 100644 --- a/dcalc/DmpDelayCalc.cc +++ b/dcalc/DmpDelayCalc.cc @@ -125,8 +125,12 @@ DmpCeffElmoreDelayCalc::loadDelaySlew(const Pin *load_pin, float elmore = 0.0; if (parasitic) parasitics_->findElmore(parasitic, load_pin, elmore, elmore_exists); - if (elmore_exists) - loadDelaySlewElmore(load_pin, elmore, wire_delay, load_slew); + if (elmore_exists) { + if (auto r = loadDelaySlewElmore(load_pin, elmore)) { + wire_delay = r->first; + load_slew = r->second; + } + } thresholdAdjust(load_pin, drvr_library, rf, wire_delay, load_slew); } diff --git a/dcalc/FindRoot.cc b/dcalc/FindRoot.cc index dd35e7ba..5ca987df 100644 --- a/dcalc/FindRoot.cc +++ b/dcalc/FindRoot.cc @@ -28,47 +28,38 @@ namespace sta { -double +std::pair findRoot(FindRootFunc func, double x1, double x2, double x_tol, - int max_iter, - // Return value. - bool &fail) + int max_iter) { double y1, y2, dy1; func(x1, y1, dy1); func(x2, y2, dy1); - return findRoot(func, x1, y1, x2, y2, x_tol, max_iter, fail); + return findRoot(func, x1, y1, x2, y2, x_tol, max_iter); } -double +std::pair findRoot(FindRootFunc func, double x1, double y1, double x2, double y2, double x_tol, - int max_iter, - // Return value. - bool &fail) + int max_iter) { if ((y1 > 0.0 && y2 > 0.0) || (y1 < 0.0 && y2 < 0.0)) { // Initial bounds do not surround a root. - fail = true; - return 0.0; + return {0.0, true}; } - if (y1 == 0.0) { - fail = false; - return x1; - } + if (y1 == 0.0) + return {x1, false}; - if (y2 == 0.0) { - fail = false; - return x2; - } + if (y2 == 0.0) + return {x2, false}; if (y1 > 0.0) // Swap x1/x2 so func(x1) < 0. @@ -95,8 +86,7 @@ findRoot(FindRootFunc func, } if (std::abs(dx) <= x_tol * std::abs(root)) { // Converged. - fail = false; - return root; + return {root, false}; } func(root, y, dy); @@ -105,8 +95,7 @@ findRoot(FindRootFunc func, else x2 = root; } - fail = true; - return root; + return {root, true}; } } // namespace diff --git a/dcalc/FindRoot.hh b/dcalc/FindRoot.hh index a137b48a..ab35ab4e 100644 --- a/dcalc/FindRoot.hh +++ b/dcalc/FindRoot.hh @@ -25,6 +25,7 @@ #pragma once #include +#include namespace sta { @@ -33,24 +34,22 @@ using FindRootFunc = const std::function; -double +// first: root estimate; second: true if the search failed. +std::pair findRoot(FindRootFunc func, double x1, double x2, double x_tol, - int max_iter, - // Return value. - bool &fail); + int max_iter); -double +// first: root estimate; second: true if the search failed. +std::pair findRoot(FindRootFunc func, double x1, double y1, double x2, double y2, double x_tol, - int max_iter, - // Return value. - bool &fail); + int max_iter); } // namespace diff --git a/dcalc/GraphDelayCalc.cc b/dcalc/GraphDelayCalc.cc index f8984474..67536ef0 100644 --- a/dcalc/GraphDelayCalc.cc +++ b/dcalc/GraphDelayCalc.cc @@ -648,12 +648,12 @@ GraphDelayCalc::findInputArcDelay(const Pin *drvr_pin, LoadPinIndexMap load_pin_index_map = makeLoadPinIndexMap(drvr_vertex); ArcDcalcResult intrinsic_result = - arc_delay_calc->gateDelay(drvr_pin, arc, Slew(from_slew), 0.0, nullptr, + arc_delay_calc->gateDelay(drvr_pin, arc, from_slew, 0.0, nullptr, load_pin_index_map, scene, min_max); const ArcDelay &intrinsic_delay = intrinsic_result.gateDelay(); ArcDcalcResult gate_result = arc_delay_calc->gateDelay(drvr_pin, arc, - Slew(from_slew), load_cap, + from_slew, load_cap, parasitic, load_pin_index_map, scene, min_max); diff --git a/dcalc/PrimaDelayCalc.cc b/dcalc/PrimaDelayCalc.cc index 9cea3ea6..be0a3d89 100644 --- a/dcalc/PrimaDelayCalc.cc +++ b/dcalc/PrimaDelayCalc.cc @@ -194,8 +194,8 @@ PrimaDelayCalc::gateDelay(const Pin *drvr_pin, ArcDcalcArgSeq dcalc_args; dcalc_args.emplace_back(nullptr, drvr_pin, nullptr, arc, in_slew, load_cap, parasitic); - ArcDcalcResultSeq dcalc_results = - gateDelays(dcalc_args, load_pin_index_map, scene, min_max); + ArcDcalcResultSeq dcalc_results = gateDelays(dcalc_args, load_pin_index_map, + scene, min_max); return dcalc_results[0]; } @@ -399,6 +399,7 @@ void PrimaDelayCalc::initSim() { ceff_.resize(drvr_count_); + ceff_vth_.resize(drvr_count_); drvr_current_.resize(drvr_count_); findNodeCount(); @@ -615,8 +616,12 @@ PrimaDelayCalc::updateCeffIdrvr() if (drvr_rf_ == RiseFall::rise()) { if (drvr_current != 0.0 && dv > 0.0) { double ceff = drvr_current * time_step_ / dv; - if (output_waveforms_[drvr_idx]->capAxis()->inBounds(ceff)) + if (output_waveforms_[drvr_idx]->capAxis()->inBounds(ceff)) { ceff_[drvr_idx] = ceff; + // Record the Ceff at Vth. + if (v1 >= vth_ && v2 < vth_) + ceff_vth_[drvr_idx] = ceff; + } } if (v1 > (vdd_ - .01)) // Whoa partner. Head'n for the weeds. @@ -628,8 +633,12 @@ PrimaDelayCalc::updateCeffIdrvr() else { if (drvr_current != 0.0 && dv < 0.0) { double ceff = drvr_current * time_step_ / dv; - if (output_waveforms_[drvr_idx]->capAxis()->inBounds(ceff)) + if (output_waveforms_[drvr_idx]->capAxis()->inBounds(ceff)) { ceff_[drvr_idx] = ceff; + // Record the Ceff at Vth. + if (v1 <= vth_ && v2 > vth_) + ceff_vth_[drvr_idx] = ceff; + } } if (v1 < 0.01) { // Whoa partner. Head'n for the weeds. @@ -711,8 +720,13 @@ PrimaDelayCalc::dcalcResults() float ref_time = output_waveforms_[drvr_idx]->referenceTime(dcalc_arg.inSlewFlt()); double gate_delay = drvr_times[threshold_vth] - ref_time; double drvr_slew = std::abs(drvr_times[threshold_vh] - drvr_times[threshold_vl]); - dcalc_result.setGateDelay(gate_delay); - dcalc_result.setDrvrSlew(drvr_slew); + + ArcDelay gate_delay2(gate_delay); + Slew drvr_slew2(drvr_slew); + delaySlewPocv(dcalc_arg, drvr_idx, gate_delay2, drvr_slew2); + dcalc_result.setGateDelay(gate_delay2); + dcalc_result.setDrvrSlew(drvr_slew2); + debugPrint(debug_, "ccs_dcalc", 2, "{} gate delay {} slew {}", network_->pathName(drvr_pin), delayAsString(gate_delay, this), delayAsString(drvr_slew, this)); @@ -740,6 +754,28 @@ PrimaDelayCalc::dcalcResults() return dcalc_results; } +// Fill in pocv parameters in gate_delay/drvr_slew. +void +PrimaDelayCalc::delaySlewPocv(ArcDcalcArg &dcalc_arg, + size_t drvr_idx, + ArcDelay &gate_delay, + Slew &drvr_slew) +{ + if (variables_->pocvEnabled()) { + GateTableModel *table_model = dcalc_arg.arc()->gateTableModel(scene_, min_max_); + if (table_model) { + double ceff = ceff_vth_[drvr_idx]; + if (ceff == 0.0) + ceff = dcalc_arg.loadCap(); + float in_slew = delayAsFloat(dcalc_arg.inSlew()); + const Pvt *pvt = pinPvt(dcalc_arg.drvrPin(), scene_, min_max_); + table_model->gateDelayPocv(pvt, in_slew, ceff, min_max_, + variables_->pocvMode(), + gate_delay, drvr_slew); + } + } +} + //////////////////////////////////////////////////////////////// void @@ -895,7 +931,7 @@ std::string PrimaDelayCalc::reportGateDelay(const Pin *drvr_pin, const TimingArc *arc, const Slew &in_slew, - float load_cap, + float, const Parasitic *, const LoadPinIndexMap &, const Scene *scene, @@ -905,8 +941,9 @@ PrimaDelayCalc::reportGateDelay(const Pin *drvr_pin, GateTimingModel *model = arc->gateModel(scene, min_max); if (model) { float in_slew1 = delayAsFloat(in_slew); + float ceff = ceff_vth_[0]; return model->reportGateDelay(pinPvt(drvr_pin, scene, min_max), - in_slew1, load_cap, min_max, + in_slew1, ceff, min_max, PocvMode::scalar, digits); } return ""; diff --git a/dcalc/PrimaDelayCalc.hh b/dcalc/PrimaDelayCalc.hh index 8ed47a05..c0b39ba7 100644 --- a/dcalc/PrimaDelayCalc.hh +++ b/dcalc/PrimaDelayCalc.hh @@ -108,6 +108,10 @@ public: Waveform watchWaveform(const Pin *pin) override; protected: + void delaySlewPocv(ArcDcalcArg &dcalc_arg, + size_t drvr_idx, + ArcDelay &gate_delay, + Slew &drvr_slew); ArcDcalcResultSeq tableDcalcResults(); void simulate(); void simulate1(const MatrixSd &G, @@ -215,6 +219,8 @@ protected: // Indexed by driver index. std::vector ceff_; + // Ceff at Vth + std::vector ceff_vth_; std::vector drvr_current_; double time_step_; diff --git a/include/sta/ConcreteLibrary.hh b/include/sta/ConcreteLibrary.hh index e3983076..fc831a99 100644 --- a/include/sta/ConcreteLibrary.hh +++ b/include/sta/ConcreteLibrary.hh @@ -56,8 +56,8 @@ using ConcretePortMemberIterator = VectorIterator +#include +#include +#include +#include +#include #include #include // for std::declval -#include -#include #include -#include -#include -#include namespace sta { diff --git a/include/sta/FilterObjects.hh b/include/sta/FilterObjects.hh index bbabd4b0..7420b450 100644 --- a/include/sta/FilterObjects.hh +++ b/include/sta/FilterObjects.hh @@ -40,67 +40,56 @@ class Report; PortSeq filterPorts(std::string_view filter_expression, PortSeq *objects, - bool bool_props_as_int, Sta *sta); InstanceSeq filterInstances(std::string_view filter_expression, InstanceSeq *objects, - bool bool_props_as_int, Sta *sta); PinSeq filterPins(std::string_view filter_expression, PinSeq *objects, - bool bool_props_as_int, Sta *sta); NetSeq filterNets(std::string_view filter_expression, NetSeq *objects, - bool bool_props_as_int, Sta *sta); ClockSeq filterClocks(std::string_view filter_expression, ClockSeq *objects, - bool bool_props_as_int, Sta *sta); LibertyCellSeq filterLibCells(std::string_view filter_expression, LibertyCellSeq *objects, - bool bool_props_as_int, Sta *sta); LibertyPortSeq filterLibPins(std::string_view filter_expression, LibertyPortSeq *objects, - bool bool_props_as_int, Sta *sta); LibertyLibrarySeq filterLibertyLibraries(std::string_view filter_expression, LibertyLibrarySeq *objects, - bool bool_props_as_int, Sta *sta); EdgeSeq filterTimingArcs(std::string_view filter_expression, EdgeSeq *objects, - bool bool_props_as_int, Sta *sta); PathEndSeq filterPathEnds(std::string_view filter_expression, PathEndSeq *objects, - bool bool_props_as_int, Sta *sta); // For FilterExpr unit tests. StringSeq filterExprToPostfix(std::string_view expr, - bool bool_props_as_int, Report *report); } // namespace diff --git a/include/sta/Liberty.hh b/include/sta/Liberty.hh index 732545a4..a6f8b5b3 100644 --- a/include/sta/Liberty.hh +++ b/include/sta/Liberty.hh @@ -69,7 +69,7 @@ class DriverWaveform; class ModeValueDef { public: - ModeValueDef(std::string value); + ModeValueDef(std::string_view value); ModeValueDef(ModeValueDef &&other) noexcept; ~ModeValueDef(); const std::string &value() const { return value_; } @@ -204,8 +204,8 @@ timingSenseOpposite(TimingSense sense); class LibertyLibrary : public ConcreteLibrary { public: - LibertyLibrary(std::string name, - std::string filename); + LibertyLibrary(std::string_view name, + std::string_view filename); virtual ~LibertyLibrary(); LibertyCell *findLibertyCell(std::string_view name) const; LibertyCellSeq findLibertyCellsMatching(PatternMatch *pattern); @@ -215,12 +215,12 @@ public: DelayModelType delayModelType() const { return delay_model_type_; } void setDelayModelType(DelayModelType type); - BusDcl *makeBusDcl(std::string name, + BusDcl *makeBusDcl(std::string_view name, int from, int to); BusDcl *findBusDcl(std::string_view name); BusDclSeq busDcls() const; - TableTemplate *makeTableTemplate(std::string name, + TableTemplate *makeTableTemplate(std::string_view name, TableTemplateType type); TableTemplate *findTableTemplate(std::string_view name, TableTemplateType type); @@ -235,7 +235,7 @@ public: void setScaleFactors(ScaleFactors *scales); // Make named scale factor group. Returns pointer to the inserted element. - ScaleFactors *makeScaleFactors(std::string name); + ScaleFactors *makeScaleFactors(std::string_view name); ScaleFactors *findScaleFactors(std::string_view name); ScaleFactors *scaleFactors() const { return scale_factors_; } float scaleFactor(ScaleFactorType type, @@ -336,18 +336,18 @@ public: Units *units() { return units_; } const Units *units() const { return units_; } - Wireload *makeWireload(std::string name); + Wireload *makeWireload(std::string_view name); const Wireload *findWireload(std::string_view name); void setDefaultWireload(const Wireload *wireload); const Wireload *defaultWireload() const; - WireloadSelection *makeWireloadSelection(std::string name); + WireloadSelection *makeWireloadSelection(std::string_view name); const WireloadSelection *findWireloadSelection(std::string_view name) const; const WireloadSelection *defaultWireloadSelection() const; WireloadMode defaultWireloadMode() const; void setDefaultWireloadMode(WireloadMode mode); void setDefaultWireloadSelection(const WireloadSelection *selection); - OperatingConditions *makeOperatingConditions(std::string name); + OperatingConditions *makeOperatingConditions(std::string_view name); OperatingConditions *findOperatingConditions(std::string_view name); OperatingConditions *defaultOperatingConditions() const; void setDefaultOperatingConditions(OperatingConditions *op_cond); @@ -358,9 +358,9 @@ public: void setOcvArcDepth(float depth); OcvDerate *defaultOcvDerate() const; void setDefaultOcvDerate(OcvDerate *derate); - OcvDerate *makeOcvDerate(std::string name); + OcvDerate *makeOcvDerate(std::string_view name); OcvDerate *findOcvDerate(std::string_view derate_name); - void addSupplyVoltage(std::string suppy_name, + void addSupplyVoltage(std::string_view suppy_name, float voltage); bool supplyExists(std::string_view supply_name) const; void supplyVoltage(std::string_view supply_name, @@ -369,8 +369,8 @@ public: bool &exists) const; // Make scaled cell. Call LibertyCell::addScaledCell after it is complete. - LibertyCell *makeScaledCell(std::string name, - std::string filename); + LibertyCell *makeScaledCell(std::string_view name, + std::string_view filename); static void makeSceneMap(LibertyLibrary *lib, @@ -395,7 +395,7 @@ public: DriverWaveform *findDriverWaveform(std::string_view name); DriverWaveform *driverWaveformDefault() { return findDriverWaveform(""); } - DriverWaveform *makeDriverWaveform(std::string name, + DriverWaveform *makeDriverWaveform(std::string_view name, TablePtr waveforms); protected: @@ -474,8 +474,8 @@ class LibertyCell : public ConcreteCell { public: LibertyCell(LibertyLibrary *library, - std::string name, - std::string filename); + std::string_view name, + std::string_view filename); virtual ~LibertyCell(); LibertyLibrary *libertyLibrary() const { return liberty_library_; } LibertyLibrary *libertyLibrary() { return liberty_library_; } @@ -484,7 +484,7 @@ public: bool hasInternalPorts() const { return has_internal_ports_; } ScaleFactors *scaleFactors() const { return scale_factors_; } void setScaleFactors(ScaleFactors *scale_factors); - ModeDef *makeModeDef(std::string name); + ModeDef *makeModeDef(std::string_view name); const ModeDef *findModeDef(std::string_view name) const; float area() const { return area_; } @@ -544,7 +544,7 @@ public: const Statetable *statetable() const { return statetable_; } // Find bus declaration local to this cell. - BusDcl *makeBusDcl(std::string name, + BusDcl *makeBusDcl(std::string_view name, int from, int to); BusDcl *findBusDcl(std::string_view name); @@ -565,7 +565,7 @@ public: // AOCV float ocvArcDepth() const; OcvDerate *ocvDerate() const; - OcvDerate *makeOcvDerate(std::string name); + OcvDerate *makeOcvDerate(std::string_view name); OcvDerate *findOcvDerate(std::string_view derate_name); // Build helpers. @@ -620,9 +620,9 @@ public: static void checkLibertyScenes(); void ensureVoltageWaveforms(const SceneSeq &scenes); const std::string &footprint() const { return footprint_; } - void setFootprint(std::string footprint); + void setFootprint(std::string_view footprint); const std::string &userFunctionClass() const { return user_function_class_; } - void setUserFunctionClass(std::string user_function_class); + void setUserFunctionClass(std::string_view user_function_class); protected: void addPort(ConcretePort *port); @@ -758,7 +758,7 @@ public: PwrGndType pwrGndType() const { return pwr_gnd_type_; } void setPwrGndType(PwrGndType type); const std::string &voltageName() const { return voltage_name_; } - void setVoltageName(std::string voltage_name); + void setVoltageName(std::string_view voltage_name); //////////////////////////////////////////////////////////////// ScanSignalType scanSignalType() const { return scan_signal_type_; } @@ -906,7 +906,7 @@ public: protected: // Constructor is internal to LibertyBuilder. LibertyPort(LibertyCell *cell, - std::string name, + std::string_view name, bool is_bus, BusDcl *bus_dcl, int from_index, @@ -1016,7 +1016,7 @@ protected: class OperatingConditions : public Pvt { public: - OperatingConditions(std::string name); + OperatingConditions(std::string_view name); const std::string &name() const { return name_; } WireloadTree wireloadTree() const { return wire_load_tree_; } void setWireloadTree(WireloadTree tree); @@ -1029,7 +1029,7 @@ protected: class ScaleFactors { public: - ScaleFactors(std::string name); + ScaleFactors(std::string_view name); const std::string &name() const { return name_; } float scale(ScaleFactorType type, ScaleFactorPvt pvt, @@ -1056,7 +1056,7 @@ protected: class BusDcl { public: - BusDcl(std::string name, + BusDcl(std::string_view name, int from, int to); const std::string &name() const { return name_; } @@ -1073,9 +1073,9 @@ protected: class ModeDef { public: - ModeDef(std::string name); + ModeDef(std::string_view name); const std::string &name() const { return name_; } - ModeValueDef *defineValue(std::string value); + ModeValueDef *defineValue(std::string_view value); const ModeValueDef *findValueDef(std::string_view value) const; const ModeValueMap &values() const { return values_; } @@ -1090,15 +1090,15 @@ private: class TableTemplate { public: - TableTemplate(std::string name); - TableTemplate(std::string name, + TableTemplate(std::string_view name); + TableTemplate(std::string_view name, TableTemplateType type); - TableTemplate(std::string name, + TableTemplate(std::string_view name, TableAxisPtr axis1, TableAxisPtr axis2, TableAxisPtr axis3); const std::string &name() const { return name_; } - void setName(std::string name); + void setName(std::string_view name); TableTemplateType type() const { return type_; } const TableAxis *axis1() const { return axis1_.get(); } TableAxisPtr axis1ptr() const { return axis1_; } @@ -1122,8 +1122,8 @@ class TestCell : public LibertyCell { public: TestCell(LibertyLibrary *library, - std::string name, - std::string filename); + std::string_view name, + std::string_view filename); protected: }; @@ -1131,7 +1131,7 @@ protected: class OcvDerate { public: - OcvDerate(std::string name); + OcvDerate(std::string_view name); ~OcvDerate(); const std::string &name() const { return name_; } const Table *derateTable(const RiseFall *rf, diff --git a/include/sta/Network.hh b/include/sta/Network.hh index b12db2db..32dd25b3 100644 --- a/include/sta/Network.hh +++ b/include/sta/Network.hh @@ -307,18 +307,18 @@ public: [[nodiscard]] bool isHierarchical(const Pin *pin) const; [[nodiscard]] bool isTopLevelPort(const Pin *pin) const; // Is pin inside the instance hier_pin is attached to? - bool isInside(const Pin *pin, - const Pin *hier_pin) const; + [[nodiscard]] bool isInside(const Pin *pin, + const Pin *hier_pin) const; // Is pin inside of hier_inst? - bool isInside(const Pin *pin, - const Instance *hier_inst) const; - bool isDriver(const Pin *pin) const; - bool isLoad(const Pin *pin) const; + [[nodiscard]] bool isInside(const Pin *pin, + const Instance *hier_inst) const; + [[nodiscard]] bool isDriver(const Pin *pin) const; + [[nodiscard]] bool isLoad(const Pin *pin) const; // Has register/latch rise/fall edges from pin. - bool isRegClkPin(const Pin *pin) const; + [[nodiscard]] bool isRegClkPin(const Pin *pin) const; // Pin clocks a timing check. - bool isCheckClk(const Pin *pin) const; - bool isLatchData(const Pin *pin) const; + [[nodiscard]] bool isCheckClk(const Pin *pin) const; + [[nodiscard]] bool isLatchData(const Pin *pin) const; // Iterate over all of the pins connected to a pin and the parent // and child nets it is hierarchically connected to (port, leaf and diff --git a/liberty/Liberty.cc b/liberty/Liberty.cc index a26aee13..741ce875 100644 --- a/liberty/Liberty.cc +++ b/liberty/Liberty.cc @@ -62,9 +62,9 @@ deleteLiberty() TimingArcSet::destroy(); } -LibertyLibrary::LibertyLibrary(std::string name, - std::string filename) : - ConcreteLibrary(std::move(name), std::move(filename), true), +LibertyLibrary::LibertyLibrary(std::string_view name, + std::string_view filename) : + ConcreteLibrary(name, filename, true), units_(new Units()), delay_model_type_(DelayModelType::table), // default nominal_process_(0.0), @@ -178,12 +178,12 @@ LibertyLibrary::setDelayModelType(DelayModelType type) } BusDcl * -LibertyLibrary::makeBusDcl(std::string name, +LibertyLibrary::makeBusDcl(std::string_view name, int from, int to) { - std::string key = name; - auto [it, inserted] = bus_dcls_.try_emplace(std::move(key), std::move(name), from, to); + std::string key(name); + auto [it, inserted] = bus_dcls_.try_emplace(std::move(key), std::string(name), from, to); return &it->second; } @@ -203,13 +203,13 @@ LibertyLibrary::busDcls() const } TableTemplate * -LibertyLibrary::makeTableTemplate(std::string name, - TableTemplateType type) +LibertyLibrary::makeTableTemplate(std::string_view name, + TableTemplateType type) { - std::string key = name; + std::string key(name); auto [it, inserted] = template_maps_[int(type)].try_emplace(std::move(key), - std::move(name), - type); + std::string(name), + type); return &it->second; } @@ -265,10 +265,10 @@ LibertyLibrary::setScaleFactors(ScaleFactors *scales) } ScaleFactors * -LibertyLibrary::makeScaleFactors(std::string name) +LibertyLibrary::makeScaleFactors(std::string_view name) { - std::string key = name; - auto [it, inserted] = scale_factors_map_.emplace(std::move(key), std::move(name)); + std::string key(name); + auto [it, inserted] = scale_factors_map_.emplace(std::move(key), std::string(name)); return &it->second; } @@ -565,9 +565,10 @@ LibertyLibrary::setDefaultOutputPinRes(const RiseFall *rf, } Wireload * -LibertyLibrary::makeWireload(std::string name) +LibertyLibrary::makeWireload(std::string_view name) { - auto [it, inserted] = wireloads_.try_emplace(name, name, this); + std::string key(name); + auto [it, inserted] = wireloads_.try_emplace(std::move(key), std::string(name), this); return &it->second; } @@ -590,11 +591,11 @@ LibertyLibrary::defaultWireload() const } WireloadSelection * -LibertyLibrary::makeWireloadSelection(std::string name) +LibertyLibrary::makeWireloadSelection(std::string_view name) { - std::string key = name; + std::string key(name); auto [it, inserted] = wire_load_selections_.try_emplace(std::move(key), - std::move(name)); + std::string(name)); return &it->second; } @@ -629,10 +630,10 @@ LibertyLibrary::setDefaultWireloadMode(WireloadMode mode) } OperatingConditions * -LibertyLibrary::makeOperatingConditions(std::string name) +LibertyLibrary::makeOperatingConditions(std::string_view name) { - std::string key = name; - auto [it, inserted] = operating_conditions_.try_emplace(std::move(key), std::move(name)); + std::string key(name); + auto [it, inserted] = operating_conditions_.try_emplace(std::move(key), std::string(name)); return &it->second; } @@ -719,10 +720,10 @@ LibertyLibrary::setSlewDerateFromLibrary(float derate) } LibertyCell * -LibertyLibrary::makeScaledCell(std::string name, - std::string filename) +LibertyLibrary::makeScaledCell(std::string_view name, + std::string_view filename) { - return new LibertyCell(this, std::move(name), std::move(filename)); + return new LibertyCell(this, name, filename); } //////////////////////////////////////////////////////////////// @@ -853,10 +854,10 @@ LibertyLibrary::setDefaultOcvDerate(OcvDerate *derate) } OcvDerate * -LibertyLibrary::makeOcvDerate(std::string name) +LibertyLibrary::makeOcvDerate(std::string_view name) { - std::string key = name; - auto [it, inserted] = ocv_derate_map_.try_emplace(std::move(key), std::move(name)); + std::string key(name); + auto [it, inserted] = ocv_derate_map_.try_emplace(std::move(key), std::string(name)); return &it->second; } @@ -867,10 +868,10 @@ LibertyLibrary::findOcvDerate(std::string_view derate_name) } void -LibertyLibrary::addSupplyVoltage(std::string supply_name, +LibertyLibrary::addSupplyVoltage(std::string_view supply_name, float voltage) { - supply_voltage_map_[std::move(supply_name)] = voltage; + supply_voltage_map_[std::string(supply_name)] = voltage; } void @@ -903,13 +904,13 @@ LibertyLibrary::findDriverWaveform(std::string_view name) } DriverWaveform * -LibertyLibrary::makeDriverWaveform(std::string name, +LibertyLibrary::makeDriverWaveform(std::string_view name, TablePtr waveforms) { - std::string key = name; + std::string key(name); auto [it, inserted] = driver_waveform_map_.try_emplace(std::move(key), - std::move(name), - waveforms); + std::string(name), + waveforms); return &it->second; } @@ -935,8 +936,8 @@ LibertyCellIterator::next() //////////////////////////////////////////////////////////////// LibertyCell::LibertyCell(LibertyLibrary *library, - std::string name, - std::string filename) : + std::string_view name, + std::string_view filename) : ConcreteCell(name, filename, true, library), liberty_library_(library), area_(0.0), @@ -1019,10 +1020,10 @@ LibertyCell::setHasInternalPorts(bool has_internal) } ModeDef * -LibertyCell::makeModeDef(std::string name) +LibertyCell::makeModeDef(std::string_view name) { - std::string key = name; - auto [it, inserted] = mode_defs_.try_emplace(std::move(key), std::move(name)); + std::string key(name); + auto [it, inserted] = mode_defs_.try_emplace(std::move(key), std::string(name)); return &it->second; } @@ -1039,12 +1040,12 @@ LibertyCell::setScaleFactors(ScaleFactors *scale_factors) } BusDcl * -LibertyCell::makeBusDcl(std::string name, +LibertyCell::makeBusDcl(std::string_view name, int from, int to) { - std::string key = name; - auto [it, inserted] = bus_dcls_.try_emplace(std::move(key), std::move(name), from, to); + std::string key(name); + auto [it, inserted] = bus_dcls_.try_emplace(std::move(key), std::string(name), from, to); return &it->second; } @@ -1624,10 +1625,10 @@ LibertyCell::setOcvDerate(OcvDerate *derate) } OcvDerate * -LibertyCell::makeOcvDerate(std::string name) +LibertyCell::makeOcvDerate(std::string_view name) { - std::string key = name; - auto [it, inserted] = ocv_derate_map_.try_emplace(std::move(key), std::move(name)); + std::string key(name); + auto [it, inserted] = ocv_derate_map_.try_emplace(std::move(key), std::string(name)); return &it->second; } @@ -1929,15 +1930,15 @@ LibertyCell::ensureVoltageWaveforms(const SceneSeq &scenes) } void -LibertyCell::setFootprint(std::string footprint) +LibertyCell::setFootprint(std::string_view footprint) { - footprint_ = std::move(footprint); + footprint_ = footprint; } void -LibertyCell::setUserFunctionClass(std::string user_function_class) +LibertyCell::setUserFunctionClass(std::string_view user_function_class) { - user_function_class_ = std::move(user_function_class); + user_function_class_ = user_function_class; } //////////////////////////////////////////////////////////////// @@ -1986,7 +1987,7 @@ LibertyCellPortBitIterator::next() //////////////////////////////////////////////////////////////// LibertyPort::LibertyPort(LibertyCell *cell, - std::string name, + std::string_view name, bool is_bus, BusDcl *bus_dcl, int from_index, @@ -2079,9 +2080,9 @@ LibertyPort::setPwrGndType(PwrGndType type) } void -LibertyPort::setVoltageName(std::string voltage_name) +LibertyPort::setVoltageName(std::string_view voltage_name) { - voltage_name_ = std::move(voltage_name); + voltage_name_ = voltage_name; } static EnumNameMap pwr_gnd_type_map = @@ -2840,10 +2841,10 @@ LibertyPortMemberIterator::next() //////////////////////////////////////////////////////////////// -BusDcl::BusDcl(std::string name, +BusDcl::BusDcl(std::string_view name, int from, int to) : - name_(std::move(name)), + name_(name), from_(from), to_(to) { @@ -2851,16 +2852,16 @@ BusDcl::BusDcl(std::string name, //////////////////////////////////////////////////////////////// -ModeDef::ModeDef(std::string name) : - name_(std::move(name)) +ModeDef::ModeDef(std::string_view name) : + name_(name) { } ModeValueDef * -ModeDef::defineValue(std::string value) +ModeDef::defineValue(std::string_view value) { - std::string key = value; - auto [it, inserted] = values_.try_emplace(std::move(key), std::move(value)); + std::string key(value); + auto [it, inserted] = values_.try_emplace(std::move(key), std::string(value)); return &it->second; } @@ -2872,8 +2873,8 @@ ModeDef::findValueDef(std::string_view value) const //////////////////////////////////////////////////////////////// -ModeValueDef::ModeValueDef(std::string value) : - value_(std::move(value)), +ModeValueDef::ModeValueDef(std::string_view value) : + value_(value), cond_(nullptr) { } @@ -2905,8 +2906,8 @@ ModeValueDef::setSdfCond(std::string sdf_cond) //////////////////////////////////////////////////////////////// -TableTemplate::TableTemplate(std::string name) : - name_(std::move(name)), +TableTemplate::TableTemplate(std::string_view name) : + name_(name), type_(TableTemplateType::delay), axis1_(nullptr), axis2_(nullptr), @@ -2914,9 +2915,9 @@ TableTemplate::TableTemplate(std::string name) : { } -TableTemplate::TableTemplate(std::string name, +TableTemplate::TableTemplate(std::string_view name, TableTemplateType type) : - name_(std::move(name)), + name_(name), type_(type), axis1_(nullptr), axis2_(nullptr), @@ -2924,11 +2925,11 @@ TableTemplate::TableTemplate(std::string name, { } -TableTemplate::TableTemplate(std::string name, +TableTemplate::TableTemplate(std::string_view name, TableAxisPtr axis1, TableAxisPtr axis2, TableAxisPtr axis3) : - name_(std::move(name)), + name_(name), type_(TableTemplateType::delay), axis1_(axis1), axis2_(axis2), @@ -2937,9 +2938,9 @@ TableTemplate::TableTemplate(std::string name, } void -TableTemplate::setName(std::string name) +TableTemplate::setName(std::string_view name) { - name_ = std::move(name); + name_ = name; } void @@ -2989,9 +2990,9 @@ Pvt::setTemperature(float temp) temperature_ = temp; } -OperatingConditions::OperatingConditions(std::string name) : +OperatingConditions::OperatingConditions(std::string_view name) : Pvt(0.0, 0.0, 0.0), - name_(std::move(name)), + name_(name), // Default wireload tree. wire_load_tree_(WireloadTree::unknown) { @@ -3085,8 +3086,8 @@ scaleFactorPvtName(ScaleFactorPvt pvt) //////////////////////////////////////////////////////////////// -ScaleFactors::ScaleFactors(std::string name) : - name_(std::move(name)) +ScaleFactors::ScaleFactors(std::string_view name) : + name_(name) { for (int type = 0; type < scale_factor_type_count; type++) { for (int pvt = 0; pvt < scale_factor_pvt_count; pvt++) { @@ -3168,16 +3169,16 @@ ScaleFactors::report(Report *report) } TestCell::TestCell(LibertyLibrary *library, - std::string name, - std::string filename) : + std::string_view name, + std::string_view filename) : LibertyCell(library, name, filename) { } //////////////////////////////////////////////////////////////// -OcvDerate::OcvDerate(std::string name) : - name_(std::move(name)) +OcvDerate::OcvDerate(std::string_view name) : + name_(name) { for (auto el_index : EarlyLate::rangeIndex()) { for (auto rf_index : RiseFall::rangeIndex()) { diff --git a/liberty/LibertyBuilder.cc b/liberty/LibertyBuilder.cc index e7e92791..f296fdec 100644 --- a/liberty/LibertyBuilder.cc +++ b/liberty/LibertyBuilder.cc @@ -124,7 +124,7 @@ LibertyBuilder::makePort(LibertyCell *cell, LibertyPort * LibertyBuilder::makeBundlePort(LibertyCell *cell, - const char *name, + std::string_view name, ConcretePortSeq *members) { LibertyPort *port = new LibertyPort(cell, name, false, nullptr, -1, -1, true, members); diff --git a/liberty/LibertyBuilder.hh b/liberty/LibertyBuilder.hh index 11e8c2b1..27a07677 100644 --- a/liberty/LibertyBuilder.hh +++ b/liberty/LibertyBuilder.hh @@ -54,7 +54,7 @@ public: int to_index, BusDcl *bus_dcl); LibertyPort *makeBundlePort(LibertyCell *cell, - const char *name, + std::string_view name, ConcretePortSeq *members); // Build timing arc sets and their arcs given a type and sense. // Port functions and cell latches are also used by this builder diff --git a/liberty/LibertyReader.cc b/liberty/LibertyReader.cc index 8489f6f8..b8379943 100644 --- a/liberty/LibertyReader.cc +++ b/liberty/LibertyReader.cc @@ -176,7 +176,7 @@ LibertyReader::endCell(const LibertyGroup *cell_group, if (cell_group->hasFirstParam()) { const std::string &name = cell_group->firstParam(); debugPrint(debug_, "liberty", 1, "cell {}", name); - LibertyCell *cell = builder_.makeCell(library_, name, std::string(filename_)); + LibertyCell *cell = builder_.makeCell(library_, name, filename_); readCell(cell, cell_group); } else @@ -849,7 +849,7 @@ LibertyReader::readDefaultWireLoadSelection(const LibertyGroup *library_group) library_group->findAttrString("default_wire_load_selection"); if (!selection_name.empty()) { const WireloadSelection *selection = - library_->findWireloadSelection(selection_name.c_str()); + library_->findWireloadSelection(selection_name); if (selection) library_->setDefaultWireloadSelection(selection); else @@ -1003,9 +1003,8 @@ LibertyReader::readScaledCell(const LibertyGroup *scaled_cell_group) OperatingConditions *op_cond = library_->findOperatingConditions(op_cond_name); if (op_cond) { debugPrint(debug_, "liberty", 1, "scaled cell {} {}", - name.c_str(), op_cond_name.c_str()); - LibertyCell *scaled_cell = library_->makeScaledCell(name, - std::string(filename_)); + name, op_cond_name); + LibertyCell *scaled_cell = library_->makeScaledCell(name, filename_); readCell(scaled_cell, scaled_cell_group); checkScaledCell(scaled_cell, owner, scaled_cell_group, op_cond_name); // Add scaled cell AFTER ports and timing arcs are defined. @@ -1163,8 +1162,7 @@ LibertyReader::makeBundlePort(LibertyCell *cell, members->push_back(member); } } - LibertyPort *bundle_port = builder_.makeBundlePort(cell, bundle_name.c_str(), - members); + LibertyPort *bundle_port = builder_.makeBundlePort(cell, bundle_name, members); port_group_map[bundle_group].push_back(bundle_port); // Make ports for pin groups inside the bundle group. makeBundlePinPorts(cell, bundle_group, port_group_map); @@ -1204,7 +1202,7 @@ LibertyReader::makePgPinPort(LibertyCell *cell, const std::string &type_name = pg_pin_group->findAttrString("pg_type"); if (!type_name.empty()) { - PwrGndType type = findPwrGndType(type_name.c_str()); + PwrGndType type = findPwrGndType(type_name); PortDirection *dir = PortDirection::unknown(); switch (type) { case PwrGndType::primary_ground: @@ -1235,7 +1233,7 @@ LibertyReader::makePgPinPort(LibertyCell *cell, const std::string &voltate_name = pg_pin_group->findAttrString("voltage_name"); if (!voltate_name.empty()) - pg_port->setVoltageName(voltate_name.c_str()); + pg_port->setVoltageName(voltate_name); } else warn(1314, pg_pin_group, "pg_pin missing name."); @@ -1295,7 +1293,7 @@ LibertyReader::readDriverWaveform(const LibertyPortSeq &ports, : "driver_waveform_fall"; const std::string &name = port_group->findAttrString(attr_name); if (!name.empty()) { - DriverWaveform *waveform = library_->findDriverWaveform(name.c_str()); + DriverWaveform *waveform = library_->findDriverWaveform(name); if (waveform) { for (LibertyPort *port : ports) port->setDriverWaveform(waveform, rf); @@ -1830,9 +1828,9 @@ LibertyReader::readCellAttributes(LibertyCell *cell, const std::string &clock_gate_type = cell_group->findAttrString("clock_gating_integrated_cell"); if (!clock_gate_type.empty()) { - if (stringBeginEqual(clock_gate_type.c_str(), "latch_posedge")) + if (stringBeginEqual(clock_gate_type, "latch_posedge")) cell->setClockGateType(ClockGateType::latch_posedge); - else if (stringBeginEqual(clock_gate_type.c_str(), "latch_negedge")) + else if (stringBeginEqual(clock_gate_type, "latch_negedge")) cell->setClockGateType(ClockGateType::latch_negedge); else cell->setClockGateType(ClockGateType::other); @@ -1852,7 +1850,7 @@ LibertyReader::readScaleFactors(LibertyCell *cell, cell_group->findAttrString("scaling_factors"); if (!scale_factors_name.empty()) { ScaleFactors *scale_factors = - library_->findScaleFactors(scale_factors_name.c_str()); + library_->findScaleFactors(scale_factors_name); if (scale_factors) cell->setScaleFactors(scale_factors); else @@ -1862,7 +1860,7 @@ LibertyReader::readScaleFactors(LibertyCell *cell, void LibertyReader::readCellAttrString(std::string_view attr_name, - void (LibertyCell::*set_func)(std::string value), + void (LibertyCell::*set_func)(std::string_view value), LibertyCell *cell, const LibertyGroup *group) { @@ -2943,9 +2941,9 @@ LibertyReader::readCellOcvDerateGroup(LibertyCell *cell, { const std::string &derate_name = cell_group->findAttrString("ocv_derate_group"); if (!derate_name.empty()) { - OcvDerate *derate = cell->findOcvDerate(derate_name.c_str()); + OcvDerate *derate = cell->findOcvDerate(derate_name); if (derate == nullptr) - derate = library_->findOcvDerate(derate_name.c_str()); + derate = library_->findOcvDerate(derate_name); if (derate) cell->setOcvDerate(derate); else @@ -3453,7 +3451,7 @@ LibertyReader::readDefaultOcvDerateGroup(const LibertyGroup *library_group) const std::string &derate_name = library_group->findAttrString("default_ocv_derate_group"); if (!derate_name.empty()) { - OcvDerate *derate = library_->findOcvDerate(derate_name.c_str()); + OcvDerate *derate = library_->findOcvDerate(derate_name); if (derate) library_->setDefaultOcvDerate(derate); else diff --git a/liberty/LibertyReaderPvt.hh b/liberty/LibertyReaderPvt.hh index a840ebb2..28683aef 100644 --- a/liberty/LibertyReaderPvt.hh +++ b/liberty/LibertyReaderPvt.hh @@ -375,7 +375,7 @@ protected: void readScaleFactors(LibertyCell *cell, const LibertyGroup *cell_group); void readCellAttrString(std::string_view attr_name, - void (LibertyCell::*set_func)(std::string value), + void (LibertyCell::*set_func)(std::string_view value), LibertyCell *cell, const LibertyGroup *group); void readCellAttrFloat(std::string_view attr_name, diff --git a/network/ConcreteLibrary.cc b/network/ConcreteLibrary.cc index 74c37b15..3864239c 100644 --- a/network/ConcreteLibrary.cc +++ b/network/ConcreteLibrary.cc @@ -38,12 +38,12 @@ namespace sta { static constexpr char escape_ = '\\'; -ConcreteLibrary::ConcreteLibrary(std::string name, - std::string filename, +ConcreteLibrary::ConcreteLibrary(std::string_view name, + std::string_view filename, bool is_liberty) : - name_(std::move(name)), + name_(name), id_(ConcreteNetwork::nextObjectId()), - filename_(std::move(filename)), + filename_(filename), is_liberty_(is_liberty), bus_brkt_left_('['), bus_brkt_right_(']') diff --git a/sdc/FilterObjects.cc b/sdc/FilterObjects.cc index b7d47671..6e263037 100644 --- a/sdc/FilterObjects.cc +++ b/sdc/FilterObjects.cc @@ -73,9 +73,9 @@ public: FilterExpr(std::string_view expression, Report *report); - std::vector> postfix(bool bool_props_as_int); + std::vector> postfix(); private: - std::vector> lex(bool bool_props_as_int); + std::vector> lex(); std::vector> shuntingYard(std::vector> &infix); std::string raw_; @@ -106,20 +106,21 @@ FilterExpr::FilterExpr(std::string_view expression, } std::vector> -FilterExpr::postfix(bool bool_props_as_int) +FilterExpr::postfix() { - auto infix = lex(bool_props_as_int); + auto infix = lex(); return shuntingYard(infix); } std::vector> -FilterExpr::lex(bool bool_props_as_int) +FilterExpr::lex() { std::vector> token_regexes = { {std::regex("^\\s+"), Token::Kind::skip}, {std::regex("^defined\\(([a-zA-Z_]+)\\)"), Token::Kind::defined}, {std::regex("^undefined\\(([a-zA-Z_]+)\\)"), Token::Kind::undefined}, - {std::regex("^@?([a-zA-Z_]+) *((==|!=|=~|!~) *([0-9a-zA-Z_\\/$\\[\\]*?.]+))?"), Token::Kind::predicate}, + {std::regex("^@?([a-zA-Z_]+) *((==|!=|=~|!~) *([0-9a-zA-Z_\\/$\\[\\]*?.]+))?"), + Token::Kind::predicate}, {std::regex("^(&&)"), Token::Kind::op_and}, {std::regex("^(\\|\\|)"), Token::Kind::op_or}, {std::regex("^(!)"), Token::Kind::op_inv}, @@ -139,9 +140,9 @@ FilterExpr::lex(bool bool_props_as_int) std::string property = token_match[1].str(); // The default operation on a predicate if an op and arg are - // omitted is 'arg == 1' / 'arg == true'. + // omitted is 'prop == 1 || true'. std::string op = "=="; - std::string arg = (bool_props_as_int ? "1" : "true"); + std::string arg = "1"; if (token_match[2].length() != 0) { op = token_match[3].str(); @@ -250,13 +251,18 @@ filterObjects(const char *property, bool not_pattern_match = stringEq(op, "!~"); for (T *object : all) { PropertyValue value = properties.getProperty(object, property); - std::string prop_str = value.to_string(network); - const char *prop = prop_str.c_str(); - if (prop && - ((exact_match && stringEq(prop, pattern)) - || (not_match && !stringEq(prop, pattern)) - || (pattern_match && patternMatch(pattern, prop)) - || (not_pattern_match && !patternMatch(pattern, prop)))) + std::string prop = value.to_string(network); + if (value.type() == PropertyValue::Type::bool_) { + // Canonicalize bool true/false to 1/0. + if (stringEqual(pattern, "true")) + pattern = "1"; + else if (stringEqual(pattern, "false")) + pattern = "0"; + } + if ((exact_match && stringEq(prop.c_str(), pattern)) + || (not_match && !stringEq(prop.c_str(), pattern)) + || (pattern_match && patternMatch(pattern, prop)) + || (not_pattern_match && !patternMatch(pattern, prop))) filtered_objects.insert(object); } return filtered_objects; @@ -265,7 +271,6 @@ filterObjects(const char *property, template std::vector filterObjects(std::string_view filter_expression, std::vector *objects, - bool bool_props_as_int, Sta *sta) { Report *report = sta->report(); @@ -278,7 +283,7 @@ filterObjects(std::string_view filter_expression, all.insert(object); FilterExpr filter(filter_expression, report); - auto postfix = filter.postfix(bool_props_as_int); + auto postfix = filter.postfix(); std::stack> eval_stack; for (auto &token : postfix) { if (token->kind == FilterExpr::Token::Kind::op_or) { @@ -405,100 +410,89 @@ filterObjects(std::string_view filter_expression, PortSeq filterPorts(std::string_view filter_expression, PortSeq *objects, - bool bool_props_as_int, Sta *sta) { - return filterObjects(filter_expression, objects, bool_props_as_int, sta); + return filterObjects(filter_expression, objects, sta); } InstanceSeq filterInstances(std::string_view filter_expression, InstanceSeq *objects, - bool bool_props_as_int, Sta *sta) { - return filterObjects(filter_expression, objects, bool_props_as_int, sta); + return filterObjects(filter_expression, objects, sta); } PinSeq filterPins(std::string_view filter_expression, PinSeq *objects, - bool bool_props_as_int, Sta *sta) { - return filterObjects(filter_expression, objects, bool_props_as_int, sta); + return filterObjects(filter_expression, objects, sta); } NetSeq filterNets(std::string_view filter_expression, NetSeq *objects, - bool bool_props_as_int, Sta *sta) { - return filterObjects(filter_expression, objects, bool_props_as_int, sta); + return filterObjects(filter_expression, objects, sta); } ClockSeq filterClocks(std::string_view filter_expression, ClockSeq *objects, - bool bool_props_as_int, Sta *sta) { - return filterObjects(filter_expression, objects, bool_props_as_int, sta); + return filterObjects(filter_expression, objects, sta); } LibertyCellSeq filterLibCells(std::string_view filter_expression, LibertyCellSeq *objects, - bool bool_props_as_int, Sta *sta) { - return filterObjects(filter_expression, objects, bool_props_as_int, sta); + return filterObjects(filter_expression, objects, sta); } LibertyPortSeq filterLibPins(std::string_view filter_expression, LibertyPortSeq *objects, - bool bool_props_as_int, Sta *sta) { - return filterObjects(filter_expression, objects, bool_props_as_int, sta); + return filterObjects(filter_expression, objects, sta); } LibertyLibrarySeq filterLibertyLibraries(std::string_view filter_expression, LibertyLibrarySeq *objects, - bool bool_props_as_int, Sta *sta) { - return filterObjects(filter_expression, objects, bool_props_as_int, sta); + return filterObjects(filter_expression, objects, sta); } EdgeSeq filterTimingArcs(std::string_view filter_expression, EdgeSeq *objects, - bool bool_props_as_int, Sta *sta) { - return filterObjects(filter_expression, objects, bool_props_as_int, sta); + return filterObjects(filter_expression, objects, sta); } PathEndSeq filterPathEnds(std::string_view filter_expression, PathEndSeq *objects, - bool bool_props_as_int, Sta *sta) { - return filterObjects(filter_expression, objects, bool_props_as_int, sta); + return filterObjects(filter_expression, objects, sta); } StringSeq filterExprToPostfix(std::string_view expr, - bool bool_props_as_int, Report *report) { FilterExpr filter(expr, report); - auto postfix = filter.postfix(bool_props_as_int); + auto postfix = filter.postfix(); StringSeq result; for (auto &token : postfix) result.push_back(token->text); diff --git a/sdc/Sdc.i b/sdc/Sdc.i index eccd234e..60107704 100644 --- a/sdc/Sdc.i +++ b/sdc/Sdc.i @@ -1493,101 +1493,90 @@ find_register_output_pins(ClockSet *clks, PortSeq filter_ports(const char *filter_expression, - PortSeq *ports, - bool bool_props_as_int) + PortSeq *ports) { sta::Sta *sta = Sta::sta(); - return filterPorts(filter_expression, ports, bool_props_as_int, sta); + return filterPorts(filter_expression, ports, sta); } InstanceSeq filter_insts(const char *filter_expression, - InstanceSeq *insts, - bool bool_props_as_int) + InstanceSeq *insts) { sta::Sta *sta = Sta::sta(); - return filterInstances(filter_expression, insts, bool_props_as_int, sta); + return filterInstances(filter_expression, insts, sta); } PinSeq filter_pins(const char *filter_expression, - PinSeq *pins, - bool bool_props_as_int) + PinSeq *pins) { sta::Sta *sta = Sta::sta(); - return filterPins(filter_expression, pins, bool_props_as_int, sta); + return filterPins(filter_expression, pins, sta); } NetSeq filter_nets(const char *filter_expression, - NetSeq *nets, - bool bool_props_as_int) + NetSeq *nets) { sta::Sta *sta = Sta::sta(); - return filterNets(filter_expression, nets, bool_props_as_int, sta); + return filterNets(filter_expression, nets, sta); } ClockSeq filter_clocks(const char *filter_expression, - ClockSeq *clocks, - bool bool_props_as_int) + ClockSeq *clocks) { sta::Sta *sta = Sta::sta(); - return filterClocks(filter_expression, clocks, bool_props_as_int, sta); + return filterClocks(filter_expression, clocks, sta); } LibertyCellSeq filter_lib_cells(const char *filter_expression, - LibertyCellSeq *cells, - bool bool_props_as_int) + LibertyCellSeq *cells) { sta::Sta *sta = Sta::sta(); - return filterLibCells(filter_expression, cells, bool_props_as_int, sta); + return filterLibCells(filter_expression, cells, sta); } LibertyPortSeq filter_lib_pins(const char *filter_expression, - LibertyPortSeq *pins, - bool bool_props_as_int) + LibertyPortSeq *pins) { sta::Sta *sta = Sta::sta(); - return filterLibPins(filter_expression, pins, bool_props_as_int, sta); + return filterLibPins(filter_expression, pins, sta); } LibertyLibrarySeq filter_liberty_libraries(const char *filter_expression, - LibertyLibrarySeq *libs, - bool bool_props_as_int) + LibertyLibrarySeq *libs) { sta::Sta *sta = Sta::sta(); - return filterLibertyLibraries(filter_expression, libs, bool_props_as_int, sta); + return filterLibertyLibraries(filter_expression, libs, sta); } EdgeSeq filter_timing_arcs(const char *filter_expression, - EdgeSeq *edges, - bool bool_props_as_int) + EdgeSeq *edges) { sta::Sta *sta = Sta::sta(); - return filterTimingArcs(filter_expression, edges, bool_props_as_int, sta); + return filterTimingArcs(filter_expression, edges, sta); } PathEndSeq filter_path_ends(const char *filter_expression, - PathEndSeq *path_ends, - bool bool_props_as_int) + PathEndSeq *path_ends) { sta::Sta *sta = Sta::sta(); - return filterPathEnds(filter_expression, path_ends, bool_props_as_int, sta); + return filterPathEnds(filter_expression, path_ends, sta); } // For FilterExpr unit tests. StringSeq -filter_expr_to_postfix(const char* expr, - bool bool_props_as_int) +filter_expr_to_postfix(const char* expr) { Report *report = Sta::sta()->report(); - return filterExprToPostfix(expr, bool_props_as_int, report); + return filterExprToPostfix(expr, report); } //////////////////////////////////////////////////////////////// diff --git a/sdc/Sdc.tcl b/sdc/Sdc.tcl index dd5374cd..d8e5aef1 100644 --- a/sdc/Sdc.tcl +++ b/sdc/Sdc.tcl @@ -393,7 +393,7 @@ proc get_cells { args } { } } if [info exists keys(-filter)] { - set insts [filter_insts $keys(-filter) $insts 1] + set insts [filter_insts $keys(-filter) $insts] } return $insts } @@ -436,7 +436,7 @@ proc get_clocks { args } { } } if [info exists keys(-filter)] { - set clocks [filter_clocks $keys(-filter) $clocks 1] + set clocks [filter_clocks $keys(-filter) $clocks] } return $clocks } @@ -517,7 +517,7 @@ proc get_lib_cells { args } { } } if [info exists keys(-filter)] { - set cells [filter_lib_cells $keys(-filter) $cells 1] + set cells [filter_lib_cells $keys(-filter) $cells] } return $cells } @@ -621,7 +621,7 @@ proc get_lib_pins { args } { } } if [info exists keys(-filter)] { - set ports [filter_lib_pins $keys(-filter) $ports 1] + set ports [filter_lib_pins $keys(-filter) $ports] } return $ports } @@ -671,7 +671,7 @@ proc get_libs { args } { } } if [info exists keys(-filter)] { - set libs [filter_liberty_libraries $keys(-filter) $libs 1] + set libs [filter_liberty_libraries $keys(-filter) $libs] } return $libs } @@ -772,7 +772,7 @@ proc get_nets { args } { } } if [info exists keys(-filter)] { - set nets [filter_nets $keys(-filter) $nets 1] + set nets [filter_nets $keys(-filter) $nets] } return $nets } @@ -863,7 +863,7 @@ proc get_pins { args } { } } if [info exists keys(-filter)] { - set pins [filter_pins $keys(-filter) $pins 1] + set pins [filter_pins $keys(-filter) $pins] } return $pins } @@ -919,7 +919,7 @@ proc get_ports { args } { } } if [info exists keys(-filter)] { - set ports [filter_ports $keys(-filter) $ports 1] + set ports [filter_ports $keys(-filter) $ports] } return $ports } diff --git a/search/Property.cc b/search/Property.cc index cdb0c088..067298d7 100644 --- a/search/Property.cc +++ b/search/Property.cc @@ -564,7 +564,7 @@ PropertyValue::to_string(const Network *network) const case Type::float_: return unit_->asString(float_, 6); case Type::bool_: - // true/false would be better but these are TCL true/false values. + // These are TCL true/false values. if (bool_) return "1"; else diff --git a/tcl/Sta.tcl b/tcl/Sta.tcl index f6daed10..8796df34 100644 --- a/tcl/Sta.tcl +++ b/tcl/Sta.tcl @@ -300,7 +300,7 @@ proc get_timing_edges_cmd { cmd cmd_args } { cmd_usage_error $cmd } if [info exists keys(-filter)] { - set arcs [filter_timing_arcs $keys(-filter) $arcs 1] + set arcs [filter_timing_arcs $keys(-filter) $arcs] } return $arcs } diff --git a/tcl/StaTclTypes.i b/tcl/StaTclTypes.i index 9157a3fc..afbc74f5 100644 --- a/tcl/StaTclTypes.i +++ b/tcl/StaTclTypes.i @@ -280,7 +280,7 @@ using namespace sta; } %typemap(in) std::string_view { - int length; + Tcl_Size length; const char *str = Tcl_GetStringFromObj($input, &length); $1 = std::string_view(str, length); } @@ -415,7 +415,7 @@ using namespace sta; } %typemap(in) Transition* { - int length; + Tcl_Size length; const char *arg = Tcl_GetStringFromObj($input, &length); Transition *tr = Transition::find(std::string_view(arg, length)); if (tr == nullptr) { @@ -433,7 +433,7 @@ using namespace sta; } %typemap(in) RiseFall* { - int length; + Tcl_Size length; const char *arg = Tcl_GetStringFromObj($input, &length); const RiseFall *rf = RiseFall::find(std::string_view(arg, length)); if (rf == nullptr) { @@ -451,7 +451,7 @@ using namespace sta; } %typemap(in) RiseFallBoth* { - int length; + Tcl_Size length; const char *arg = Tcl_GetStringFromObj($input, &length); const RiseFallBoth *rf = RiseFallBoth::find(std::string_view(arg, length)); if (rf == nullptr) { @@ -469,7 +469,7 @@ using namespace sta; } %typemap(in) PortDirection* { - int length; + Tcl_Size length; const char *arg = Tcl_GetStringFromObj($input, &length); PortDirection *dir = PortDirection::find(arg); if (dir == nullptr) { @@ -481,7 +481,7 @@ using namespace sta; } %typemap(in) TimingRole* { - int length; + Tcl_Size length; const char *arg = Tcl_GetStringFromObj($input, &length); const TimingRole *role = TimingRole::find(arg); if (role) @@ -498,7 +498,7 @@ using namespace sta; } %typemap(in) LogicValue { - int length; + Tcl_Size length; std::string arg = Tcl_GetStringFromObj($input, &length); if (arg == "0" || stringEqual(arg, "zero")) $1 = LogicValue::zero; @@ -517,7 +517,7 @@ using namespace sta; } %typemap(in) AnalysisType { - int length; + Tcl_Size length; const char *arg = Tcl_GetStringFromObj($input, &length); if (stringEqual(arg, "single")) $1 = AnalysisType::single; @@ -831,7 +831,7 @@ using namespace sta; } %typemap(in) MinMax* { - int length; + Tcl_Size length; char *arg = Tcl_GetStringFromObj($input, &length); // Swig is retarded and drops const on args. MinMax *min_max = const_cast(MinMax::find(arg)); @@ -852,7 +852,7 @@ using namespace sta; } %typemap(in) MinMaxAll* { - int length; + Tcl_Size length; char *arg = Tcl_GetStringFromObj($input, &length); // Swig is retarded and drops const on args. MinMaxAll *min_max = const_cast(MinMaxAll::find(arg)); @@ -865,7 +865,7 @@ using namespace sta; } %typemap(in) MinMaxAllNull* { - int length; + Tcl_Size length; char *arg = Tcl_GetStringFromObj($input, &length); if (stringEqual(arg, "NULL")) $1 = nullptr; @@ -887,7 +887,7 @@ using namespace sta; // SetupHold is typedef'd to MinMax. %typemap(in) const SetupHold* { - int length; + Tcl_Size length; char *arg = Tcl_GetStringFromObj($input, &length); // Swig is retarded and drops const on args. if (stringEqual(arg, "hold") @@ -904,7 +904,7 @@ using namespace sta; // SetupHoldAll is typedef'd to MinMaxAll. %typemap(in) const SetupHoldAll* { - int length; + Tcl_Size length; char *arg = Tcl_GetStringFromObj($input, &length); // Swig is retarded and drops const on args. if (stringEqual(arg, "hold") @@ -925,7 +925,7 @@ using namespace sta; // EarlyLate is typedef'd to MinMax. %typemap(in) const EarlyLate* { - int length; + Tcl_Size length; char *arg = Tcl_GetStringFromObj($input, &length); // Swig is retarded and drops const on args. EarlyLate *early_late = const_cast(EarlyLate::find(arg)); @@ -939,7 +939,7 @@ using namespace sta; // EarlyLateAll is typedef'd to MinMaxAll. %typemap(in) const EarlyLateAll* { - int length; + Tcl_Size length; char *arg = Tcl_GetStringFromObj($input, &length); // Swig is retarded and drops const on args. EarlyLateAll *early_late = const_cast(EarlyLateAll::find(arg)); @@ -952,7 +952,7 @@ using namespace sta; } %typemap(in) TimingDerateType { - int length; + Tcl_Size length; char *arg = Tcl_GetStringFromObj($input, &length); if (stringEqual(arg, "net_delay")) $1 = TimingDerateType::net_delay; @@ -967,7 +967,7 @@ using namespace sta; } %typemap(in) TimingDerateCellType { - int length; + Tcl_Size length; char *arg = Tcl_GetStringFromObj($input, &length); if (stringEqual(arg, "cell_delay")) $1 = TimingDerateCellType::cell_delay; @@ -980,7 +980,7 @@ using namespace sta; } %typemap(in) PathClkOrData { - int length; + Tcl_Size length; std::string arg = Tcl_GetStringFromObj($input, &length); if (stringEqual(arg, "clk")) $1 = PathClkOrData::clk; @@ -993,7 +993,7 @@ using namespace sta; } %typemap(in) ReportSortBy { - int length; + Tcl_Size length; std::string arg = Tcl_GetStringFromObj($input, &length); if (stringEqual(arg, "group")) $1 = sort_by_group; @@ -1006,7 +1006,7 @@ using namespace sta; } %typemap(in) ReportPathFormat { - int length; + Tcl_Size length; std::string arg = Tcl_GetStringFromObj($input, &length); if (stringEqual(arg, "full")) $1 = ReportPathFormat::full; @@ -1188,7 +1188,7 @@ using namespace sta; if (Tcl_ListObjGetElements(interp, $input, &argc, &argv) == TCL_OK && argc > 0) { for (int i = 0; i < argc; i++) { - int length; + Tcl_Size length; const char *mode_name = Tcl_GetStringFromObj(argv[i], &length); Mode *mode = sta->findMode(mode_name); if (mode) @@ -1215,7 +1215,7 @@ using namespace sta; %typemap(in) Scene* { sta::Sta *sta = Sta::sta(); - int length; + Tcl_Size length; std::string scene_name = Tcl_GetStringFromObj($input, &length); // parse_scene_or_all support depreated 11/21/2025 if (scene_name == "NULL") @@ -1248,7 +1248,7 @@ using namespace sta; if (Tcl_ListObjGetElements(interp, $input, &argc, &argv) == TCL_OK && argc > 0) { for (int i = 0; i < argc; i++) { - int length; + Tcl_Size length; const char *scene_name = Tcl_GetStringFromObj(argv[i], &length); Scene *scene = sta->findScene(scene_name); if (scene) @@ -1274,7 +1274,7 @@ using namespace sta; } %typemap(in) PropertyValue { - int length; + Tcl_Size length; const char *arg = Tcl_GetStringFromObj($input, &length); $1 = PropertyValue(arg); } @@ -1411,7 +1411,7 @@ using namespace sta; } %typemap(in) CircuitSim { - int length; + Tcl_Size length; std::string arg = Tcl_GetStringFromObj($input, &length); if (stringEqual(arg, "hspice")) $1 = CircuitSim::hspice; diff --git a/tcl/TclTypeHelpers.cc b/tcl/TclTypeHelpers.cc index 48ccbf57..bcd4f264 100644 --- a/tcl/TclTypeHelpers.cc +++ b/tcl/TclTypeHelpers.cc @@ -40,7 +40,7 @@ tclListStringSeq(Tcl_Obj *const source, StringSeq seq; if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK) { for (int i = 0; i < argc; i++) { - int length; + Tcl_Size length; const char *str = Tcl_GetStringFromObj(argv[i], &length); seq.push_back(str); } @@ -58,7 +58,7 @@ tclListStringSeqPtr(Tcl_Obj *const source, if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK) { StringSeq *seq = new StringSeq; for (int i = 0; i < argc; i++) { - int length; + Tcl_Size length; const char *str = Tcl_GetStringFromObj(argv[i], &length); seq->push_back(str); } @@ -78,7 +78,7 @@ tclListStringSet(Tcl_Obj *const source, if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK) { StringSet *set = new StringSet; for (int i = 0; i < argc; i++) { - int length; + Tcl_Size length; const char *str = Tcl_GetStringFromObj(argv[i], &length); set->insert(str); } @@ -183,11 +183,11 @@ arcDcalcArgTcl(Tcl_Obj *obj, { Sta *sta = Sta::sta(); sta->ensureGraph(); - int list_argc; + Tcl_Size list_argc; Tcl_Obj **list_argv; if (Tcl_ListObjGetElements(interp, obj, &list_argc, &list_argv) == TCL_OK) { const char *input_delay = "0.0"; - int length; + Tcl_Size length; if (list_argc == 6) input_delay = Tcl_GetStringFromObj(list_argv[5], &length); if (list_argc == 5 || list_argc == 6) { diff --git a/tcl/Variables.tcl b/tcl/Variables.tcl index ba8f37b3..0ea66690 100644 --- a/tcl/Variables.tcl +++ b/tcl/Variables.tcl @@ -33,13 +33,13 @@ namespace eval sta { # Default digits to print after decimal point for reporting commands. set ::sta_report_default_digits 2 -trace variable ::sta_report_default_digits "rw" \ +trace add variable ::sta_report_default_digits {read write} \ sta::trace_report_default_digits proc trace_report_default_digits { name1 name2 op } { global sta_report_default_digits - if { $op == "w" } { + if { $op == "write" } { if { !([string is integer $sta_report_default_digits] \ && $sta_report_default_digits >= 0) } { sta_error 590 "sta_report_default_digits must be a positive integer." @@ -47,7 +47,7 @@ proc trace_report_default_digits { name1 name2 op } { } } -trace variable ::sta_crpr_enabled "rw" \ +trace add variable ::sta_crpr_enabled {read write} \ sta::trace_crpr_enabled proc trace_crpr_enabled { name1 name2 op } { @@ -55,15 +55,15 @@ proc trace_crpr_enabled { name1 name2 op } { crpr_enabled set_crpr_enabled } -trace variable ::sta_crpr_mode "rw" \ +trace add variable ::sta_crpr_mode {read write} \ sta::trace_crpr_mode proc trace_crpr_mode { name1 name2 op } { global sta_crpr_mode - if { $op == "r" } { + if { $op == "read" } { set sta_crpr_mode [crpr_mode] - } elseif { $op == "w" } { + } elseif { $op == "write" } { if { $sta_crpr_mode == "same_pin" || $sta_crpr_mode == "same_transition" } { set_crpr_mode $sta_crpr_mode } else { @@ -72,7 +72,7 @@ proc trace_crpr_mode { name1 name2 op } { } } -trace variable ::sta_cond_default_arcs_enabled "rw" \ +trace add variable ::sta_cond_default_arcs_enabled {read write} \ sta::trace_cond_default_arcs_enabled proc trace_cond_default_arcs_enabled { name1 name2 op } { @@ -80,7 +80,7 @@ proc trace_cond_default_arcs_enabled { name1 name2 op } { cond_default_arcs_enabled set_cond_default_arcs_enabled } -trace variable ::sta_gated_clock_checks_enabled "rw" \ +trace add variable ::sta_gated_clock_checks_enabled {read write} \ sta::trace_gated_clk_checks_enabled proc trace_gated_clk_checks_enabled { name1 name2 op } { @@ -88,7 +88,7 @@ proc trace_gated_clk_checks_enabled { name1 name2 op } { gated_clk_checks_enabled set_gated_clk_checks_enabled } -trace variable ::sta_internal_bidirect_instance_paths_enabled "rw" \ +trace add variable ::sta_internal_bidirect_instance_paths_enabled {read write} \ sta::trace_internal_bidirect_instance_paths_enabled proc trace_internal_bidirect_instance_paths_enabled { name1 name2 op } { @@ -96,7 +96,7 @@ proc trace_internal_bidirect_instance_paths_enabled { name1 name2 op } { bidirect_inst_paths_enabled set_bidirect_inst_paths_enabled } -trace variable ::sta_clock_through_tristate_enabled "rw" \ +trace add variable ::sta_clock_through_tristate_enabled {read write} \ sta::trace_clock_through_tristate_enabled proc trace_clock_through_tristate_enabled { name1 name2 op } { @@ -104,7 +104,7 @@ proc trace_clock_through_tristate_enabled { name1 name2 op } { clk_thru_tristate_enabled set_clk_thru_tristate_enabled } -trace variable ::sta_preset_clear_arcs_enabled "rw" \ +trace add variable ::sta_preset_clear_arcs_enabled {read write} \ sta::trace_preset_clr_arcs_enabled proc trace_preset_clr_arcs_enabled { name1 name2 op } { @@ -112,7 +112,7 @@ proc trace_preset_clr_arcs_enabled { name1 name2 op } { preset_clr_arcs_enabled set_preset_clr_arcs_enabled } -trace variable ::sta_recovery_removal_checks_enabled "rw" \ +trace add variable ::sta_recovery_removal_checks_enabled {read write} \ sta::trace_recovery_removal_checks_enabled proc trace_recovery_removal_checks_enabled { name1 name2 op } { @@ -120,7 +120,7 @@ proc trace_recovery_removal_checks_enabled { name1 name2 op } { recovery_removal_checks_enabled set_recovery_removal_checks_enabled } -trace variable ::sta_dynamic_loop_breaking "rw" \ +trace add variable ::sta_dynamic_loop_breaking {read write} \ sta::trace_dynamic_loop_breaking proc trace_dynamic_loop_breaking { name1 name2 op } { @@ -128,7 +128,7 @@ proc trace_dynamic_loop_breaking { name1 name2 op } { dynamic_loop_breaking set_dynamic_loop_breaking } -trace variable ::sta_input_port_default_clock "rw" \ +trace add variable ::sta_input_port_default_clock {read write} \ sta::trace_input_port_default_clock proc trace_input_port_default_clock { name1 name2 op } { @@ -136,7 +136,7 @@ proc trace_input_port_default_clock { name1 name2 op } { use_default_arrival_clock set_use_default_arrival_clock } -trace variable ::sta_propagate_all_clocks "rw" \ +trace add variable ::sta_propagate_all_clocks {read write} \ sta::trace_propagate_all_clocks proc trace_propagate_all_clocks { name1 name2 op } { @@ -144,7 +144,7 @@ proc trace_propagate_all_clocks { name1 name2 op } { propagate_all_clocks set_propagate_all_clocks } -trace variable ::sta_propagate_gated_clock_enable "rw" \ +trace add variable ::sta_propagate_gated_clock_enable {read write} \ sta::trace_propagate_gated_clock_enable proc trace_propagate_gated_clock_enable { name1 name2 op } { @@ -152,15 +152,15 @@ proc trace_propagate_gated_clock_enable { name1 name2 op } { propagate_gated_clock_enable set_propagate_gated_clock_enable } -trace variable ::sta_pocv_mode "rw" \ +trace add variable ::sta_pocv_mode {read write} \ sta::trace_pocv_mode proc trace_pocv_mode { name1 name2 op } { global sta_pocv_mode - if { $op == "r" } { + if { $op == "read" } { set sta_pocv_mode [pocv_mode] - } elseif { $op == "w" } { + } elseif { $op == "write" } { if { $sta_pocv_mode == "scalar" \ || $sta_pocv_mode == "normal" \ || $sta_pocv_mode == "skew_normal" } { @@ -171,15 +171,15 @@ proc trace_pocv_mode { name1 name2 op } { } } -trace variable ::sta_pocv_quantile "rw" \ +trace add variable ::sta_pocv_quantile {read write} \ sta::trace_pocv_quantile proc trace_pocv_quantile { name1 name2 op } { global sta_pocv_quantile - if { $op == "r" } { + if { $op == "read" } { set sta_pocv_quantile [pocv_quantile] - } elseif { $op == "w" } { + } elseif { $op == "write" } { if { [string is double $sta_pocv_quantile] \ && $sta_pocv_quantile >= 0.0 } { set_pocv_quantile $sta_pocv_quantile @@ -194,9 +194,9 @@ proc trace_pocv_quantile { name1 name2 op } { proc trace_boolean_var { op var_name get_proc set_proc } { upvar 1 $var_name var - if { $op == "r" } { + if { $op == "read" } { set var [$get_proc] - } elseif { $op == "w" } { + } elseif { $op == "write" } { if { $var == 0 } { $set_proc 0 } elseif { $var == 1 } { diff --git a/test/asap7_small.lib.gz b/test/asap7_small.lib.gz index 3c47419f..f0381ded 100644 Binary files a/test/asap7_small.lib.gz and b/test/asap7_small.lib.gz differ diff --git a/test/get_filter.ok b/test/get_filter.ok index 8bd8c18a..1f0402ec 100644 --- a/test/get_filter.ok +++ b/test/get_filter.ok @@ -1,24 +1,11 @@ [get_cells -filter liberty_cell==BUFx2_ASAP7_75t_R *] u1 -[get_clocks -filter is_virtual==0 *] -clk -[get_clocks -filter is_virtual==1 *] -vclk [get_clocks -filter is_virtual *] vclk -[get_clocks -filter is_virtual&&is_generated *] -[get_clocks -filter is_virtual&&is_generated==0 *] -vclk -[get_clocks -filter is_virtual||is_generated *] -vclk -[get_clocks -filter is_virtual==0||is_generated *] -clk -[get_lib_cells -filter is_buffer==1 *] +[get_lib_cells -filter is_buffer *] asap7_small/BUFx2_ASAP7_75t_R -[get_lib_cells -filter is_inverter==0 *] -asap7_small/AND2x2_ASAP7_75t_R -asap7_small/BUFx2_ASAP7_75t_R -asap7_small/DFFHQx4_ASAP7_75t_R +[get_lib_cells -filter is_inverter *] +asap7_small/INVx2_ASAP7_75t_R [get_lib_pins -filter direction==input BUFx2_ASAP7_75t_R/*] A [get_lib_pins -filter direction==output BUFx2_ASAP7_75t_R/*] @@ -54,9 +41,22 @@ in2 out [get_cells -filter {name ~= *r1*} *] Error: 2600 -filter parsing failed at '~= *r1*'. +direction == input && name =~ clk* clk1 clk2 clk3 +(direction == input) && (name =~ clk*)" clk1 clk2 clk3 +[get_clocks -filter is_virtual||is_generated *] +vclk +[get_clocks -filter is_virtual==0 *] +clk +[get_clocks -filter is_virtual==false *] +clk +[get_clocks -filter is_virtual==1 *] +vclk +[get_clocks -filter is_virtual==true *] +vclk +{direction == input} {name =~ clk*} {is_clock == 1} && && diff --git a/test/get_filter.tcl b/test/get_filter.tcl index d6009a89..b373e944 100644 --- a/test/get_filter.tcl +++ b/test/get_filter.tcl @@ -5,29 +5,16 @@ link_design top create_clock -name clk -period 500 {clk1 clk2 clk3} create_clock -name vclk -period 1000 -# Test filters for each SDC get_* command. puts {[get_cells -filter liberty_cell==BUFx2_ASAP7_75t_R *]} report_object_full_names [get_cells -filter liberty_cell==BUFx2_ASAP7_75t_R *] -puts {[get_clocks -filter is_virtual==0 *]} -report_object_full_names [get_clocks -filter is_virtual==0 *] -puts {[get_clocks -filter is_virtual==1 *]} -report_object_full_names [get_clocks -filter is_virtual==1 *] puts {[get_clocks -filter is_virtual *]} report_object_full_names [get_clocks -filter is_virtual *] -puts {[get_clocks -filter is_virtual&&is_generated *]} -report_object_full_names [get_clocks -filter is_virtual&&is_generated *] -puts {[get_clocks -filter is_virtual&&is_generated==0 *]} -report_object_full_names [get_clocks -filter is_virtual&&is_generated==0 *] -puts {[get_clocks -filter is_virtual||is_generated *]} -report_object_full_names [get_clocks -filter is_virtual||is_generated *] -puts {[get_clocks -filter is_virtual==0||is_generated *]} -report_object_full_names [get_clocks -filter is_virtual==0||is_generated *] -puts {[get_lib_cells -filter is_buffer==1 *]} -report_object_full_names [get_lib_cells -filter is_buffer==1 *] -puts {[get_lib_cells -filter is_inverter==0 *]} -report_object_full_names [get_lib_cells -filter is_inverter==0 *] +puts {[get_lib_cells -filter is_buffer *]} +report_object_full_names [get_lib_cells -filter is_buffer *] +puts {[get_lib_cells -filter is_inverter *]} +report_object_full_names [get_lib_cells -filter is_inverter *] puts {[get_lib_pins -filter direction==input BUFx2_ASAP7_75t_R/*]} report_object_full_names [get_lib_pins -filter direction==input BUFx2_ASAP7_75t_R/*] @@ -55,9 +42,32 @@ puts {[get_cells -filter {name ~= *r1*} *]} catch {get_cells -filter {name ~= *r1*} *} result puts $result -# AND pattern match expr +# AND expr +puts {direction == input && name =~ clk*} report_object_names [get_ports -filter "direction == input && name =~ clk*" *] # parens around sub-exprs +puts {(direction == input) && (name =~ clk*)"} report_object_names [get_ports -filter "(direction == input) && (name =~ clk*)" *] -sta::filter_expr_to_postfix "direction == input && name =~ clk* && is_clock" 1 +# OR expr +puts {[get_clocks -filter is_virtual||is_generated *]} +report_object_full_names [get_clocks -filter is_virtual||is_generated *] + + +# unary==0 / unary==false +puts {[get_clocks -filter is_virtual==0 *]} +report_object_full_names [get_clocks -filter is_virtual==0 *] +puts {[get_clocks -filter is_virtual==false *]} +report_object_full_names [get_clocks -filter is_virtual==false *] + +# unary==1 / unary==true +puts {[get_clocks -filter is_virtual==1 *]} +report_object_full_names [get_clocks -filter is_virtual==1 *] +puts {[get_clocks -filter is_virtual==true *]} +report_object_full_names [get_clocks -filter is_virtual==true *] + +# glob pattern with . (literal dot, no match symantics) +report_object_full_names [get_cells -filter {name =~ .1} *] + +puts [sta::filter_expr_to_postfix "direction == input && name =~ clk* && is_clock"] + diff --git a/test/get_lib_pins_of_objects.ok b/test/get_lib_pins_of_objects.ok index 8c8489b9..850bfc85 100644 --- a/test/get_lib_pins_of_objects.ok +++ b/test/get_lib_pins_of_objects.ok @@ -5,6 +5,7 @@ Y [get_lib_pins -of_objects [get_lib_cells *]] A A +A B CLK D @@ -13,3 +14,4 @@ IQN Q Y Y +Y diff --git a/test/get_noargs.ok b/test/get_noargs.ok index b952fdaa..4da70ba1 100644 --- a/test/get_noargs.ok +++ b/test/get_noargs.ok @@ -11,9 +11,11 @@ vclk asap7_small/AND2x2_ASAP7_75t_R asap7_small/BUFx2_ASAP7_75t_R asap7_small/DFFHQx4_ASAP7_75t_R +asap7_small/INVx2_ASAP7_75t_R [get_lib_pins] A A +A B CLK D @@ -22,6 +24,7 @@ IQN Q Y Y +Y [get_libs] asap7_small [get_nets] diff --git a/test/get_objrefs.ok b/test/get_objrefs.ok index 5430faff..08593630 100644 --- a/test/get_objrefs.ok +++ b/test/get_objrefs.ok @@ -9,9 +9,11 @@ vclk asap7_small/AND2x2_ASAP7_75t_R asap7_small/BUFx2_ASAP7_75t_R asap7_small/DFFHQx4_ASAP7_75t_R +asap7_small/INVx2_ASAP7_75t_R [get_lib_pins [get_lib_pins]] A A +A B CLK D @@ -20,6 +22,7 @@ IQN Q Y Y +Y [get_libs [get_libs]] asap7_small [get_nets [get_nets]] diff --git a/test/regression.tcl b/test/regression.tcl index 8afefbf4..3afe8287 100755 --- a/test/regression.tcl +++ b/test/regression.tcl @@ -176,11 +176,10 @@ proc run_tests {} { run_test $test } } - write_failure_file } proc run_test { test } { - global result_dir diff_file errors diff_options + global result_dir diff_file errors diff_options failed_tests puts -nonewline $test flush stdout @@ -267,8 +266,6 @@ proc run_tests_parallel {} { vwait reg_parallel_job_done } } - # update results/failures and results/diffs - write_failure_file } } @@ -432,26 +429,21 @@ proc test_failed { test reason } { } lappend failed_tests $test incr errors($reason) + append_diff_file $test } -proc write_failure_file {} { - global failure_file failed_tests failed_tests_summery +proc append_diff_file { test } { + global failure_file global diff_file diff_options set fail_ch [open $failure_file "a"] - foreach test $failed_tests { - if { ![info exists failed_tests_summery($test)] } { - puts $fail_ch $test - - # Append diff to results/diffs - set log_file [test_log_file $test] - set ok_file [test_ok_file $test] - catch [concat exec diff $diff_options $ok_file $log_file >> $diff_file] - - set failed_tests_summery($test) 1 - } - } + puts $fail_ch $test close $fail_ch + + # Append diff to results/diffs + set log_file [test_log_file $test] + set ok_file [test_ok_file $test] + catch [concat exec diff $diff_options $ok_file $log_file >> $diff_file] } # Error messages can be found in "valgrind/memcheck/mc_errcontext.c". @@ -530,6 +522,10 @@ proc show_summary {} { global app_path app puts "------------------------------------------------------" + if { $valgrind_shared_lib_failure } { + puts "WARNING: valgrind failed because the executable is not statically linked." + } + puts "See $result_dir for log files" set test_count [llength $tests] if { [found_errors] } { if { $errors(error) != 0 } { @@ -556,10 +552,6 @@ proc show_summary {} { } else { puts "Passed $test_count" } - if { $valgrind_shared_lib_failure } { - puts "WARNING: valgrind failed because the executable is not statically linked." - } - puts "See $result_dir for log files" } proc found_errors {} { @@ -590,22 +582,27 @@ proc save_ok_main {} { } } else { foreach test $argv { - save_ok $test + if { [lsearch [group_tests "all"] $test] == -1 } { + puts "Error: test $test not found." + } else { + save_ok $test + } } } } +# hook for pvt/public sync. proc save_ok { test } { - if { [lsearch [group_tests "all"] $test] == -1 } { - puts "Error: test $test not found." + save_ok_file $test +} + +proc save_ok_file { test } { + set ok_file [test_ok_file $test] + set log_file [test_log_file $test] + if { ! [file exists $log_file] } { + puts "Error: log file $log_file not found." } else { - set ok_file [test_ok_file $test] - set log_file [test_log_file $test] - if { ! [file exists $log_file] } { - puts "Error: log file $log_file not found." - } else { - file copy -force $log_file $ok_file - } + file copy -force $log_file $ok_file } } diff --git a/util/ReportTcl.cc b/util/ReportTcl.cc index a418a53a..e782c23c 100644 --- a/util/ReportTcl.cc +++ b/util/ReportTcl.cc @@ -72,6 +72,11 @@ encapGetHandleProc(ClientData instanceData, static int encapBlockModeProc(ClientData instanceData, int mode); +static int +encapClose2Proc(ClientData instanceData, + Tcl_Interp *interp, + int flags); + #if TCL_MAJOR_VERSION < 9 static int encapCloseProc(ClientData instanceData, Tcl_Interp *interp); @@ -97,13 +102,13 @@ Tcl_ChannelType tcl_encap_type_stdout = { #if TCL_MAJOR_VERSION < 9 encapSeekProc, #else - nullptr, // close2Proc + nullptr, // seekProc unused #endif encapSetOptionProc, encapGetOptionProc, encapWatchProc, encapGetHandleProc, - nullptr, // close2Proc + encapClose2Proc, encapBlockModeProc, nullptr, // flushProc nullptr, // handlerProc @@ -290,17 +295,31 @@ encapBlockModeProc(ClientData, return 0; } +// Close channel implementing CloseProc() or Close2Proc() +static int +closeChannel(ReportTcl *report) +{ + report->logEnd(); + report->redirectFileEnd(); + report->redirectStringEnd(); + return 0; +} + +static int +encapClose2Proc(ClientData instanceData, + Tcl_Interp *, + int) +{ + return closeChannel(reinterpret_cast(instanceData)); +} + #if TCL_MAJOR_VERSION < 9 static int encapCloseProc(ClientData instanceData, Tcl_Interp *) { - ReportTcl *report = reinterpret_cast(instanceData); - report->logEnd(); - report->redirectFileEnd(); - report->redirectStringEnd(); - return 0; + return closeChannel(reinterpret_cast(instanceData)); } static int diff --git a/util/StringUtil.cc b/util/StringUtil.cc index 00a36ec4..c070cb6e 100644 --- a/util/StringUtil.cc +++ b/util/StringUtil.cc @@ -28,6 +28,7 @@ #include #include #include +#include namespace sta { @@ -56,12 +57,22 @@ std::pair stringFloat(const std::string &str) { float value; + // OsX 15.xx and earlier clang do not support std::from_chars. +#if defined(__cpp_lib_to_chars) && __cpp_lib_to_chars >= 201611L auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), value); if (ec == std::errc() && *ptr == '\0') return {value, true}; else return {0.0, false}; +#else + char *ptr; + value = strtof(str.data(), &ptr); + if (!errno || *ptr != '\0') + return {0.0, false}; + else + return {value, true}; +#endif } void