From 3f7df84fb88c9d0c9bbbf15626fd6347e1e9d9bf Mon Sep 17 00:00:00 2001 From: James Cherry Date: Thu, 19 Jan 2023 11:23:45 -0700 Subject: [PATCH] Network::id for maps/sets commit be70d30ae05665021254b0d7e69fb8d2f0a82890 Author: James Cherry Date: Tue Jan 17 17:04:49 2023 -0700 cmp Signed-off-by: James Cherry commit 4d4ef96948afe3d6a00c4521aeb5bc74274f5737 Author: James Cherry Date: Tue Jan 17 16:08:50 2023 -0700 rvo, const Signed-off-by: James Cherry commit bb584e4264af2bea867b17d07e8d38c0e9eb0025 Author: James Cherry Date: Tue Jan 17 15:05:00 2023 -0700 const Signed-off-by: James Cherry commit a08fe558bca6b769b2728882258bd85aed990a27 Author: James Cherry Date: Tue Jan 17 14:57:33 2023 -0700 LibertyPortPair no ptrs Signed-off-by: James Cherry commit 4d3bd60c109d1ce9d0589d746f4968fa7bebd90d Author: James Cherry Date: Tue Jan 17 14:13:07 2023 -0700 cleanup Signed-off-by: James Cherry commit dc25ff77771cfbe26f9318bad2b3c45879614783 Author: James Cherry Date: Tue Jan 17 14:06:13 2023 -0700 const Signed-off-by: James Cherry commit 06e81586ce11a0cc06948ed78fef99353077d69e Author: James Cherry Date: Tue Jan 17 14:01:10 2023 -0700 sortByName Signed-off-by: James Cherry commit 9d8592aff5b246f83e47e1b94490e3cef8d8e119 Author: James Cherry Date: Tue Jan 17 11:57:17 2023 -0700 sort pred Signed-off-by: James Cherry commit 462a8e14df8b561ddfc842addc62c4b8435b6347 Author: James Cherry Date: Tue Jan 17 11:09:57 2023 -0700 const Signed-off-by: James Cherry commit 69f71505b684e88b22d395510429497e87bf1015 Author: James Cherry Date: Tue Jan 17 10:45:14 2023 -0700 flush ConstPortSeq Signed-off-by: James Cherry commit 6429d578b78eac3fe7e99fcd67a120789932b2eb Author: James Cherry Date: Tue Jan 17 09:19:15 2023 -0700 rm ConstNetSet Signed-off-by: James Cherry commit f247930b16e40560b957a36af68947249ed1ef04 Author: James Cherry Date: Tue Jan 17 08:50:50 2023 -0700 sortPathNames Signed-off-by: James Cherry commit 4ca2b0e0af7252c7bcbc65cf141d0ce40634d329 Author: James Cherry Date: Mon Jan 16 10:14:05 2023 -0700 const Signed-off-by: James Cherry commit 3d18640d2ebc4aae3098c7e7242a554fcb64fd42 Author: James Cherry Date: Mon Jan 16 09:41:27 2023 -0700 set_input/ouput_delay -reference_pin Signed-off-by: James Cherry commit d4a0854dd2102f46f96a94fb9eb8749f1593a85f Author: James Cherry Date: Mon Jan 16 09:13:46 2023 -0700 PinPairSet no malloc Signed-off-by: James Cherry commit a6f1583fc6a856c5ecc0dcb15a1d8b1f61e30718 Author: James Cherry Date: Mon Jan 16 08:53:33 2023 -0700 no malloc for EdgePins Signed-off-by: James Cherry commit c8e4b92e8b619109d6aa3c141c720646067ccb4b Author: James Cherry Date: Mon Jan 16 06:31:08 2023 +0000 leak commit abab99e0fc3e466d914f6c1705aa08cdc204df51 Author: James Cherry Date: Mon Jan 16 06:07:36 2023 +0000 leaks commit d1913b554bb6e98b89673d80d2295f552eb4ffca Author: James Cherry Date: Sun Jan 15 19:48:39 2023 -0700 LibertyCell::checkCornerCell Signed-off-by: James Cherry commit bcc172237d48deed647374f9592bac70bd2d5425 Author: James Cherry Date: Sun Jan 15 18:19:47 2023 -0700 rvo Signed-off-by: James Cherry commit 8ef9800b87f5e5548055a13afc21397f28a6bcf7 Author: James Cherry Date: Sun Jan 15 18:07:46 2023 -0700 sdc net id Signed-off-by: James Cherry commit d7235abed04ced4e2d84e91bf9968e621268567d Author: James Cherry Date: Sun Jan 15 16:00:27 2023 -0700 range iter Signed-off-by: James Cherry commit a22f91a3c54c644574339d1126821d9bc8045bd6 Author: James Cherry Date: Sun Jan 15 15:52:50 2023 -0700 range iter Signed-off-by: James Cherry commit 762615ce3de91d950eeaaa4680549a45b13e0e0a Author: James Cherry Date: Sun Jan 15 15:42:19 2023 -0700 range iter Signed-off-by: James Cherry commit 7e0c531613d343d23f064c24873bf5a498f6f4ce Author: James Cherry Date: Sun Jan 15 12:26:49 2023 -0700 rm removeLoadCaps, removeNetLoadCaps Signed-off-by: James Cherry commit f2e88c6082e2d4605e9849348008bf4065401fc8 Author: James Cherry Date: Sun Jan 15 12:21:03 2023 -0700 sdc rm map ptrs Signed-off-by: James Cherry commit b5939666188c0b94dfe957e22bbd8a92f4786125 Author: James Cherry Date: Sun Jan 15 11:36:16 2023 -0700 sdc rm map ptrs Signed-off-by: James Cherry commit a435081bafe10260743319f53a59cbe2ed0388b7 Author: James Cherry Date: Sun Jan 15 08:43:37 2023 -0700 sdc rm map ptrs Signed-off-by: James Cherry commit acfb247559db7b726d47f203613488df0f7add53 Author: James Cherry Date: Sun Jan 15 08:38:07 2023 -0700 sdc rm map ptrs Signed-off-by: James Cherry commit 7541b71da92ea15085615988a1e6ea1d4d53d8d6 Author: James Cherry Date: Sun Jan 15 08:00:55 2023 -0700 sdc rm map ptrs Signed-off-by: James Cherry commit d033210132656ea68fa834228575b9def1d02d90 Author: James Cherry Date: Sun Jan 15 07:52:03 2023 -0700 sdc rm map ptrs Signed-off-by: James Cherry commit ca6e9ecb7821b83ab024c4fee6df8f7fc8fc2ce2 Author: James Cherry Date: Sun Jan 15 07:38:12 2023 -0700 instance_pvt_maps_ Signed-off-by: James Cherry commit 631e4209b596386f5818045d521784db5239f58d Author: James Cherry Date: Sun Jan 15 07:26:42 2023 -0700 rm GroupPathIterator Signed-off-by: James Cherry commit 059c32afa87617fff530c9afa1ef8005a136739d Author: James Cherry Date: Sat Jan 14 20:07:44 2023 -0700 rm ClockIterator Signed-off-by: James Cherry commit c65fe873a6a6696220bbb44c4ecac87d5ca978ac Author: James Cherry Date: Sat Jan 14 19:45:58 2023 -0700 rvo Signed-off-by: James Cherry commit ce15c9a0cc78915acddc2f03749573d989ae96d6 Author: James Cherry Date: Sun Jan 15 01:04:03 2023 +0000 leaks commit f97955a0c7e70b65ceb3f697ff47c0524a9b3cd4 Author: James Cherry Date: Sat Jan 14 01:17:58 2023 +0000 leaks commit 7cdd65684adeb14e02827f5d93e7fab3b19af5dd Author: James Cherry Date: Fri Jan 13 16:07:47 2023 -0700 leaks Signed-off-by: James Cherry commit ee97c7e50394a3927458e7ef09c5dbeb27719d15 Author: James Cherry Date: Fri Jan 13 11:52:48 2023 -0700 swig rm Tmp collections Signed-off-by: James Cherry commit c49935da8704e41459280971b7645fccd97e3d13 Author: James Cherry Date: Fri Jan 13 11:18:36 2023 -0700 swig rm Tmp types Signed-off-by: James Cherry commit 4320b00ce700914843006f592126cd8cc1c4657a Author: James Cherry Date: Fri Jan 13 10:55:10 2023 -0700 swig rm TmpPinSet, TmpPinSeq Signed-off-by: James Cherry commit ff6004910980c9b09b41f63a553a4481404cc539 Author: James Cherry Date: Fri Jan 13 10:45:06 2023 -0700 swig rm Tmp collections Signed-off-by: James Cherry commit 9a5bf5c1a3e5a6d2996b3ab327fa2f3015f2ff20 Author: James Cherry Date: Fri Jan 13 10:15:29 2023 -0700 swig rm one TmpPinSet Signed-off-by: James Cherry commit f441116b56e23849485b2393b30e7086c33165a8 Author: James Cherry Date: Fri Jan 13 09:16:56 2023 -0700 leak Signed-off-by: James Cherry commit 050b08df8618340b568d9cd41fd3d5f052e2c680 Author: James Cherry Date: Fri Jan 13 09:10:53 2023 -0700 leak Signed-off-by: James Cherry commit be8c17f3a715ab53140748dc1d94698209965cf9 Author: James Cherry Date: Fri Jan 13 08:59:06 2023 -0700 leak Signed-off-by: James Cherry commit e43b82f8fb52eaeda90e3c7e76cf350ae6735ebd Author: James Cherry Date: Thu Jan 12 18:57:49 2023 -0700 range iter Signed-off-by: James Cherry commit 8db56209de7805ac2574fd2f76170bf68afd156d Author: James Cherry Date: Thu Jan 12 18:08:54 2023 -0700 GroupPathSet net id Signed-off-by: James Cherry commit cb7917f9827c2ea3afebd735cd4508405a0d77d4 Author: James Cherry Date: Thu Jan 12 12:00:15 2023 -0700 DataCheckLess net id Signed-off-by: James Cherry commit d9da3c62d7a76699c6ad62cebb1f5c39f89722fa Author: James Cherry Date: Thu Jan 12 11:42:27 2023 -0700 rm hashPtr uses Signed-off-by: James Cherry commit 5bbea162bb1e023aba813598c7992c740ddf9d0b Author: James Cherry Date: Thu Jan 12 11:30:12 2023 -0700 EdgePins has use net id Signed-off-by: James Cherry commit df38405e2ebaabdd7bbf99f3b19d78b25bd95720 Author: James Cherry Date: Thu Jan 12 09:51:38 2023 -0700 ExceptionPath hash use net id Signed-off-by: James Cherry commit 9a6dcfa54c54c9f50b14248a2449c70c20a0d977 Author: James Cherry Date: Thu Jan 12 08:56:49 2023 -0700 ClockInsertion, ClockLatency net id Signed-off-by: James Cherry commit dbb6dc0b8c93812458df31e93f08e0dbd74e8105 Author: James Cherry Date: Thu Jan 12 08:34:03 2023 -0700 ExceptionStateSet obj id Signed-off-by: James Cherry commit 70b8721c48ec0816289ee09b664c332ee095875f Author: James Cherry Date: Thu Jan 12 08:14:37 2023 -0700 ClockGroups cmp Signed-off-by: James Cherry commit 4c6c4ca191a99cd8541e106fec3202ee14968f39 Author: James Cherry Date: Thu Jan 12 07:38:17 2023 -0700 ClockGroup typedef to ClockSet Signed-off-by: James Cherry commit 66f425315e16deee5f00b05c0a505766e7afbf01 Author: James Cherry Date: Wed Jan 11 20:32:38 2023 -0700 set cmps Signed-off-by: James Cherry commit a94866c7828af5b6714e3e4fffc13bdaf5155c0e Author: James Cherry Date: Wed Jan 11 19:08:09 2023 -0700 net use id Signed-off-by: James Cherry commit 6348320908f42ebb5262117182e13d0024f65537 Author: James Cherry Date: Wed Jan 11 11:52:13 2023 -0700 exception id cmp Signed-off-by: James Cherry commit 0edfca41b6d6408ac17f8dfe10e697c55146c1ef Author: James Cherry Date: Wed Jan 11 10:47:02 2023 -0700 range iter Signed-off-by: James Cherry commit 44ad77985da9f0b9e7f4780e3f233c8d94fa7db7 Author: James Cherry Date: Wed Jan 11 08:27:58 2023 -0700 non-ptr set cmp Signed-off-by: James Cherry commit 36de7d88c3fa683465604a9e16b2fc1f6bc5fdd0 Author: James Cherry Date: Wed Jan 11 08:00:54 2023 -0700 range iteration Signed-off-by: James Cherry commit 4a31a2c8d9bdae58b09af8c05a64702ea3ac6c15 Author: James Cherry Date: Tue Jan 10 16:43:54 2023 -0700 tcl types Signed-off-by: James Cherry commit 056a7447b494a4c8ecc9764650d78a5bed3d87e8 Author: James Cherry Date: Tue Jan 10 16:10:36 2023 -0700 tcl types Signed-off-by: James Cherry commit 97239554c7625ba50ee729260f08eda7dec02365 Author: James Cherry Date: Tue Jan 10 13:10:42 2023 -0700 use RVO Signed-off-by: James Cherry commit c3247d8937d483102e3e1f2b69d7ac1d331ba9d4 Author: James Cherry Date: Mon Jan 9 22:41:20 2023 -0700 swig template seq's Signed-off-by: James Cherry commit 5431c06feb256adb46858819fcf5d513cfa6b5ec Author: James Cherry Date: Mon Jan 9 20:50:24 2023 -0700 swig set in template Signed-off-by: James Cherry commit 592ad641bf01d3beb862314a0d8986f66e258642 Author: James Cherry Date: Mon Jan 9 17:27:25 2023 -0700 network return containers Signed-off-by: James Cherry commit c95f8b77e0d6bd5ffa5ba8102413c70883c756e1 Author: James Cherry Date: Mon Jan 9 12:15:37 2023 -0700 PinSeq const Signed-off-by: James Cherry commit 702e7f9ba2f901066a38f32e67b35602b6c7bbdf Author: James Cherry Date: Mon Jan 9 12:02:29 2023 -0700 InstanceSeq const Signed-off-by: James Cherry commit 44fc25ba4a15e4ae570d74af27c9435872a126e0 Author: James Cherry Date: Mon Jan 9 12:01:45 2023 -0700 NetSeq const Signed-off-by: James Cherry commit 03b2725c81f5d52c33c875b55056c11d482144f1 Author: James Cherry Date: Mon Jan 9 11:33:18 2023 -0700 rm PortPair Signed-off-by: James Cherry commit 3fb82a7344dc053171c9883a113764ba691ab827 Author: James Cherry Date: Mon Jan 9 11:20:53 2023 -0700 PinSet id Signed-off-by: James Cherry commit 3dd31f027e15d40d62a11d0a88ef2a115f01fb73 Author: James Cherry Date: Sun Jan 8 15:03:33 2023 -0700 InstanceSet id Signed-off-by: James Cherry commit a91dea5cc0af3bede36b3faed13adb05239ff907 Author: James Cherry Date: Sun Jan 8 11:40:15 2023 -0700 NetSet id Signed-off-by: James Cherry commit b91e4b6410134eccae7969ddcfb0b27933b2e746 Author: James Cherry Date: Sun Jan 8 10:44:47 2023 -0700 CellSet, PortSet id Signed-off-by: James Cherry commit 6f891f77fae5a6b19c1454a1a4b4e3dfae0b5c50 Author: James Cherry Date: Sun Jan 8 10:29:25 2023 -0700 network object sets Signed-off-by: James Cherry commit eb8c627a57ecc6e7c5846a01d62b090ff91c08bf Author: James Cherry Date: Sun Jan 8 10:09:00 2023 -0700 PinSet1 Signed-off-by: James Cherry commit 8e864ecbdf87000fbb3c3097c39f06173c941e35 Author: James Cherry Date: Sat Jan 7 17:13:03 2023 -0700 concrete network object id Signed-off-by: James Cherry Signed-off-by: James Cherry --- CMakeLists.txt | 2 +- dcalc/ArcDelayCalc.cc | 8 +- dcalc/Arnoldi.hh | 3 +- dcalc/ArnoldiDelayCalc.cc | 39 +- dcalc/ArnoldiReduce.cc | 2 +- dcalc/DelayCalc.cc | 13 +- dcalc/DelayCalc.i | 2 +- dcalc/DmpCeff.cc | 20 +- dcalc/DmpCeff.hh | 16 +- dcalc/DmpDelayCalc.cc | 27 +- dcalc/GraphDelayCalc.cc | 4 +- dcalc/GraphDelayCalc1.cc | 34 +- dcalc/GraphDelayCalc1.hh | 22 +- dcalc/LumpedCapDelayCalc.cc | 25 +- dcalc/LumpedCapDelayCalc.hh | 18 +- dcalc/RCDelayCalc.cc | 2 +- dcalc/RCDelayCalc.hh | 4 +- dcalc/SimpleRCDelayCalc.cc | 6 +- dcalc/SimpleRCDelayCalc.hh | 6 +- dcalc/UnitDelayCalc.cc | 18 +- dcalc/UnitDelayCalc.hh | 18 +- doc/ApiChanges.txt | 18 + graph/Graph.cc | 36 +- include/sta/ArcDelayCalc.hh | 24 +- include/sta/ClkNetwork.hh | 3 +- include/sta/Clock.hh | 33 +- include/sta/ClockGroups.hh | 14 +- include/sta/ConcreteLibrary.hh | 32 +- include/sta/ConcreteNetwork.hh | 48 +- include/sta/DataCheck.hh | 6 +- include/sta/DelayCalc.hh | 3 +- include/sta/DisabledPorts.hh | 19 +- include/sta/ExceptionPath.hh | 137 +- include/sta/Graph.hh | 16 +- include/sta/Hash.hh | 2 + include/sta/HpinDrvrLoad.hh | 18 +- include/sta/InputDrive.hh | 48 +- include/sta/Liberty.hh | 11 +- include/sta/LibertyClass.hh | 2 - include/sta/Map.hh | 11 + include/sta/Network.hh | 142 +- include/sta/NetworkClass.hh | 133 +- include/sta/NetworkCmp.hh | 30 +- include/sta/NullParasitics.hh | 26 +- include/sta/Parasitics.hh | 14 +- include/sta/Path.hh | 4 +- include/sta/PathEnd.hh | 16 +- include/sta/PinPair.hh | 27 +- include/sta/PortDelay.hh | 33 +- include/sta/PortExtCap.hh | 12 +- include/sta/Property.hh | 61 +- include/sta/Sdc.hh | 380 +++-- include/sta/SdcClass.hh | 41 +- include/sta/SdcNetwork.hh | 49 +- include/sta/Search.hh | 43 +- include/sta/Set.hh | 16 +- include/sta/Sta.hh | 213 ++- include/sta/TimingArc.hh | 2 +- include/sta/UnorderedMap.hh | 18 + include/sta/VertexVisitor.hh | 6 +- liberty/Liberty.cc | 57 +- liberty/TimingArc.cc | 4 +- network/ConcreteLibrary.cc | 57 +- network/ConcreteNetwork.cc | 107 +- network/HpinDrvrLoad.cc | 30 +- network/Network.cc | 447 ++++-- network/NetworkCmp.cc | 58 +- network/SdcNetwork.cc | 147 +- parasitics/ConcreteParasitics.cc | 46 +- parasitics/ConcreteParasitics.hh | 30 +- parasitics/ConcreteParasiticsPvt.hh | 14 +- parasitics/EstimateParasitics.cc | 2 +- parasitics/NullParasitics.cc | 12 +- parasitics/Parasitics.cc | 2 +- parasitics/Parasitics.i | 13 +- parasitics/ReduceParasitics.cc | 4 +- parasitics/ReportParasiticAnnotation.cc | 6 +- power/Power.cc | 32 +- power/Power.hh | 18 +- power/Power.i | 62 +- sdc/Clock.cc | 82 +- sdc/ClockGroups.cc | 38 +- sdc/DataCheck.cc | 14 +- sdc/DisabledPorts.cc | 88 +- sdc/ExceptionPath.cc | 837 ++++------ sdc/InputDrive.cc | 32 +- sdc/PinPair.cc | 51 +- sdc/PortDelay.cc | 41 +- sdc/PortExtCap.cc | 2 +- sdc/Sdc.cc | 1901 ++++++++++------------- sdc/SdcGraph.cc | 70 +- sdc/WriteSdc.cc | 459 ++---- sdc/WriteSdcPvt.hh | 36 +- sdf/ReportAnnotation.cc | 22 +- sdf/Sdf.tcl | 28 +- sdf/SdfWriter.cc | 4 +- search/CheckCapacitanceLimits.cc | 44 +- search/CheckCapacitanceLimits.hh | 18 +- search/CheckFanoutLimits.cc | 48 +- search/CheckFanoutLimits.hh | 16 +- search/CheckMinPeriods.cc | 5 +- search/CheckMinPulseWidths.cc | 12 +- search/CheckMinPulseWidths.hh | 4 +- search/CheckSlewLimits.cc | 48 +- search/CheckSlewLimits.hh | 16 +- search/CheckTiming.cc | 32 +- search/ClkInfo.cc | 8 +- search/ClkInfo.hh | 8 +- search/ClkNetwork.cc | 25 +- search/ClkSkew.cc | 32 +- search/ClkSkew.hh | 2 +- search/Crpr.cc | 14 +- search/Crpr.hh | 4 +- search/FindRegister.cc | 52 +- search/FindRegister.hh | 10 +- search/Genclks.cc | 29 +- search/Latches.cc | 8 +- search/Latches.hh | 2 +- search/MakeTimingModel.cc | 18 +- search/MakeTimingModel.hh | 2 +- search/Path.cc | 8 +- search/PathEnd.cc | 26 +- search/PathExpanded.cc | 2 +- search/PathGroup.cc | 31 +- search/PathVertex.cc | 2 +- search/Property.cc | 39 +- search/ReportPath.cc | 57 +- search/ReportPath.hh | 10 +- search/Search.cc | 144 +- search/Sim.cc | 92 +- search/Sim.hh | 22 +- search/Sta.cc | 320 ++-- search/Tag.cc | 29 +- search/Tag.hh | 6 +- search/VertexVisitor.cc | 4 +- search/VisitPathEnds.cc | 12 +- search/WritePathSpice.cc | 8 +- tcl/Cmds.tcl | 1 + tcl/Network.tcl | 9 +- tcl/Sdc.tcl | 22 +- tcl/Search.tcl | 10 +- tcl/Sta.tcl | 5 +- tcl/StaTcl.i | 1031 +++++------- verilog/VerilogWriter.cc | 5 +- 144 files changed, 4509 insertions(+), 4732 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 791026e9..dc61b90f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14) cmake_policy(SET CMP0086 NEW) endif() -project(STA VERSION 2.3.3 +project(STA VERSION 2.4.0 LANGUAGES CXX ) diff --git a/dcalc/ArcDelayCalc.cc b/dcalc/ArcDelayCalc.cc index 6eb92032..5ed93b2f 100644 --- a/dcalc/ArcDelayCalc.cc +++ b/dcalc/ArcDelayCalc.cc @@ -28,23 +28,23 @@ ArcDelayCalc::ArcDelayCalc(StaState *sta): } TimingModel * -ArcDelayCalc::model(TimingArc *arc, +ArcDelayCalc::model(const TimingArc *arc, const DcalcAnalysisPt *dcalc_ap) const { const OperatingConditions *op_cond = dcalc_ap->operatingConditions(); - TimingArc *corner_arc = arc->cornerArc(dcalc_ap->libertyIndex()); + const TimingArc *corner_arc = arc->cornerArc(dcalc_ap->libertyIndex()); return corner_arc->model(op_cond); } GateTimingModel * -ArcDelayCalc::gateModel(TimingArc *arc, +ArcDelayCalc::gateModel(const TimingArc *arc, const DcalcAnalysisPt *dcalc_ap) const { return dynamic_cast(model(arc, dcalc_ap)); } CheckTimingModel * -ArcDelayCalc::checkModel(TimingArc *arc, +ArcDelayCalc::checkModel(const TimingArc *arc, const DcalcAnalysisPt *dcalc_ap) const { return dynamic_cast(model(arc, dcalc_ap)); diff --git a/dcalc/Arnoldi.hh b/dcalc/Arnoldi.hh index adbeba3b..fe447cf3 100644 --- a/dcalc/Arnoldi.hh +++ b/dcalc/Arnoldi.hh @@ -25,7 +25,6 @@ namespace sta { struct delay_work; -class rcmodel; class GateTableModel; class Pin; @@ -71,7 +70,7 @@ public: struct timing_table { - GateTableModel *table; + const GateTableModel *table; const LibertyCell *cell; const Pvt *pvt; float in_slew; diff --git a/dcalc/ArnoldiDelayCalc.cc b/dcalc/ArnoldiDelayCalc.cc index 299029e9..2d985912 100644 --- a/dcalc/ArnoldiDelayCalc.cc +++ b/dcalc/ArnoldiDelayCalc.cc @@ -119,11 +119,11 @@ public: const DcalcAnalysisPt *dcalc_ap); virtual ReducedParasiticType reducedParasiticType() const; virtual void gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, // Pass in load_cap or drvr_parasitic. float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -137,13 +137,13 @@ public: virtual void inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap); virtual void reportGateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *, + const Parasitic *, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -157,15 +157,18 @@ public: private: void gateDelaySlew(const LibertyCell *drvr_cell, - GateTableModel *table_model, + const GateTableModel *table_model, const Slew &in_slew, float related_out_cap, const Pvt *pvt, // Return values. ArcDelay &gate_delay, Slew &drvr_slew); - void ar1_ceff_delay(delay_work *D,timing_table *tab, arnoldi1 *mod, - double *delays, double *slews); + void ar1_ceff_delay(delay_work *D, + timing_table *tab, + arnoldi1 *mod, + double *delays, + double *slews); double ra_rdelay_1(timing_table *tab, double ctot); double ra_get_r(delay_work *D, @@ -265,8 +268,9 @@ ArnoldiDelayCalc::findParasitic(const Pin *drvr_pin, const RiseFall *drvr_rf, const DcalcAnalysisPt *dcalc_ap) { + const Corner *corner = dcalc_ap->corner(); // set_load has precidence over parasitics. - if (!sdc_->drvrPinHasWireCap(drvr_pin)) { + if (!sdc_->drvrPinHasWireCap(drvr_pin, corner)) { const ParasiticAnalysisPt *parasitic_ap = dcalc_ap->parasiticAnalysisPt(); Parasitic *parasitic_network = parasitics_->findParasiticNetwork(drvr_pin, parasitic_ap); @@ -274,7 +278,6 @@ ArnoldiDelayCalc::findParasitic(const Pin *drvr_pin, const MinMax *cnst_min_max = dcalc_ap->constraintMinMax(); const OperatingConditions *op_cond = dcalc_ap->operatingConditions(); - const Corner *corner = dcalc_ap->corner(); if (parasitic_network == nullptr) { Wireload *wireload = sdc_->wireload(cnst_min_max); if (wireload) { @@ -317,7 +320,7 @@ void ArnoldiDelayCalc::inputPortDelay(const Pin *drvr_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap) { RCDelayCalc::inputPortDelay(drvr_pin, in_slew, rf, parasitic, dcalc_ap); @@ -327,7 +330,7 @@ ArnoldiDelayCalc::inputPortDelay(const Pin *drvr_pin, int j; if (parasitic) { - rcmodel_ = reinterpret_cast(parasitic); + rcmodel_ = reinterpret_cast(const_cast(parasitic)); pin_n_ = rcmodel_->n; if (pin_n_ >= _pinNmax) { _pinNmax *= 2; @@ -358,10 +361,10 @@ ArnoldiDelayCalc::inputPortDelay(const Pin *drvr_pin, void ArnoldiDelayCalc::gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -374,7 +377,7 @@ ArnoldiDelayCalc::gateDelay(const LibertyCell *drvr_cell, drvr_library_ = drvr_cell->libertyLibrary(); drvr_parasitic_ = drvr_parasitic; ConcreteParasitic *drvr_cparasitic = - reinterpret_cast(drvr_parasitic); + reinterpret_cast(const_cast(drvr_parasitic)); rcmodel_ = dynamic_cast(drvr_cparasitic); GateTimingModel *model = gateModel(arc, dcalc_ap); GateTableModel *table_model = dynamic_cast(model); @@ -392,7 +395,7 @@ ArnoldiDelayCalc::gateDelay(const LibertyCell *drvr_cell, void ArnoldiDelayCalc::gateDelaySlew(const LibertyCell *drvr_cell, - GateTableModel *table_model, + const GateTableModel *table_model, const Slew &in_slew, float related_out_cap, const Pvt *pvt, @@ -454,10 +457,10 @@ ArnoldiDelayCalc::loadDelay(const Pin *load_pin, void ArnoldiDelayCalc::reportGateDelay(const LibertyCell *, - TimingArc *, + const TimingArc *, const Slew &, float, - Parasitic *, + const Parasitic *, float, const Pvt *, const DcalcAnalysisPt *, diff --git a/dcalc/ArnoldiReduce.cc b/dcalc/ArnoldiReduce.cc index 6e81449a..8f6d8b53 100644 --- a/dcalc/ArnoldiReduce.cc +++ b/dcalc/ArnoldiReduce.cc @@ -451,7 +451,7 @@ ArnoldiReduce::pinCapacitance(ParasiticNode *node) if (lib_port) pin_cap = sdc_->pinCapacitance(pin,rf_, op_cond_, corner_, cnst_min_max_); else if (network_->isTopLevelPort(pin)) - pin_cap = sdc_->portExtCap(port, rf_, cnst_min_max_); + pin_cap = sdc_->portExtCap(port, rf_, corner_, cnst_min_max_); } return pin_cap; } diff --git a/dcalc/DelayCalc.cc b/dcalc/DelayCalc.cc index de12a7e3..040933f4 100644 --- a/dcalc/DelayCalc.cc +++ b/dcalc/DelayCalc.cc @@ -74,16 +74,13 @@ isDelayCalcName(const char *name) return delay_calcs->hasKey(name); } -StringSeq * +StringSeq delayCalcNames() { - StringSeq *names = new StringSeq; - DelayCalcMap::Iterator dcalc_iter(delay_calcs); - while (dcalc_iter.hasNext()) { - MakeArcDelayCalc maker; - const char *name; - dcalc_iter.next(name, maker); - names->push_back(name); + StringSeq names; + for (auto name_dcalc : *delay_calcs) { + const char *name = name_dcalc.first; + names.push_back(name); } return names; } diff --git a/dcalc/DelayCalc.i b/dcalc/DelayCalc.i index a834227c..b436bbcd 100644 --- a/dcalc/DelayCalc.i +++ b/dcalc/DelayCalc.i @@ -24,7 +24,7 @@ %inline %{ -TmpStringSeq * +StringSeq delay_calc_names() { return sta::delayCalcNames(); diff --git a/dcalc/DmpCeff.cc b/dcalc/DmpCeff.cc index b6658579..9acd11f0 100644 --- a/dcalc/DmpCeff.cc +++ b/dcalc/DmpCeff.cc @@ -83,7 +83,7 @@ private: static double gateModelRd(const LibertyCell *cell, - GateTableModel *gate_model, + const GateTableModel *gate_model, const RiseFall *rf, double in_slew, double c2, @@ -1546,7 +1546,7 @@ void DmpCeffDelayCalc::inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap) { dmp_alg_ = nullptr; @@ -1556,10 +1556,10 @@ DmpCeffDelayCalc::inputPortDelay(const Pin *port_pin, void DmpCeffDelayCalc::gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -1606,7 +1606,7 @@ void DmpCeffDelayCalc::setCeffAlgorithm(const LibertyLibrary *drvr_library, const LibertyCell *drvr_cell, const Pvt *pvt, - GateTableModel *gate_model, + const GateTableModel *gate_model, const RiseFall *rf, double in_slew, float related_out_cap, @@ -1647,10 +1647,10 @@ DmpCeffDelayCalc::setCeffAlgorithm(const LibertyLibrary *drvr_library, float DmpCeffDelayCalc::ceff(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap) @@ -1668,10 +1668,10 @@ DmpCeffDelayCalc::ceff(const LibertyCell *drvr_cell, void DmpCeffDelayCalc::reportGateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -1715,7 +1715,7 @@ DmpCeffDelayCalc::reportGateDelay(const LibertyCell *drvr_cell, static double gateModelRd(const LibertyCell *cell, - GateTableModel *gate_model, + const GateTableModel *gate_model, const RiseFall *rf, double in_slew, double c2, diff --git a/dcalc/DmpCeff.hh b/dcalc/DmpCeff.hh index 9b7e58af..35e7eec0 100644 --- a/dcalc/DmpCeff.hh +++ b/dcalc/DmpCeff.hh @@ -37,13 +37,13 @@ public: virtual void inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap); virtual void gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -51,18 +51,18 @@ public: ArcDelay &gate_delay, Slew &drvr_slew); virtual float ceff(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap); virtual void reportGateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -81,7 +81,7 @@ protected: void setCeffAlgorithm(const LibertyLibrary *library, const LibertyCell *cell, const Pvt *pvt, - GateTableModel *gate_model, + const GateTableModel *gate_model, const RiseFall *rf, double in_slew, float related_out_cap, diff --git a/dcalc/DmpDelayCalc.cc b/dcalc/DmpDelayCalc.cc index 13b6b4da..4e591ace 100644 --- a/dcalc/DmpDelayCalc.cc +++ b/dcalc/DmpDelayCalc.cc @@ -35,10 +35,10 @@ public: DmpCeffElmoreDelayCalc(StaState *sta); virtual ArcDelayCalc *copy(); virtual void gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -69,10 +69,10 @@ DmpCeffElmoreDelayCalc::copy() void DmpCeffElmoreDelayCalc::gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -133,13 +133,13 @@ public: virtual void inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap); virtual void gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -201,8 +201,9 @@ DmpCeffTwoPoleDelayCalc::findParasitic(const Pin *drvr_pin, const RiseFall *rf, const DcalcAnalysisPt *dcalc_ap) { + const Corner *corner = dcalc_ap->corner(); // set_load has precidence over parasitics. - if (!sdc_->drvrPinHasWireCap(drvr_pin)) { + if (!sdc_->drvrPinHasWireCap(drvr_pin, corner)) { Parasitic *parasitic = nullptr; const ParasiticAnalysisPt *parasitic_ap = dcalc_ap->parasiticAnalysisPt(); if (parasitics_->haveParasitics()) { @@ -221,7 +222,7 @@ DmpCeffTwoPoleDelayCalc::findParasitic(const Pin *drvr_pin, if (parasitic_network) { parasitics_->reduceToPiPoleResidue2(parasitic_network, drvr_pin, dcalc_ap->operatingConditions(), - dcalc_ap->corner(), + corner, dcalc_ap->constraintMinMax(), parasitic_ap); parasitic = parasitics_->findPiPoleResidue(drvr_pin, rf, parasitic_ap); @@ -240,7 +241,7 @@ DmpCeffTwoPoleDelayCalc::findParasitic(const Pin *drvr_pin, parasitic = parasitics_->estimatePiElmore(drvr_pin, rf, wireload, fanout, pin_cap, dcalc_ap->operatingConditions(), - dcalc_ap->corner(), + corner, cnst_min_max, parasitic_ap); // Estimated parasitics are not recorded in the "database", so @@ -263,7 +264,7 @@ void DmpCeffTwoPoleDelayCalc::inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap) { parasitic_is_pole_residue_ = parasitics_->isPiPoleResidue(parasitic); @@ -272,10 +273,10 @@ DmpCeffTwoPoleDelayCalc::inputPortDelay(const Pin *port_pin, void DmpCeffTwoPoleDelayCalc::gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, diff --git a/dcalc/GraphDelayCalc.cc b/dcalc/GraphDelayCalc.cc index 05fa4dca..56490c10 100644 --- a/dcalc/GraphDelayCalc.cc +++ b/dcalc/GraphDelayCalc.cc @@ -127,7 +127,7 @@ GraphDelayCalc::minPulseWidth(const Pin *pin, LibertyPort *port = network_->libertyPort(pin); if (port) { Instance *inst = network_->instance(pin); - Pvt *pvt = inst ? sdc_->pvt(inst, min_max) : nullptr; + const Pvt *pvt = inst ? sdc_->pvt(inst, min_max) : nullptr; OperatingConditions *op_cond=sdc_->operatingConditions(min_max); port->minPulseWidth(hi_low, op_cond, pvt, min_width, exists); } @@ -160,7 +160,7 @@ GraphDelayCalc::minPeriod(const Pin *pin, // Liberty library. Instance *inst = network_->instance(pin); OperatingConditions *op_cond = sdc_->operatingConditions(min_max); - Pvt *pvt = inst ? sdc_->pvt(inst, min_max) : nullptr; + const Pvt *pvt = inst ? sdc_->pvt(inst, min_max) : nullptr; port->minPeriod(op_cond, pvt, min_period, exists); } } diff --git a/dcalc/GraphDelayCalc1.cc b/dcalc/GraphDelayCalc1.cc index 4ec2aacd..609c2d07 100644 --- a/dcalc/GraphDelayCalc1.cc +++ b/dcalc/GraphDelayCalc1.cc @@ -452,7 +452,7 @@ public: FindNetDrvrs(PinSet &drvr_pins, const Network *network, const Graph *graph); - virtual void operator()(Pin *pin); + virtual void operator()(const Pin *pin); protected: PinSet &drvr_pins_; @@ -470,7 +470,7 @@ FindNetDrvrs::FindNetDrvrs(PinSet &drvr_pins, } void -FindNetDrvrs::operator()(Pin *pin) +FindNetDrvrs::operator()(const Pin *pin) { Vertex *vertex = graph_->pinDrvrVertex(pin); if (isLeafDriver(pin, network_) @@ -491,7 +491,7 @@ GraphDelayCalc1::ensureMultiDrvrNetsFound() Vertex *drvr_vertex = graph_->pinDrvrVertex(pin); if (network_->isDriver(pin) && !multi_drvr_net_map_.hasKey(drvr_vertex)) { - PinSet drvr_pins; + PinSet drvr_pins(network_); FindNetDrvrs visitor(drvr_pins, network_, graph_); network_->visitConnectedPins(pin, visitor); if (drvr_pins.size() > 1) @@ -515,7 +515,7 @@ GraphDelayCalc1::makeMultiDrvrNet(PinSet &drvr_pins) Vertex *max_drvr = nullptr; PinSet::Iterator pin_iter(drvr_pins); while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + const Pin *pin = pin_iter.next(); Vertex *drvr_vertex = graph_->pinDrvrVertex(pin); debugPrint(debug_, "delay_calc", 3, " %s", network_->pathName(pin)); @@ -581,8 +581,8 @@ GraphDelayCalc1::seedDrvrSlew(Vertex *drvr_vertex, for (auto dcalc_ap : corners_->dcalcAnalysisPts()) { if (drive) { const MinMax *cnst_min_max = dcalc_ap->constraintMinMax(); - LibertyCell *drvr_cell; - LibertyPort *from_port, *to_port; + const LibertyCell *drvr_cell; + const LibertyPort *from_port, *to_port; float *from_slews; drive->driveCell(tr, cnst_min_max, drvr_cell, from_port, from_slews, to_port); @@ -705,8 +705,8 @@ GraphDelayCalc1::seedLoadSlew(Vertex *vertex) // defined in the cell that has a timing group to the output port // is used. Not exactly reasonable, but it's compatible. LibertyPort * -GraphDelayCalc1::driveCellDefaultFromPort(LibertyCell *cell, - LibertyPort *to_port) +GraphDelayCalc1::driveCellDefaultFromPort(const LibertyCell *cell, + const LibertyPort *to_port) { LibertyPort *from_port = 0; int from_port_index = 0; @@ -724,8 +724,8 @@ GraphDelayCalc1::driveCellDefaultFromPort(LibertyCell *cell, // Find the index that port is defined in cell. int -GraphDelayCalc1::findPortIndex(LibertyCell *cell, - LibertyPort *port) +GraphDelayCalc1::findPortIndex(const LibertyCell *cell, + const LibertyPort *port) { int index = 0; LibertyCellPortIterator port_iter(cell); @@ -740,14 +740,14 @@ GraphDelayCalc1::findPortIndex(LibertyCell *cell, } void -GraphDelayCalc1::findInputDriverDelay(LibertyCell *drvr_cell, +GraphDelayCalc1::findInputDriverDelay(const LibertyCell *drvr_cell, const Pin *drvr_pin, Vertex *drvr_vertex, const RiseFall *rf, - LibertyPort *from_port, + const LibertyPort *from_port, float *from_slews, - LibertyPort *to_port, - DcalcAnalysisPt *dcalc_ap) + const LibertyPort *to_port, + const DcalcAnalysisPt *dcalc_ap) { debugPrint(debug_, "delay_calc", 2, " driver cell %s %s", drvr_cell->name(), @@ -767,12 +767,12 @@ GraphDelayCalc1::findInputDriverDelay(LibertyCell *drvr_cell, // delay minus the intrinsic delay. Driving cell delays are annotated // to the wire arcs from the input port pin to the load pins. void -GraphDelayCalc1::findInputArcDelay(LibertyCell *drvr_cell, +GraphDelayCalc1::findInputArcDelay(const LibertyCell *drvr_cell, const Pin *drvr_pin, Vertex *drvr_vertex, - TimingArc *arc, + const TimingArc *arc, float from_slew, - DcalcAnalysisPt *dcalc_ap) + const DcalcAnalysisPt *dcalc_ap) { debugPrint(debug_, "delay_calc", 3, " %s %s -> %s %s (%s)", arc->from()->name(), diff --git a/dcalc/GraphDelayCalc1.hh b/dcalc/GraphDelayCalc1.hh index ba5c700a..da81c596 100644 --- a/dcalc/GraphDelayCalc1.hh +++ b/dcalc/GraphDelayCalc1.hh @@ -104,24 +104,24 @@ protected: ArcDelayCalc *arc_delay_calc); void seedLoadSlew(Vertex *vertex); void setInputPortWireDelays(Vertex *vertex); - void findInputDriverDelay(LibertyCell *drvr_cell, + void findInputDriverDelay(const LibertyCell *drvr_cell, const Pin *drvr_pin, Vertex *drvr_vertex, const RiseFall *rf, - LibertyPort *from_port, + const LibertyPort *from_port, float *from_slews, - LibertyPort *to_port, - DcalcAnalysisPt *dcalc_ap); - LibertyPort *driveCellDefaultFromPort(LibertyCell *cell, - LibertyPort *to_port); - int findPortIndex(LibertyCell *cell, - LibertyPort *port); - void findInputArcDelay(LibertyCell *drvr_cell, + const LibertyPort *to_port, + const DcalcAnalysisPt *dcalc_ap); + LibertyPort *driveCellDefaultFromPort(const LibertyCell *cell, + const LibertyPort *to_port); + int findPortIndex(const LibertyCell *cell, + const LibertyPort *port); + void findInputArcDelay(const LibertyCell *drvr_cell, const Pin *drvr_pin, Vertex *drvr_vertex, - TimingArc *arc, + const TimingArc *arc, float from_slew, - DcalcAnalysisPt *dcalc_ap); + const DcalcAnalysisPt *dcalc_ap); bool findDriverDelays(Vertex *drvr_vertex, ArcDelayCalc *arc_delay_calc); bool findDriverDelays1(Vertex *drvr_vertex, diff --git a/dcalc/LumpedCapDelayCalc.cc b/dcalc/LumpedCapDelayCalc.cc index 249619fb..f5cad374 100644 --- a/dcalc/LumpedCapDelayCalc.cc +++ b/dcalc/LumpedCapDelayCalc.cc @@ -51,8 +51,9 @@ LumpedCapDelayCalc::findParasitic(const Pin *drvr_pin, const RiseFall *rf, const DcalcAnalysisPt *dcalc_ap) { + const Corner *corner = dcalc_ap->corner(); // set_load has precidence over parasitics. - if (!sdc_->drvrPinHasWireCap(drvr_pin)) { + if (!sdc_->drvrPinHasWireCap(drvr_pin, corner)) { Parasitic *parasitic = nullptr; const ParasiticAnalysisPt *parasitic_ap = dcalc_ap->parasiticAnalysisPt(); if (parasitics_->haveParasitics()) { @@ -66,7 +67,7 @@ LumpedCapDelayCalc::findParasitic(const Pin *drvr_pin, if (parasitic_network) { parasitics_->reduceToPiElmore(parasitic_network, drvr_pin, dcalc_ap->operatingConditions(), - dcalc_ap->corner(), + corner, dcalc_ap->constraintMinMax(), parasitic_ap); parasitic = parasitics_->findPiElmore(drvr_pin, rf, parasitic_ap); @@ -85,7 +86,7 @@ LumpedCapDelayCalc::findParasitic(const Pin *drvr_pin, parasitic = parasitics_->estimatePiElmore(drvr_pin, rf, wireload, fanout, pin_cap, dcalc_ap->operatingConditions(), - dcalc_ap->corner(), + corner, cnst_min_max, parasitic_ap); // Estimated parasitics are not recorded in the "database", so @@ -118,7 +119,7 @@ LumpedCapDelayCalc::finishDrvrPin() void LumpedCapDelayCalc::inputPortDelay(const Pin *, float in_slew, const RiseFall *rf, - Parasitic *, + const Parasitic *, const DcalcAnalysisPt *) { drvr_slew_ = in_slew; @@ -129,10 +130,10 @@ LumpedCapDelayCalc::inputPortDelay(const Pin *, float in_slew, float LumpedCapDelayCalc::ceff(const LibertyCell *, - TimingArc *, + const TimingArc *, const Slew &, float load_cap, - Parasitic *, + const Parasitic *, float, const Pvt *, const DcalcAnalysisPt *) @@ -142,10 +143,10 @@ LumpedCapDelayCalc::ceff(const LibertyCell *, void LumpedCapDelayCalc::gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *, + const Parasitic *, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -239,10 +240,10 @@ LumpedCapDelayCalc::thresholdLibrary(const Pin *load_pin) void LumpedCapDelayCalc::reportGateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *, + const Parasitic *, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -259,7 +260,7 @@ LumpedCapDelayCalc::reportGateDelay(const LibertyCell *drvr_cell, void LumpedCapDelayCalc::checkDelay(const LibertyCell *cell, - TimingArc *arc, + const TimingArc *arc, const Slew &from_slew, const Slew &to_slew, float related_out_cap, @@ -281,7 +282,7 @@ LumpedCapDelayCalc::checkDelay(const LibertyCell *cell, void LumpedCapDelayCalc::reportCheckDelay(const LibertyCell *cell, - TimingArc *arc, + const TimingArc *arc, const Slew &from_slew, const char *from_slew_annotation, const Slew &to_slew, diff --git a/dcalc/LumpedCapDelayCalc.hh b/dcalc/LumpedCapDelayCalc.hh index 702a8824..df3662dd 100644 --- a/dcalc/LumpedCapDelayCalc.hh +++ b/dcalc/LumpedCapDelayCalc.hh @@ -34,13 +34,13 @@ public: virtual void inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap); virtual void gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -53,7 +53,7 @@ public: ArcDelay &wire_delay, Slew &load_slew); virtual void checkDelay(const LibertyCell *cell, - TimingArc *arc, + const TimingArc *arc, const Slew &from_slew, const Slew &to_slew, float related_out_cap, @@ -62,25 +62,25 @@ public: // Return values. ArcDelay &margin); virtual float ceff(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap); virtual void reportGateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, int digits, string *result); virtual void reportCheckDelay(const LibertyCell *cell, - TimingArc *arc, + const TimingArc *arc, const Slew &from_slew, const char *from_slew_annotation, const Slew &to_slew, diff --git a/dcalc/RCDelayCalc.cc b/dcalc/RCDelayCalc.cc index 05a21f9e..2a92ec3c 100644 --- a/dcalc/RCDelayCalc.cc +++ b/dcalc/RCDelayCalc.cc @@ -39,7 +39,7 @@ void RCDelayCalc::inputPortDelay(const Pin *, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *) { drvr_parasitic_ = parasitic; diff --git a/dcalc/RCDelayCalc.hh b/dcalc/RCDelayCalc.hh index 77bc6b6a..f74c06d4 100644 --- a/dcalc/RCDelayCalc.hh +++ b/dcalc/RCDelayCalc.hh @@ -29,7 +29,7 @@ public: virtual void inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap); protected: @@ -40,7 +40,7 @@ protected: Slew &load_slew); const LibertyCell *drvr_cell_; - Parasitic *drvr_parasitic_; + const Parasitic *drvr_parasitic_; }; } // namespace diff --git a/dcalc/SimpleRCDelayCalc.cc b/dcalc/SimpleRCDelayCalc.cc index 7b8c3c02..053dc54f 100644 --- a/dcalc/SimpleRCDelayCalc.cc +++ b/dcalc/SimpleRCDelayCalc.cc @@ -46,7 +46,7 @@ void SimpleRCDelayCalc::inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap) { pvt_ = dcalc_ap->operatingConditions(); @@ -55,10 +55,10 @@ SimpleRCDelayCalc::inputPortDelay(const Pin *port_pin, void SimpleRCDelayCalc::gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, diff --git a/dcalc/SimpleRCDelayCalc.hh b/dcalc/SimpleRCDelayCalc.hh index 23a3542e..e13d4084 100644 --- a/dcalc/SimpleRCDelayCalc.hh +++ b/dcalc/SimpleRCDelayCalc.hh @@ -33,13 +33,13 @@ public: virtual void inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap); virtual void gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, diff --git a/dcalc/UnitDelayCalc.cc b/dcalc/UnitDelayCalc.cc index b944595d..224cc33a 100644 --- a/dcalc/UnitDelayCalc.cc +++ b/dcalc/UnitDelayCalc.cc @@ -55,17 +55,17 @@ void UnitDelayCalc::inputPortDelay(const Pin *, float, const RiseFall *, - Parasitic *, + const Parasitic *, const DcalcAnalysisPt *) { } void UnitDelayCalc::gateDelay(const LibertyCell *, - TimingArc *, + const TimingArc *, const Slew &, float, - Parasitic *, + const Parasitic *, float, const Pvt *, const DcalcAnalysisPt *, // Return values. @@ -86,10 +86,10 @@ UnitDelayCalc::loadDelay(const Pin *, float UnitDelayCalc::ceff(const LibertyCell *, - TimingArc *, + const TimingArc *, const Slew &, float, - Parasitic *, + const Parasitic *, float, const Pvt *, const DcalcAnalysisPt *) @@ -99,10 +99,10 @@ UnitDelayCalc::ceff(const LibertyCell *, void UnitDelayCalc::reportGateDelay(const LibertyCell *, - TimingArc *, + const TimingArc *, const Slew &, float, - Parasitic *, + const Parasitic *, float, const Pvt *, const DcalcAnalysisPt *, @@ -115,7 +115,7 @@ UnitDelayCalc::reportGateDelay(const LibertyCell *, void UnitDelayCalc::checkDelay(const LibertyCell *, - TimingArc *, + const TimingArc *, const Slew &, const Slew &, float, @@ -129,7 +129,7 @@ UnitDelayCalc::checkDelay(const LibertyCell *, void UnitDelayCalc::reportCheckDelay(const LibertyCell *, - TimingArc *, + const TimingArc *, const Slew &, const char *, const Slew &, diff --git a/dcalc/UnitDelayCalc.hh b/dcalc/UnitDelayCalc.hh index f1ae8d3c..211d1287 100644 --- a/dcalc/UnitDelayCalc.hh +++ b/dcalc/UnitDelayCalc.hh @@ -31,10 +31,10 @@ public: const DcalcAnalysisPt *dcalc_ap); virtual ReducedParasiticType reducedParasiticType() const; virtual void gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -47,20 +47,20 @@ public: Slew &load_slew); virtual void setMultiDrvrSlewFactor(float) {} virtual float ceff(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap); virtual void inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap); virtual void checkDelay(const LibertyCell *cell, - TimingArc *arc, + const TimingArc *arc, const Slew &from_slew, const Slew &to_slew, float related_out_cap, @@ -69,17 +69,17 @@ public: // Return values. ArcDelay &margin); virtual void reportGateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, int digits, string *result); virtual void reportCheckDelay(const LibertyCell *cell, - TimingArc *arc, + const TimingArc *arc, const Slew &from_slew, const char *from_slew_annotation, const Slew &to_slew, diff --git a/doc/ApiChanges.txt b/doc/ApiChanges.txt index 79388b33..3709eae3 100644 --- a/doc/ApiChanges.txt +++ b/doc/ApiChanges.txt @@ -16,6 +16,24 @@ This file summarizes STA API changes for each release. +Release 2.4.0 2023/01/?? +------------------------- + +The Network API and associated containers now 'const' the network class objects. +The Network API now requires network objects to have and "id" function that +returns an ObjectId (unsigned int) that is unique to the object among objects +of the same type. + + virtual ObjectId id(const Instance *instance) const = 0; + +Object IDs are used for comparing and hashing network objects. +If network Ids are not available in the host application database object pointers +can be cast to intptr_t. Using pointers as object Ids can result in memory layout +dependent results that are inconsistent from run to run or across host systems. + +Many Network and Sta class functions now return collections rather than pointers +to temporary collections that the caller would have to delete. + Release 2.3.1 2022/06/12 ------------------------- LibertyCellTimingArcSetIterator has been removed. diff --git a/graph/Graph.cc b/graph/Graph.cc index 9257ba0c..6911f678 100644 --- a/graph/Graph.cc +++ b/graph/Graph.cc @@ -168,7 +168,7 @@ Graph::makeInstanceEdges(const Instance *inst) } void -Graph::makePinInstanceEdges(Pin *pin) +Graph::makePinInstanceEdges(const Pin *pin) { const Instance *inst = network_->instance(pin); if (inst) { @@ -232,7 +232,7 @@ Graph::makePortInstanceEdges(const Instance *inst, void Graph::makeWireEdges() { - PinSet visited_drvrs; + PinSet visited_drvrs(network_); LeafInstanceIterator *inst_iter = network_->leafInstanceIterator(); while (inst_iter->hasNext()) { Instance *inst = inst_iter->next(); @@ -243,7 +243,7 @@ Graph::makeWireEdges() } void -Graph::makeInstDrvrWireEdges(Instance *inst, +Graph::makeInstDrvrWireEdges(const Instance *inst, PinSet &visited_drvrs) { InstancePinIterator *pin_iter = network_->pinIterator(inst); @@ -257,10 +257,10 @@ Graph::makeInstDrvrWireEdges(Instance *inst, } void -Graph::makeWireEdgesFromPin(Pin *drvr_pin) +Graph::makeWireEdgesFromPin(const Pin *drvr_pin) { PinSeq loads, drvrs; - PinSet visited_drvrs; + PinSet visited_drvrs(network_); FindNetDrvrLoads visitor(drvr_pin, visited_drvrs, loads, drvrs, network_); network_->visitConnectedPins(drvr_pin, visitor); @@ -271,7 +271,7 @@ Graph::makeWireEdgesFromPin(Pin *drvr_pin) } void -Graph::makeWireEdgesFromPin(Pin *drvr_pin, +Graph::makeWireEdgesFromPin(const Pin *drvr_pin, PinSet &visited_drvrs) { // Find all drivers and loads on the net to avoid N*M run time @@ -289,7 +289,7 @@ Graph::makeWireEdgesFromPin(Pin *drvr_pin, } void -Graph::makeWireEdgesToPin(Pin *to_pin) +Graph::makeWireEdgesToPin(const Pin *to_pin) { PinSet *drvrs = network_->drivers(to_pin); if (drvrs) { @@ -306,8 +306,8 @@ public: MakeEdgesThruHierPin(Graph *graph); private: - virtual void visit(Pin *drvr, - Pin *load); + virtual void visit(const Pin *drvr, + const Pin *load); Graph *graph_; }; @@ -319,22 +319,22 @@ MakeEdgesThruHierPin::MakeEdgesThruHierPin(Graph *graph) : } void -MakeEdgesThruHierPin::visit(Pin *drvr, - Pin *load) +MakeEdgesThruHierPin::visit(const Pin *drvr, + const Pin *load) { graph_->makeWireEdge(drvr, load); } void -Graph::makeWireEdgesThruPin(Pin *hpin) +Graph::makeWireEdgesThruPin(const Pin *hpin) { MakeEdgesThruHierPin visitor(this); visitDrvrLoadsThruHierPin(hpin, network_, &visitor); } void -Graph::makeWireEdge(Pin *from_pin, - Pin *to_pin) +Graph::makeWireEdge(const Pin *from_pin, + const Pin *to_pin) { TimingArcSet *arc_set = TimingArcSet::wireTimingArcSet(); Vertex *from_vertex, *from_bidirect_drvr_vertex; @@ -1557,8 +1557,8 @@ class FindEdgesThruHierPinVisitor : public HierPinThruVisitor public: FindEdgesThruHierPinVisitor(EdgeSet &edges, Graph *graph); - virtual void visit(Pin *drvr, - Pin *load); + virtual void visit(const Pin *drvr, + const Pin *load); protected: EdgeSet &edges_; @@ -1574,8 +1574,8 @@ FindEdgesThruHierPinVisitor::FindEdgesThruHierPinVisitor(EdgeSet &edges, } void -FindEdgesThruHierPinVisitor::visit(Pin *drvr, - Pin *load) +FindEdgesThruHierPinVisitor::visit(const Pin *drvr, + const Pin *load) { Vertex *drvr_vertex = graph_->pinDrvrVertex(drvr); Vertex *load_vertex = graph_->pinLoadVertex(load); diff --git a/include/sta/ArcDelayCalc.hh b/include/sta/ArcDelayCalc.hh index 45a7037c..3a048f1a 100644 --- a/include/sta/ArcDelayCalc.hh +++ b/include/sta/ArcDelayCalc.hh @@ -60,16 +60,16 @@ public: virtual void inputPortDelay(const Pin *port_pin, float in_slew, const RiseFall *rf, - Parasitic *parasitic, + const Parasitic *parasitic, const DcalcAnalysisPt *dcalc_ap) = 0; // Find the delay and slew for arc driving drvr_pin. virtual void gateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, // Pass in load_cap or drvr_parasitic. float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -85,10 +85,10 @@ public: virtual void setMultiDrvrSlewFactor(float factor) = 0; // Ceff for parasitics with pi models. virtual float ceff(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap) = 0; @@ -96,7 +96,7 @@ public: // Find the delay for a timing check arc given the arc's // from/clock, to/data slews and related output pin parasitic. virtual void checkDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &from_slew, const Slew &to_slew, float related_out_cap, @@ -106,11 +106,11 @@ public: ArcDelay &margin) = 0; // Report delay and slew calculation. virtual void reportGateDelay(const LibertyCell *drvr_cell, - TimingArc *arc, + const TimingArc *arc, const Slew &in_slew, // Pass in load_cap or drvr_parasitic. float load_cap, - Parasitic *drvr_parasitic, + const Parasitic *drvr_parasitic, float related_out_cap, const Pvt *pvt, const DcalcAnalysisPt *dcalc_ap, @@ -118,7 +118,7 @@ public: string *result) = 0; // Report timing check delay calculation. virtual void reportCheckDelay(const LibertyCell *cell, - TimingArc *arc, + const TimingArc *arc, const Slew &from_slew, const char *from_slew_annotation, const Slew &to_slew, @@ -130,11 +130,11 @@ public: virtual void finishDrvrPin() = 0; protected: - GateTimingModel *gateModel(TimingArc *arc, + GateTimingModel *gateModel(const TimingArc *arc, const DcalcAnalysisPt *dcalc_ap) const; - CheckTimingModel *checkModel(TimingArc *arc, + CheckTimingModel *checkModel(const TimingArc *arc, const DcalcAnalysisPt *dcalc_ap) const; - TimingModel *model(TimingArc *arc, + TimingModel *model(const TimingArc *arc, const DcalcAnalysisPt *dcalc_ap) const; }; diff --git a/include/sta/ClkNetwork.hh b/include/sta/ClkNetwork.hh index a0480d34..93dc75c5 100644 --- a/include/sta/ClkNetwork.hh +++ b/include/sta/ClkNetwork.hh @@ -26,7 +26,7 @@ namespace sta { typedef Map PinClksMap; -typedef Map ClkPinsMap; +typedef Map ClkPinsMap; class Sta; @@ -36,6 +36,7 @@ class ClkNetwork : public StaState { public: ClkNetwork(StaState *sta); + ~ClkNetwork(); void ensureClkNetwork(); void clear(); bool isClock(const Pin *pin) const; diff --git a/include/sta/Clock.hh b/include/sta/Clock.hh index 1d367150..41276e5d 100644 --- a/include/sta/Clock.hh +++ b/include/sta/Clock.hh @@ -34,7 +34,6 @@ public: float period() const { return period_; } // Virtual clocks have no pins. bool isVirtual() const; - PinSet &pins() { return pins_; } const PinSet &pins() const { return pins_; } // The clock source pin's leaf pins. // If the source pin is hierarchical, the leaf pins are: @@ -44,7 +43,7 @@ public: const PinSet &leafPins() const { return leaf_pins_; } // Clock pin used by input/output delay for propagated generated // clock insertion delay. - Pin *defaultPin() const; + const Pin *defaultPin() const; bool addToPins() const { return add_to_pins_; } void setAddToPins(bool add_to_pins); FloatSeq *waveform() { return waveform_; } @@ -69,7 +68,7 @@ public: const MinMaxAll *min_max, float slew); void removeSlew(); - RiseFallMinMax *slews() { return &slews_; } + const RiseFallMinMax &slews() const { return slews_; } void setSlewLimit(const RiseFallBoth *rf, const PathClkOrData clk_data, const MinMax *min_max, @@ -94,8 +93,8 @@ public: void setPeriod(float period); void setWaveform(FloatSeq *waveform); - void addPin(Pin *pin); - void deletePin(Pin *pin); + void addPin(const Pin *pin); + void deletePin(const Pin *pin); void makeLeafPins(const Network *network); bool isGenerated() const; @@ -123,9 +122,10 @@ public: void waveformInvalid(); protected: - // Private to Constraints::makeClock. + // Private to Sdc::makeClock. Clock(const char *name, - int index); + int index, + const Network *network); void initClk(PinSet *pins, bool add_to_pins, float period, @@ -218,16 +218,17 @@ int clkCmp(const Clock *clk1, const Clock *clk2); int -clkEdgeCmp(ClockEdge *clk_edge1, - ClockEdge *clk_edge2); +clkEdgeCmp(const ClockEdge *clk_edge1, + const ClockEdge *clk_edge2); bool -clkEdgeLess(ClockEdge *clk_edge1, - ClockEdge *clk_edge2); +clkEdgeLess(const ClockEdge *clk_edge1, + const ClockEdge *clk_edge2); class ClockNameLess { public: - bool operator()(const Clock *clk1, const Clock *clk2); + bool operator()(const Clock *clk1, + const Clock *clk2); }; //////////////////////////////////////////////////////////////// @@ -278,8 +279,10 @@ public: } }; -void -sortClockSet(ClockSet * set, - ClockSeq &clks); +ClockSeq +sortByName(ClockSet *set); +int +compare(const ClockSet *set1, + const ClockSet *set2); } // namespace diff --git a/include/sta/ClockGroups.hh b/include/sta/ClockGroups.hh index f9e793c4..d81ba0d4 100644 --- a/include/sta/ClockGroups.hh +++ b/include/sta/ClockGroups.hh @@ -21,18 +21,6 @@ namespace sta { -class ClockGroup -{ -public: - ClockGroup(ClockSet *clks); - ~ClockGroup(); - bool isMember(const Clock *clk); - ClockSet *clks() const { return clks_; } - -private: - ClockSet *clks_; -}; - class ClockGroups : public SdcCmdComment { public: @@ -43,7 +31,7 @@ public: bool allow_paths, const char *comment); ~ClockGroups(); - ClockGroup *makeClockGroup(ClockSet *clks); + void makeClockGroup(ClockSet *clks); const char *name() const { return name_; } ClockGroupSet *groups() { return &groups_; } bool logicallyExclusive() const { return logically_exclusive_; } diff --git a/include/sta/ConcreteLibrary.hh b/include/sta/ConcreteLibrary.hh index 2bea143d..4ed95e81 100644 --- a/include/sta/ConcreteLibrary.hh +++ b/include/sta/ConcreteLibrary.hh @@ -53,6 +53,7 @@ public: virtual ~ConcreteLibrary(); const char *name() const { return name_; } void setName(const char *name); + ObjectId id() const { return id_; } bool isLiberty() const { return is_liberty_; } const char *filename() const { return filename_; } void addCell(ConcreteCell *cell); @@ -62,8 +63,7 @@ public: void deleteCell(ConcreteCell *cell); ConcreteLibraryCellIterator *cellIterator() const; ConcreteCell *findCell(const char *name) const; - void findCellsMatching(const PatternMatch *pattern, - CellSeq *cells) const; + CellSeq findCellsMatching(const PatternMatch *pattern) const; char busBrktLeft() const { return bus_brkt_left_; } char busBrktRight() const { return bus_brkt_right_; } void setBusBrkts(char left, @@ -74,6 +74,7 @@ protected: const char *cell_name); const char *name_; + ObjectId id_; const char *filename_; bool is_liberty_; char bus_brkt_left_; @@ -89,17 +90,17 @@ class ConcreteCell public: // Use ConcreteLibrary::deleteCell. virtual ~ConcreteCell(); - ConcreteLibrary *library() const { return library_; } const char *name() const { return name_; } + ObjectId id() const { return id_; } const char *filename() const { return filename_; } + ConcreteLibrary *library() const { return library_; } LibertyCell *libertyCell() const { return liberty_cell_; } void setLibertyCell(LibertyCell *cell); void *extCell() const { return ext_cell_; } void setExtCell(void *ext_cell); int portBitCount() const { return port_bit_count_; } ConcretePort *findPort(const char *name) const; - void findPortsMatching(const PatternMatch *pattern, - PortSeq *ports) const; + PortSeq findPortsMatching(const PatternMatch *pattern) const; ConcreteCellPortIterator *portIterator() const; ConcreteCellPortBitIterator *portBitIterator() const; bool isLeaf() const { return is_leaf_; } @@ -124,10 +125,10 @@ public: void addPortBit(ConcretePort *port); protected: - ConcreteCell(ConcreteLibrary *library, - const char *name, - bool is_leaf, - const char *filename); + ConcreteCell(const char *name, + const char *filename, + bool is_leaf, + ConcreteLibrary *library); ConcretePort *makeBusPort(const char *name, int from_index, int to_index, @@ -143,10 +144,11 @@ protected: const char *name, int index); - ConcreteLibrary *library_; const char *name_; + ObjectId id_; // Filename is optional. const char *filename_; + ConcreteLibrary *library_; LibertyCell *liberty_cell_; // External application cell. void *ext_cell_; @@ -167,6 +169,7 @@ class ConcretePort public: virtual ~ConcretePort(); const char *name() const { return name_; } + ObjectId id() const { return id_; } const char *busName() const; Cell *cell() const; ConcreteLibrary *library() const { return cell_->library(); } @@ -212,15 +215,16 @@ public: protected: // Constructors for factory in cell class. - ConcretePort(ConcreteCell *cell, - const char *name, - bool is_bus, + ConcretePort(const char *name, + bool is_bus, int from_index, int to_index, bool is_bundle, - ConcretePortSeq *member_ports); + ConcretePortSeq *member_ports, + ConcreteCell *cell); const char *name_; + ObjectId id_; ConcreteCell *cell_; PortDirection *direction_; LibertyPort *liberty_port_; diff --git a/include/sta/ConcreteNetwork.hh b/include/sta/ConcreteNetwork.hh index 48a4cef4..45530043 100644 --- a/include/sta/ConcreteNetwork.hh +++ b/include/sta/ConcreteNetwork.hh @@ -60,20 +60,21 @@ public: Report *report); virtual Instance *topInstance() const; + virtual const char *name(const Library *library) const; + virtual ObjectId id(const Library *library) const; virtual LibraryIterator *libraryIterator() const; virtual LibertyLibraryIterator *libertyLibraryIterator() const ; virtual Library *findLibrary(const char *name); - virtual const char *name(const Library *library) const; virtual LibertyLibrary *findLiberty(const char *name); virtual LibertyLibrary *libertyLibrary(Library *library) const; virtual Cell *findCell(const Library *library, const char *name) const; virtual Cell *findAnyCell(const char *name); - virtual void findCellsMatching(const Library *library, - const PatternMatch *pattern, - CellSeq *cells) const; + virtual CellSeq findCellsMatching(const Library *library, + const PatternMatch *pattern) const; virtual const char *name(const Cell *cell) const; + virtual ObjectId id(const Cell *cell) const; virtual Library *library(const Cell *cell) const; virtual LibertyCell *libertyCell(Cell *cell) const; virtual const LibertyCell *libertyCell(const Cell *cell) const; @@ -82,15 +83,15 @@ public: virtual const char *filename(const Cell *cell); virtual Port *findPort(const Cell *cell, const char *name) const; - virtual void findPortsMatching(const Cell *cell, - const PatternMatch *pattern, - PortSeq *ports) const; + virtual PortSeq findPortsMatching(const Cell *cell, + const PatternMatch *pattern) const; virtual bool isLeaf(const Cell *cell) const; virtual CellPortIterator *portIterator(const Cell *cell) const; virtual CellPortBitIterator *portBitIterator(const Cell *cell) const; virtual int portBitCount(const Cell *cell) const; virtual const char *name(const Port *port) const; + virtual ObjectId id(const Port *port) const; virtual Cell *cell(const Port *port) const; virtual LibertyPort *libertyPort(const Port *port) const; virtual PortDirection *direction(const Port *port) const; @@ -109,6 +110,7 @@ public: virtual PortMemberIterator *memberIterator(const Port *port) const; virtual const char *name(const Instance *instance) const; + virtual ObjectId id(const Instance *instance) const; virtual Cell *cell(const Instance *instance) const; virtual Instance *parent(const Instance *instance) const; virtual bool isLeaf(const Instance *instance) const; @@ -126,6 +128,7 @@ public: virtual InstanceNetIterator * netIterator(const Instance *instance) const; + virtual ObjectId id(const Pin *pin) const; virtual Instance *instance(const Pin *pin) const; virtual Net *net(const Pin *pin) const; virtual Term *term(const Pin *pin) const; @@ -135,15 +138,17 @@ public: virtual void setVertexId(Pin *pin, VertexId id); + virtual ObjectId id(const Term *term) const; virtual Net *net(const Term *term) const; virtual Pin *pin(const Term *term) const; + virtual const char *name(const Net *net) const; + virtual ObjectId id(const Net *net) const; virtual Net *findNet(const Instance *instance, const char *net_name) const; virtual void findInstNetsMatching(const Instance *instance, - const PatternMatch *pattern, - NetSeq *nets) const; - virtual const char *name(const Net *net) const; + const PatternMatch *pattern, + NetSeq &matches) const; virtual Instance *instance(const Net *net) const; virtual bool isPower(const Net *net) const; virtual bool isGround(const Net *net) const; @@ -227,6 +232,8 @@ public: virtual void setLinkFunc(LinkNetworkFunc *link); void setTopInstance(Instance *top_inst); + static ObjectId nextObjectId(); + using Network::netIterator; using Network::findPin; using Network::findNet; @@ -242,7 +249,7 @@ protected: void clearConstantNets(); virtual void visitConnectedPins(const Net *net, PinVisitor &visitor, - ConstNetSet &visited_nets) const; + NetSet &visited_nets) const; Instance *makeConcreteInstance(ConcreteCell *cell, const char *name, Instance *parent); @@ -258,6 +265,7 @@ protected: NetSet constant_nets_[2]; // LogicValue::zero/one LinkNetworkFunc *link_func_; CellNetworkViewMap cell_network_view_map_; + static ObjectId object_id_; private: friend class ConcreteLibertyLibraryIterator; @@ -267,13 +275,14 @@ class ConcreteInstance { public: const char *name() const { return name_; } + ObjectId id() const { return id_; } Cell *cell() const; ConcreteInstance *parent() const { return parent_; } ConcretePin *findPin(const char *port_name) const; ConcretePin *findPin(const Port *port) const; ConcreteNet *findNet(const char *net_name) const; void findNetsMatching(const PatternMatch *pattern, - NetSeq *nets) const; + NetSeq &matches) const; InstanceNetIterator *netIterator() const; Instance *findChild(const char *name) const; InstanceChildIterator *childIterator() const; @@ -289,13 +298,14 @@ public: void initPins(); protected: - ConcreteInstance(ConcreteCell *cell, - const char *name, - ConcreteInstance *parent); + ConcreteInstance(const char *name, + ConcreteCell *cell, + ConcreteInstance *parent); ~ConcreteInstance(); - ConcreteCell *cell_; const char *name_; + ObjectId id_; + ConcreteCell *cell_; ConcreteInstance *parent_; // Array of pins indexed by pin->port->index(). ConcretePin **pins_; @@ -315,6 +325,7 @@ public: ConcreteNet *net() const { return net_; } ConcretePort *port() const { return port_; } ConcreteTerm *term() const { return term_; } + ObjectId id() const { return id_; } VertexId vertexId() const { return vertex_id_; } void setVertexId(VertexId id); @@ -328,6 +339,7 @@ protected: ConcretePort *port_; ConcreteNet *net_; ConcreteTerm *term_; + ObjectId id_; // Doubly linked list of net pins. ConcretePin *net_next_; ConcretePin *net_prev_; @@ -343,6 +355,7 @@ class ConcreteTerm { public: const char *name() const; + ObjectId id() const { return id_; } ConcreteNet *net() const { return net_; } ConcretePin *pin() const { return pin_; } @@ -353,6 +366,7 @@ protected: ConcretePin *pin_; ConcreteNet *net_; + ObjectId id_; // Linked list of net terms. ConcreteTerm *net_next_; @@ -366,6 +380,7 @@ class ConcreteNet { public: const char *name() const { return name_; } + ObjectId id() const { return id_; } ConcreteInstance *instance() const { return instance_; } void addPin(ConcretePin *pin); void deletePin(ConcretePin *pin); @@ -379,6 +394,7 @@ protected: ConcreteInstance *instance); ~ConcreteNet(); const char *name_; + ObjectId id_; ConcreteInstance *instance_; // Pointer to head of linked list of pins. ConcretePin *pins_; diff --git a/include/sta/DataCheck.hh b/include/sta/DataCheck.hh index 91d76437..b2ce8683 100644 --- a/include/sta/DataCheck.hh +++ b/include/sta/DataCheck.hh @@ -25,8 +25,6 @@ namespace sta { -class PinPathNameLess; - class DataCheck { public: @@ -65,12 +63,12 @@ private: class DataCheckLess { public: - explicit DataCheckLess(const Network *network); + DataCheckLess(const Network *network); bool operator()(const DataCheck *check1, const DataCheck *check2) const; private: - PinPathNameLess pin_less_; + const Network *network_; }; } // namespace diff --git a/include/sta/DelayCalc.hh b/include/sta/DelayCalc.hh index 13a39671..384b6fdb 100644 --- a/include/sta/DelayCalc.hh +++ b/include/sta/DelayCalc.hh @@ -34,8 +34,7 @@ registerDelayCalc(const char *name, MakeArcDelayCalc maker); bool isDelayCalcName(const char *name); -// Caller owns return value. -StringSeq * +StringSeq delayCalcNames(); void deleteDelayCalcs(); diff --git a/include/sta/DisabledPorts.hh b/include/sta/DisabledPorts.hh index c7b2f907..b140d8ef 100644 --- a/include/sta/DisabledPorts.hh +++ b/include/sta/DisabledPorts.hh @@ -29,7 +29,7 @@ class DisabledInstancePorts; typedef Vector DisabledInstancePortsSeq; typedef Vector DisabledCellPortsSeq; -typedef Vector LibertyPortPairSeq; +typedef Vector LibertyPortPairSeq; typedef Set TimingArcSetSet; // Base class for disabled cell and instance ports. @@ -93,15 +93,12 @@ private: Instance *inst_; }; -void -sortDisabledCellPortsMap(DisabledCellPortsMap *cell_map, - DisabledCellPortsSeq &disables); -void -sortDisabledInstancePortsMap(DisabledInstancePortsMap *inst_map, - Network *network, - DisabledInstancePortsSeq &disables); -void -sortLibertyPortPairSet(LibertyPortPairSet *sets, - LibertyPortPairSeq &pairs); +DisabledCellPortsSeq +sortByName(DisabledCellPortsMap *cell_map); +DisabledInstancePortsSeq +sortByPathName(const DisabledInstancePortsMap *inst_map, + const Network *network); +LibertyPortPairSeq +sortByName(const LibertyPortPairSet *set); } // namespace diff --git a/include/sta/ExceptionPath.hh b/include/sta/ExceptionPath.hh index 53a99355..f327f8ec 100644 --- a/include/sta/ExceptionPath.hh +++ b/include/sta/ExceptionPath.hh @@ -314,22 +314,28 @@ public: virtual NetSet *nets() = 0; virtual EdgePinsSet *edges() = 0; size_t hash() const; - virtual int nameCmp(ExceptionPt *pt, const Network *network) const = 0; - virtual void mergeInto(ExceptionPt *pt) = 0; + virtual int compare(ExceptionPt *pt, + const Network *network) const = 0; + virtual void mergeInto(ExceptionPt *pt, + const Network *network) = 0; // All pins and instance/net pins. virtual void allPins(const Network *network, PinSet *pins) = 0; virtual int typePriority() const = 0; virtual const char *asString(const Network *network) const = 0; virtual size_t objectCount() const = 0; - virtual void addPin(Pin *pin) = 0; + virtual void addPin(const Pin *pin, + const Network *network) = 0; virtual void addClock(Clock *clk) = 0; - virtual void addInstance(Instance *inst) = 0; - virtual void addNet(Net *net) = 0; - virtual void addEdge(EdgePins *edge) = 0; + virtual void addInstance(const Instance *inst, + const Network *network) = 0; + virtual void addNet(const Net *net, + const Network *network) = 0; + virtual void addEdge(const EdgePins &edge, + const Network *network) = 0; virtual void connectPinAfter(PinSet *, Network *network) = 0; - virtual void disconnectPinBefore(Pin *pin, + virtual void disconnectPinBefore(const Pin *pin, Network *network) = 0; protected: @@ -351,10 +357,12 @@ protected: class ExceptionFromTo : public ExceptionPt { public: - ExceptionFromTo(PinSet *pins, ClockSet *clks, + ExceptionFromTo(PinSet *pins, + ClockSet *clks, InstanceSet *insts, const RiseFallBoth *rf, - bool own_pts); + bool own_pts, + const Network *network); ~ExceptionFromTo(); virtual PinSet *pins() { return pins_; } bool hasPins() const; @@ -365,31 +373,39 @@ public: virtual NetSet *nets() { return nullptr; } virtual EdgePinsSet *edges() { return nullptr; } bool hasObjects() const; - void deleteObjects(ExceptionFromTo *pt); + void deleteObjects(ExceptionFromTo *pt, + const Network *network); virtual void allPins(const Network *network, PinSet *pins); bool equal(ExceptionFromTo *from_to) const; - virtual int nameCmp(ExceptionPt *pt, + virtual int compare(ExceptionPt *pt, const Network *network) const; - virtual void mergeInto(ExceptionPt *pt); + virtual void mergeInto(ExceptionPt *pt, + const Network *network); virtual const char *asString(const Network *network) const; virtual size_t objectCount() const; void deleteClock(Clock *clk); - virtual void addPin(Pin *pin); + virtual void addPin(const Pin *pin, + const Network *network); virtual void addClock(Clock *clk); - virtual void addInstance(Instance *inst); - virtual void addNet(Net *) {} - virtual void addEdge(EdgePins *) {} + virtual void addInstance(const Instance *inst, + const Network *network); + virtual void addNet(const Net *, + const Network *) {} + virtual void addEdge(const EdgePins &, + const Network *) {} virtual void connectPinAfter(PinSet *, Network *) {} - virtual void disconnectPinBefore(Pin *, + virtual void disconnectPinBefore(const Pin *, Network *) {} protected: - virtual void findHash(); + virtual void findHash(const Network *network); - void deletePin(Pin *pin); - void deleteInstance(Instance *inst); + void deletePin(const Pin *pin, + const Network *network); + void deleteInstance(const Instance *inst, + const Network *network); virtual const char *cmdKeyword() const = 0; PinSet *pins_; @@ -404,15 +420,16 @@ public: ClockSet *clks, InstanceSet *insts, const RiseFallBoth *rf, - bool own_pts); - ExceptionFrom *clone(); + bool own_pts, + const Network *network); + ExceptionFrom *clone(const Network *network); virtual bool isFrom() const { return true; } bool intersectsPts(ExceptionFrom *from) const; virtual int typePriority() const { return 0; } protected: virtual const char *cmdKeyword() const; - virtual void findHash(); + virtual void findHash(const Network *network); }; class ExceptionTo : public ExceptionFromTo @@ -425,8 +442,9 @@ public: const RiseFallBoth *rf, // -rise|-fall endpoint transition. const RiseFallBoth *end_rf, - bool own_pts); - ExceptionTo *clone(); + bool own_pts, + const Network *network); + ExceptionTo *clone(const Network *network); virtual bool isTo() const { return true; } const char *asString(const Network *network) const; const RiseFallBoth *endTransition() { return end_rf_; } @@ -446,7 +464,8 @@ public: const ClockEdge *clk_edge, const RiseFall *end_rf, const Network *network) const; - virtual int nameCmp(ExceptionPt *pt, const Network *network) const; + virtual int compare(ExceptionPt *pt, + const Network *network) const; protected: bool matches(const Pin *pin, @@ -479,7 +498,8 @@ public: InstanceSet *instances() { return insts_; } virtual ClockSet *clks() { return nullptr; } bool hasObjects() const; - void deleteObjects(ExceptionThru *pt); + void deleteObjects(ExceptionThru *pt, + const Network *network); virtual void allPins(const Network *network, PinSet *pins); bool matches(const Pin *from_pin, @@ -487,41 +507,49 @@ public: const RiseFall *to_rf, const Network *network); bool equal(ExceptionThru *thru) const; - virtual int nameCmp(ExceptionPt *pt, + virtual int compare(ExceptionPt *pt, const Network *network) const; - virtual void mergeInto(ExceptionPt *pt); + virtual void mergeInto(ExceptionPt *pt, + const Network *network); bool intersectsPts(ExceptionThru *thru) const; virtual int typePriority() const { return 2; } virtual size_t objectCount() const; virtual void connectPinAfter(PinSet *drvrs, Network *network); - virtual void disconnectPinBefore(Pin *pin, + virtual void disconnectPinBefore(const Pin *pin, Network *network); protected: - void findHash(); - virtual void addPin(Pin *pin); - virtual void addEdge(EdgePins *edge); - virtual void addNet(Net *net); - virtual void addInstance(Instance *inst); + void findHash(const Network *network); + virtual void addPin(const Pin *pin, + const Network *network); + virtual void addEdge(const EdgePins &edge, + const Network *network); + virtual void addNet(const Net *net, + const Network *network); + virtual void addInstance(const Instance *inst, + const Network *network); virtual void addClock(Clock *) {} - void deletePin(Pin *pin); - void deleteEdge(EdgePins *edge); - void deleteNet(Net *net); - void deleteInstance(Instance *inst); + void deletePin(const Pin *pin, + const Network *network); + void deleteEdge(const EdgePins &edge); + void deleteNet(const Net *net, + const Network *network); + void deleteInstance(const Instance *inst, + const Network *network); void makeAllEdges(const Network *network); void makePinEdges(const Network *network); void makeNetEdges(const Network *network); void makeInstEdges(const Network *network); void makeHpinEdges(const Pin *pin, const Network *network); - void makePinEdges(Pin *pin, + void makePinEdges(const Pin *pin, const Network *network); - void makeNetEdges(Net *net, + void makeNetEdges(const Net *net, const Network *network); void makeInstEdges(Instance *inst, Network *network); - void deletePinEdges(Pin *pin, + void deletePinEdges(const Pin *pin, Network *network); void deleteNetEdges(Net *net, const Network *network); @@ -598,6 +626,7 @@ public: ExceptionThru *next_thru, int index); ExceptionPath *exception() { return exception_; } + const ExceptionPath *exception() const { return exception_; } bool matchesNextThru(const Pin *from_pin, const Pin *to_pin, const RiseFall *to_rf, @@ -607,6 +636,7 @@ public: ExceptionThru *nextThru() const { return next_thru_; } ExceptionState *nextState() const { return next_state_; } void setNextState(ExceptionState *next_state); + int index() const { return index_; } size_t hash() const; private: @@ -623,22 +653,21 @@ public: virtual const char *what() const noexcept; }; +class ExceptionPathLess +{ +public: + ExceptionPathLess(const Network *network); + bool operator()(const ExceptionPath *except1, + const ExceptionPath *except2) const; + +private: + const Network *network_; +}; + // Throws EmptyExpceptionPt it finds an empty exception point. void checkFromThrusTo(ExceptionFrom *from, ExceptionThruSeq *thrus, ExceptionTo *to); -void -sortExceptions(ExceptionPathSet *set, - ExceptionPathSeq &exceptions, - Network *network); - -bool -intersects(PinSet *set1, - PinSet *set2); -bool -intersects(ClockSet *set1, - ClockSet *set2); - } // namespace diff --git a/include/sta/Graph.hh b/include/sta/Graph.hh index 96db47f3..98dcf871 100644 --- a/include/sta/Graph.hh +++ b/include/sta/Graph.hh @@ -133,13 +133,13 @@ public: virtual Edge *makeEdge(Vertex *from, Vertex *to, TimingArcSet *arc_set); - virtual void makeWireEdge(Pin *from_pin, - Pin *to_pin); - void makePinInstanceEdges(Pin *pin); + virtual void makeWireEdge(const Pin *from_pin, + const Pin *to_pin); + void makePinInstanceEdges(const Pin *pin); void makeInstanceEdges(const Instance *inst); - void makeWireEdgesToPin(Pin *to_pin); - void makeWireEdgesThruPin(Pin *hpin); - virtual void makeWireEdgesFromPin(Pin *drvr_pin); + void makeWireEdgesToPin(const Pin *to_pin); + void makeWireEdgesThruPin(const Pin *hpin); + virtual void makeWireEdgesFromPin(const Pin *drvr_pin); virtual void deleteEdge(Edge *edge); virtual ArcDelay arcDelay(const Edge *edge, const TimingArc *arc, @@ -211,10 +211,10 @@ protected: bool is_reg_clk); virtual void makeEdgeArcDelays(Edge *edge); void makePinVertices(const Instance *inst); - void makeWireEdgesFromPin(Pin *drvr_pin, + void makeWireEdgesFromPin(const Pin *drvr_pin, PinSet &visited_drvrs); void makeWireEdges(); - virtual void makeInstDrvrWireEdges(Instance *inst, + virtual void makeInstDrvrWireEdges(const Instance *inst, PinSet &visited_drvrs); virtual void makePortInstanceEdges(const Instance *inst, LibertyCell *cell, diff --git a/include/sta/Hash.hh b/include/sta/Hash.hh index d668dbb1..5a4bb0e4 100644 --- a/include/sta/Hash.hh +++ b/include/sta/Hash.hh @@ -52,6 +52,8 @@ nextMersenne(size_t n) size_t hashString(const char *str); +// Pointer hashing is strongly discouraged because it causes results to change +// from run to run. Use Network::id functions instead. #if __WORDSIZE == 64 #define hashPtr(ptr) (reinterpret_cast(ptr) >> 3) #else diff --git a/include/sta/HpinDrvrLoad.hh b/include/sta/HpinDrvrLoad.hh index a5e4c9c0..356cad50 100644 --- a/include/sta/HpinDrvrLoad.hh +++ b/include/sta/HpinDrvrLoad.hh @@ -48,23 +48,23 @@ public: class HpinDrvrLoad { public: - HpinDrvrLoad(Pin *drvr, - Pin *load, + HpinDrvrLoad(const Pin *drvr, + const Pin *load, PinSet *hpins_from_drvr, PinSet *hpins_to_load); ~HpinDrvrLoad(); void report(const Network *network); - HpinDrvrLoad(Pin *drvr, - Pin *load); - Pin *drvr() const { return drvr_; } - Pin *load() const { return load_; } + HpinDrvrLoad(const Pin *drvr, + const Pin *load); + const Pin *drvr() const { return drvr_; } + const Pin *load() const { return load_; } PinSet *hpinsFromDrvr() { return hpins_from_drvr_; } PinSet *hpinsToLoad() { return hpins_to_load_; } - void setDrvr(Pin *drvr); + void setDrvr(const Pin *drvr); private: - Pin *drvr_; - Pin *load_; + const Pin *drvr_; + const Pin *load_; PinSet *hpins_from_drvr_; PinSet *hpins_to_load_; }; diff --git a/include/sta/InputDrive.hh b/include/sta/InputDrive.hh index 0f4d49f3..de5c0e1f 100644 --- a/include/sta/InputDrive.hh +++ b/include/sta/InputDrive.hh @@ -47,20 +47,20 @@ public: bool hasDriveResistance(const RiseFall *rf, const MinMax *min_max); bool driveResistanceMinMaxEqual(const RiseFall *rf); - void setDriveCell(LibertyLibrary *library, - LibertyCell *cell, - LibertyPort *from_port, + void setDriveCell(const LibertyLibrary *library, + const LibertyCell *cell, + const LibertyPort *from_port, float *from_slews, - LibertyPort *to_port, + const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max); void driveCell(const RiseFall *rf, const MinMax *min_max, // Return values. - LibertyCell *&cell, - LibertyPort *&from_port, + const LibertyCell *&cell, + const LibertyPort *&from_port, float *&from_slews, - LibertyPort *&to_port); + const LibertyPort *&to_port); InputDriveCell *driveCell(const RiseFall *rf, const MinMax *min_max); bool hasDriveCell(const RiseFall *rf, @@ -83,29 +83,29 @@ private: class InputDriveCell { public: - InputDriveCell(LibertyLibrary *library, - LibertyCell *cell, - LibertyPort *from_port, + InputDriveCell(const LibertyLibrary *library, + const LibertyCell *cell, + const LibertyPort *from_port, float *from_slews, - LibertyPort *to_port); - LibertyLibrary *library() const { return library_; } - void setLibrary(LibertyLibrary *library); - LibertyCell *cell() const { return cell_; } - void setCell(LibertyCell *cell); - LibertyPort *fromPort() const { return from_port_; } - void setFromPort(LibertyPort *from_port); + const LibertyPort *to_port); + const LibertyLibrary *library() const { return library_; } + void setLibrary(const LibertyLibrary *library); + const LibertyCell *cell() const { return cell_; } + void setCell(const LibertyCell *cell); + const LibertyPort *fromPort() const { return from_port_; } + void setFromPort(const LibertyPort *from_port); float *fromSlews() { return from_slews_; } void setFromSlews(float *from_slews); - LibertyPort *toPort() const { return to_port_; } - void setToPort(LibertyPort *to_port); - bool equal(InputDriveCell *drive) const; + const LibertyPort *toPort() const { return to_port_; } + void setToPort(const LibertyPort *to_port); + bool equal(const InputDriveCell *drive) const; private: - LibertyLibrary *library_; - LibertyCell *cell_; - LibertyPort *from_port_; + const LibertyLibrary *library_; + const LibertyCell *cell_; + const LibertyPort *from_port_; float from_slews_[RiseFall::index_count]; - LibertyPort *to_port_; + const LibertyPort *to_port_; }; } // namespace diff --git a/include/sta/Liberty.hh b/include/sta/Liberty.hh index 33cf9a38..850d84ee 100644 --- a/include/sta/Liberty.hh +++ b/include/sta/Liberty.hh @@ -132,8 +132,7 @@ public: const char *filename); virtual ~LibertyLibrary(); LibertyCell *findLibertyCell(const char *name) const; - void findLibertyCellsMatching(PatternMatch *pattern, - LibertyCellSeq *cells); + LibertyCellSeq findLibertyCellsMatching(PatternMatch *pattern); // Liberty cells that are buffers. LibertyCellSeq *buffers(); @@ -398,8 +397,7 @@ public: LibertyLibrary *libertyLibrary() const { return liberty_library_; } LibertyLibrary *libertyLibrary() { return liberty_library_; } LibertyPort *findLibertyPort(const char *name) const; - void findLibertyPortsMatching(PatternMatch *pattern, - LibertyPortSeq *ports) const; + LibertyPortSeq findLibertyPortsMatching(PatternMatch *pattern) const; bool hasInternalPorts() const { return has_internal_ports_; } LibertyPgPort *findPgPort(const char *name) const; size_t pgPortCount() const { return pg_port_map_.size(); } @@ -842,9 +840,8 @@ private: friend class LibertyReader; }; -void -sortLibertyPortSet(LibertyPortSet *set, - LibertyPortSeq &ports); +LibertyPortSeq +sortByName(const LibertyPortSet *set); class LibertyPortMemberIterator : public Iterator { diff --git a/include/sta/LibertyClass.hh b/include/sta/LibertyClass.hh index 0d6d2461..b5d8bc2f 100644 --- a/include/sta/LibertyClass.hh +++ b/include/sta/LibertyClass.hh @@ -151,8 +151,6 @@ public: class LibertyPortPairLess { public: - bool operator()(const LibertyPortPair *pair1, - const LibertyPortPair *pair2) const; bool operator()(const LibertyPortPair &pair1, const LibertyPortPair &pair2) const; }; diff --git a/include/sta/Map.hh b/include/sta/Map.hh index 368723da..718b4229 100644 --- a/include/sta/Map.hh +++ b/include/sta/Map.hh @@ -98,6 +98,17 @@ public: delete iter.next(); } + void + deleteKeysContents() + { + for (auto key_value : this) { + KEY key = key_value.first; + VALUE value = key_value.second; + delete key; + delete value; + } + } + void deleteArrayContents() { diff --git a/include/sta/Network.hh b/include/sta/Network.hh index ec399403..b05b432e 100644 --- a/include/sta/Network.hh +++ b/include/sta/Network.hh @@ -31,7 +31,6 @@ class Report; class PatternMatch; class PinVisitor; -typedef Set ConstNetSet; typedef Map LibertyLibraryMap; // Link network function returns top level instance. // Return nullptr if link fails. @@ -103,20 +102,19 @@ public: //////////////////////////////////////////////////////////////// // Library functions. + virtual const char *name(const Library *library) const = 0; + virtual ObjectId id(const Library *library) const = 0; virtual LibraryIterator *libraryIterator() const = 0; virtual LibertyLibraryIterator *libertyLibraryIterator() const = 0; virtual Library *findLibrary(const char *name) = 0; virtual LibertyLibrary *findLiberty(const char *name) = 0; // Find liberty library by filename. virtual LibertyLibrary *findLibertyFilename(const char *filename); - virtual const char *name(const Library *library) const = 0; virtual Cell *findCell(const Library *library, const char *name) const = 0; // Search the design (non-liberty) libraries for cells matching pattern. - virtual void findCellsMatching(const Library *library, - const PatternMatch *pattern, - // Return value. - CellSeq *cells) const = 0; + virtual CellSeq findCellsMatching(const Library *library, + const PatternMatch *pattern) const = 0; // Search liberty libraries for cell name. virtual LibertyCell *findLibertyCell(const char *name) const; virtual LibertyLibrary *makeLibertyLibrary(const char *name, @@ -136,6 +134,7 @@ public: //////////////////////////////////////////////////////////////// // Cell functions. virtual const char *name(const Cell *cell) const = 0; + virtual ObjectId id(const Cell *cell) const = 0; virtual Library *library(const Cell *cell) const = 0; virtual LibertyLibrary *libertyLibrary(const Cell *cell) const; // Find the corresponding liberty cell. @@ -148,10 +147,8 @@ public: // Name can be a simple, bundle, bus, or bus bit name. virtual Port *findPort(const Cell *cell, const char *name) const = 0; - virtual void findPortsMatching(const Cell *cell, - const PatternMatch *pattern, - // Return value. - PortSeq *ports) const = 0; + virtual PortSeq findPortsMatching(const Cell *cell, + const PatternMatch *pattern) const = 0; virtual bool isLeaf(const Cell *cell) const = 0; virtual CellPortIterator *portIterator(const Cell *cell) const = 0; // Iterate over port bits (expanded buses). @@ -162,6 +159,7 @@ public: //////////////////////////////////////////////////////////////// // Port functions virtual const char *name(const Port *port) const = 0; + virtual ObjectId id(const Port *port) const = 0; virtual Cell *cell(const Port *port) const = 0; virtual LibertyPort *libertyPort(const Port *port) const = 0; virtual PortDirection *direction(const Port *port) const = 0; @@ -193,6 +191,9 @@ public: //////////////////////////////////////////////////////////////// // Instance functions + // Name local to containing cell/instance. + virtual const char *name(const Instance *instance) const = 0; + virtual ObjectId id(const Instance *instance) const = 0; // Top level instance of the design (defined after link). virtual Instance *topInstance() const = 0; virtual bool isTopInstance(const Instance *inst) const; @@ -201,16 +202,10 @@ public: Instance *findInstanceRelative(const Instance *inst, const char *path_name) const; // Default implementation uses linear search. - virtual void findInstancesMatching(const Instance *context, - const PatternMatch *pattern, - // Return value. - InstanceSeq *insts) const; - virtual void findInstancesHierMatching(const Instance *instance, - const PatternMatch *pattern, - // Return value. - InstanceSeq *insts) const; - // Name local to containing cell/instance. - virtual const char *name(const Instance *instance) const = 0; + virtual InstanceSeq findInstancesMatching(const Instance *context, + const PatternMatch *pattern) const; + virtual InstanceSeq findInstancesHierMatching(const Instance *instance, + const PatternMatch *pattern) const; // Hierarchical path name. virtual const char *pathName(const Instance *instance) const; bool pathNameLess(const Instance *inst1, @@ -220,7 +215,7 @@ public: // Path from instance up to top level (last in the sequence). void path(const Instance *inst, // Return value. - ConstInstanceSeq &path) const; + InstanceSeq &path) const; virtual Cell *cell(const Instance *instance) const = 0; virtual const char *cellName(const Instance *instance) const; virtual LibertyLibrary *libertyLibrary(const Instance *instance) const; @@ -232,8 +227,8 @@ public: const char *name) const = 0; virtual void findChildrenMatching(const Instance *parent, const PatternMatch *pattern, - // Return value. - InstanceSeq *insts) const; + // Return value. + InstanceSeq &matches) const; // Is inst inside of hier_inst? bool isInside(const Instance *inst, const Instance *hier_inst) const; @@ -260,6 +255,9 @@ public: //////////////////////////////////////////////////////////////// // Pin functions + // Name is instance_name/port_name (the same as path name). + virtual const char *name(const Pin *pin) const; + virtual ObjectId id(const Pin *pin) const = 0; virtual Pin *findPin(const char *path_name) const; virtual Pin *findPin(const Instance *instance, const char *port_name) const = 0; @@ -271,18 +269,12 @@ public: Pin *findPinRelative(const Instance *inst, const char *path_name) const; // Default implementation uses linear search. - virtual void findPinsMatching(const Instance *instance, - const PatternMatch *pattern, - // Return value. - PinSeq *pins) const; + virtual PinSeq findPinsMatching(const Instance *instance, + const PatternMatch *pattern) const; // Traverse the hierarchy from instance down and find pins matching // pattern of the form instance_name/port_name. - virtual void findPinsHierMatching(const Instance *instance, - const PatternMatch *pattern, - // Return value. - PinSeq *pins) const; - // Name is instance_name/port_name (the same as path name). - virtual const char *name(const Pin *pin) const; + virtual PinSeq findPinsHierMatching(const Instance *instance, + const PatternMatch *pattern) const; virtual const char *portName(const Pin *pin) const; // Path name is instance_name/port_name. virtual const char *pathName(const Pin *pin) const; @@ -317,7 +309,7 @@ public: // and child nets it is hierarchically connected to (port, leaf and // hierarchical pins). virtual PinConnectedPinIterator *connectedPinIterator(const Pin *pin) const; - virtual void visitConnectedPins(Pin *pin, + virtual void visitConnectedPins(const Pin *pin, PinVisitor &visitor) const; // Find driver pins for the net connected to pin. @@ -344,6 +336,7 @@ public: // Terminal functions // Name is instance_name/port_name (the same as path name). virtual const char *name(const Term *term) const; + virtual ObjectId id(const Term *term) const = 0; virtual const char *portName(const Term *term) const; // Path name is instance_name/port_name (pin name). virtual const char *pathName(const Term *term) const; @@ -352,28 +345,25 @@ public: //////////////////////////////////////////////////////////////// // Net functions + virtual const char *name(const Net *net) const = 0; // no hierarchy prefix + virtual ObjectId id(const Net *net) const = 0; virtual Net *findNet(const char *path_name) const; // Find net relative to hierarchical instance. Net *findNetRelative(const Instance *inst, const char *path_name) const; // Default implementation uses linear search. - virtual void findNetsMatching(const Instance *context, - const PatternMatch *pattern, - // Return value. - NetSeq *nets) const; + virtual NetSeq findNetsMatching(const Instance *context, + const PatternMatch *pattern) const; virtual Net *findNet(const Instance *instance, const char *net_name) const = 0; // Traverse the hierarchy from instance down and find nets matching // pattern of the form instance_name/net_name. - virtual void findNetsHierMatching(const Instance *instance, - const PatternMatch *pattern, - // Return value. - NetSeq *nets) const; + virtual NetSeq findNetsHierMatching(const Instance *instance, + const PatternMatch *pattern) const; + // Primitive used by findNetsMatching. virtual void findInstNetsMatching(const Instance *instance, - const PatternMatch *pattern, - // Return value. - NetSeq *nets) const = 0; - virtual const char *name(const Net *net) const = 0; // no hierarchy prefix + const PatternMatch *pattern, + NetSeq &matches) const = 0; virtual const char *pathName(const Net *net) const; bool pathNameLess(const Net *net1, const Net *net2) const; @@ -390,7 +380,7 @@ public: virtual bool isConnected(const Net *net1, const Net *net2) const; virtual Net *highestNetAbove(Net *net) const; - virtual Net *highestConnectedNet(Net *net) const; + virtual const Net *highestConnectedNet(Net *net) const; virtual void connectedNets(Net *net, NetSet *nets) const; virtual void connectedNets(const Pin *pin, @@ -445,35 +435,45 @@ protected: void findInstancesMatching1(const Instance *context, size_t context_name_length, const PatternMatch *pattern, - // Return value. - InstanceSeq *insts) const; + InstanceSeq &insts) const; + void findInstancesHierMatching1(const Instance *instance, + const PatternMatch *pattern, + InstanceSeq &matches) const; + void findNetsMatching(const Instance *context, + const PatternMatch *pattern, + NetSeq &matches) const; + void findNetsHierMatching(const Instance *instance, + const PatternMatch *pattern, + NetSeq &matches) const; + void findPinsHierMatching(const Instance *instance, + const PatternMatch *pattern, + // Return value. + PinSeq &matches) const; bool isConnected(const Net *net, const Pin *pin, - ConstNetSet &nets) const; + NetSet &nets) const; bool isConnected(const Net *net1, const Net *net2, - ConstNetSet &nets) const; + NetSet &nets) const; int hierarchyLevel(const Net *net) const; virtual void visitConnectedPins(const Net *net, PinVisitor &visitor, - ConstNetSet &visited_nets) const; + NetSet &visited_nets) const; // Default implementation uses linear search. virtual void findInstPinsMatching(const Instance *instance, - const PatternMatch *pattern, - // Return value. - PinSeq *pins) const; + const PatternMatch *pattern, + // Return value. + PinSeq &matches) const; void findInstPinsHierMatching(const Instance *parent, - const PatternMatch *pattern, - // Return value. - PinSeq *pins) const; + const PatternMatch *pattern, + // Return value. + PinSeq &matches) const; // findNet using linear search. Net *findNetLinear(const Instance *instance, const char *net_name) const; // findNetsMatching using linear search. - void findNetsMatchingLinear(const Instance *instance, - const PatternMatch *pattern, - // Return value. - NetSeq *nets) const; + NetSeq findNetsMatchingLinear(const Instance *instance, + const PatternMatch *pattern) const; // Connect/disconnect net/pins should clear the net->drvrs map. // Incrementally maintaining the map is expensive because // nets may be connected across hierarchy levels. @@ -588,7 +588,7 @@ public: ConstantPinIterator() {} virtual ~ConstantPinIterator() {} virtual bool hasNext() = 0; - virtual void next(Pin *&pin, + virtual void next(const Pin *&pin, LogicValue &value) = 0; }; @@ -601,7 +601,7 @@ public: NetSet &one_nets); ~NetworkConstantPinIterator(); virtual bool hasNext(); - virtual void next(Pin *&pin, LogicValue &value); + virtual void next(const Pin *&pin, LogicValue &value); private: void findConstantPins(NetSet &nets, @@ -619,29 +619,29 @@ class HierPinThruVisitor public: HierPinThruVisitor() {} virtual ~HierPinThruVisitor() {} - virtual void visit(Pin *drvr, - Pin *load) = 0; + virtual void visit(const Pin *drvr, + const Pin *load) = 0; }; class PinVisitor { public: virtual ~PinVisitor() {} - virtual void operator()(Pin *pin) = 0; + virtual void operator()(const Pin *pin) = 0; }; class FindNetDrvrLoads : public PinVisitor { public: - FindNetDrvrLoads(Pin *drvr_pin, + FindNetDrvrLoads(const Pin *drvr_pin, PinSet &visited_drvrs, PinSeq &loads, PinSeq &drvrs, const Network *network); - virtual void operator()(Pin *pin); + virtual void operator()(const Pin *pin); protected: - Pin *drvr_pin_; + const Pin *drvr_pin_; PinSet &visited_drvrs_; PinSeq &loads_; PinSeq &drvrs_; @@ -654,7 +654,7 @@ visitDrvrLoadsThruHierPin(const Pin *hpin, const Network *network, HierPinThruVisitor *visitor); void -visitDrvrLoadsThruNet(Net *net, +visitDrvrLoadsThruNet(const Net *net, const Network *network, HierPinThruVisitor *visitor); diff --git a/include/sta/NetworkClass.hh b/include/sta/NetworkClass.hh index 4559f4db..5e70c23f 100644 --- a/include/sta/NetworkClass.hh +++ b/include/sta/NetworkClass.hh @@ -16,6 +16,7 @@ #pragma once +#include #include "Set.hh" #include "Vector.hh" #include "Iterator.hh" @@ -40,40 +41,130 @@ class LibertyLibrary; typedef Iterator LibraryIterator; typedef Iterator LibertyLibraryIterator; typedef Vector CellSeq; -typedef Set CellSet; -typedef Vector PortSeq; -typedef Set PortSet; +typedef Vector PortSeq; typedef Iterator CellPortIterator; typedef Iterator CellPortBitIterator; typedef Iterator PortMemberIterator; -typedef std::pair PortPair; -typedef Vector PinSeq; -typedef Vector ConstPinSeq; -typedef Vector InstanceSeq; -typedef Vector ConstInstanceSeq; -typedef Vector NetSeq; -typedef Set PinSet; -typedef Set InstanceSet; -typedef Set NetSet; +typedef Vector PinSeq; +typedef Vector InstanceSeq; +typedef Vector NetSeq; typedef Iterator InstanceChildIterator; typedef Iterator InstancePinIterator; typedef Iterator InstanceNetIterator; typedef Iterator LeafInstanceIterator; typedef Iterator NetIterator; -typedef Iterator NetPinIterator; +typedef Iterator NetPinIterator; typedef Iterator NetTermIterator; -typedef Iterator ConnectedPinIterator; +typedef Iterator ConnectedPinIterator; typedef ConnectedPinIterator NetConnectedPinIterator; typedef ConnectedPinIterator PinConnectedPinIterator; - -class PortPairLess -{ -public: - bool operator()(const PortPair *pair1, - const PortPair *pair2) const; -}; +typedef uint32_t ObjectId; enum class LogicValue : unsigned { zero, one, unknown, rise, fall }; +class CellIdLess +{ +public: + CellIdLess(const Network *network); + bool operator()(const Cell *cell1, + const Cell *cell2) const; +private: + const Network *network_; +}; + +class PortIdLess +{ +public: + PortIdLess(const Network *network); + bool operator()(const Port *port1, + const Port *port2) const; +private: + const Network *network_; +}; + +class InstanceIdLess +{ +public: + InstanceIdLess(const Network *network); + bool operator()(const Instance *inst1, + const Instance *inst2) const; +private: + const Network *network_; +}; + +class PinIdLess +{ +public: + PinIdLess(const Network *network); + bool operator()(const Pin *pin1, + const Pin *pin2) const; +private: + const Network *network_; +}; + +class PinIdHash +{ +public: + PinIdHash(const Network *network); + size_t operator()(const Pin *pin) const; + +private: + const Network *network_; +}; + +class NetIdLess +{ +public: + NetIdLess(const Network *network); + bool operator()(const Net *net1, + const Net *net2) const; +private: + const Network *network_; +}; + +//////////////////////////////////////////////////////////////// + +class CellSet : public Set +{ +public: + CellSet(const Network *network); +}; + +class PortSet : public Set +{ +public: + PortSet(const Network *network); +}; + +class InstanceSet : public Set +{ +public: + InstanceSet(); + InstanceSet(const Network *network); + static int compare(const InstanceSet *set1, + const InstanceSet *set2, + const Network *network); +}; + +class PinSet : public Set +{ +public: + PinSet(); + PinSet(const Network *network); + static int compare(const PinSet *set1, + const PinSet *set2, + const Network *network); +}; + +class NetSet : public Set +{ +public: + NetSet(); + NetSet(const Network *network); + static int compare(const NetSet *set1, + const NetSet *set2, + const Network *network); +}; + } // namespace diff --git a/include/sta/NetworkCmp.hh b/include/sta/NetworkCmp.hh index 5abc4453..35133241 100644 --- a/include/sta/NetworkCmp.hh +++ b/include/sta/NetworkCmp.hh @@ -21,7 +21,7 @@ namespace sta { -// Comparison operators for sorting network objects. +// Comparison operators for network objects. class PortNameLess { @@ -67,21 +67,17 @@ private: const Network *network_; }; -void -sortPinSet(PinSet *set, - const Network *network, - PinSeq &pins); -void -sortPortSet(PortSet *set, - const Network *network, - PortSeq &ports); -void -sortInstanceSet(InstanceSet *set, - const Network *network, - InstanceSeq &insts); -void -sortNetSet(NetSet *set, - const Network *network, - NetSeq &nets); +PinSeq +sortByPathName(const PinSet *set, + const Network *network); +PortSeq +sortByName(const PortSet *set, + const Network *network); +InstanceSeq +sortByPathName(InstanceSet *set, + const Network *network); +NetSeq +sortByPathName(NetSet *set, + const Network *network); } // namespace diff --git a/include/sta/NullParasitics.hh b/include/sta/NullParasitics.hh index 54048f6a..8f4837f6 100644 --- a/include/sta/NullParasitics.hh +++ b/include/sta/NullParasitics.hh @@ -47,23 +47,31 @@ public: virtual Parasitic *makePiElmore(const Pin *drvr_pin, const RiseFall *rf, const ParasiticAnalysisPt *ap, - float c2, float rpi, float c1); - virtual bool isPiElmore(Parasitic *parasitic) const; + float c2, + float rpi, + float c1); + virtual bool isPiElmore(const Parasitic *parasitic) const; virtual bool - isReducedParasiticNetwork(Parasitic *parasitic) const; + isReducedParasiticNetwork(const Parasitic *parasitic) const; virtual void setIsReducedParasiticNetwork(Parasitic *parasitic, bool is_reduced); - virtual void piModel(Parasitic *parasitic, float &c2, float &rpi, + virtual void piModel(const Parasitic *parasitic, + float &c2, + float &rpi, float &c1) const; - virtual void setPiModel(Parasitic *parasitic, float c2, float rpi, + virtual void setPiModel(Parasitic *parasitic, + float c2, + float rpi, float c1); - virtual void findElmore(Parasitic *parasitic, const Pin *load_pin, - float &elmore, bool &exists) const; + virtual void findElmore(const Parasitic *parasitic, + const Pin *load_pin, + float &elmore, + bool &exists) const; virtual void setElmore(Parasitic *parasitic, const Pin *load_pin, float elmore); - virtual bool isPiModel(Parasitic* parasitic) const; - virtual bool isPiPoleResidue(Parasitic* parasitic) const; + virtual bool isPiModel(const Parasitic* parasitic) const; + virtual bool isPiPoleResidue(const Parasitic* parasitic) const; virtual Parasitic * findPiPoleResidue(const Pin *drvr_pin, const RiseFall *rf, diff --git a/include/sta/Parasitics.hh b/include/sta/Parasitics.hh index 6dfafe76..cbe4d56c 100644 --- a/include/sta/Parasitics.hh +++ b/include/sta/Parasitics.hh @@ -64,7 +64,7 @@ public: const ParasiticAnalysisPt *ap) = 0; virtual void deleteDrvrReducedParasitics(const Pin *drvr_pin) = 0; - virtual bool isReducedParasiticNetwork(Parasitic *parasitic) const = 0; + virtual bool isReducedParasiticNetwork(const Parasitic *parasitic) const = 0; // Flag this parasitic as reduced from a parasitic network. virtual void setIsReducedParasiticNetwork(Parasitic *parasitic, bool is_reduced) = 0; @@ -76,7 +76,7 @@ public: // Pi model driver load with elmore delays to load pins (RSPF). // This follows the SPEF documentation of c2/c1, with c2 being the // capacitor on the driver pin. - virtual bool isPiElmore(Parasitic *parasitic) const = 0; + virtual bool isPiElmore(const Parasitic *parasitic) const = 0; virtual Parasitic *findPiElmore(const Pin *drvr_pin, const RiseFall *rf, const ParasiticAnalysisPt *ap) const = 0; @@ -89,8 +89,8 @@ public: //////////////////////////////////////////////////////////////// // Pi models are common to PiElmore and PiPoleResidue. - virtual bool isPiModel(Parasitic *parasitic) const = 0; - virtual void piModel(Parasitic *parasitic, + virtual bool isPiModel(const Parasitic *parasitic) const = 0; + virtual void piModel(const Parasitic *parasitic, float &c2, float &rpi, float &c1) const = 0; @@ -103,7 +103,7 @@ public: //////////////////////////////////////////////////////////////// // Elmore driver to load delay. // Common to LumpedElmore and PiElmore parasitics. - virtual void findElmore(Parasitic *parasitic, + virtual void findElmore(const Parasitic *parasitic, const Pin *load_pin, float &elmore, bool &exists) const = 0; @@ -114,7 +114,7 @@ public: //////////////////////////////////////////////////////////////// // Pi model driver load with pole/residue interconnect model to load pins. - virtual bool isPiPoleResidue(Parasitic* parasitic) const = 0; + virtual bool isPiPoleResidue(const Parasitic* parasitic) const = 0; virtual Parasitic *findPiPoleResidue(const Pin *drvr_pin, const RiseFall *rf, const ParasiticAnalysisPt *ap) const=0; @@ -310,7 +310,7 @@ protected: float fanout, const ParasiticAnalysisPt *ap); - Net *findParasiticNet(const Pin *pin) const; + const Net *findParasiticNet(const Pin *pin) const; }; // Managed by the Corner class. diff --git a/include/sta/Path.hh b/include/sta/Path.hh index ee438ff7..ed57684d 100644 --- a/include/sta/Path.hh +++ b/include/sta/Path.hh @@ -47,8 +47,8 @@ public: virtual Tag *tag(const StaState *sta) const = 0; virtual TagIndex tagIndex(const StaState *sta) const; virtual ClkInfo *clkInfo(const StaState *sta) const; - virtual ClockEdge *clkEdge(const StaState *sta) const; - virtual Clock *clock(const StaState *sta) const; + virtual const ClockEdge *clkEdge(const StaState *sta) const; + virtual const Clock *clock(const StaState *sta) const; virtual bool isClock(const StaState *sta) const; virtual const RiseFall *transition(const StaState *sta) const = 0; virtual int rfIndex(const StaState *sta) const; diff --git a/include/sta/PathEnd.hh b/include/sta/PathEnd.hh index 121df051..b6452ae3 100644 --- a/include/sta/PathEnd.hh +++ b/include/sta/PathEnd.hh @@ -104,7 +104,7 @@ public: virtual Slack slack(const StaState *sta) const = 0; virtual Slack slackNoCrpr(const StaState *sta) const = 0; virtual Arrival borrow(const StaState *sta) const; - ClockEdge *sourceClkEdge(const StaState *sta) const; + const ClockEdge *sourceClkEdge(const StaState *sta) const; // Time offset for the path start so the path begins in the correct // source cycle. virtual float sourceClkOffset(const StaState *sta) const = 0; @@ -112,8 +112,8 @@ public: virtual Delay sourceClkInsertionDelay(const StaState *sta) const; virtual PathVertex *targetClkPath(); virtual const PathVertex *targetClkPath() const; - virtual Clock *targetClk(const StaState *sta) const; - virtual ClockEdge *targetClkEdge(const StaState *sta) const; + virtual const Clock *targetClk(const StaState *sta) const; + virtual const ClockEdge *targetClkEdge(const StaState *sta) const; const RiseFall *targetClkEndTrans(const StaState *sta) const; // Target clock with cycle accounting and source clock offsets. virtual float targetClkTime(const StaState *sta) const; @@ -232,8 +232,8 @@ public: virtual float sourceClkOffset(const StaState *sta) const; virtual Delay sourceClkLatency(const StaState *sta) const; virtual Delay sourceClkInsertionDelay(const StaState *sta) const; - virtual Clock *targetClk(const StaState *sta) const; - virtual ClockEdge *targetClkEdge(const StaState *sta) const; + virtual const Clock *targetClk(const StaState *sta) const; + virtual const ClockEdge *targetClkEdge(const StaState *sta) const; virtual PathVertex *targetClkPath(); virtual const PathVertex *targetClkPath() const; virtual float targetClkTime(const StaState *sta) const; @@ -420,7 +420,7 @@ public: virtual bool isOutputDelay() const { return true; } virtual ArcDelay margin(const StaState *sta) const; virtual TimingRole *checkRole(const StaState *sta) const; - virtual ClockEdge *targetClkEdge(const StaState *sta) const; + virtual const ClockEdge *targetClkEdge(const StaState *sta) const; virtual Arrival targetClkArrivalNoCrpr(const StaState *sta) const; virtual Delay targetClkDelay(const StaState *sta) const; virtual Delay targetClkInsertionDelay(const StaState *sta) const; @@ -496,7 +496,7 @@ public: virtual void reportShort(ReportPath *report) const; virtual void reportFull(ReportPath *report) const; virtual bool isDataCheck() const { return true; } - virtual ClockEdge *targetClkEdge(const StaState *sta) const; + virtual const ClockEdge *targetClkEdge(const StaState *sta) const; virtual TimingRole *checkRole(const StaState *sta) const; virtual ArcDelay margin(const StaState *sta) const; virtual int exceptPathCmp(const PathEnd *path_end, @@ -553,7 +553,7 @@ public: virtual PathDelay *pathDelay() const { return path_delay_; } virtual ArcDelay margin(const StaState *sta) const; virtual float sourceClkOffset(const StaState *sta) const; - virtual ClockEdge *targetClkEdge(const StaState *sta) const; + virtual const ClockEdge *targetClkEdge(const StaState *sta) const; virtual float targetClkTime(const StaState *sta) const; virtual Arrival targetClkArrivalNoCrpr(const StaState *sta) const; virtual float targetClkOffset(const StaState *sta) const; diff --git a/include/sta/PinPair.hh b/include/sta/PinPair.hh index 68e5cf04..771e8486 100644 --- a/include/sta/PinPair.hh +++ b/include/sta/PinPair.hh @@ -22,28 +22,41 @@ namespace sta { -typedef std::pair PinPair; +typedef std::pair PinPair; class PinPairLess { public: - bool operator()(const PinPair *pair1, - const PinPair *pair2) const; + PinPairLess(const Network *network); + bool operator()(const PinPair &pair1, + const PinPair &pair2) const; + +private: + const Network *network_; }; -typedef Set PinPairSet; + +class PinPairSet : public Set +{ +public: + PinPairSet(const Network *network); +}; class PinPairHash { public: - size_t operator()(const PinPair *pair) const; + PinPairHash(const Network *network); + size_t operator()(const PinPair &pair) const; + +private: + const Network *network_; }; class PinPairEqual { public: - bool operator()(const PinPair *pair1, - const PinPair *pair2) const; + bool operator()(const PinPair &pair1, + const PinPair &pair2) const; }; } // namespace diff --git a/include/sta/PortDelay.hh b/include/sta/PortDelay.hh index 896be23b..bed28557 100644 --- a/include/sta/PortDelay.hh +++ b/include/sta/PortDelay.hh @@ -30,27 +30,28 @@ class PortDelay { public: RiseFallMinMax *delays() { return &delays_; } - Pin *pin() const { return pin_; } + const Pin *pin() const { return pin_; } PinSet &leafPins() { return leaf_pins_; } Clock *clock() const; - ClockEdge *clkEdge() const { return clk_edge_; } + const ClockEdge *clkEdge() const { return clk_edge_; } bool sourceLatencyIncluded() const; void setSourceLatencyIncluded(bool included); bool networkLatencyIncluded() const; void setNetworkLatencyIncluded(bool included); - Pin *refPin() const { return ref_pin_; } + const Pin *refPin() const { return ref_pin_; } + void setRefPin(const Pin *ref_pin); RiseFall *refTransition() const; protected: - PortDelay(Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin); + PortDelay(const Pin *pin, + const ClockEdge *clk_edge, + const Network *network); - Pin *pin_; - ClockEdge *clk_edge_; + const Pin *pin_; + const ClockEdge *clk_edge_; bool source_latency_included_; bool network_latency_included_; - Pin *ref_pin_; + const Pin *ref_pin_; RiseFallMinMax delays_; PinSet leaf_pins_; }; @@ -61,11 +62,10 @@ public: int index() const { return index_; } protected: - InputDelay(Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin, + InputDelay(const Pin *pin, + const ClockEdge *clk_edge, int index, - Network *network); + const Network *network); private: int index_; @@ -78,10 +78,9 @@ class OutputDelay : public PortDelay public: protected: - OutputDelay(Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin, - Network *network); + OutputDelay(const Pin *pin, + const ClockEdge *clk_edge, + const Network *network); private: friend class Sdc; diff --git a/include/sta/PortExtCap.hh b/include/sta/PortExtCap.hh index 3a520f26..c8aff232 100644 --- a/include/sta/PortExtCap.hh +++ b/include/sta/PortExtCap.hh @@ -30,12 +30,13 @@ typedef MinMaxIntValues FanoutValues; class PortExtCap { public: - explicit PortExtCap(Port *port); - Port *port() { return port_; } + PortExtCap(const Port *port); + const Port *port() { return port_; } void pinCap(const RiseFall *rf, const MinMax *min_max, // Return values. - float &cap, bool &exists); + float &cap, + bool &exists); RiseFallMinMax *pinCap() { return &pin_cap_; } void setPinCap(float cap, const RiseFall *rf, @@ -43,7 +44,8 @@ public: void wireCap(const RiseFall *rf, const MinMax *min_max, // Return values. - float &cap, bool &exists); + float &cap, + bool &exists); RiseFallMinMax *wireCap() { return &wire_cap_; } void setWireCap(float cap, const RiseFall *rf, @@ -57,7 +59,7 @@ public: FanoutValues *fanout() { return &fanout_; } private: - Port *port_; + const Port *port_; RiseFallMinMax pin_cap_; RiseFallMinMax wire_cap_; FanoutValues fanout_; diff --git a/include/sta/Property.hh b/include/sta/Property.hh index 242e6cc7..7ddb1af4 100644 --- a/include/sta/Property.hh +++ b/include/sta/Property.hh @@ -54,18 +54,19 @@ public: PropertyValue(float value, const Unit *unit); explicit PropertyValue(bool value); - PropertyValue(Library *value); - PropertyValue(Cell *value); - PropertyValue(Port *value); - PropertyValue(LibertyLibrary *value); - PropertyValue(LibertyCell *value); - PropertyValue(LibertyPort *value); - PropertyValue(Instance *value); - PropertyValue(Pin *value); + PropertyValue(const Library *value); + PropertyValue(const Cell *value); + PropertyValue(const Port *value); + PropertyValue(const LibertyLibrary *value); + PropertyValue(const LibertyCell *value); + PropertyValue(const LibertyPort *value); + PropertyValue(const Instance *value); + PropertyValue(const Pin *value); PropertyValue(PinSeq *value); PropertyValue(PinSet *value); - PropertyValue(Net *value); - PropertyValue(Clock *value); + PropertyValue(const PinSet &value); + PropertyValue(const Net *value); + PropertyValue(const Clock *value); PropertyValue(ClockSeq *value); PropertyValue(ClockSet *value); PropertyValue(PathRefSeq *value); @@ -81,17 +82,17 @@ public: const char *stringValue() const { return string_; } float floatValue() const { return float_; } bool boolValue() const { return bool_; } - LibertyLibrary *libertyLibrary() const { return liberty_library_; } - LibertyCell *libertyCell() const { return liberty_cell_; } - LibertyPort *libertyPort() const { return liberty_port_; } - Library *library() const { return library_; } - Cell *cell() const { return cell_; } - Port *port() const { return port_; } - Instance *instance() const { return inst_; } - Pin *pin() const { return pin_; } + const LibertyLibrary *libertyLibrary() const { return liberty_library_; } + const LibertyCell *libertyCell() const { return liberty_cell_; } + const LibertyPort *libertyPort() const { return liberty_port_; } + const Library *library() const { return library_; } + const Cell *cell() const { return cell_; } + const Port *port() const { return port_; } + const Instance *instance() const { return inst_; } + const Pin *pin() const { return pin_; } PinSeq *pins() const { return pins_; } - Net *net() const { return net_; } - Clock *clock() const { return clk_; } + const Net *net() const { return net_; } + const Clock *clock() const { return clk_; } ClockSeq *clocks() const { return clks_; } PathRefSeq *pathRefs() const { return path_refs_; } PwrActivity pwrActivity() const { return pwr_activity_; } @@ -107,17 +108,17 @@ private: const char *string_; float float_; bool bool_; - Library *library_; - Cell *cell_; - Port *port_; - LibertyLibrary *liberty_library_; - LibertyCell *liberty_cell_; - LibertyPort *liberty_port_; - Instance *inst_; - Pin *pin_; + const Library *library_; + const Cell *cell_; + const Port *port_; + const LibertyLibrary *liberty_library_; + const LibertyCell *liberty_cell_; + const LibertyPort *liberty_port_; + const Instance *inst_; + const Pin *pin_; PinSeq *pins_; - Net *net_; - Clock *clk_; + const Net *net_; + const Clock *clk_; ClockSeq *clks_; PathRefSeq *path_refs_; PwrActivity pwr_activity_; diff --git a/include/sta/Sdc.hh b/include/sta/Sdc.hh index b00e3bad..86ecef5e 100644 --- a/include/sta/Sdc.hh +++ b/include/sta/Sdc.hh @@ -32,6 +32,7 @@ #include "Clock.hh" #include "DataCheck.hh" #include "CycleAccting.hh" +#include "ExceptionPath.hh" namespace sta { @@ -50,24 +51,33 @@ class FindNetCaps; class ClkHpinDisable; class FindClkHpinDisables; class Corner; -class GroupPathIterator; class ClockPinIterator; class ClockIterator; +using std::vector; + typedef std::pair PinClockPair; -class ClockInsertionPinClkLess +class ClockInsertionkLess { public: + ClockInsertionkLess(const Network *network); bool operator()(const ClockInsertion *insert1, const ClockInsertion *insert2) const; + +private: + const Network *network_; }; -class ClockLatencyPinClkLess +class ClockLatencyLess { public: + ClockLatencyLess(const Network *network); bool operator()(const ClockLatency *latency1, const ClockLatency *latency2) const; + +private: + const Network *network_; }; // This is symmetric with respect to the clocks @@ -94,53 +104,55 @@ protected: class ClkHpinDisableLess { public: + ClkHpinDisableLess(const Network *network); bool operator()(const ClkHpinDisable *disable1, const ClkHpinDisable *disable2) const; + +private: + const Network *network_; }; typedef Map ClockNameMap; -typedef UnorderedMap ClockPinMap; +typedef UnorderedMap ClockPinMap; typedef Set InputDelaySet; -typedef Map InputDelaysPinMap; +typedef Map InputDelaysPinMap; typedef Set OutputDelaySet; -typedef Map OutputDelaysPinMap; -typedef Set InstanceSet; +typedef Map OutputDelaysPinMap; typedef UnorderedMap PinExceptionsMap; typedef Map ClockExceptionsMap; typedef Map InstanceExceptionsMap; typedef Map NetExceptionsMap; -typedef UnorderedMap EdgeExceptionsMap; typedef Vector ExceptionThruSeq; typedef Map InputDriveMap; typedef Map > ExceptionPathPtHash; -typedef Set ClockLatencies; +typedef Set ClockLatencies; typedef Map PinClockUncertaintyMap; -typedef Set InterClockUncertaintySet; +typedef Set InterClockUncertaintySet; typedef Map ClockGatingCheckMap; typedef Map InstanceClockGatingCheckMap; typedef Map PinClockGatingCheckMap; -typedef Set ClockInsertions; +typedef Set ClockInsertions; typedef Map PinLatchBorrowLimitMap; typedef Map InstLatchBorrowLimitMap; typedef Map ClockLatchBorrowLimitMap; typedef Set DataCheckSet; typedef Map DataChecksMap; -typedef Map PortExtCapMap; -typedef Map NetResistanceMap; -typedef Map PortSlewLimitMap; +typedef Map NetResistanceMap; +typedef Map PortSlewLimitMap; typedef Map PinSlewLimitMap; -typedef Map CellSlewLimitMap; -typedef Map CellCapLimitMap; -typedef Map PortCapLimitMap; -typedef Map PinCapLimitMap; -typedef Map PortFanoutLimitMap; -typedef Map CellFanoutLimitMap; -typedef Map NetWireCapMap; -typedef Map PinWireCapMap; -typedef Map InstancePvtMap; -typedef Map EdgeClockLatencyMap; +typedef Map CellSlewLimitMap; +typedef Map CellCapLimitMap; +typedef Map PortCapLimitMap; +typedef Map PinCapLimitMap; +typedef Map PortFanoutLimitMap; +typedef Map CellFanoutLimitMap; +typedef Map PortExtCapMap; +typedef Map NetWireCapMap; +typedef Map PinWireCapMap; +typedef Map InstancePvtMap; +typedef Map EdgeClockLatencyMap; typedef Map PinMinPulseWidthMap; typedef Map ClockMinPulseWidthMap; typedef Map InstMinPulseWidthMap; @@ -152,16 +164,16 @@ typedef Map ClockGroupsClkMap; typedef Map ClockGroupsNameMap; typedef Map ClockSenseMap; typedef Set ClkHpinDisables; -typedef Set GroupPathSet; +typedef Set GroupPathSet; typedef Map GroupPathMap; typedef Set ClockPairSet; void -findLeafLoadPins(Pin *pin, +findLeafLoadPins(const Pin *pin, const Network *network, PinSet *leaf_pins); void -findLeafDriverPins(Pin *pin, +findLeafDriverPins(const Pin *pin, const Network *network, PinSet *leaf_pins); @@ -172,6 +184,7 @@ public: ~Sdc(); // Note that Search may reference a Filter exception removed by clear(). void clear(); + void makeCornersAfter(Corners *corners); // Return true if pin is referenced by any constraint. bool isConstrained(const Pin *pin) const; // Return true if inst is referenced by any constraint. @@ -182,7 +195,7 @@ public: bool isConstrained(const Net *net) const; // Build data structures for search. void searchPreamble(); - void deleteNetBefore(Net *net); + void deleteNetBefore(const Net *net); // SWIG sdc interface. AnalysisType analysisType() { return analysis_type_; } @@ -227,34 +240,36 @@ public: static void moveDeratingFactors(Sdc *from, Sdc *to); - void setInputSlew(Port *port, const RiseFallBoth *rf, - const MinMaxAll *min_max, float slew); + void setInputSlew(const Port *port, + const RiseFallBoth *rf, + const MinMaxAll *min_max, + float slew); // Set the rise/fall drive resistance on design port. - void setDriveResistance(Port *port, + void setDriveResistance(const Port *port, const RiseFallBoth *rf, const MinMaxAll *min_max, float res); // Set the drive on design port using external cell timing arcs of // cell driven by from_slews between from_port and to_port. - void setDriveCell(LibertyLibrary *library, - LibertyCell *cell, - Port *port, - LibertyPort *from_port, + void setDriveCell(const LibertyLibrary *library, + const LibertyCell *cell, + const Port *port, + const LibertyPort *from_port, float *from_slews, - LibertyPort *to_port, + const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max); - void setLatchBorrowLimit(Pin *pin, + void setLatchBorrowLimit(const Pin *pin, float limit); - void setLatchBorrowLimit(Instance *inst, + void setLatchBorrowLimit(const Instance *inst, float limit); - void setLatchBorrowLimit(Clock *clk, + void setLatchBorrowLimit(const Clock *clk, float limit); // Return the latch borrow limit respecting precidence if multiple // limits apply. - void latchBorrowLimit(Pin *data_pin, - Pin *enable_pin, - Clock *clk, + void latchBorrowLimit(const Pin *data_pin, + const Pin *enable_pin, + const Clock *clk, // Return values. float &limit, bool &exists); @@ -442,7 +457,7 @@ public: // Return values. float &insertion, bool &exists) const; - ClockInsertions *clockInsertions() { return clk_insertions_; } + const ClockInsertions &clockInsertions() const { return clk_insertions_; } // Clock uncertainty. virtual void setClockUncertainty(Pin *pin, const SetupHoldAll *setup_hold, @@ -520,44 +535,47 @@ public: const SetupHoldAll *setup_hold); DataCheckSet *dataChecksFrom(const Pin *from) const; DataCheckSet *dataChecksTo(const Pin *to) const; - void setInputDelay(Pin *pin, + void setInputDelay(const Pin *pin, const RiseFallBoth *rf, - Clock *clk, + const Clock *clk, const RiseFall *clk_rf, - Pin *ref_pin, + const Pin *ref_pin, bool source_latency_included, bool network_latency_included, const MinMaxAll *min_max, - bool add, float delay); - void removeInputDelay(Pin *pin, + bool add, + float delay); + void removeInputDelay(const Pin *pin, const RiseFallBoth *rf, - Clock *clk, - RiseFall *clk_rf, - MinMaxAll *min_max); - void setOutputDelay(Pin *pin, + const Clock *clk, + const RiseFall *clk_rf, + const MinMaxAll *min_max); + void setOutputDelay(const Pin *pin, const RiseFallBoth *rf, - Clock *clk, + const Clock *clk, const RiseFall *clk_tr, - Pin *ref_pin, + const Pin *ref_pin, bool source_latency_included, bool network_latency_included, const MinMaxAll *min_max, - bool add, float delay); - void removeOutputDelay(Pin *pin, - RiseFallBoth *rf, - Clock *clk, - RiseFall *clk_rf, - MinMaxAll *min_max); + bool add, + float delay); + void removeOutputDelay(const Pin *pin, + const RiseFallBoth *rf, + const Clock *clk, + const RiseFall *clk_rf, + const MinMaxAll *min_max); static void movePortDelays(Sdc *from, Sdc *to); // Set port external pin load (set_load -pin_load port). - void setPortExtPinCap(Port *port, + void setPortExtPinCap(const Port *port, const RiseFall *rf, + const Corner *corner, const MinMax *min_max, float cap); // Set port external wire load (set_load -wire port). - void setPortExtWireCap(Port *port, + void setPortExtWireCap(const Port *port, bool subtract_pin_cap, const RiseFall *rf, const Corner *corner, @@ -565,18 +583,15 @@ public: float cap); static void movePortExtCaps(Sdc *from, Sdc *to); - // Remove all "set_load" and "set_fanout_load" annotations. - void removeLoadCaps(); - // Remove all "set_load net" annotations. - void removeNetLoadCaps(); - void setNetWireCap(Net *net, + void setNetWireCap(const Net *net, bool subtract_pin_cap, const Corner *corner, const MinMax *min_max, float cap); - bool hasNetWireCap(Net *net) const; + bool hasNetWireCap(const Net *net) const; // True if driver pin net has wire capacitance. - bool drvrPinHasWireCap(const Pin *pin); + bool drvrPinHasWireCap(const Pin *pin, + const Corner *corner); // Net wire capacitance (set_load -wire net). void drvrPinWireCap(const Pin *drvr_pin, const Corner *corner, @@ -590,15 +605,16 @@ public: const OperatingConditions *op_cond, const Corner *corner, const MinMax *min_max); - void setResistance(Net *net, + void setResistance(const Net *net, const MinMaxAll *min_max, float res); - void resistance(Net *net, + void resistance(const Net *net, const MinMax *min_max, float &res, bool &exists); - NetResistanceMap *netResistances() { return &net_res_map_; } - void setPortExtFanout(Port *port, + NetResistanceMap &netResistances() { return net_res_map_; } + void setPortExtFanout(const Port *port, + const Corner *corner, const MinMax *min_max, int fanout); // set_disable_timing cell [-from] [-to] @@ -628,7 +644,7 @@ public: LibertyPort *from, LibertyPort *to); // set_disable_timing pin - void disable(Pin *pin); + void disable(const Pin *pin); void removeDisable(Pin *pin); // set_disable_timing [get_timing_arc -of_objects instance]] void disable(Edge *edge); @@ -652,11 +668,11 @@ public: bool isDisabled(Edge *edge); bool isDisabled(TimingArcSet *arc_set) const; DisabledCellPortsMap *disabledCellPorts(); - DisabledInstancePortsMap *disabledInstancePorts(); - PinSet *disabledPins() { return &disabled_pins_; } - PortSet *disabledPorts() { return &disabled_ports_; } - LibertyPortSet *disabledLibPorts() { return &disabled_lib_ports_; } - EdgeSet *disabledEdges() { return &disabled_edges_; } + const DisabledInstancePortsMap *disabledInstancePorts() const; + const PinSet *disabledPins() const { return &disabled_pins_; } + const PortSet *disabledPorts() const { return &disabled_ports_; } + const LibertyPortSet *disabledLibPorts() const { return &disabled_lib_ports_; } + const EdgeSet *disabledEdges() const { return &disabled_edges_; } void disableClockGatingCheck(Instance *inst); void disableClockGatingCheck(Pin *pin); void removeDisableClockGatingCheck(Instance *inst); @@ -664,16 +680,18 @@ public: bool isDisableClockGatingCheck(const Pin *pin); bool isDisableClockGatingCheck(const Instance *inst); // set_LogicValue::zero, set_LogicValue::one, set_logic_dc - void setLogicValue(Pin *pin, + void setLogicValue(const Pin *pin, LogicValue value); // set_case_analysis - void setCaseAnalysis(Pin *pin, + void setCaseAnalysis(const Pin *pin, LogicValue value); - void removeCaseAnalysis(Pin *pin); + void removeCaseAnalysis(const Pin *pin); void logicValue(const Pin *pin, LogicValue &value, bool &exists); - void caseLogicValue(const Pin *pin, LogicValue &value, bool &exists); + void caseLogicValue(const Pin *pin, + LogicValue &value, + bool &exists); // Pin has set_case_analysis or set_logic constant value. bool hasLogicValue(const Pin *pin); // The from/thrus/to arguments passed into the following functions @@ -716,8 +734,8 @@ public: ExceptionThruSeq *thrus, ExceptionTo *to, const char *comment); - GroupPathIterator *groupPathIterator(); bool isGroupPathName(const char *group_name); + GroupPathMap &groupPaths() { return group_path_map_; } void addException(ExceptionPath *exception); // The pin/clk/instance/net set arguments passed into the following // functions that make exception from/thru/to's are owned by the @@ -741,9 +759,6 @@ public: FilterPath *makeFilterPath(ExceptionFrom *from, ExceptionThruSeq *thrus, ExceptionTo *to); - Clock *findClock(const char *name) const; - virtual void findClocksMatching(PatternMatch *pattern, - ClockSeq *clks) const; Wireload *wireload(const MinMax *min_max); void setWireload(Wireload *wireload, const MinMaxAll *min_max); @@ -803,17 +818,19 @@ public: // STA interface. InputDelaySet *refPinInputDelays(const Pin *ref_pin) const; - LogicValueMap *logicValues() { return &logic_value_map_; } - LogicValueMap *caseLogicValues() { return &case_value_map_; } + LogicValueMap &logicValues() { return logic_value_map_; } + LogicValueMap &caseLogicValues() { return case_value_map_; } // Returns nullptr if set_operating_conditions has not been called. OperatingConditions *operatingConditions(const MinMax *min_max); // Instance specific process/voltage/temperature. - Pvt *pvt(Instance *inst, const MinMax *min_max) const; + const Pvt *pvt(Instance *inst, const MinMax *min_max) const; // Pvt may be shared among multiple instances. - void setPvt(Instance *inst, + void setPvt(const Instance *inst, const MinMaxAll *min_max, - Pvt *pvt); + const Pvt &pvt); InputDrive *findInputDrive(Port *port); + Clock *findClock(const char *name) const; + virtual ClockSeq findClocksMatching(PatternMatch *pattern) const; // True if pin is defined as a clock source (pin may be hierarchical). bool isClock(const Pin *pin) const; // True if pin is a clock source vertex. @@ -882,15 +899,17 @@ public: const OutputDelaySet &outputDelays() const { return output_delays_; } // Pin -> output delays. - const OutputDelaysPinMap &outputDelayPinMap() const { return output_delay_pin_map_; } + const OutputDelaysPinMap &outputDelaysPinMap() const { return output_delay_pin_map_; } // Output delays on leaf_pin. OutputDelaySet *outputDelaysLeafPin(const Pin *leaf_pin); bool hasOutputDelay(const Pin *leaf_pin) const; - PortExtCap *portExtCap(Port *port) const; - bool hasPortExtCap(Port *port) const; - void portExtCap(Port *port, + PortExtCap *portExtCap(const Port *port, + const Corner *corner) const; + bool hasPortExtCap(const Port *port) const; + void portExtCap(const Port *port, const RiseFall *rf, + const Corner *corner, const MinMax *min_max, // Return values. float &pin_cap, @@ -899,8 +918,9 @@ public: bool &has_wire_cap, int &fanout, bool &has_fanout) const; - float portExtCap(Port *port, + float portExtCap(const Port *port, const RiseFall *rf, + const Corner *corner, const MinMax *min_max) const; // Connected total capacitance. // pin_cap = pin capacitance + port external pin @@ -914,12 +934,14 @@ public: float &wire_cap, float &fanout, bool &has_set_load) const; - void portExtFanout(Port *port, + void portExtFanout(const Port *port, + const Corner *corner, const MinMax *min_max, // Return values. int &fanout, bool &exists); int portExtFanout(Port *port, + const Corner *corner, const MinMax *min_max); // Return true if search should proceed from pin/clk (no false paths // start at pin/clk). When thru is true, consider -thru exceptions @@ -984,7 +1006,7 @@ public: const RiseFall *rf, const MinMax *min_max) const; bool isPathDelayInternalStartpoint(const Pin *pin) const; - PinSet *pathDelayInternalStartpoints() const; + const PinSet &pathDelayInternalStartpoints() const; bool isPathDelayInternalEndpoint(const Pin *pin) const; ExceptionPathSet *exceptions() { return &exceptions_; } void deleteExceptions(); @@ -995,12 +1017,12 @@ public: void removeGraphAnnotations(); // Network edit before/after methods. - void disconnectPinBefore(Pin *pin); - void connectPinAfter(Pin *pin); - void clkHpinDisablesChanged(Pin *pin); - void makeClkHpinDisable(Clock *clk, - Pin *drvr, - Pin *load); + void disconnectPinBefore(const Pin *pin); + void connectPinAfter(const Pin *pin); + void clkHpinDisablesChanged(const Pin *pin); + void makeClkHpinDisable(const Clock *clk, + const Pin *drvr, + const Pin *load); void ensureClkHpinDisables(); bool bidirectDrvrSlewFromLoad(const Pin *pin) const; @@ -1008,11 +1030,6 @@ protected: void initVariables(); void clearCycleAcctings(); void removeLibertyAnnotations(); - void deleteExceptionMap(PinExceptionsMap *&exception_map); - void deleteExceptionMap(InstanceExceptionsMap *&exception_map); - void deleteExceptionMap(NetExceptionsMap *&exception_map); - void deleteExceptionMap(ClockExceptionsMap *&exception_map); - void deleteExceptionMap(EdgeExceptionsMap *&exception_map); void deleteExceptionsReferencing(Clock *clk); void deleteClkPinMappings(Clock *clk); void deleteExceptionPtHashMapSets(ExceptionPathPtHash &map); @@ -1020,8 +1037,9 @@ protected: virtual void deletePinClocks(Clock *defining_clk, PinSet *pins); void makeDefaultArrivalClock(); - InputDrive *ensureInputDrive(Port *port); - PortExtCap *ensurePortExtPinCap(Port *port); + InputDrive *ensureInputDrive(const Port *port); + PortExtCap *ensurePortExtPinCap(const Port *port, + const Corner *corner); ExceptionPath *findMergeMatch(ExceptionPath *exception); void addException1(ExceptionPath *exception); void addException2(ExceptionPath *exception); @@ -1044,15 +1062,15 @@ protected: ExceptionPathSet &matches); void findMatchingExceptionsClks(ExceptionPath *exception, ClockSet *clks, - ClockExceptionsMap *exception_map, + ClockExceptionsMap &exception_map, ExceptionPathSet &matches); void findMatchingExceptionsPins(ExceptionPath *exception, PinSet *pins, - PinExceptionsMap *exception_map, + PinExceptionsMap &exception_map, ExceptionPathSet &matches); void findMatchingExceptionsInsts(ExceptionPath *exception, InstanceSet *insts, - InstanceExceptionsMap *exception_map, + InstanceExceptionsMap &exception_map, ExceptionPathSet &matches); void findMatchingExceptions(ExceptionPath *exception, ExceptionPathSet *potential_matches, @@ -1067,43 +1085,43 @@ protected: void recordExceptionFirstTo(ExceptionPath *exception); void recordExceptionClks(ExceptionPath *exception, ClockSet *clks, - ClockExceptionsMap *&exception_map); + ClockExceptionsMap &exception_map); void recordExceptionInsts(ExceptionPath *exception, InstanceSet *insts, - InstanceExceptionsMap *&exception_map); + InstanceExceptionsMap &exception_map); void recordExceptionPins(ExceptionPath *exception, PinSet *pins, - PinExceptionsMap *&exception_map); + PinExceptionsMap &exception_map); void recordExceptionNets(ExceptionPath *exception, NetSet *nets, - NetExceptionsMap *&exception_map); + NetExceptionsMap &exception_map); void recordExceptionHpin(ExceptionPath *exception, Pin *pin, - PinExceptionsMap *&exception_map); + PinExceptionsMap &exception_map); void recordExceptionEdges(ExceptionPath *exception, EdgePinsSet *edges, - EdgeExceptionsMap *&exception_map); + EdgeExceptionsMap &exception_map); void recordMergeHash(ExceptionPath *exception, ExceptionPt *missing_pt); void recordMergeHashes(ExceptionPath *exception); void unrecordExceptionFirstPts(ExceptionPath *exception); void unrecordExceptionClks(ExceptionPath *exception, ClockSet *clks, - ClockExceptionsMap *exception_map); + ClockExceptionsMap &exception_map); void unrecordExceptionPins(ExceptionPath *exception, PinSet *pins, - PinExceptionsMap *exception_map); + PinExceptionsMap &exception_map); void unrecordExceptionInsts(ExceptionPath *exception, InstanceSet *insts, - InstanceExceptionsMap *exception_map); + InstanceExceptionsMap &exception_map); void unrecordExceptionEdges(ExceptionPath *exception, EdgePinsSet *edges, - EdgeExceptionsMap *exception_map); + EdgeExceptionsMap &exception_map); void unrecordExceptionNets(ExceptionPath *exception, NetSet *nets, - NetExceptionsMap *exception_map); + NetExceptionsMap &exception_map); void unrecordExceptionHpin(ExceptionPath *exception, Pin *pin, - PinExceptionsMap *&exception_map); + PinExceptionsMap &exception_map); void unrecordMergeHashes(ExceptionPath *exception); void unrecordMergeHash(ExceptionPath *exception, ExceptionPt *missing_pt); @@ -1142,33 +1160,29 @@ protected: ExceptionPath *&hi_priority_exception, int &hi_priority) const; void makeLoopPath(ExceptionThruSeq *thrus); - void makeLoopException(Pin *loop_input_pin, - Pin *loop_pin, - Pin *loop_prev_pin); - void makeLoopExceptionThru(Pin *pin, + void makeLoopException(const Pin *loop_input_pin, + const Pin *loop_pin, + const Pin *loop_prev_pin); + void makeLoopExceptionThru(const Pin *pin, ExceptionThruSeq *thrus); void deleteLoopExceptions(); void deleteConstraints(); InputDelay *findInputDelay(const Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin); - InputDelay *makeInputDelay(Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin); - void deleteInputDelays(Pin *pin, + const ClockEdge *clk_edge); + InputDelay *makeInputDelay(const Pin *pin, + const ClockEdge *clk_edge); + void deleteInputDelays(const Pin *pin, InputDelay *except); - void deleteInputDelaysReferencing(Clock *clk); + void deleteInputDelaysReferencing(const Clock *clk); void deleteInputDelay(InputDelay *input_delay); OutputDelay *findOutputDelay(const Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin); - OutputDelay *makeOutputDelay(Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin); - void deleteOutputDelays(Pin *pin, OutputDelay *except); - void deleteOutputDelaysReferencing(Clock *clk); + const ClockEdge *clk_edge); + OutputDelay *makeOutputDelay(const Pin *pin, + const ClockEdge *clk_edge); + void deleteOutputDelays(const Pin *pin, + OutputDelay *except); + void deleteOutputDelaysReferencing(const Clock *clk); void deleteOutputDelay(OutputDelay *output_delay); - void deleteInstancePvts(); void deleteClockInsertion(ClockInsertion *insertion); void deleteClockInsertionsReferencing(Clock *clk); void deleteInterClockUncertainty(InterClockUncertainty *uncertainties); @@ -1198,7 +1212,6 @@ protected: void annotateHierClkLatency(); void annotateHierClkLatency(const Pin *hpin, ClockLatency *latency); - void initInstancePvtMaps(); void pinCaps(const Pin *pin, const RiseFall *rf, const OperatingConditions *op_cond, @@ -1244,18 +1257,18 @@ protected: const Clock *clk, const RiseFall *from_rf, const RiseFall *to_rf) const; - void disconnectPinBefore(Pin *pin, + void disconnectPinBefore(const Pin *pin, ExceptionPathSet *exceptions); void clockGroupsDeleteClkRefs(Clock *clk); void clearGroupPathMap(); AnalysisType analysis_type_; OperatingConditions *operating_conditions_[MinMax::index_count]; - InstancePvtMap *instance_pvt_maps_[MinMax::index_count]; + InstancePvtMap instance_pvt_maps_[MinMax::index_count]; DeratingFactorsGlobal *derating_factors_; - NetDeratingFactorsMap *net_derating_factors_; - InstDeratingFactorsMap *inst_derating_factors_; - CellDeratingFactorsMap *cell_derating_factors_; + NetDeratingFactorsMap net_derating_factors_; + InstDeratingFactorsMap inst_derating_factors_; + CellDeratingFactorsMap cell_derating_factors_; // Clock sequence retains clock definition order. // This is important for getting consistent regression results, // which iterating over the name map can't provide. @@ -1273,15 +1286,15 @@ protected: bool clk_hpin_disables_valid_; PinSet propagated_clk_pins_; ClockLatencies clk_latencies_; - ClockInsertions *clk_insertions_; + ClockInsertions clk_insertions_; PinClockUncertaintyMap pin_clk_uncertainty_map_; InterClockUncertaintySet inter_clk_uncertainties_; // clk_groups name -> clk_groups ClockGroupsNameMap clk_groups_name_map_; // clk to clk paths excluded by clock groups. - ClockPairSet *clk_group_exclusions_; + ClockPairSet clk_group_exclusions_; // clks in the same set_clock_group set. - ClockPairSet *clk_group_same_; + ClockPairSet clk_group_same_; ClockSenseMap clk_sense_map_; ClockGatingCheck *clk_gating_check_; ClockGatingCheckMap clk_gating_check_map_; @@ -1294,11 +1307,11 @@ protected: InputDelaySet input_delays_; InputDelaysPinMap input_delay_pin_map_; - int input_delay_index_; InputDelaysPinMap input_delay_ref_pin_map_; // Input delays on hierarchical pins are indexed by the load pins. InputDelaysPinMap input_delay_leaf_pin_map_; InputDelaysPinMap input_delay_internal_pin_map_; + int input_delay_index_; OutputDelaySet output_delays_; OutputDelaysPinMap output_delay_pin_map_; @@ -1318,12 +1331,12 @@ protected: // set_load port // set_fanout_load port // Indexed by corner_index. - PortExtCapMap *port_cap_map_; + vector port_ext_cap_maps_; // set_load net // Indexed by corner_index. - NetWireCapMap *net_wire_cap_map_; + vector net_wire_cap_maps_; // Indexed by corner_index. - PinWireCapMap *drvr_pin_wire_cap_map_; + vector drvr_pin_wire_cap_maps_; NetResistanceMap net_res_map_; PinSet disabled_pins_; PortSet disabled_ports_; @@ -1338,25 +1351,24 @@ protected: bool have_thru_hpin_exceptions_; // First pin/clock/instance/net/edge exception point to exception set map. - PinExceptionsMap *first_from_pin_exceptions_; - ClockExceptionsMap *first_from_clk_exceptions_; - InstanceExceptionsMap *first_from_inst_exceptions_; - PinExceptionsMap *first_thru_pin_exceptions_; - InstanceExceptionsMap *first_thru_inst_exceptions_; + PinExceptionsMap first_from_pin_exceptions_; + ClockExceptionsMap first_from_clk_exceptions_; + InstanceExceptionsMap first_from_inst_exceptions_; + PinExceptionsMap first_thru_pin_exceptions_; + InstanceExceptionsMap first_thru_inst_exceptions_; // Nets that have exception -thru nets. - NetExceptionsMap *first_thru_net_exceptions_; - PinExceptionsMap *first_to_pin_exceptions_; - ClockExceptionsMap *first_to_clk_exceptions_; - InstanceExceptionsMap *first_to_inst_exceptions_; + NetExceptionsMap first_thru_net_exceptions_; + PinExceptionsMap first_to_pin_exceptions_; + ClockExceptionsMap first_to_clk_exceptions_; + InstanceExceptionsMap first_to_inst_exceptions_; // Edges that traverse hierarchical exception pins. - EdgeExceptionsMap *first_thru_edge_exceptions_; - + EdgeExceptionsMap first_thru_edge_exceptions_; // Exception hash with one missing from/thru/to point, used for merging. ExceptionPathPtHash exception_merge_hash_; // Path delay -from pin internal startpoints. - PinSet *path_delay_internal_startpoints_; + PinSet path_delay_internal_startpoints_; // Path delay -to pin internal endpoints. - PinSet *path_delay_internal_endpoints_; + PinSet path_delay_internal_endpoints_; // There is a path delay exception without a -to. bool path_delays_without_to_; // Group path exception names. @@ -1401,26 +1413,4 @@ private: friend class GroupPathIterator; }; -class ClockIterator : public ClockSeq::Iterator -{ -public: - ClockIterator(Sdc *sdc); - -private: - ClockIterator(ClockSeq &clocks); - - friend class Sdc; -}; - -class GroupPathIterator : public GroupPathMap::Iterator -{ -public: - GroupPathIterator(Sdc *sdc); - -private: - GroupPathIterator(GroupPathMap &group_path_map); - - friend class Sdc; -}; - } // namespace diff --git a/include/sta/SdcClass.hh b/include/sta/SdcClass.hh index 297718c7..1afc6aaa 100644 --- a/include/sta/SdcClass.hh +++ b/include/sta/SdcClass.hh @@ -53,7 +53,6 @@ class DataCheck; class Wireload; class ClockLatency; class ClockInsertion; -class ClockGroup; class ClockGroups; class PortDelay; @@ -66,28 +65,56 @@ enum class ClockSense { positive, negative, stop }; typedef std::pair ClockPair; +class ClockIndexLess +{ +public: + bool operator()(const Clock *clk1, + const Clock *clk2) const; +}; + typedef Vector FloatSeq; typedef Vector IntSeq; typedef Vector ClockSeq; -typedef Set ClockSet; +typedef Set ClockSet; +typedef ClockSet ClockGroup; typedef Vector PinSetSeq; typedef MinMax SetupHold; typedef MinMaxAll SetupHoldAll; typedef Vector ExceptionThruSeq; -typedef Set LibertyPortPairSet; -typedef Map DisabledInstancePortsMap; -typedef Map DisabledCellPortsMap; +typedef Set LibertyPortPairSet; +typedef Map DisabledInstancePortsMap; +typedef Map DisabledCellPortsMap; typedef MinMaxValues ClockUncertainties; typedef Set ExceptionPathSet; typedef PinPair EdgePins; typedef PinPairSet EdgePinsSet; typedef Map LogicValueMap; -typedef Set ClockGroupSet; + +class ClockSetLess +{ +public: + bool operator()(const ClockSet *set1, + const ClockSet *set2) const; +}; + +typedef Set ClockGroupSet; // For Search. class ExceptionState; + +class ExceptionStateLess +{ +public: + ExceptionStateLess(const Network *network); + bool operator()(const ExceptionState *state1, + const ExceptionState *state2) const; + +private: + const Network *network_; +}; + class ExceptionPath; -typedef Set ExceptionStateSet; +typedef Set ExceptionStateSet; enum class CrprMode { same_pin, same_transition }; diff --git a/include/sta/SdcNetwork.hh b/include/sta/SdcNetwork.hh index 57cadaf5..f47a8459 100644 --- a/include/sta/SdcNetwork.hh +++ b/include/sta/SdcNetwork.hh @@ -32,19 +32,20 @@ public: bool make_black_boxes, Report *report); + virtual const char *name(const Library *library) const; + virtual ObjectId id(const Library *library) const; virtual LibraryIterator *libraryIterator() const; virtual LibertyLibraryIterator *libertyLibraryIterator() const; virtual Library *findLibrary(const char *name); virtual LibertyLibrary *findLibertyFilename(const char *filename); virtual LibertyLibrary *findLiberty(const char *name); - virtual const char *name(const Library *library) const; virtual Cell *findCell(const Library *library, const char *name) const; - virtual void findCellsMatching(const Library *library, - const PatternMatch *pattern, - CellSeq *cells) const; + virtual CellSeq findCellsMatching(const Library *library, + const PatternMatch *pattern) const; virtual const char *name(const Cell *cell) const; + virtual ObjectId id(const Cell *cell) const; virtual Library *library(const Cell *cell) const; virtual LibertyCell *libertyCell(Cell *cell) const; virtual const LibertyCell *libertyCell(const Cell *cell) const; @@ -53,15 +54,15 @@ public: virtual const char *filename(const Cell *cell); virtual Port *findPort(const Cell *cell, const char *name) const; - virtual void findPortsMatching(const Cell *cell, - const PatternMatch *pattern, - PortSeq *ports) const; + virtual PortSeq findPortsMatching(const Cell *cell, + const PatternMatch *pattern) const; virtual bool isLeaf(const Cell *cell) const; virtual CellPortIterator *portIterator(const Cell *cell) const; virtual CellPortBitIterator *portBitIterator(const Cell *cell) const; virtual int portBitCount(const Cell *cell) const; virtual const char *name(const Port *port) const; + virtual ObjectId id(const Port *port) const; virtual Cell *cell(const Port *port) const; virtual LibertyPort *libertyPort(const Port *port) const; virtual PortDirection *direction(const Port *port) const; @@ -78,6 +79,7 @@ public: virtual PortMemberIterator *memberIterator(const Port *port) const; virtual bool hasMembers(const Port *port) const; + virtual ObjectId id(const Instance *instance) const; virtual Instance *topInstance() const; virtual Cell *cell(const Instance *instance) const; virtual Instance *parent(const Instance *instance) const; @@ -94,6 +96,7 @@ public: virtual InstanceNetIterator * netIterator(const Instance *instance) const; + virtual ObjectId id(const Pin *pin) const; virtual Port *port(const Pin *pin) const; virtual Instance *instance(const Pin *pin) const; virtual Net *net(const Pin *pin) const; @@ -108,9 +111,11 @@ public: double &y, bool &exists) const; + virtual ObjectId id(const Term *term) const; virtual Net *net(const Term *term) const; virtual Pin *pin(const Term *term) const; + virtual ObjectId id(const Net *net) const; virtual Instance *instance(const Net *net) const; virtual bool isPower(const Net *net) const; virtual bool isGround(const Net *net) const; @@ -151,6 +156,7 @@ public: // Any overloaded functions from the base class must be listed here. using Network::name; + using Network::id; using Network::isLeaf; using Network::netIterator; using Network::findPin; @@ -175,9 +181,8 @@ public: virtual Port *findPort(const Cell *cell, const char *name) const; - virtual void findPortsMatching(const Cell *cell, - const PatternMatch *pattern, - PortSeq *ports) const; + virtual PortSeq findPortsMatching(const Cell *cell, + const PatternMatch *pattern) const; virtual const char *name(const Port *port) const; virtual const char *busName(const Port *port) const; @@ -185,30 +190,28 @@ public: virtual const char *pathName(const Instance *instance) const; virtual const char *pathName(const Pin *pin) const; virtual const char *portName(const Pin *pin) const; + virtual const char *name(const Net *net) const; virtual const char *pathName(const Net *net) const; virtual Instance *findInstance(const char *path_name) const; - virtual void findInstancesMatching(const Instance *context, - const PatternMatch *pattern, - InstanceSeq *insts) const; + virtual InstanceSeq findInstancesMatching(const Instance *context, + const PatternMatch *pattern) const; virtual Net *findNet(const char *path_name) const; virtual Net *findNet(const Instance *instance, const char *net_name) const; - virtual void findNetsMatching(const Instance *parent, - const PatternMatch *pattern, - NetSeq *nets) const; + virtual NetSeq findNetsMatching(const Instance *parent, + const PatternMatch *pattern) const; virtual void findInstNetsMatching(const Instance *instance, const PatternMatch *pattern, - NetSeq *nets) const; + NetSeq &nets) const; virtual Instance *findChild(const Instance *parent, const char *name) const; virtual Pin *findPin(const char *path_name) const; virtual Pin *findPin(const Instance *instance, const char *port_name) const; - virtual void findPinsMatching(const Instance *instance, - const PatternMatch *pattern, - PinSeq *pins) const; + virtual PinSeq findPinsMatching(const Instance *instance, + const PatternMatch *pattern) const; virtual Instance *makeInstance(LibertyCell *cell, const char *name, @@ -221,6 +224,7 @@ public: // findInstPinsMatching(instance, pattern) using Network::name; + using Network::id; using Network::findPin; protected: @@ -246,7 +250,10 @@ protected: visit_tail) const; bool visitPinTail(const Instance *instance, const PatternMatch *tail, - PinSeq *pins) const; + PinSeq &matches) const; + void findInstancesMatching1(const Instance *context, + const PatternMatch *pattern, + InstanceSeq &matches) const; const char *staToSdc(const char *sta_name) const; }; diff --git a/include/sta/Search.hh b/include/sta/Search.hh index 6f1a8a95..810ef62b 100644 --- a/include/sta/Search.hh +++ b/include/sta/Search.hh @@ -114,7 +114,7 @@ public: void requiredsInvalid(); // Invalidate vertex required time. void requiredInvalid(Vertex *vertex); - void requiredInvalid(Instance *inst); + void requiredInvalid(const Instance *inst); void requiredInvalid(const Pin *pin); // Vertex will be deleted. void deleteVertexBefore(Vertex *vertex); @@ -150,7 +150,7 @@ public: Arrival clkPathArrival(const Path *clk_path) const; Arrival clkPathArrival(const Path *clk_path, ClkInfo *clk_info, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, const MinMax *min_max, const PathAnalysisPt *path_ap) const; // Clock arrival at the path source/launch point. @@ -179,12 +179,8 @@ public: // Vertices on propagated generated clock source paths. bool isGenClkSrc(const Vertex *vertex) const; // The set of clocks that arrive at vertex. - void clocks(const Vertex *vertex, - // Return value. - ClockSet &clks) const; - void clocks(const Pin *pin, - // Return value. - ClockSet &clks) const; + ClockSet clocks(const Vertex *vertex) const; + ClockSet clocks(const Pin *pin) const; void visitStartpoints(VertexVisitor *visitor); void visitEndpoints(VertexVisitor *visitor); bool havePathGroups() const; @@ -222,7 +218,7 @@ public: bool require_exception); Tag *fromRegClkTag(const Pin *from_pin, const RiseFall *from_rf, - Clock *clk, + const Clock *clk, const RiseFall *clk_rf, ClkInfo *clk_info, const Pin *to_pin, @@ -305,7 +301,7 @@ public: bool own_states); void reportTags() const; void reportClkInfos() const; - virtual ClkInfo *findClkInfo(ClockEdge *clk_edge, + virtual ClkInfo *findClkInfo(const ClockEdge *clk_edge, const Pin *clk_src, bool is_propagated, const Pin *gen_clk_src, @@ -316,7 +312,7 @@ public: ClockUncertainties *uncertainties, const PathAnalysisPt *path_ap, PathVertex *crpr_clk_path); - ClkInfo *findClkInfo(ClockEdge *clk_edge, + ClkInfo *findClkInfo(const ClockEdge *clk_edge, const Pin *clk_src, bool is_propagated, Arrival insertion, @@ -368,24 +364,24 @@ protected: void findClockVertices(VertexSet &vertices); void seedClkDataArrival(const Pin *pin, const RiseFall *rf, - Clock *clk, - ClockEdge *clk_edge, + const Clock *clk, + const ClockEdge *clk_edge, const MinMax *min_max, const PathAnalysisPt *path_ap, Arrival insertion, TagGroupBldr *tag_bldr); void seedClkArrival(const Pin *pin, const RiseFall *rf, - Clock *clk, - ClockEdge *clk_edge, + const Clock *clk, + const ClockEdge *clk_edge, const MinMax *min_max, const PathAnalysisPt *path_ap, Arrival insertion, TagGroupBldr *tag_bldr); Tag *clkDataTag(const Pin *pin, - Clock *clk, + const Clock *clk, const RiseFall *rf, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, Arrival insertion, const MinMax *min_max, const PathAnalysisPt *path_ap); @@ -402,7 +398,7 @@ protected: ClockSet *wrt_clks); void seedInputDelayArrival(const Pin *pin, InputDelay *input_delay, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, float clk_arrival, float clk_insertion, float clk_latency, @@ -414,7 +410,7 @@ protected: const RiseFall *rf, float arrival, InputDelay *input_delay, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, float clk_insertion, float clk_latency, bool is_segment_start, @@ -422,7 +418,7 @@ protected: PathAnalysisPt *path_ap, TagGroupBldr *tag_bldr); void inputDelayClkArrival(InputDelay *input_delay, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, const MinMax *min_max, const PathAnalysisPt *path_ap, // Return values. @@ -430,7 +426,7 @@ protected: float &clk_insertion, float &clk_latency); void inputDelayRefPinArrival(Path *ref_path, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, const MinMax *min_max, // Return values. float &ref_arrival, @@ -438,7 +434,7 @@ protected: float &ref_latency); Tag *inputDelayTag(const Pin *pin, const RiseFall *rf, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, float clk_insertion, float clk_latency, InputDelay *input_delay, @@ -527,6 +523,9 @@ protected: bool matchesFilterTo(Path *path, const ClockEdge *to_clk_edge) const; PathRef pathClkPathArrival1(const Path *path) const; + void clocks(const Vertex *vertex, + // Return value. + ClockSet &clks) const; //////////////////////////////////////////////////////////////// diff --git a/include/sta/Set.hh b/include/sta/Set.hh index 0b062898..85fea212 100644 --- a/include/sta/Set.hh +++ b/include/sta/Set.hh @@ -71,11 +71,11 @@ public: } static bool - intersects(std::set &set1, - std::set &set2); + intersects(const std::set &set1, + const std::set &set2); static bool - intersects(std::set *set1, - std::set *set2); + intersects(const std::set *set1, + const std::set *set2); // Java style container itererator // Set::Iterator iter(set); @@ -174,16 +174,16 @@ Set::isSubset(const std::set *set2) template bool -Set::intersects(std::set &set1, - std::set &set2) +Set::intersects(const std::set &set1, + const std::set &set2) { return intersects(&set1, &set2); } template bool -Set::intersects(std::set *set1, - std::set *set2) +Set::intersects(const std::set *set1, + const std::set *set2) { if (set1 && !set1->empty() && set2 && !set2->empty()) { diff --git a/include/sta/Sta.hh b/include/sta/Sta.hh index ac31cb47..03195b56 100644 --- a/include/sta/Sta.hh +++ b/include/sta/Sta.hh @@ -59,7 +59,6 @@ class ClkSkews; class ReportField; class Power; class PowerResult; -class ClockIterator; class EquivCells; typedef InstanceSeq::Iterator SlowDrvrIterator; @@ -151,75 +150,77 @@ public: const EarlyLate *early_late, float derate); void unsetTimingDerate(); - void setInputSlew(Port *port, + void setInputSlew(const Port *port, const RiseFallBoth *rf, const MinMaxAll *min_max, float slew); // Set port external pin load (set_load -pin port). - void setPortExtPinCap(Port *port, + void setPortExtPinCap(const Port *port, const RiseFallBoth *rf, + const Corner *corner, const MinMaxAll *min_max, float cap); - void portExtCaps(Port *port, + void portExtCaps(const Port *port, + const Corner *corner, const MinMax *min_max, float &pin_cap, float &wire_cap, int &fanout); // Set port external wire load (set_load -wire port). - void setPortExtWireCap(Port *port, + void setPortExtWireCap(const Port *port, bool subtract_pin_cap, const RiseFallBoth *rf, + const Corner *corner, const MinMaxAll *min_max, float cap); // Set net wire capacitance (set_load -wire net). - void setNetWireCap(Net *net, + void setNetWireCap(const Net *net, bool subtract_pin_load, const Corner *corner, const MinMaxAll *min_max, float cap); // Set port external fanout (used by wireload models). - void setPortExtFanout(Port *port, + void setPortExtFanout(const Port *port, int fanout, + const Corner *corner, const MinMaxAll *min_max); - // Remove all "set_load net" annotations. - void removeNetLoadCaps() const; // Liberty port capacitance. float capacitance(const LibertyPort *port, Corner *corner, const MinMax *min_max); // pin_cap = net pin capacitances + port external pin capacitance, // wire_cap = annotated net capacitance + port external wire capacitance. - void connectedCap(Pin *drvr_pin, + void connectedCap(const Pin *drvr_pin, const RiseFall *rf, const Corner *corner, const MinMax *min_max, float &pin_cap, float &wire_cap) const; - void connectedCap(Net *net, + void connectedCap(const Net *net, Corner *corner, const MinMax *min_max, float &pin_cap, float &wire_cap) const; - void setResistance(Net *net, + void setResistance(const Net *net, const MinMaxAll *min_max, float res); - void setDriveCell(LibertyLibrary *library, - LibertyCell *cell, - Port *port, - LibertyPort *from_port, + void setDriveCell(const LibertyLibrary *library, + const LibertyCell *cell, + const Port *port, + const LibertyPort *from_port, float *from_slews, - LibertyPort *to_port, + const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max); - void setDriveResistance(Port *port, + void setDriveResistance(const Port *port, const RiseFallBoth *rf, const MinMaxAll *min_max, float res); - void setLatchBorrowLimit(Pin *pin, + void setLatchBorrowLimit(const Pin *pin, float limit); - void setLatchBorrowLimit(Instance *inst, + void setLatchBorrowLimit(const Instance *inst, float limit); - void setLatchBorrowLimit(Clock *clk, + void setLatchBorrowLimit(const Clock *clk, float limit); void setMinPulseWidth(const RiseFallBoth *rf, float min_width); @@ -430,7 +431,7 @@ public: bool isDisabledClock(Edge *edge); // Return a set of constant pins that disabled edge. // Caller owns the returned set. - PinSet *disabledConstantPins(Edge *edge); + PinSet disabledConstantPins(Edge *edge); // Edge timing sense with propagated constants. TimingSense simTimingSense(Edge *edge); // Edge is disabled by set_disable_timing constraint. @@ -444,8 +445,8 @@ public: bool isDisabledPresetClr(Edge *edge) const; // Return a vector of graph edges that are disabled, sorted by // from/to vertex names. Caller owns the returned vector. - EdgeSeq *disabledEdges(); - EdgeSeq *disabledEdgesSorted(); + EdgeSeq disabledEdges(); + EdgeSeq disabledEdgesSorted(); void disableClockGatingCheck(Instance *inst); void disableClockGatingCheck(Pin *pin); void removeDisableClockGatingCheck(Instance *inst); @@ -540,35 +541,34 @@ public: void checkExceptionToPins(ExceptionTo *to, const char *file, int) const; void deleteExceptionTo(ExceptionTo *to); - InstanceSet *findRegisterInstances(ClockSet *clks, - const RiseFallBoth *clk_rf, - bool edge_triggered, - bool latches); - PinSet *findRegisterDataPins(ClockSet *clks, - const RiseFallBoth *clk_rf, - bool registers, - bool latches); - PinSet *findRegisterClkPins(ClockSet *clks, - const RiseFallBoth *clk_rf, - bool registers, - bool latches); - PinSet *findRegisterAsyncPins(ClockSet *clks, - const RiseFallBoth *clk_rf, - bool registers, - bool latches); - PinSet *findRegisterOutputPins(ClockSet *clks, - const RiseFallBoth *clk_rf, - bool registers, - bool latches); - PinSet * - findFaninPins(PinSeq *to, - bool flat, - bool startpoints_only, - int inst_levels, - int pin_levels, - bool thru_disabled, - bool thru_constants); - InstanceSet * + InstanceSet findRegisterInstances(ClockSet *clks, + const RiseFallBoth *clk_rf, + bool edge_triggered, + bool latches); + PinSet findRegisterDataPins(ClockSet *clks, + const RiseFallBoth *clk_rf, + bool registers, + bool latches); + PinSet findRegisterClkPins(ClockSet *clks, + const RiseFallBoth *clk_rf, + bool registers, + bool latches); + PinSet findRegisterAsyncPins(ClockSet *clks, + const RiseFallBoth *clk_rf, + bool registers, + bool latches); + PinSet findRegisterOutputPins(ClockSet *clks, + const RiseFallBoth *clk_rf, + bool registers, + bool latches); + PinSet findFaninPins(PinSeq *to, + bool flat, + bool startpoints_only, + int inst_levels, + int pin_levels, + bool thru_disabled, + bool thru_constants); + InstanceSet findFaninInstances(PinSeq *to, bool flat, bool startpoints_only, @@ -576,7 +576,7 @@ public: int pin_levels, bool thru_disabled, bool thru_constants); - PinSet * + PinSet findFanoutPins(PinSeq *from, bool flat, bool endpoints_only, @@ -584,7 +584,7 @@ public: int pin_levels, bool thru_disabled, bool thru_constants); - InstanceSet * + InstanceSet findFanoutInstances(PinSeq *from, bool flat, bool endpoints_only, @@ -594,18 +594,16 @@ public: bool thru_constants); // The set of clocks that reach pin. - void clocks(const Pin *pin, - // Return value. - ClockSet &clks); + ClockSet clocks(const Pin *pin); void checkSlewLimitPreamble(); // Return pins with the min/max slew limit slack. // net=null check all nets // corner=nullptr checks all corners. - PinSeq *checkSlewLimits(Net *net, - bool violators, - const Corner *corner, - const MinMax *min_max); + PinSeq checkSlewLimits(Net *net, + bool violators, + const Corner *corner, + const MinMax *min_max); void reportSlewLimitShortHeader(); void reportSlewLimitShort(Pin *pin, const Corner *corner, @@ -625,7 +623,7 @@ public: float &limit, float &slack); void maxSlewCheck(// Return values. - Pin *&pin, + const Pin *&pin, Slew &slew, float &slack, float &limit); @@ -640,9 +638,9 @@ public: // Return pins with the min/max fanout limit slack. // net=null check all nets // corner=nullptr checks all corners. - PinSeq *checkFanoutLimits(Net *net, - bool violators, - const MinMax *min_max); + PinSeq checkFanoutLimits(Net *net, + bool violators, + const MinMax *min_max); void reportFanoutLimitShortHeader(); void reportFanoutLimitShort(Pin *pin, const MinMax *min_max); @@ -656,7 +654,7 @@ public: float &limit, float &slack); void maxFanoutCheck(// Return values. - Pin *&pin, + const Pin *&pin, float &fanout, float &slack, float &limit); @@ -665,10 +663,10 @@ public: // Return pins with the min/max slew limit slack. // net=null check all nets // corner=nullptr checks all corners. - PinSeq *checkCapacitanceLimits(Net *net, - bool violators, - const Corner *corner, - const MinMax *min_max); + PinSeq checkCapacitanceLimits(Net *net, + bool violators, + const Corner *corner, + const MinMax *min_max); void reportCapacitanceLimitShortHeader(); void reportCapacitanceLimitShort(Pin *pin, const Corner *corner, @@ -687,7 +685,7 @@ public: float &limit, float &slack); void maxCapacitanceCheck(// Return values. - Pin *&pin, + const Pin *&pin, float &capacitance, float &slack, float &limit); @@ -734,17 +732,17 @@ public: // Instance specific process/voltage/temperature. // Defaults to operating condition if instance is not annotated. - Pvt *pvt(Instance *inst, - const MinMax *min_max); + const Pvt *pvt(Instance *inst, + const MinMax *min_max); void setPvt(Instance *inst, const MinMaxAll *min_max, float process, float voltage, float temperature); // Pvt may be shared among multiple instances. - void setPvt(Instance *inst, + void setPvt(const Instance *inst, const MinMaxAll *min_max, - Pvt *pvt); + const Pvt &pvt); // Clear all state except network. virtual void clear(); // Remove all constraints. @@ -931,8 +929,7 @@ public: int endpointViolationCount(const MinMax *min_max); // Find the fanin vertices for a group path. // Vertices in the clock network are NOT included. - // Return value is owned by the caller. - PinSet *findGroupPathPins(const char *group_path_name); + PinSet findGroupPathPins(const char *group_path_name); // Find all required times after updateTiming(). void findRequireds(); string *reportDelayCalc(Edge *edge, @@ -1176,26 +1173,26 @@ public: virtual void disconnectPin(Pin *pin); // Notify STA of network change. void networkChanged(); - void deleteLeafInstanceBefore(Instance *inst); - void deleteInstancePinsBefore(Instance *inst); + void deleteLeafInstanceBefore(const Instance *inst); + void deleteInstancePinsBefore(const Instance *inst); // Network edit before/after methods. - void makeInstanceAfter(Instance *inst); + void makeInstanceAfter(const Instance *inst); // Replace the instance cell with to_cell. // equivCells(from_cell, to_cell) must be true. - virtual void replaceEquivCellBefore(Instance *inst, - LibertyCell *to_cell); - virtual void replaceEquivCellAfter(Instance *inst); + virtual void replaceEquivCellBefore(const Instance *inst, + const LibertyCell *to_cell); + virtual void replaceEquivCellAfter(const Instance *inst); // Replace the instance cell with to_cell. // equivCellPorts(from_cell, to_cell) must be true. - virtual void replaceCellBefore(Instance *inst, - LibertyCell *to_cell); - virtual void replaceCellAfter(Instance *inst); - virtual void connectPinAfter(Pin *pin); - virtual void disconnectPinBefore(Pin *pin); - virtual void deleteNetBefore(Net *net); - virtual void deleteInstanceBefore(Instance *inst); - virtual void deletePinBefore(Pin *pin); + virtual void replaceCellBefore(const Instance *inst, + const LibertyCell *to_cell); + virtual void replaceCellAfter(const Instance *inst); + virtual void connectPinAfter(const Pin *pin); + virtual void disconnectPinBefore(const Pin *pin); + virtual void deleteNetBefore(const Net *net); + virtual void deleteInstanceBefore(const Instance *inst); + virtual void deletePinBefore(const Pin *pin); //////////////////////////////////////////////////////////////// @@ -1241,18 +1238,18 @@ public: int level); // Delays and arrivals downsteam from inst are invalid. - void delaysInvalidFrom(Instance *inst); + void delaysInvalidFrom(const Instance *inst); // Delays and arrivals downsteam from pin are invalid. - void delaysInvalidFrom(Pin *pin); + void delaysInvalidFrom(const Pin *pin); void delaysInvalidFrom(Vertex *vertex); // Delays to driving pins of net (fanin) are invalid. // Arrivals downsteam from net are invalid. - void delaysInvalidFromFanin(Net *net); - void delaysInvalidFromFanin(Pin *pin); + void delaysInvalidFromFanin(const Net *net); + void delaysInvalidFromFanin(const Pin *pin); void delaysInvalidFromFanin(Vertex *vertex); - void replaceCellPinInvalidate(LibertyPort *from_port, + void replaceCellPinInvalidate(const LibertyPort *from_port, Vertex *vertex, - LibertyCell *to_cell); + const LibertyCell *to_cell); // Power API. Power *power() { return power_; } @@ -1264,10 +1261,8 @@ public: PowerResult &combinational, PowerResult ¯o, PowerResult &pad); - void power(const Instance *inst, - const Corner *corner, - // Return values. - PowerResult &result); + PowerResult power(const Instance *inst, + const Corner *corner); PwrActivity findClkedActivity(const Pin *pin); void writeTimingModel(const char *lib_name, @@ -1321,18 +1316,18 @@ protected: virtual LibertyLibrary *readLibertyFile(const char *filename, bool infer_latches); void delayCalcPreamble(); - void delaysInvalidFrom(Port *port); - void delaysInvalidFromFanin(Port *port); + void delaysInvalidFrom(const Port *port); + void delaysInvalidFromFanin(const Port *port); void deleteEdge(Edge *edge); void netParasiticCaps(Net *net, const RiseFall *rf, const MinMax *min_max, float &pin_cap, float &wire_cap) const; - Pin *findNetParasiticDrvrPin(Net *net) const; + const Pin *findNetParasiticDrvrPin(const Net *net) const; void exprConstantPins(FuncExpr *expr, - Instance *inst, - PinSet *pins); + const Instance *inst, + PinSet &pins); Slack vertexSlack1(Vertex *vertex, const RiseFall *rf, const ClockEdge *clk_edge, @@ -1359,7 +1354,7 @@ protected: bool startpoints_only, int inst_levels, int pin_levels, - PinSet *fanin, + PinSet &fanin, SearchPred &pred); void findFaninPins(Vertex *to, bool flat, @@ -1374,7 +1369,7 @@ protected: bool endpoints_only, int inst_levels, int pin_levels, - PinSet *fanout, + PinSet &fanout, SearchPred &pred); void findFanoutPins(Vertex *from, bool flat, diff --git a/include/sta/TimingArc.hh b/include/sta/TimingArc.hh index 2e14c888..1c52cd24 100644 --- a/include/sta/TimingArc.hh +++ b/include/sta/TimingArc.hh @@ -239,7 +239,7 @@ public: unsigned index() const { return index_; } TimingModel *model(const OperatingConditions *op_cond) const; TimingModel *model() const { return model_; } - TimingArc *cornerArc(int ap_index); + const TimingArc *cornerArc(int ap_index) const; void setCornerArc(TimingArc *corner_arc, int ap_index); float driveResistance() const; diff --git a/include/sta/UnorderedMap.hh b/include/sta/UnorderedMap.hh index 2aa117d7..9784ab9f 100644 --- a/include/sta/UnorderedMap.hh +++ b/include/sta/UnorderedMap.hh @@ -31,6 +31,11 @@ public: { } + explicit UnorderedMap(const HASH &hash) : + std::unordered_map(0, hash, std::equal_to()) + { + } + explicit UnorderedMap(size_t size, const HASH &hash, const EQUAL &equal) : @@ -101,6 +106,19 @@ public: delete iter.next(); } + void + deleteKeysContents() + { + Iterator iter(this); + while (iter.hasNext()) { + KEY key; + VALUE value; + iter.next(key, value); + delete key; + delete value; + } + } + void deleteArrayContents() { diff --git a/include/sta/VertexVisitor.hh b/include/sta/VertexVisitor.hh index cf14ebd8..e28419b6 100644 --- a/include/sta/VertexVisitor.hh +++ b/include/sta/VertexVisitor.hh @@ -37,13 +37,13 @@ public: class VertexPinCollector : public VertexVisitor { public: - VertexPinCollector(PinSet *pins); - PinSet *pins() const { return pins_; } + VertexPinCollector(PinSet &pins); + const PinSet &pins() const { return pins_; } void visit(Vertex *vertex); virtual VertexVisitor *copy() const; protected: - PinSet *pins_; + PinSet &pins_; }; } // namespace diff --git a/liberty/Liberty.cc b/liberty/Liberty.cc index 6c649208..afe13b81 100644 --- a/liberty/Liberty.cc +++ b/liberty/Liberty.cc @@ -132,16 +132,17 @@ LibertyLibrary::findLibertyCell(const char *name) const return static_cast(findCell(name)); } -void -LibertyLibrary::findLibertyCellsMatching(PatternMatch *pattern, - LibertyCellSeq *cells) +LibertyCellSeq +LibertyLibrary::findLibertyCellsMatching(PatternMatch *pattern) { + LibertyCellSeq matches; LibertyCellIterator cell_iter(this); while (cell_iter.hasNext()) { LibertyCell *cell = cell_iter.next(); if (pattern->match(cell->name())) - cells->push_back(cell); + matches.push_back(cell); } + return matches; } LibertyCellSeq * @@ -790,7 +791,7 @@ LibertyLibrary::checkCorners(LibertyCell *cell, for (const Corner *corner : *corners) { for (auto min_max : MinMax::range()) { if (!cell->checkCornerCell(corner, min_max)) - report->error(705, "Liberty cell %s/%s for corner %s/%s not found", + report->error(705, "Liberty cell %s/%s for corner %s/%s not found.", cell->libertyLibrary()->name(), cell->name(), corner->name(), @@ -883,7 +884,7 @@ LibertyCellIterator::next() LibertyCell::LibertyCell(LibertyLibrary *library, const char *name, const char *filename) : - ConcreteCell(library, name, true, filename), + ConcreteCell(name, filename, true, library), liberty_library_(library), area_(0.0), dont_use_(false), @@ -940,16 +941,17 @@ LibertyCell::findLibertyPort(const char *name) const return static_cast(findPort(name)); } -void -LibertyCell::findLibertyPortsMatching(PatternMatch *pattern, - LibertyPortSeq *ports) const +LibertyPortSeq +LibertyCell::findLibertyPortsMatching(PatternMatch *pattern) const { + LibertyPortSeq matches; LibertyCellPortIterator port_iter(this); while (port_iter.hasNext()) { LibertyPort *port = port_iter.next(); if (pattern->match(port->name())) - ports->push_back(port); + matches.push_back(port); } + return matches; } void @@ -1570,9 +1572,9 @@ bool LibertyCell::checkCornerCell(const Corner *corner, const MinMax *min_max) const { - int lib_index = corner->libertyIndex(min_max); + unsigned lib_index = corner->libertyIndex(min_max); return corner_cells_.empty() - || (lib_index <= static_cast(corner_cells_.size()) + || (lib_index < corner_cells_.size() && corner_cells_[lib_index]); } @@ -1904,7 +1906,7 @@ LibertyPort::LibertyPort(LibertyCell *cell, int to_index, bool is_bundle, ConcretePortSeq *members) : - ConcretePort(cell, name, is_bus, from_index, to_index, is_bundle, members), + ConcretePort(name, is_bus, from_index, to_index, is_bundle, members, cell), liberty_cell_(cell), bus_dcl_(bus_dcl), function_(nullptr), @@ -2492,14 +2494,14 @@ LibertyPort::setRelatedPowerPin(const char *related_power_pin) //////////////////////////////////////////////////////////////// -void -sortLibertyPortSet(LibertyPortSet *set, - LibertyPortSeq &ports) +LibertyPortSeq +sortByName(const LibertyPortSet *set) { - LibertyPortSet::Iterator port_iter(set); - while (port_iter.hasNext()) - ports.push_back(port_iter.next()); + LibertyPortSeq ports; + for (LibertyPort *port : *set) + ports.push_back(port); sort(ports, LibertyPortNameLess()); + return ports; } bool @@ -2509,22 +2511,15 @@ LibertyPortNameLess::operator()(const LibertyPort *port1, return stringLess(port1->name(), port2->name()); } -bool -LibertyPortPairLess::operator()(const LibertyPortPair *pair1, - const LibertyPortPair *pair2) const -{ - return pair1->first < pair2->first - || (pair1->first == pair2->first - && pair1->second < pair2->second); -} - bool LibertyPortPairLess::operator()(const LibertyPortPair &pair1, const LibertyPortPair &pair2) const { - return pair1.first < pair2.first - || (pair1.first == pair2.first - && pair1.second < pair2.second); + ObjectId id1 = pair1.first->id(); + ObjectId id2 = pair2.first->id(); + return id1 < id2 + || (id1 == id2 + && pair1.second->id() < pair2.second->id()); } //////////////////////////////////////////////////////////////// diff --git a/liberty/TimingArc.cc b/liberty/TimingArc.cc index 6d440394..581be03b 100644 --- a/liberty/TimingArc.cc +++ b/liberty/TimingArc.cc @@ -583,8 +583,8 @@ TimingArc::setIndex(unsigned index) index_ = index; } -TimingArc * -TimingArc::cornerArc(int ap_index) +const TimingArc * +TimingArc::cornerArc(int ap_index) const { if (ap_index < static_cast(corner_arcs_.size())) { TimingArc *corner_arc = corner_arcs_[ap_index]; diff --git a/network/ConcreteLibrary.cc b/network/ConcreteLibrary.cc index 936613e7..1c74733d 100644 --- a/network/ConcreteLibrary.cc +++ b/network/ConcreteLibrary.cc @@ -21,6 +21,7 @@ #include "PatternMatch.hh" #include "PortDirection.hh" #include "ParseBus.hh" +#include "ConcreteNetwork.hh" namespace sta { @@ -30,6 +31,7 @@ ConcreteLibrary::ConcreteLibrary(const char *name, const char *filename, bool is_liberty) : name_(stringCopy(name)), + id_(ConcreteNetwork::nextObjectId()), filename_(stringCopy(filename)), is_liberty_(is_liberty), bus_brkt_left_('['), @@ -49,7 +51,7 @@ ConcreteLibrary::makeCell(const char *name, bool is_leaf, const char *filename) { - ConcreteCell *cell = new ConcreteCell(this, name, is_leaf, filename); + ConcreteCell *cell = new ConcreteCell(name, filename, is_leaf, this); addCell(cell); return cell; } @@ -87,16 +89,17 @@ ConcreteLibrary::findCell(const char *name) const return cell_map_.findKey(name); } -void -ConcreteLibrary::findCellsMatching(const PatternMatch *pattern, - CellSeq *cells) const +CellSeq +ConcreteLibrary::findCellsMatching(const PatternMatch *pattern) const { + CellSeq matches; ConcreteLibraryCellIterator cell_iter=ConcreteLibraryCellIterator(cell_map_); while (cell_iter.hasNext()) { ConcreteCell *cell = cell_iter.next(); if (pattern->match(cell->name())) - cells->push_back(reinterpret_cast(cell)); + matches.push_back(reinterpret_cast(cell)); } + return matches; } void @@ -109,13 +112,14 @@ ConcreteLibrary::setBusBrkts(char left, //////////////////////////////////////////////////////////////// -ConcreteCell::ConcreteCell(ConcreteLibrary *library, - const char *name, +ConcreteCell::ConcreteCell(const char *name, + const char *filename, bool is_leaf, - const char *filename): - library_(library), + ConcreteLibrary *library) : name_(stringCopy(name)), + id_(ConcreteNetwork::nextObjectId()), filename_(stringCopy(filename)), + library_(library), liberty_cell_(nullptr), ext_cell_(nullptr), port_bit_count_(0), @@ -155,7 +159,7 @@ ConcreteCell::setExtCell(void *ext_cell) ConcretePort * ConcreteCell::makePort(const char *name) { - ConcretePort *port = new ConcretePort(this, name, false, -1, -1, false, nullptr); + ConcretePort *port = new ConcretePort(name, false, -1, -1, false, nullptr, this); addPort(port); return port; } @@ -164,8 +168,7 @@ ConcretePort * ConcreteCell::makeBundlePort(const char *name, ConcretePortSeq *members) { - ConcretePort *port = new ConcretePort(this, name, false, -1, -1, - true, members); + ConcretePort *port = new ConcretePort(name, false, -1, -1, true, members, this); addPort(port); return port; } @@ -175,8 +178,8 @@ ConcreteCell::makeBusPort(const char *name, int from_index, int to_index) { - ConcretePort *port = new ConcretePort(this, name, true, from_index, to_index, - false, new ConcretePortSeq); + ConcretePort *port = new ConcretePort(name, true, from_index, to_index, + false, new ConcretePortSeq, this); addPort(port); makeBusPortBits(port, name, from_index, to_index); return port; @@ -188,8 +191,8 @@ ConcreteCell::makeBusPort(const char *name, int to_index, ConcretePortSeq *members) { - ConcretePort *port = new ConcretePort(this, name, true, from_index, to_index, - false, members); + ConcretePort *port = new ConcretePort(name, true, from_index, to_index, + false, members, this); addPort(port); return port; } @@ -230,8 +233,8 @@ ConcretePort * ConcreteCell::makePort(const char *bit_name, int bit_index) { - ConcretePort *port = new ConcretePort(this, bit_name, false, bit_index, - bit_index, false, nullptr); + ConcretePort *port = new ConcretePort(bit_name, false, bit_index, + bit_index, false, nullptr, this); addPortBit(port); return port; } @@ -270,10 +273,10 @@ ConcreteCell::portCount() const return ports_.size(); } -void -ConcreteCell::findPortsMatching(const PatternMatch *pattern, - PortSeq *ports) const +PortSeq +ConcreteCell::findPortsMatching(const PatternMatch *pattern) const { + PortSeq matches; char bus_brkt_right = library_->busBrktRight(); const char *pattern1 = pattern->pattern(); bool bus_pattern = (pattern1[strlen(pattern1) - 1] == bus_brkt_right); @@ -285,14 +288,15 @@ ConcreteCell::findPortsMatching(const PatternMatch *pattern, while (member_iter->hasNext()) { ConcretePort *port_bit = member_iter->next(); if (pattern->match(port_bit->name())) - ports->push_back(reinterpret_cast(port_bit)); + matches.push_back(reinterpret_cast(port_bit)); } delete member_iter; } else if (pattern->match(port->name())) - ports->push_back(reinterpret_cast(port)); + matches.push_back(reinterpret_cast(port)); } delete port_iter; + return matches; } ConcreteCellPortIterator * @@ -456,14 +460,15 @@ ConcreteCell::groupBusPorts(const char bus_brkt_left, //////////////////////////////////////////////////////////////// -ConcretePort::ConcretePort(ConcreteCell *cell, - const char *name, +ConcretePort::ConcretePort(const char *name, bool is_bus, int from_index, int to_index, bool is_bundle, - ConcretePortSeq *member_ports) : + ConcretePortSeq *member_ports, + ConcreteCell *cell) : name_(stringCopy(name)), + id_(ConcreteNetwork::nextObjectId()), cell_(cell), direction_(PortDirection::unknown()), liberty_port_(nullptr), diff --git a/network/ConcreteNetwork.cc b/network/ConcreteNetwork.cc index 825f322d..1c944547 100644 --- a/network/ConcreteNetwork.cc +++ b/network/ConcreteNetwork.cc @@ -39,6 +39,9 @@ makeClonePins(Instance *proto, ConcreteBindingTbl *parent_bindings, NetworkReader *network); + +//////////////////////////////////////////////////////////////// + NetworkReader * makeConcreteNetwork() { @@ -243,9 +246,12 @@ ConcreteNetTermIterator::next() //////////////////////////////////////////////////////////////// +ObjectId ConcreteNetwork::object_id_ = 0; + ConcreteNetwork::ConcreteNetwork() : NetworkReader(), top_instance_(nullptr), + constant_nets_{NetSet(this), NetSet(this)}, link_func_(nullptr) { } @@ -443,6 +449,14 @@ ConcreteNetwork::name(const Library *library) const return clib->name(); } +ObjectId +ConcreteNetwork::id(const Library *library) const +{ + const ConcreteLibrary *clib = + reinterpret_cast(library); + return clib->id(); +} + LibertyLibrary * ConcreteNetwork::findLiberty(const char *name) { @@ -501,14 +515,13 @@ ConcreteNetwork::findAnyCell(const char *name) return nullptr; } -void +CellSeq ConcreteNetwork::findCellsMatching(const Library *library, - const PatternMatch *pattern, - CellSeq *cells) const + const PatternMatch *pattern) const { const ConcreteLibrary *clib = reinterpret_cast(library); - clib->findCellsMatching(pattern, cells); + return clib->findCellsMatching(pattern); } void @@ -528,6 +541,13 @@ ConcreteNetwork::name(const Cell *cell) const return ccell->name(); } +ObjectId +ConcreteNetwork::id(const Cell *cell) const +{ + const ConcreteCell *ccell = reinterpret_cast(cell); + return ccell->id(); +} + void ConcreteNetwork::setName(Cell *cell, const char *name) @@ -592,13 +612,12 @@ ConcreteNetwork::findPort(const Cell *cell, return reinterpret_cast(ccell->findPort(name)); } -void +PortSeq ConcreteNetwork::findPortsMatching(const Cell *cell, - const PatternMatch *pattern, - PortSeq *ports) const + const PatternMatch *pattern) const { const ConcreteCell *ccell = reinterpret_cast(cell); - ccell->findPortsMatching(pattern, ports); + return ccell->findPortsMatching(pattern); } bool @@ -635,7 +654,8 @@ ConcreteNetwork::groupBusPorts(Cell *cell, Library *lib = library(cell); ConcreteLibrary *clib = reinterpret_cast(lib); ConcreteCell *ccell = reinterpret_cast(cell); - ccell->groupBusPorts(clib->busBrktLeft(), clib->busBrktRight(), port_msb_first); + ccell->groupBusPorts(clib->busBrktLeft(), clib->busBrktRight(), + port_msb_first); } Port * @@ -657,6 +677,12 @@ ConcreteNetwork::setDirection(Port *port, cport->setDirection(dir); } +ObjectId +ConcreteNetwork::nextObjectId() +{ + return object_id_++; +} + //////////////////////////////////////////////////////////////// class ConcreteCellPortIterator1 : public CellPortIterator @@ -747,6 +773,13 @@ ConcreteNetwork::name(const Port *port) const return cport->name(); } +ObjectId +ConcreteNetwork::id(const Port *port) const +{ + const ConcretePort *cport = reinterpret_cast(port); + return cport->id(); +} + Cell * ConcreteNetwork::cell(const Port *port) const { @@ -881,6 +914,14 @@ ConcreteNetwork::name(const Instance *instance) const return inst->name(); } +ObjectId +ConcreteNetwork::id(const Instance *instance) const +{ + const ConcreteInstance *inst = + reinterpret_cast(instance); + return inst->id(); +} + Cell * ConcreteNetwork::cell(const Instance *instance) const { @@ -945,11 +986,11 @@ ConcreteNetwork::findNet(const Instance *instance, void ConcreteNetwork::findInstNetsMatching(const Instance *instance, const PatternMatch *pattern, - NetSeq *nets) const + NetSeq &matches) const { const ConcreteInstance *inst = reinterpret_cast(instance); - inst->findNetsMatching(pattern, nets); + return inst->findNetsMatching(pattern, matches); } //////////////////////////////////////////////////////////////// @@ -982,6 +1023,13 @@ ConcreteNetwork::netIterator(const Instance *instance) const //////////////////////////////////////////////////////////////// +ObjectId +ConcreteNetwork::id(const Pin *pin) const +{ + const ConcretePin *cpin = reinterpret_cast(pin); + return cpin->id(); +} + Instance * ConcreteNetwork::instance(const Pin *pin) const { @@ -1035,6 +1083,13 @@ ConcreteNetwork::setVertexId(Pin *pin, //////////////////////////////////////////////////////////////// +ObjectId +ConcreteNetwork::id(const Term *term) const +{ + const ConcreteTerm *cterm = reinterpret_cast(term); + return cterm->id(); +} + Net * ConcreteNetwork::net(const Term *term) const { @@ -1058,6 +1113,13 @@ ConcreteNetwork::name(const Net *net) const return cnet->name(); } +ObjectId +ConcreteNetwork::id(const Net *net) const +{ + const ConcreteNet *cnet = reinterpret_cast(net); + return cnet->id(); +} + Instance * ConcreteNetwork::instance(const Net *net) const { @@ -1140,7 +1202,7 @@ ConcreteNetwork::makeConcreteInstance(ConcreteCell *cell, { ConcreteInstance *cparent = reinterpret_cast(parent); - ConcreteInstance *inst = new ConcreteInstance(cell, name, cparent); + ConcreteInstance *inst = new ConcreteInstance(name, cell, cparent); if (parent) cparent->addChild(inst); return reinterpret_cast(inst); @@ -1176,6 +1238,7 @@ ConcreteNetwork::replaceCell(Instance *inst, if (cport) { rpins[cport->pinIndex()] = cpin; cpin->port_ = cport; + cpin->id_ = ConcreteNetwork::nextObjectId(); } } } @@ -1443,7 +1506,7 @@ ConcreteNetwork::constantPinIterator() void ConcreteNetwork::visitConnectedPins(const Net *net, PinVisitor &visitor, - ConstNetSet &visited_nets) const + NetSet &visited_nets) const { if (!visited_nets.hasKey(net)) { visited_nets.insert(net); @@ -1477,11 +1540,12 @@ ConcreteNetwork::visitConnectedPins(const Net *net, //////////////////////////////////////////////////////////////// -ConcreteInstance::ConcreteInstance(ConcreteCell *cell, - const char *name, - ConcreteInstance *parent) : - cell_(cell), +ConcreteInstance::ConcreteInstance(const char *name, + ConcreteCell *cell, + ConcreteInstance *parent) : name_(stringCopy(name)), + id_(ConcreteNetwork::nextObjectId()), + cell_(cell), parent_(parent), children_(nullptr), nets_(nullptr) @@ -1556,7 +1620,7 @@ ConcreteInstance::findNet(const char *net_name) const void ConcreteInstance::findNetsMatching(const PatternMatch *pattern, - NetSeq *nets) const + NetSeq &matches) const { if (pattern->hasWildcards()) { ConcreteInstanceNetMap::Iterator net_iter(nets_); @@ -1565,13 +1629,13 @@ ConcreteInstance::findNetsMatching(const PatternMatch *pattern, ConcreteNet *cnet; net_iter.next(net_name, cnet); if (pattern->match(net_name)) - nets->push_back(reinterpret_cast(cnet)); + matches.push_back(reinterpret_cast(cnet)); } } else { ConcreteNet *cnet = findNet(pattern->pattern()); if (cnet) - nets->push_back(reinterpret_cast(cnet)); + matches.push_back(reinterpret_cast(cnet)); } } @@ -1654,6 +1718,7 @@ ConcretePin::ConcretePin(ConcreteInstance *instance, port_(port), net_(net), term_(nullptr), + id_(ConcreteNetwork::nextObjectId()), net_next_(nullptr), net_prev_(nullptr), vertex_id_(vertex_id_null) @@ -1687,6 +1752,7 @@ ConcreteTerm::ConcreteTerm(ConcretePin *pin, ConcreteNet *net) : pin_(pin), net_(net), + id_(ConcreteNetwork::nextObjectId()), net_next_(nullptr) { } @@ -1696,6 +1762,7 @@ ConcreteTerm::ConcreteTerm(ConcretePin *pin, ConcreteNet::ConcreteNet(const char *name, ConcreteInstance *instance) : name_(stringCopy(name)), + id_(ConcreteNetwork::nextObjectId()), instance_(instance), pins_(nullptr), terms_(nullptr), diff --git a/network/HpinDrvrLoad.cc b/network/HpinDrvrLoad.cc index 07551c55..c782de75 100644 --- a/network/HpinDrvrLoad.cc +++ b/network/HpinDrvrLoad.cc @@ -51,10 +51,10 @@ visitHpinDrvrLoads(const Pin *pin, const Network *network, HpinDrvrLoadVisitor *visitor) { - NetSet visited; + NetSet visited(network); HpinDrvrLoads above_drvrs; HpinDrvrLoads above_loads; - PinSet hpin_path; + PinSet hpin_path(network); Net *above_net = network->net(pin); if (above_net) { visitPinsAboveNet2(pin, above_net, visited, @@ -113,7 +113,7 @@ visitPinsAboveNet2(const Pin *hpin, // Visit above net pins. NetPinIterator *pin_iter = network->pinIterator(above_net); while (pin_iter->hasNext()) { - Pin *above_pin = pin_iter->next(); + const Pin *above_pin = pin_iter->next(); if (above_pin != hpin) { if (network->isDriver(above_pin)) { HpinDrvrLoad *drvr = new HpinDrvrLoad(above_pin, nullptr, @@ -185,7 +185,7 @@ visitPinsBelowNet2(const Pin *hpin, // Visit below net pins. NetPinIterator *pin_iter = network->pinIterator(below_net); while (pin_iter->hasNext()) { - Pin *below_pin = pin_iter->next(); + const Pin *below_pin = pin_iter->next(); if (below_pin != hpin) { if (above_net && !visited.hasKey(above_net)) visitPinsAboveNet2(below_pin, above_net, @@ -260,8 +260,8 @@ visitHpinDrvrLoads(HpinDrvrLoads drvrs, //////////////////////////////////////////////////////////////// -HpinDrvrLoad::HpinDrvrLoad(Pin *drvr, - Pin *load, +HpinDrvrLoad::HpinDrvrLoad(const Pin *drvr, + const Pin *load, PinSet *hpins_from_drvr, PinSet *hpins_to_load) : drvr_(drvr), @@ -271,8 +271,8 @@ HpinDrvrLoad::HpinDrvrLoad(Pin *drvr, { } -HpinDrvrLoad::HpinDrvrLoad(Pin *drvr, - Pin *load) : +HpinDrvrLoad::HpinDrvrLoad(const Pin *drvr, + const Pin *load) : drvr_(drvr), load_(load) { @@ -292,20 +292,20 @@ HpinDrvrLoad::report(const Network *network) load_ ? network->pathName(load_) : "-"); PinSet::Iterator pin_iter(hpins_from_drvr_); while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + const Pin *pin = pin_iter.next(); printf("%s ", network->pathName(pin)); } printf("* "); PinSet::Iterator pin_iter2(hpins_to_load_); while (pin_iter2.hasNext()) { - Pin *pin = pin_iter2.next(); + const Pin *pin = pin_iter2.next(); printf("%s ", network->pathName(pin)); } printf("\n"); } void -HpinDrvrLoad::setDrvr(Pin *drvr) +HpinDrvrLoad::setDrvr(const Pin *drvr) { drvr_ = drvr; } @@ -314,11 +314,11 @@ bool HpinDrvrLoadLess::operator()(const HpinDrvrLoad *drvr_load1, const HpinDrvrLoad *drvr_load2) const { - Pin *load1 = drvr_load1->load(); - Pin *load2 = drvr_load2->load(); + const Pin *load1 = drvr_load1->load(); + const Pin *load2 = drvr_load2->load(); if (load1 == load2) { - Pin *drvr1 = drvr_load1->drvr(); - Pin *drvr2 = drvr_load2->drvr(); + const Pin *drvr1 = drvr_load1->drvr(); + const Pin *drvr2 = drvr_load2->drvr(); return drvr1 < drvr2; } else diff --git a/network/Network.cc b/network/Network.cc index da692e11..1853771e 100644 --- a/network/Network.cc +++ b/network/Network.cc @@ -191,10 +191,10 @@ Network::hasMembers(const Port *port) const const char * Network::pathName(const Instance *instance) const { - ConstInstanceSeq inst_path; + InstanceSeq inst_path; path(instance, inst_path); size_t name_length = 0; - ConstInstanceSeq::Iterator path_iter1(inst_path); + InstanceSeq::Iterator path_iter1(inst_path); while (path_iter1.hasNext()) { const Instance *inst = path_iter1.next(); name_length += strlen(name(inst)) + 1; @@ -234,8 +234,8 @@ Network::pathNameCmp(const Instance *inst1, else if (inst1 == inst2) return 0; else { - ConstInstanceSeq path1; - ConstInstanceSeq path2; + InstanceSeq path1; + InstanceSeq path2; path(inst1, path1); path(inst2, path2); while (!path1.empty() && !path2.empty()) { @@ -259,7 +259,7 @@ Network::pathNameCmp(const Instance *inst1, void Network::path(const Instance *inst, // Return value. - ConstInstanceSeq &path) const + InstanceSeq &path) const { while (!isTopInstance(inst)) { path.push_back(inst); @@ -454,16 +454,16 @@ Network::highestNetAbove(Net *net) const return highest_net; } -Net * +const Net * Network::highestConnectedNet(Net *net) const { - NetSet nets; + NetSet nets(this); connectedNets(net, &nets); - Net *highest_net = net; + const Net *highest_net = net; int highest_level = hierarchyLevel(net); NetSet::Iterator net_iter(nets); while (net_iter.hasNext()) { - Net *net1 = net_iter.next(); + const Net *net1 = net_iter.next(); int level = hierarchyLevel(net1); if (level < highest_level || (level == highest_level @@ -497,7 +497,7 @@ Network::connectedNets(Net *net, // Search down from net pins. NetPinIterator *pin_iter = pinIterator(net); while (pin_iter->hasNext()) { - Pin *pin1 = pin_iter->next(); + const Pin *pin1 = pin_iter->next(); Term *below_term = term(pin1); if (below_term) { Net *below_net = this->net(below_term); @@ -653,30 +653,31 @@ Network::findInstanceRelative(const Instance *inst, return findChild(inst, path_name); } -void +InstanceSeq Network::findInstancesMatching(const Instance *context, - const PatternMatch *pattern, - InstanceSeq *insts) const + const PatternMatch *pattern) const { + InstanceSeq matches; if (pattern->hasWildcards()) { size_t context_name_length = 0; if (context != topInstance()) // Add one for the trailing divider. context_name_length = strlen(pathName(context)) + 1; - findInstancesMatching1(context, context_name_length, pattern, insts); + findInstancesMatching1(context, context_name_length, pattern, matches); } else { Instance *inst = findInstanceRelative(context, pattern->pattern()); if (inst) - insts->push_back(inst); + matches.push_back(inst); } + return matches; } void Network::findInstancesMatching1(const Instance *context, size_t context_name_length, const PatternMatch *pattern, - InstanceSeq *insts) const + InstanceSeq &matches) const { InstanceChildIterator *child_iter = childIterator(context); while (child_iter->hasNext()) { @@ -685,26 +686,34 @@ Network::findInstancesMatching1(const Instance *context, // Remove context prefix from the name. const char *child_context_name = &child_name[context_name_length]; if (pattern->match(child_context_name)) - insts->push_back(child); + matches.push_back(child); if (!isLeaf(child)) - findInstancesMatching1(child, context_name_length, pattern, insts); + findInstancesMatching1(child, context_name_length, pattern, matches); } delete child_iter; } -void +InstanceSeq Network::findInstancesHierMatching(const Instance *instance, - const PatternMatch *pattern, - // Return value. - InstanceSeq *insts) const + const PatternMatch *pattern) const +{ + InstanceSeq matches; + findInstancesHierMatching1(instance, pattern, matches); + return matches; +} + +void +Network::findInstancesHierMatching1(const Instance *instance, + const PatternMatch *pattern, + InstanceSeq &matches) const { InstanceChildIterator *child_iter = childIterator(instance); while (child_iter->hasNext()) { Instance *child = child_iter->next(); if (pattern->match(name(child))) - insts->push_back(child); + matches.push_back(child); if (!isLeaf(child)) - findInstancesHierMatching(child, pattern, insts); + findInstancesHierMatching1(child, pattern, matches); } delete child_iter; } @@ -712,21 +721,21 @@ Network::findInstancesHierMatching(const Instance *instance, void Network::findChildrenMatching(const Instance *parent, const PatternMatch *pattern, - InstanceSeq *insts) const + InstanceSeq &matches) const { if (pattern->hasWildcards()) { InstanceChildIterator *child_iter = childIterator(parent); while (child_iter->hasNext()) { Instance *child = child_iter->next(); if (pattern->match(name(child))) - insts->push_back(child); + matches.push_back(child); } delete child_iter; } else { Instance *child = findChild(parent, pattern->pattern()); if (child) - insts->push_back(child); + matches.push_back(child); } } @@ -834,10 +843,19 @@ Network::findNetLinear(const Instance *instance, return nullptr; } +NetSeq +Network::findNetsMatching(const Instance *context, + const PatternMatch *pattern) const +{ + NetSeq matches; + findNetsMatching(context, pattern, matches); + return matches; +} + void Network::findNetsMatching(const Instance *context, const PatternMatch *pattern, - NetSeq *nets) const + NetSeq &matches) const { if (pattern->hasWildcards()) { char *inst_path, *net_name; @@ -845,99 +863,116 @@ Network::findNetsMatching(const Instance *context, if (inst_path) { PatternMatch inst_pattern(inst_path, pattern); PatternMatch net_pattern(net_name, pattern); - InstanceSeq insts; - findInstancesMatching(context, &inst_pattern, &insts); + InstanceSeq insts = findInstancesMatching(context, &inst_pattern); InstanceSeq::Iterator inst_iter(insts); while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - findNetsMatching(inst, &net_pattern, nets); + const Instance *inst = inst_iter.next(); + findNetsMatching(inst, &net_pattern, matches); } stringDelete(inst_path); stringDelete(net_name); } else // Top level net. - findInstNetsMatching(context, pattern, nets); + findInstNetsMatching(context, pattern, matches); } else { Net *net = findNet(pattern->pattern()); if (net) - nets->push_back(net); + matches.push_back(net); } } +NetSeq +Network::findNetsHierMatching(const Instance *instance, + const PatternMatch *pattern) const +{ + NetSeq matches; + findNetsHierMatching(instance, pattern, matches); + return matches; +} + void Network::findNetsHierMatching(const Instance *instance, const PatternMatch *pattern, - // Return value. - NetSeq *nets) const + NetSeq &matches) const { - findInstNetsMatching(instance, pattern, nets); + findInstNetsMatching(instance, pattern, matches); InstanceChildIterator *child_iter = childIterator(instance); while (child_iter->hasNext()) { Instance *child = child_iter->next(); - findNetsHierMatching(child, pattern, nets); + findNetsHierMatching(child, pattern, matches); } delete child_iter; } -void +NetSeq Network::findNetsMatchingLinear(const Instance *instance, - const PatternMatch *pattern, - NetSeq *nets) const + const PatternMatch *pattern) const { + NetSeq matches; InstanceNetIterator *net_iter = netIterator(instance); while (net_iter->hasNext()) { Net *net = net_iter->next(); if (pattern->match(name(net))) - nets->push_back(net); + matches.push_back(net); } delete net_iter; + return matches; } -void +PinSeq Network::findPinsMatching(const Instance *instance, - const PatternMatch *pattern, - PinSeq *pins) const + const PatternMatch *pattern) const { + PinSeq matches; if (pattern->hasWildcards()) { char *inst_path, *port_name; pathNameLast(pattern->pattern(), inst_path, port_name); if (inst_path) { PatternMatch inst_pattern(inst_path, pattern); PatternMatch port_pattern(port_name, pattern); - InstanceSeq insts; - findInstancesMatching(instance, &inst_pattern, &insts); + InstanceSeq insts = findInstancesMatching(instance, &inst_pattern); InstanceSeq::Iterator inst_iter(insts); while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - findInstPinsMatching(inst, &port_pattern, pins); + const Instance *inst = inst_iter.next(); + findInstPinsMatching(inst, &port_pattern, matches); } stringDelete(inst_path); stringDelete(port_name); } else // Top level pin. - findInstPinsMatching(instance, pattern, pins); + findInstPinsMatching(instance, pattern, matches); } else { Pin *pin = findPin(pattern->pattern()); if (pin) - pins->push_back(pin); + matches.push_back(pin); } + return matches; +} + +PinSeq +Network::findPinsHierMatching(const Instance *instance, + const PatternMatch *pattern) const +{ + PinSeq matches; + findPinsHierMatching(instance, pattern, matches); + return matches; } void Network::findPinsHierMatching(const Instance *instance, const PatternMatch *pattern, - // Return value. - PinSeq *pins) const + // Return value. + PinSeq &matches) const { InstanceChildIterator *child_iter = childIterator(instance); while (child_iter->hasNext()) { Instance *child = child_iter->next(); - findInstPinsHierMatching(child, pattern, pins); - findPinsHierMatching(child, pattern, pins); + findInstPinsHierMatching(child, pattern, matches); + findPinsHierMatching(child, pattern, matches); } delete child_iter; } @@ -946,17 +981,17 @@ void Network::findInstPinsHierMatching(const Instance *instance, const PatternMatch *pattern, // Return value. - PinSeq *pins) const + PinSeq &matches) const { const char *inst_name = name(instance); InstancePinIterator *pin_iter = pinIterator(instance); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); const char *port_name = name(port(pin)); string pin_name; stringPrint(pin_name, "%s%c%s", inst_name,divider_, port_name); if (pattern->match(pin_name.c_str())) - pins->push_back(pin); + matches.push_back(pin); } delete pin_iter; } @@ -964,21 +999,21 @@ Network::findInstPinsHierMatching(const Instance *instance, void Network::findInstPinsMatching(const Instance *instance, const PatternMatch *pattern, - PinSeq *pins) const + PinSeq &matches) const { if (pattern->hasWildcards()) { InstancePinIterator *pin_iter = pinIterator(instance); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (pattern->match(name(pin))) - pins->push_back(pin); + matches.push_back(pin); } delete pin_iter; } else { Pin *pin = findPin(instance, pattern->pattern()); if (pin) - pins->push_back(pin); + matches.push_back(pin); } } @@ -1188,10 +1223,10 @@ Network::leafInstanceIterator(const Instance *hier_inst) const //////////////////////////////////////////////////////////////// void -Network::visitConnectedPins(Pin *pin, +Network::visitConnectedPins(const Pin *pin, PinVisitor &visitor) const { - ConstNetSet visited_nets; + NetSet visited_nets(network_); Net *pin_net = net(pin); Term *pin_term = term(pin); if (pin_net) @@ -1212,14 +1247,14 @@ void Network::visitConnectedPins(const Net *net, PinVisitor &visitor) const { - ConstNetSet visited_nets; + NetSet visited_nets(this); visitConnectedPins(net, visitor, visited_nets); } void Network::visitConnectedPins(const Net *net, PinVisitor &visitor, - ConstNetSet &visited_nets) const + NetSet &visited_nets) const { if (!visited_nets.hasKey(net)) { visited_nets.insert(net); @@ -1241,7 +1276,7 @@ Network::visitConnectedPins(const Net *net, // Search down from net pins. NetPinIterator *pin_iter = pinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); visitor(pin); Term *below_term = term(pin); if (below_term) { @@ -1262,7 +1297,7 @@ public: explicit ConnectedPinIterator1(PinSet *pins); virtual ~ConnectedPinIterator1(); virtual bool hasNext(); - virtual Pin *next(); + virtual const Pin *next(); protected: PinSet::Iterator pin_iter_; @@ -1284,7 +1319,7 @@ ConnectedPinIterator1::hasNext() return pin_iter_.hasNext(); } -Pin * +const Pin * ConnectedPinIterator1::next() { return pin_iter_.next(); @@ -1294,7 +1329,7 @@ class FindConnectedPins : public PinVisitor { public: explicit FindConnectedPins(PinSet *pins); - virtual void operator()(Pin *pin); + virtual void operator()(const Pin *pin); protected: PinSet *pins_; @@ -1307,7 +1342,7 @@ FindConnectedPins::FindConnectedPins(PinSet *pins) : } void -FindConnectedPins::operator()(Pin *pin) +FindConnectedPins::operator()(const Pin *pin) { pins_->insert(pin); } @@ -1315,7 +1350,7 @@ FindConnectedPins::operator()(Pin *pin) NetConnectedPinIterator * Network::connectedPinIterator(const Net *net) const { - PinSet *pins = new PinSet; + PinSet *pins = new PinSet(this); FindConnectedPins visitor(pins); visitConnectedPins(net, visitor); return new ConnectedPinIterator1(pins); @@ -1324,7 +1359,7 @@ Network::connectedPinIterator(const Net *net) const PinConnectedPinIterator * Network::connectedPinIterator(const Pin *pin) const { - PinSet *pins = new PinSet; + PinSet *pins = new PinSet(this); pins->insert(const_cast(pin)); FindConnectedPins visitor(pins); @@ -1351,7 +1386,7 @@ Network::isConnected(const Net *net, if (this->net(pin) == net) return true; else { - ConstNetSet nets; + NetSet nets(this); return isConnected(net, pin, nets); } } @@ -1359,7 +1394,7 @@ Network::isConnected(const Net *net, bool Network::isConnected(const Net *net, const Pin *pin, - ConstNetSet &nets) const + NetSet &nets) const { if (!nets.hasKey(net)) { nets.insert(net); @@ -1387,7 +1422,7 @@ Network::isConnected(const Net *net, // Search down from net pins. NetPinIterator *pin_iter = pinIterator(net); while (pin_iter->hasNext()) { - Pin *pin1 = pin_iter->next(); + const Pin *pin1 = pin_iter->next(); if (pin1 == pin) { delete pin_iter; return true; @@ -1412,14 +1447,14 @@ bool Network::isConnected(const Net *net1, const Net *net2) const { - ConstNetSet nets; + NetSet nets(this); return isConnected(net1, net2, nets); } bool Network::isConnected(const Net *net1, const Net *net2, - ConstNetSet &nets) const + NetSet &nets) const { if (net1 == net2) return true; @@ -1443,7 +1478,7 @@ Network::isConnected(const Net *net1, // Search down from net pins. NetPinIterator *pin_iter = pinIterator(net1); while (pin_iter->hasNext()) { - Pin *pin1 = pin_iter->next(); + const Pin *pin1 = pin_iter->next(); Term *below_term = term(pin1); if (below_term) { Net *below_net = net(below_term); @@ -1465,7 +1500,7 @@ class FindDrvrPins : public PinVisitor public: explicit FindDrvrPins(PinSet *pins, const Network *network); - virtual void operator()(Pin *pin); + virtual void operator()(const Pin *pin); protected: PinSet *pins_; @@ -1481,7 +1516,7 @@ FindDrvrPins::FindDrvrPins(PinSet *pins, } void -FindDrvrPins::operator()(Pin *pin) +FindDrvrPins::operator()(const Pin *pin) { if (network_->isDriver(pin)) pins_->insert(pin); @@ -1508,7 +1543,7 @@ Network::drivers(const Net *net) { PinSet *drvrs = net_drvr_pin_map_.findKey(net); if (drvrs == nullptr) { - drvrs = new PinSet; + drvrs = new PinSet(this); FindDrvrPins visitor(drvrs, this); visitConnectedPins(net, visitor); net_drvr_pin_map_[net] = drvrs; @@ -1601,7 +1636,8 @@ NetworkConstantPinIterator(const Network *network, NetSet &zero_nets, NetSet &one_nets) : ConstantPinIterator(), - network_(network) + network_(network), + constant_pins_{PinSet(network), PinSet(network)} { findConstantPins(zero_nets, constant_pins_[0]); findConstantPins(one_nets, constant_pins_[1]); @@ -1623,7 +1659,7 @@ NetworkConstantPinIterator::findConstantPins(NetSet &nets, const Net *net = net_iter.next(); NetConnectedPinIterator *pin_iter = network_->connectedPinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); pins.insert(pin); } delete pin_iter; @@ -1646,7 +1682,7 @@ NetworkConstantPinIterator::hasNext() } void -NetworkConstantPinIterator::next(Pin *&pin, +NetworkConstantPinIterator::next(const Pin *&pin, LogicValue &value) { pin = pin_iter_->next(); @@ -1655,7 +1691,7 @@ NetworkConstantPinIterator::next(Pin *&pin, //////////////////////////////////////////////////////////////// -FindNetDrvrLoads::FindNetDrvrLoads(Pin *drvr_pin, +FindNetDrvrLoads::FindNetDrvrLoads(const Pin *drvr_pin, PinSet &visited_drvrs, PinSeq &loads, PinSeq &drvrs, @@ -1669,7 +1705,7 @@ FindNetDrvrLoads::FindNetDrvrLoads(Pin *drvr_pin, } void -FindNetDrvrLoads::operator()(Pin *pin) +FindNetDrvrLoads::operator()(const Pin *pin) { if (network_->isLoad(pin)) loads_.push_back(pin); @@ -1694,7 +1730,7 @@ visitPinsAboveNet1(const Pin *hpin, // Visit above net pins. NetPinIterator *pin_iter = network->pinIterator(above_net); while (pin_iter->hasNext()) { - Pin *above_pin = pin_iter->next(); + const Pin *above_pin = pin_iter->next(); if (above_pin != hpin) { if (network->isDriver(above_pin)) above_drvrs.insert(above_pin); @@ -1743,9 +1779,9 @@ visitPinsBelowNet1(const Pin *hpin, // Visit below net pins. NetPinIterator *pin_iter = network->pinIterator(below_net); while (pin_iter->hasNext()) { - Pin *below_pin = pin_iter->next(); + const Pin *below_pin = pin_iter->next(); if (below_pin != hpin) { - NetSet visited_above; + NetSet visited_above(network); if (network->isDriver(below_pin)) below_drvrs.insert(below_pin); if (network->isLoad(below_pin)) @@ -1771,10 +1807,10 @@ visitDrvrLoads(PinSet drvrs, { PinSet::Iterator drvr_iter(drvrs); while (drvr_iter.hasNext()) { - Pin *drvr = drvr_iter.next(); + const Pin *drvr = drvr_iter.next(); PinSet::Iterator load_iter(loads); while (load_iter.hasNext()) { - Pin *load = load_iter.next(); + const Pin *load = load_iter.next(); visitor->visit(drvr, load); } } @@ -1792,13 +1828,13 @@ visitDrvrLoadsThruHierPin(const Pin *hpin, if (term) { Net *below_net = network->net(term); if (below_net) { - NetSet visited; - PinSet above_drvrs; - PinSet above_loads; + NetSet visited(network); + PinSet above_drvrs(network); + PinSet above_loads(network); visitPinsAboveNet1(hpin, above_net, visited, above_drvrs, above_loads, network); - PinSet below_drvrs; - PinSet below_loads; + PinSet below_drvrs(network); + PinSet below_loads(network); visitPinsBelowNet1(hpin, below_net, visited, below_drvrs, below_loads, network); visitDrvrLoads(above_drvrs, below_loads, visitor); @@ -1809,20 +1845,20 @@ visitDrvrLoadsThruHierPin(const Pin *hpin, } void -visitDrvrLoadsThruNet(Net *net, +visitDrvrLoadsThruNet(const Net *net, const Network *network, HierPinThruVisitor *visitor) { - NetSet visited; - PinSet above_drvrs; - PinSet above_loads; - PinSet below_drvrs; - PinSet below_loads; - PinSet net_drvrs; - PinSet net_loads; + NetSet visited(network); + PinSet above_drvrs(network); + PinSet above_loads(network); + PinSet below_drvrs(network); + PinSet below_loads(network); + PinSet net_drvrs(network); + PinSet net_loads(network); NetPinIterator *pin_iter = network->pinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (network->isHierarchical(pin)) { // Search down from pin terminal. const Term *term = network->term(pin); @@ -1877,13 +1913,200 @@ logicValueString(LogicValue value) return str[int(value)]; } -bool -PortPairLess::operator()(const PortPair *pair1, - const PortPair *pair2) const +//////////////////////////////////////////////////////////////// + +CellIdLess::CellIdLess(const Network *network) : + network_(network) { - return pair1->first < pair2->first - || (pair1->first == pair2->first - && pair1->second < pair2->second); +} + +bool +CellIdLess::operator()(const Cell *cell1, + const Cell *cell2) const +{ + return network_->id(cell1) < network_->id(cell2); +} + +PortIdLess::PortIdLess(const Network *network) : + network_(network) +{ +} + +bool +PortIdLess::operator()(const Port *port1, + const Port *port2) const +{ + return network_->id(port1) < network_->id(port2); +} + +InstanceIdLess::InstanceIdLess(const Network *network) : + network_(network) +{ +} + +bool +InstanceIdLess::operator()(const Instance *inst1, + const Instance *inst2) const +{ + return network_->id(inst1) < network_->id(inst2); +} + +PinIdLess::PinIdLess(const Network *network) : + network_(network) +{ +} + +bool +PinIdLess::operator()(const Pin *pin1, + const Pin *pin2) const +{ + return network_->id(pin1) < network_->id(pin2); +} + +PinIdHash::PinIdHash(const Network *network) : + network_(network) +{ +} + +size_t +PinIdHash::operator()(const Pin *pin) const +{ + return network_->id(pin); +} + +NetIdLess::NetIdLess(const Network *network) : + network_(network) +{ +} + +bool +NetIdLess::operator()(const Net *net1, + const Net *net2) const +{ + return network_->id(net1) < network_->id(net2); +} + +//////////////////////////////////////////////////////////////// + +CellSet::CellSet(const Network *network) : + Set(CellIdLess(network)) +{ +} + +PortSet::PortSet(const Network *network) : + Set(PortIdLess(network)) +{ +} + +InstanceSet::InstanceSet() : + Set(InstanceIdLess(nullptr)) +{ +} + +InstanceSet::InstanceSet(const Network *network) : + Set(InstanceIdLess(network)) +{ +} + +int +InstanceSet::compare(const InstanceSet *set1, + const InstanceSet *set2, + const Network *network) +{ + size_t size1 = set1 ? set1->size() : 0; + size_t size2 = set2 ? set2->size() : 0; + if (size1 == size2) { + InstanceSet::ConstIterator iter1(set1); + InstanceSet::ConstIterator iter2(set2); + while (iter1.hasNext() && iter2.hasNext()) { + const Instance *inst1 = iter1.next(); + const Instance *inst2 = iter2.next(); + ObjectId id1 = network->id(inst1); + ObjectId id2 = network->id(inst2); + if (id1 < id2) + return -1; + else if (id1 > id2) + return 1; + } + // Sets are equal. + return 0; + } + else + return (size1 > size2) ? 1 : -1; +} + +PinSet::PinSet() : + Set(PinIdLess(nullptr)) +{ +} + +PinSet::PinSet(const Network *network) : + Set(PinIdLess(network)) +{ +} + +int +PinSet::compare(const PinSet *set1, + const PinSet *set2, + const Network *network) +{ + size_t size1 = set1 ? set1->size() : 0; + size_t size2 = set2 ? set2->size() : 0; + if (size1 == size2) { + PinSet::ConstIterator iter1(set1); + PinSet::ConstIterator iter2(set2); + while (iter1.hasNext() && iter2.hasNext()) { + const Pin *pin1 = iter1.next(); + const Pin *pin2 = iter2.next(); + ObjectId id1 = network->id(pin1); + ObjectId id2 = network->id(pin2); + if (id1 < id2) + return -1; + else if (id1 > id2) + return 1; + } + // Sets are equal. + return 0; + } + else + return (size1 > size2) ? 1 : -1; +} + +NetSet::NetSet() : + Set(NetIdLess(nullptr)) +{ +} + +NetSet::NetSet(const Network *network) : + Set(NetIdLess(network)) +{ +} + +int +NetSet::compare(const NetSet *set1, + const NetSet *set2, + const Network *network) +{ + size_t size1 = set1 ? set1->size() : 0; + size_t size2 = set2 ? set2->size() : 0; + if (size1 == size2) { + NetSet::ConstIterator iter1(set1); + NetSet::ConstIterator iter2(set2); + while (iter1.hasNext() && iter2.hasNext()) { + const Net *net1 = iter1.next(); + const Net *net2 = iter2.next(); + ObjectId id1 = network->id(net1); + ObjectId id2 = network->id(net2); + if (id1 < id2) + return -1; + else if (id1 > id2) + return 1; + } + // Sets are equal. + return 0; + } + else + return (size1 > size2) ? 1 : -1; } } // namespace diff --git a/network/NetworkCmp.cc b/network/NetworkCmp.cc index 14ae3db4..03a33204 100644 --- a/network/NetworkCmp.cc +++ b/network/NetworkCmp.cc @@ -74,50 +74,48 @@ InstancePathNameLess::operator()(const Instance *inst1, //////////////////////////////////////////////////////////////// -void -sortPinSet(PinSet *set, - const Network *network, - PinSeq &pins) +PinSeq +sortByPathName(const PinSet *set, + const Network *network) { - PinSet::Iterator pin_iter(set); - while (pin_iter.hasNext()) - pins.push_back(pin_iter.next()); + PinSeq pins; + for (const Pin *pin : *set) + pins.push_back(pin); sort(pins, PinPathNameLess(network)); + return pins; } -void -sortPortSet(PortSet *set, - const Network *network, - PortSeq &ports) +PortSeq +sortByName(const PortSet *set, + const Network *network) { - PortSet::Iterator port_iter(set); - while (port_iter.hasNext()) - ports.push_back(port_iter.next()); + PortSeq ports; + for (const Port *port : *set) + ports.push_back(port); sort(ports, PortNameLess(network)); + return ports; } -void -sortInstanceSet(InstanceSet *set, - const Network *network, - InstanceSeq &insts) +InstanceSeq +sortByPathName(InstanceSet *set, + const Network *network) { - InstanceSet::Iterator inst_iter(set); - while (inst_iter.hasNext()) - insts.push_back(inst_iter.next()); - // Sort ports so regression results are portable. + InstanceSeq insts; + for (const Instance *inst : *set) + insts.push_back(inst); sort(insts, InstancePathNameLess(network)); + return insts; } -void -sortNetSet(NetSet *set, - const Network *network, - NetSeq &nets) +NetSeq +sortByPathName(NetSet *set, + const Network *network) { - NetSet::Iterator net_iter(set); - while (net_iter.hasNext()) - nets.push_back(net_iter.next()); - // Sort nets so regression results are netable. + NetSeq nets; + for (const Net *net : *set) + nets.push_back(net); sort(nets, NetPathNameLess(network)); + return nets; } } // namespace diff --git a/network/SdcNetwork.cc b/network/SdcNetwork.cc index e77a30a2..99a4ee70 100644 --- a/network/SdcNetwork.cc +++ b/network/SdcNetwork.cc @@ -86,6 +86,12 @@ NetworkNameAdapter::name(const Library *library) const return network_->name(library); } +ObjectId +NetworkNameAdapter::id(const Library *library) const +{ + return network_->id(library); +} + Cell * NetworkNameAdapter::findCell(const Library *library, const char *name) const @@ -93,12 +99,11 @@ NetworkNameAdapter::findCell(const Library *library, return network_->findCell(library, name); } -void +CellSeq NetworkNameAdapter::findCellsMatching(const Library *library, - const PatternMatch *pattern, - CellSeq *cells) const + const PatternMatch *pattern) const { - network_->findCellsMatching(library, pattern, cells); + return network_->findCellsMatching(library, pattern); } //////////////////////////////////////////////////////////////// @@ -109,6 +114,12 @@ NetworkNameAdapter::name(const Cell *cell) const return network_->name(cell); } +ObjectId +NetworkNameAdapter::id(const Cell *cell) const +{ + return network_->id(cell); +} + Library * NetworkNameAdapter::library(const Cell *cell) const { @@ -152,12 +163,11 @@ NetworkNameAdapter::findPort(const Cell *cell, return network_->findPort(cell, name); } -void +PortSeq NetworkNameAdapter::findPortsMatching(const Cell *cell, - const PatternMatch *pattern, - PortSeq *ports) const + const PatternMatch *pattern) const { - network_->findPortsMatching(cell, pattern, ports); + return network_->findPortsMatching(cell, pattern); } bool @@ -192,6 +202,12 @@ NetworkNameAdapter::name(const Port *port) const return network_->name(port); } +ObjectId +NetworkNameAdapter::id(const Port *port) const +{ + return network_->id(port); +} + Cell * NetworkNameAdapter::cell(const Port *port) const { @@ -297,6 +313,12 @@ NetworkNameAdapter::memberIterator(const Port *port) const //////////////////////////////////////////////////////////////// +ObjectId +NetworkNameAdapter::id(const Instance *instance) const +{ + return network_->id(instance); +} + Cell * NetworkNameAdapter::cell(const Instance *instance) const { @@ -347,6 +369,12 @@ NetworkNameAdapter::netIterator(const Instance *instance) const return network_->netIterator(instance); } +ObjectId +NetworkNameAdapter::id(const Pin *pin) const +{ + return network_->id(pin); +} + Port * NetworkNameAdapter::port(const Pin *pin) const { @@ -377,6 +405,12 @@ NetworkNameAdapter::direction(const Pin *pin) const return network_->direction(pin); } +ObjectId +NetworkNameAdapter::id(const Term *term) const +{ + return network_->id(term); +} + Net * NetworkNameAdapter::net(const Term *term) const { @@ -389,6 +423,12 @@ NetworkNameAdapter::pin(const Term *term) const return network_->pin(term); } +ObjectId +NetworkNameAdapter::id(const Net *net) const +{ + return network_->id(net); +} + Instance * NetworkNameAdapter::instance(const Net *net) const { @@ -611,13 +651,12 @@ SdcNetwork::findPort(const Cell *cell, return port; } -void +PortSeq SdcNetwork::findPortsMatching(const Cell *cell, - const PatternMatch *pattern, - PortSeq *ports) const + const PatternMatch *pattern) const { - network_->findPortsMatching(cell, pattern, ports); - if (ports->empty()) { + PortSeq matches = network_->findPortsMatching(cell, pattern); + if (matches.empty()) { // Look for matches after escaping brackets. char *bus_name; int index; @@ -625,19 +664,20 @@ SdcNetwork::findPortsMatching(const Cell *cell, if (bus_name) { const char *escaped1 = escapeBrackets(pattern->pattern(), this); PatternMatch escaped_pattern1(escaped1, pattern); - network_->findPortsMatching(cell, &escaped_pattern1, ports); - if (ports->empty() + matches = network_->findPortsMatching(cell, &escaped_pattern1); + if (matches.empty() && bus_name[strlen(bus_name) - 1] == ']') { // Try escaping base foo\[0\][1] const char *escaped2 = stringPrintTmp("%s[%d]", escapeBrackets(bus_name, this), index); PatternMatch escaped_pattern2(escaped2, pattern); - network_->findPortsMatching(cell, &escaped_pattern2, ports); + matches = network_->findPortsMatching(cell, &escaped_pattern2); } stringDelete(bus_name); } } + return matches; } const char * @@ -704,18 +744,27 @@ SdcNetwork::findInstance(const char *path_name) const return child; } -void +InstanceSeq SdcNetwork::findInstancesMatching(const Instance *context, - const PatternMatch *pattern, - InstanceSeq *insts) const + const PatternMatch *pattern) const +{ + InstanceSeq matches; + findInstancesMatching1(context, pattern, matches); + return matches; +} + +void +SdcNetwork::findInstancesMatching1(const Instance *context, + const PatternMatch *pattern, + InstanceSeq &matches) const { visitMatches(context, pattern, [&](const Instance *instance, const PatternMatch *tail) { - size_t match_count = insts->size(); - network_->findChildrenMatching(instance, tail, insts); - return insts->size() != match_count; + size_t match_count = matches.size(); + network_->findChildrenMatching(instance, tail, matches); + return matches.size() != match_count; }); } @@ -756,38 +805,39 @@ SdcNetwork::findNet(const Instance *instance, return net; } -void +NetSeq SdcNetwork::findNetsMatching(const Instance *parent, - const PatternMatch *pattern, - NetSeq *nets) const + const PatternMatch *pattern) const { + NetSeq matches; visitMatches(parent, pattern, [&](const Instance *instance, const PatternMatch *tail) { - size_t match_count = nets->size(); - network_->findInstNetsMatching(instance, tail, nets); - return nets->size() != match_count; + size_t match_count = matches.size(); + network_->findInstNetsMatching(instance, tail, matches); + return matches.size() != match_count; }); + return matches; } void SdcNetwork::findInstNetsMatching(const Instance *instance, const PatternMatch *pattern, - NetSeq *nets) const + NetSeq &matches) const { - network_->findInstNetsMatching(instance, pattern, nets); - if (nets->empty()) { + network_->findInstNetsMatching(instance, pattern, matches); + if (matches.empty()) { // Look for matches after escaping path dividers. const PatternMatch escaped_dividers(escapeDividers(pattern->pattern(), this), pattern); - network_->findInstNetsMatching(instance, &escaped_dividers, nets); - if (nets->empty()) { + network_->findInstNetsMatching(instance, &escaped_dividers, matches); + if (matches.empty()) { // Look for matches after escaping brackets. const PatternMatch escaped_brkts(escapeBrackets(pattern->pattern(),this), pattern); - network_->findInstNetsMatching(instance, &escaped_brkts, nets); + network_->findInstNetsMatching(instance, &escaped_brkts, matches); } } } @@ -833,11 +883,11 @@ SdcNetwork::findPin(const Instance *instance, } // Top level ports are not considered pins by get_pins. -void +PinSeq SdcNetwork::findPinsMatching(const Instance *instance, - const PatternMatch *pattern, - PinSeq *pins) const + const PatternMatch *pattern) const { + PinSeq matches; if (stringEq(pattern->pattern(), "*")) { // Pattern of '*' matches all child instance pins. InstanceChildIterator *child_iter = childIterator(instance); @@ -845,8 +895,8 @@ SdcNetwork::findPinsMatching(const Instance *instance, Instance *child = child_iter->next(); InstancePinIterator *pin_iter = pinIterator(child); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); - pins->push_back(pin); + const Pin *pin = pin_iter->next(); + matches.push_back(pin); } delete pin_iter; } @@ -857,14 +907,15 @@ SdcNetwork::findPinsMatching(const Instance *instance, [&](const Instance *instance, const PatternMatch *tail) { - return visitPinTail(instance, tail, pins); + return visitPinTail(instance, tail, matches); }); + return matches; } bool SdcNetwork::visitPinTail(const Instance *instance, const PatternMatch *tail, - PinSeq *pins) const + PinSeq &matches) const { bool found_match = false; if (instance != network_->topInstance()) { @@ -879,17 +930,17 @@ SdcNetwork::visitPinTail(const Instance *instance, PortMemberIterator *member_iter = network_->memberIterator(port); while (member_iter->hasNext()) { Port *member_port = member_iter->next(); - Pin *pin = network_->findPin(instance, member_port); + const Pin *pin = network_->findPin(instance, member_port); if (pin) { if (bus_matches) { - pins->push_back(pin); + matches.push_back(pin); found_match = true; } else { const char *member_name = network_->name(member_port); if (tail->match(member_name) || tail->match(escapeDividers(member_name, network_))) { - pins->push_back(pin); + matches.push_back(pin); found_match = true; } } @@ -901,7 +952,7 @@ SdcNetwork::visitPinTail(const Instance *instance, || tail->match(escapeDividers(port_name, network_))) { Pin *pin = network_->findPin(instance, port); if (pin) { - pins->push_back(pin); + matches.push_back(pin); found_match = true; } } @@ -1067,19 +1118,19 @@ SdcNetwork::visitMatches(const Instance *parent, *p = '\0'; PatternMatch matcher(inst_path, pattern); InstanceSeq matches; - findChildrenMatching(parent, &matcher, &matches); + findChildrenMatching(parent, &matcher, matches); if (has_brkts && matches.empty()) { // Look for matches after escaping brackets. const PatternMatch escaped_brkts(escapeBrackets(inst_path, this), pattern); - network_->findChildrenMatching(parent, &escaped_brkts, &matches); + network_->findChildrenMatching(parent, &escaped_brkts, matches); } if (!matches.empty()) { // Found instance matches for the sub-path up to this divider. const PatternMatch tail_pattern(s + 1, pattern); InstanceSeq::Iterator match_iter(matches); while (match_iter.hasNext()) { - Instance *match = match_iter.next(); + const Instance *match = match_iter.next(); // Recurse to save the iterator state so we can iterate over // multiple nested partial matches. found_match |= visitMatches(match, &tail_pattern, visit_tail); diff --git a/parasitics/ConcreteParasitics.cc b/parasitics/ConcreteParasitics.cc index bd3abb13..f5c213c9 100644 --- a/parasitics/ConcreteParasitics.cc +++ b/parasitics/ConcreteParasitics.cc @@ -692,7 +692,7 @@ ConcreteParasiticNetwork::deleteNodes() { ConcreteParasiticSubNodeMap::Iterator node_iter1(sub_nodes_); while (node_iter1.hasNext()) { - NetId *net_id; + NetIdPair *net_id; ConcreteParasiticSubNode *node; node_iter1.next(net_id, node); delete net_id; @@ -782,11 +782,11 @@ ConcreteParasiticNode * ConcreteParasiticNetwork::ensureParasiticNode(const Net *net, int id) { - NetId net_id(net, id); + NetIdPair net_id(net, id); ConcreteParasiticSubNode *node = sub_nodes_.findKey(&net_id); if (node == nullptr) { node = new ConcreteParasiticSubNode(net, id); - sub_nodes_[new NetId(net, id)] = node; + sub_nodes_[new NetIdPair(net, id)] = node; max_node_id_ = max((int) max_node_id_, id); } return node; @@ -800,7 +800,7 @@ ConcreteParasiticNetwork::findNode(const Pin *pin) void ConcreteParasiticNetwork::disconnectPin(const Pin *pin, - Net *net) + const Net *net) { ConcreteParasiticNode *node = pin_nodes_.findKey(pin); if (node) { @@ -831,8 +831,8 @@ ConcreteParasiticNetwork::ensureParasiticNode(const Pin *pin) } bool -NetIdLess::operator()(const NetId *net_id1, - const NetId *net_id2) const +NetIdPairLess::operator()(const NetIdPair *net_id1, + const NetIdPair *net_id2) const { const Net *net1 = net_id1->first; const Net *net2 = net_id2->first; @@ -957,9 +957,9 @@ ConcreteParasitics::capacitance(Parasitic *parasitic) const } bool -ConcreteParasitics::isReducedParasiticNetwork(Parasitic *parasitic) const +ConcreteParasitics::isReducedParasiticNetwork(const Parasitic *parasitic) const { - ConcreteParasitic *cparasitic = static_cast(parasitic); + const ConcreteParasitic *cparasitic = static_cast(parasitic); return cparasitic->isReducedParasiticNetwork(); } @@ -977,7 +977,7 @@ ConcreteParasitics::disconnectPinBefore(const Pin *pin) if (haveParasitics()) { deleteReducedParasitics(pin); - Net *net = findParasiticNet(pin); + const Net *net = findParasiticNet(pin); if (net) { ConcreteParasiticNetwork **parasitics = parasitic_network_map_[net]; if (parasitics) { @@ -1056,9 +1056,9 @@ ConcreteParasitics::deleteDrvrReducedParasitics(const Pin *drvr_pin, //////////////////////////////////////////////////////////////// bool -ConcreteParasitics::isPiElmore(Parasitic *parasitic) const +ConcreteParasitics::isPiElmore(const Parasitic *parasitic) const { - ConcreteParasitic *cparasitic = static_cast(parasitic); + const ConcreteParasitic *cparasitic = static_cast(parasitic); return cparasitic && cparasitic->isPiElmore(); } @@ -1126,19 +1126,19 @@ ConcreteParasitics::makePiElmore(const Pin *drvr_pin, //////////////////////////////////////////////////////////////// bool -ConcreteParasitics::isPiModel(Parasitic *parasitic) const +ConcreteParasitics::isPiModel(const Parasitic *parasitic) const { - ConcreteParasitic *cparasitic = static_cast(parasitic); + const ConcreteParasitic *cparasitic = static_cast(parasitic); return cparasitic && cparasitic->isPiModel(); } void -ConcreteParasitics::piModel(Parasitic *parasitic, +ConcreteParasitics::piModel(const Parasitic *parasitic, float &c2, float &rpi, float &c1) const { - ConcreteParasitic *cparasitic = static_cast(parasitic); + const ConcreteParasitic *cparasitic = static_cast(parasitic); cparasitic->piModel(c2, rpi, c1); } @@ -1155,12 +1155,12 @@ ConcreteParasitics::setPiModel(Parasitic *parasitic, //////////////////////////////////////////////////////////////// void -ConcreteParasitics::findElmore(Parasitic *parasitic, +ConcreteParasitics::findElmore(const Parasitic *parasitic, const Pin *load_pin, float &elmore, bool &exists) const { - ConcreteParasitic *cparasitic = static_cast(parasitic); + const ConcreteParasitic *cparasitic = static_cast(parasitic); cparasitic->findElmore(load_pin, elmore, exists); } @@ -1176,9 +1176,9 @@ ConcreteParasitics::setElmore(Parasitic *parasitic, //////////////////////////////////////////////////////////////// bool -ConcreteParasitics::isPiPoleResidue(Parasitic* parasitic) const +ConcreteParasitics::isPiPoleResidue(const Parasitic* parasitic) const { - ConcreteParasitic *cparasitic = static_cast(parasitic); + const ConcreteParasitic *cparasitic = static_cast(parasitic); return cparasitic && cparasitic->isPiPoleResidue(); } @@ -1324,7 +1324,7 @@ ConcreteParasitics::findParasiticNetwork(const Pin *pin, UniqueLock lock(lock_); if (!parasitic_network_map_.empty()) { // Only call findParasiticNet if parasitics exist. - Net *net = findParasiticNet(pin); + const Net *net = findParasiticNet(pin); ConcreteParasiticNetwork **parasitics=parasitic_network_map_.findKey(net); if (parasitics) return parasitics[ap->index()]; @@ -1635,17 +1635,17 @@ ConcreteParasitics::unannotatedLoads(Parasitic *parasitic_network, ParasiticNode *drvr_node = findNode(parasitic_network, drvr_pin); if (drvr_node) return checkAnnotation1(drvr_pin, drvr_node); - return PinSet(); + return PinSet(network_); } PinSet ConcreteParasitics::checkAnnotation1(const Pin *drvr_pin, ParasiticNode *drvr_node) { - PinSet loads; + PinSet loads(network_); NetConnectedPinIterator *pin_iter = network_->connectedPinIterator(drvr_pin); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (network_->isLoad(pin) && !network_->isHierarchical(pin)) loads.insert(pin); } diff --git a/parasitics/ConcreteParasitics.hh b/parasitics/ConcreteParasitics.hh index 60247310..43934aaf 100644 --- a/parasitics/ConcreteParasitics.hh +++ b/parasitics/ConcreteParasitics.hh @@ -55,32 +55,42 @@ public: const ParasiticAnalysisPt *ap); virtual void deleteUnsavedParasitic(Parasitic *parasitic); - virtual bool isReducedParasiticNetwork(Parasitic *parasitic) const; + virtual bool isReducedParasiticNetwork(const Parasitic *parasitic) const; virtual void setIsReducedParasiticNetwork(Parasitic *parasitic, bool is_reduced); virtual float capacitance(Parasitic *parasitic) const; - virtual bool isPiElmore(Parasitic *parasitic) const; + virtual bool isPiElmore(const Parasitic *parasitic) const; virtual Parasitic *findPiElmore(const Pin *drvr_pin, const RiseFall *rf, const ParasiticAnalysisPt *ap) const; virtual Parasitic *makePiElmore(const Pin *drvr_pin, const RiseFall *rf, const ParasiticAnalysisPt *ap, - float c2, float rpi, float c1); + float c2, + float rpi, + float c1); - virtual bool isPiModel(Parasitic *parasitic) const; - virtual void piModel(Parasitic *parasitic, float &c2, float &rpi, + virtual bool isPiModel(const Parasitic *parasitic) const; + virtual void piModel(const Parasitic *parasitic, + float &c2, + float &rpi, float &c1) const; - virtual void setPiModel(Parasitic *parasitic, float c2, float rpi, float c1); + virtual void setPiModel(Parasitic *parasitic, + float c2, + float rpi, + float c1); - virtual void findElmore(Parasitic *parasitic, const Pin *load_pin, - float &elmore, bool &exists) const; - virtual void setElmore(Parasitic *parasitic, const Pin *load_pin, + virtual void findElmore(const Parasitic *parasitic, + const Pin *load_pin, + float &elmore, + bool &exists) const; + virtual void setElmore(Parasitic *parasitic, + const Pin *load_pin, float elmore); - virtual bool isPiPoleResidue(Parasitic* parasitic) const; + virtual bool isPiPoleResidue(const Parasitic* parasitic) const; virtual Parasitic *findPiPoleResidue(const Pin *drvr_pin, const RiseFall *rf, const ParasiticAnalysisPt *ap) const; diff --git a/parasitics/ConcreteParasiticsPvt.hh b/parasitics/ConcreteParasiticsPvt.hh index 3803be36..72d79e8b 100644 --- a/parasitics/ConcreteParasiticsPvt.hh +++ b/parasitics/ConcreteParasiticsPvt.hh @@ -29,14 +29,14 @@ class ConcreteParasiticNode; typedef Map ConcreteElmoreLoadMap; typedef ConcreteElmoreLoadMap::Iterator ConcretePiElmoreLoadIterator; typedef Map ConcretePoleResidueMap; -typedef std::pair NetId; -struct NetIdLess +typedef std::pair NetIdPair; +struct NetIdPairLess { - bool operator()(const NetId *net_id1, - const NetId *net_id2) const; + bool operator()(const NetIdPair *net_id1, + const NetIdPair *net_id2) const; }; -typedef Map ConcreteParasiticSubNodeMap; +typedef Map ConcreteParasiticSubNodeMap; typedef Map ConcreteParasiticPinNodeMap; typedef Vector ConcreteParasiticDeviceSeq; @@ -427,7 +427,7 @@ public: ConcreteParasiticPinNodeMap *pinNodes() { return &pin_nodes_; } ConcreteParasiticSubNodeMap *subNodes() { return &sub_nodes_; } void disconnectPin(const Pin *pin, - Net *net); + const Net *net); virtual ParasiticDeviceIterator *deviceIterator(); virtual ParasiticNodeIterator *nodeIterator(); virtual void devices(// Return value. diff --git a/parasitics/EstimateParasitics.cc b/parasitics/EstimateParasitics.cc index fb31f778..b7ac0cce 100644 --- a/parasitics/EstimateParasitics.cc +++ b/parasitics/EstimateParasitics.cc @@ -183,7 +183,7 @@ EstimateParasitics::estimatePiElmoreBalanced(const Pin *drvr_pin, load_cap = sdc->pinCapacitance(load_pin, rf, op_cond, corner, min_max); else if (network->isTopLevelPort(load_pin)) - load_cap = sdc->portExtCap(port, rf, min_max); + load_cap = sdc->portExtCap(port, rf, corner, min_max); else report->critical(597, "load pin not leaf or top level"); double cap = load_cap + cap_fanout; diff --git a/parasitics/NullParasitics.cc b/parasitics/NullParasitics.cc index 52c001c9..25b585d0 100644 --- a/parasitics/NullParasitics.cc +++ b/parasitics/NullParasitics.cc @@ -97,13 +97,13 @@ NullParasitics::makePiElmore(const Pin *, } bool -NullParasitics::isPiElmore(Parasitic *) const +NullParasitics::isPiElmore(const Parasitic *) const { return false; } bool -NullParasitics::isReducedParasiticNetwork(Parasitic *) const +NullParasitics::isReducedParasiticNetwork(const Parasitic *) const { return false; } @@ -115,7 +115,7 @@ NullParasitics::setIsReducedParasiticNetwork(Parasitic *, } void -NullParasitics::piModel(Parasitic *, +NullParasitics::piModel(const Parasitic *, float &, float &, float &) const @@ -131,7 +131,7 @@ NullParasitics::setPiModel(Parasitic *, } void -NullParasitics::findElmore(Parasitic *, +NullParasitics::findElmore(const Parasitic *, const Pin *, float &, bool &) const @@ -146,13 +146,13 @@ NullParasitics::setElmore(Parasitic *, } bool -NullParasitics::isPiModel(Parasitic*) const +NullParasitics::isPiModel(const Parasitic*) const { return false; } bool -NullParasitics::isPiPoleResidue(Parasitic* ) const +NullParasitics::isPiPoleResidue(const Parasitic* ) const { return false; } diff --git a/parasitics/Parasitics.cc b/parasitics/Parasitics.cc index 7b0aad9a..a5eef7dc 100644 --- a/parasitics/Parasitics.cc +++ b/parasitics/Parasitics.cc @@ -32,7 +32,7 @@ Parasitics::Parasitics(StaState *sta) : { } -Net * +const Net * Parasitics::findParasiticNet(const Pin *pin) const { Net *net = network_->net(pin); diff --git a/parasitics/Parasitics.i b/parasitics/Parasitics.i index 2f923f86..0f77c79a 100644 --- a/parasitics/Parasitics.i +++ b/parasitics/Parasitics.i @@ -27,7 +27,6 @@ using sta::MinMaxAll; using sta::ReducedParasiticType; using sta::RiseFall; using sta::Pin; -using sta::TmpFloatSeq; %} @@ -60,7 +59,7 @@ report_parasitic_annotation_cmd(bool report_unannotated, Sta::sta()->reportParasiticAnnotation(report_unannotated, corner); } -TmpFloatSeq * +FloatSeq find_pi_elmore(Pin *drvr_pin, RiseFall *rf, MinMax *min_max) @@ -68,13 +67,13 @@ find_pi_elmore(Pin *drvr_pin, float c2, rpi, c1; bool exists; Sta::sta()->findPiElmore(drvr_pin, rf, min_max, c2, rpi, c1, exists); - TmpFloatSeq *floats = new FloatSeq; + FloatSeq pi_elmore; if (exists) { - floats->push_back(c2); - floats->push_back(rpi); - floats->push_back(c1); + pi_elmore.push_back(c2); + pi_elmore.push_back(rpi); + pi_elmore.push_back(c1); } - return floats; + return pi_elmore; } float diff --git a/parasitics/ReduceParasitics.cc b/parasitics/ReduceParasitics.cc index aa6d07f5..b939ff3a 100644 --- a/parasitics/ReduceParasitics.cc +++ b/parasitics/ReduceParasitics.cc @@ -226,7 +226,7 @@ ReduceToPi::pinCapacitance(ParasiticNode *node) } } else if (network_->isTopLevelPort(pin)) - pin_cap = sdc_->portExtCap(port, rf_, cnst_min_max_); + pin_cap = sdc_->portExtCap(port, rf_, corner_, cnst_min_max_); } return pin_cap; } @@ -535,7 +535,7 @@ ReduceToPiPoleResidue2::findPolesResidues(Parasitic *parasitic_network, PinConnectedPinIterator *pin_iter = network_->connectedPinIterator(drvr_pin); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (network_->isLoad(pin)) { ParasiticNode *load_node = parasitics_->findNode(parasitic_network, pin); if (load_node) { diff --git a/parasitics/ReportParasiticAnnotation.cc b/parasitics/ReportParasiticAnnotation.cc index 204aeaf7..e34f7188 100644 --- a/parasitics/ReportParasiticAnnotation.cc +++ b/parasitics/ReportParasiticAnnotation.cc @@ -83,7 +83,7 @@ ReportParasiticAnnotation::reportAnnotationCounts() report_->reportLine("Found %lu unannotated drivers.", unannotated_.size()); if (report_unannotated_) { sort(unannotated_, PinPathNameLess(network_)); - for (Pin *drvr_pin : unannotated_) + for (const Pin *drvr_pin : unannotated_) report_->reportLine(" %s", network_->pathName(drvr_pin)); } @@ -91,12 +91,12 @@ ReportParasiticAnnotation::reportAnnotationCounts() partially_annotated_.size()); if (report_unannotated_) { sort(partially_annotated_, PinPathNameLess(network_)); - for (Pin *drvr_pin : partially_annotated_) { + for (const Pin *drvr_pin : partially_annotated_) { report_->reportLine(" %s", network_->pathName(drvr_pin)); Parasitic *parasitic = parasitics_->findParasiticNetwork(drvr_pin, parasitic_ap_); PinSet unannotated_loads = parasitics_->unannotatedLoads(parasitic, drvr_pin); - for (Pin *load_pin : unannotated_loads) + for (const Pin *load_pin : unannotated_loads) report_->reportLine(" %s", network_->pathName(load_pin)); } } diff --git a/power/Power.cc b/power/Power.cc index cea7f604..a3ee7888 100644 --- a/power/Power.cc +++ b/power/Power.cc @@ -74,6 +74,7 @@ Power::Power(StaState *sta) : StaState(sta), global_activity_{0.0, 0.0, PwrActivityOrigin::unknown}, input_activity_{0.1, 0.5, PwrActivityOrigin::input}, + seq_activity_map_(100, SeqPinHash(network_), SeqPinEqual()), activities_valid_(false) { } @@ -173,10 +174,15 @@ Power::seqActivity(const Instance *reg, return seq_activity_map_[SeqPin(reg, output)]; } +SeqPinHash::SeqPinHash(const Network *network) : + network_(network) +{ +} + size_t SeqPinHash::operator()(const SeqPin &pin) const { - return hashSum(hashPtr(pin.first), hashPtr(pin.second)); + return hashSum(network_->id(pin.first), pin.second->id()); } bool @@ -210,8 +216,7 @@ Power::power(const Corner *corner, Instance *inst = inst_iter->next(); LibertyCell *cell = network_->libertyCell(inst); if (cell) { - PowerResult inst_power; - power(inst, cell, corner, inst_power); + PowerResult inst_power = power(inst, cell, corner); if (cell->isMacro() || cell->isMemory()) macro.incr(inst_power); @@ -227,17 +232,16 @@ Power::power(const Corner *corner, delete inst_iter; } -void +PowerResult Power::power(const Instance *inst, - const Corner *corner, - // Return values. - PowerResult &result) + const Corner *corner) { LibertyCell *cell = network_->libertyCell(inst); if (cell) { ensureActivities(); - power(inst, cell, corner, result); + return power(inst, cell, corner); } + return PowerResult(); } //////////////////////////////////////////////////////////////// @@ -306,7 +310,7 @@ PropActivityVisitor::copy() const void PropActivityVisitor::init() { - visited_regs_ = new InstanceSet; + visited_regs_ = new InstanceSet(network_); found_reg_without_activity_ = false; } @@ -546,7 +550,7 @@ Power::ensureActivities() InstanceSet *regs = visitor.stealVisitedRegs(); InstanceSet::Iterator reg_iter(regs); while (reg_iter.hasNext()) { - Instance *reg = reg_iter.next(); + const Instance *reg = reg_iter.next(); // Propagate activiities across register D->Q. seedRegOutputActivities(reg, bfs); } @@ -636,13 +640,12 @@ Power::seedRegOutputActivities(const Instance *reg, //////////////////////////////////////////////////////////////// -void +PowerResult Power::power(const Instance *inst, LibertyCell *cell, - const Corner *corner, - // Return values. - PowerResult &result) + const Corner *corner) { + PowerResult result; MinMax *mm = MinMax::max(); const DcalcAnalysisPt *dcalc_ap = corner->findDcalcAnalysisPt(mm); const Clock *inst_clk = findInstClk(inst); @@ -667,6 +670,7 @@ Power::power(const Instance *inst, } delete pin_iter; findLeakagePower(inst, cell, corner, result); + return result; } const Clock * diff --git a/power/Power.hh b/power/Power.hh index 3b554f31..73a6110b 100644 --- a/power/Power.hh +++ b/power/Power.hh @@ -38,7 +38,11 @@ typedef std::pair SeqPin; class SeqPinHash { public: + SeqPinHash(const Network *network); size_t operator()(const SeqPin &pin) const; + +private: + const Network *network_; }; class SeqPinEqual @@ -65,10 +69,8 @@ public: PowerResult &combinational, PowerResult ¯o, PowerResult &pad); - void power(const Instance *inst, - const Corner *corner, - // Return values. - PowerResult &result); + PowerResult power(const Instance *inst, + const Corner *corner); void setGlobalActivity(float activity, float duty); void setInputActivity(float activity, @@ -99,11 +101,9 @@ protected: void setActivity(const Pin *pin, PwrActivity &activity); - void power(const Instance *inst, - LibertyCell *cell, - const Corner *corner, - // Return values. - PowerResult &result); + PowerResult power(const Instance *inst, + LibertyCell *cell, + const Corner *corner); void findInputInternalPower(const Pin *to_pin, const LibertyPort *to_port, const Instance *inst, diff --git a/power/Power.i b/power/Power.i index c30e174b..d69641e5 100644 --- a/power/Power.i +++ b/power/Power.i @@ -23,59 +23,49 @@ #include "power/VcdReader.hh" #include "power/ReadVcdActivities.hh" -namespace sta { - -typedef FloatSeq TmpFloatSeq; - -} // namespace - using namespace sta; %} -%typemap(out) TmpFloatSeq* { - FloatSeq *floats = $1; - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - if (floats) { - for (unsigned i = 0; i < floats->size(); i++) { - Tcl_Obj *obj = Tcl_NewDoubleObj((*floats)[i]); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete floats; - } - Tcl_SetObjResult(interp, list); -} - %inline %{ -TmpFloatSeq * +static void +pushPowerResultFloats(PowerResult &power, + FloatSeq &powers) +{ + powers.push_back(power.internal()); + powers.push_back(power.switching()); + powers.push_back(power.leakage()); + powers.push_back(power.total()); +} + +FloatSeq design_power(const Corner *corner) { cmdLinkedNetwork(); PowerResult total, sequential, combinational, macro, pad; Sta::sta()->power(corner, total, sequential, combinational, macro, pad); - FloatSeq *floats = new FloatSeq; - pushPowerResultFloats(total, floats); - pushPowerResultFloats(sequential, floats); - pushPowerResultFloats(combinational, floats); - pushPowerResultFloats(macro, floats); - pushPowerResultFloats(pad, floats); - return floats; + FloatSeq powers; + pushPowerResultFloats(total, powers); + pushPowerResultFloats(sequential, powers); + pushPowerResultFloats(combinational, powers); + pushPowerResultFloats(macro, powers); + pushPowerResultFloats(pad, powers); + return powers; } -TmpFloatSeq * +FloatSeq instance_power(Instance *inst, const Corner *corner) { cmdLinkedNetwork(); - PowerResult power; - Sta::sta()->power(inst, corner, power); - FloatSeq *floats = new FloatSeq; - floats->push_back(power.internal()); - floats->push_back(power.switching()); - floats->push_back(power.leakage()); - floats->push_back(power.total()); - return floats; + PowerResult power = Sta::sta()->power(inst, corner); + FloatSeq powers; + powers.push_back(power.internal()); + powers.push_back(power.switching()); + powers.push_back(power.leakage()); + powers.push_back(power.total()); + return powers; } void diff --git a/sdc/Clock.cc b/sdc/Clock.cc index 3758ebd9..f4e2cad1 100644 --- a/sdc/Clock.cc +++ b/sdc/Clock.cc @@ -33,9 +33,12 @@ static bool isPowerOfTwo(int i); Clock::Clock(const char *name, - int index) : + int index, + const Network *network) : name_(stringCopy(name)), + pins_(network), add_to_pins_(false), + leaf_pins_(network), period_(0.0), waveform_(nullptr), waveform_valid_(false), @@ -99,7 +102,7 @@ Clock::makeLeafPins(const Network *network) leaf_pins_.clear(); PinSet::Iterator pin_iter(pins_); while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + const Pin *pin = pin_iter.next(); findLeafDriverPins(pin, network, &leaf_pins_); } } @@ -135,14 +138,14 @@ Clock::~Clock() } void -Clock::addPin(Pin *pin) +Clock::addPin(const Pin *pin) { pins_.insert(pin); leaf_pins_.insert(pin); } void -Clock::deletePin(Pin *pin) +Clock::deletePin(const Pin *pin) { pins_.erase(pin); } @@ -167,7 +170,7 @@ Clock::setClkEdgeTime(const RiseFall *rf) clk_edges_[rf->index()]->setTime(time); } -Pin * +const Pin * Clock::defaultPin() const { PinSet::ConstIterator pin_iter(leaf_pins_); @@ -493,11 +496,11 @@ Clock::srcPinVertices(VertexSet &src_vertices, { if (network->isHierarchical(src_pin_)) { // Use the clocks on a non-hierarchical pin on the same net. - PinSet leaf_pins; + PinSet leaf_pins(network); findLeafDriverPins(src_pin_, network, &leaf_pins); PinSet::Iterator pin_iter(leaf_pins); while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + const Pin *pin = pin_iter.next(); Vertex *vertex, *bidirect_drvr_vertex; graph->pinVertices(pin, vertex, bidirect_drvr_vertex); if (vertex) @@ -585,8 +588,8 @@ clkCmp(const Clock *clk1, } int -clkEdgeCmp(ClockEdge *clk_edge1, - ClockEdge *clk_edge2) +clkEdgeCmp(const ClockEdge *clk_edge1, + const ClockEdge *clk_edge2) { if (clk_edge1 == nullptr && clk_edge2) return -1; @@ -607,8 +610,8 @@ clkEdgeCmp(ClockEdge *clk_edge1, } bool -clkEdgeLess(ClockEdge *clk_edge1, - ClockEdge *clk_edge2) +clkEdgeLess(const ClockEdge *clk_edge1, + const ClockEdge *clk_edge2) { return clkEdgeCmp(clk_edge1, clk_edge2) < 0; } @@ -683,14 +686,59 @@ ClockNameLess::operator()(const Clock *clk1, return stringLess(clk1->name(), clk2->name()); } -void -sortClockSet(ClockSet *set, - ClockSeq &clks) + +bool +ClockIndexLess::operator()(const Clock *clk1, + const Clock *clk2) const { - ClockSet::Iterator clk_iter(set); - while (clk_iter.hasNext()) - clks.push_back(clk_iter.next()); + return (clk1 == nullptr && clk2) + || (clk1 && clk2 + && clk1->index() < clk2->index()); +} + +ClockSeq +sortByName(ClockSet *set) +{ + ClockSeq clks; + for (Clock *clk : *set) + clks.push_back(clk); sort(clks, ClockNameLess()); + return clks; +} + +//////////////////////////////////////////////////////////////// + +bool +ClockSetLess::operator()(const ClockSet *set1, + const ClockSet *set2) const +{ + return sta::compare(set1, set2) < 0; +} + +int +compare(const ClockSet *set1, + const ClockSet *set2) +{ + size_t size1 = set1 ? set1->size() : 0; + size_t size2 = set2 ? set2->size() : 0; + if (size1 == size2) { + ClockSet::ConstIterator iter1(set1); + ClockSet::ConstIterator iter2(set2); + while (iter1.hasNext() && iter2.hasNext()) { + Clock *clk1 = iter1.next(); + Clock *clk2 = iter2.next(); + int id1 = clk1->index(); + int id2 = clk2->index(); + if (id1 < id2) + return -1; + else if (id1 > id2) + return 1; + } + // Sets are equal. + return 0; + } + else + return (size1 > size2) ? 1 : -1; } } // namespace diff --git a/sdc/ClockGroups.cc b/sdc/ClockGroups.cc index 60dc15f8..08a0c3bb 100644 --- a/sdc/ClockGroups.cc +++ b/sdc/ClockGroups.cc @@ -20,24 +20,6 @@ namespace sta { -ClockGroup::ClockGroup(ClockSet *clks) : - clks_(clks) -{ -} - -ClockGroup::~ClockGroup() -{ - delete clks_; -} - -bool -ClockGroup::isMember(const Clock *clk) -{ - return clks_->hasKey(const_cast(clk)); -} - -//////////////////////////////////////////////////////////////// - ClockGroups::ClockGroups(const char *name, bool logically_exclusive, bool physically_exclusive, @@ -59,26 +41,24 @@ ClockGroups::~ClockGroups() groups_.deleteContentsClear(); } -ClockGroup * +void ClockGroups::makeClockGroup(ClockSet *clks) { - ClockGroup *group = new ClockGroup(clks); - groups_.insert(group); - return group; + groups_.insert(clks); } void ClockGroups::removeClock(Clock *clk) { - ClockGroupSet::Iterator group_iter(groups_); - while (group_iter.hasNext()) { - ClockGroup *group = group_iter.next(); - ClockSet *clks = group->clks(); - clks->erase(clk); - if (clks->empty()) { - groups_.erase(group); + for (auto itr = groups_.cbegin(); itr != groups_.cend(); ) { + ClockGroup *group = *itr; + group->erase(clk); + if (group->empty()) { + itr = groups_.erase(itr); delete group; } + else + itr++; } } diff --git a/sdc/DataCheck.cc b/sdc/DataCheck.cc index e140f55b..1bcc56aa 100644 --- a/sdc/DataCheck.cc +++ b/sdc/DataCheck.cc @@ -17,6 +17,7 @@ #include "DataCheck.hh" #include "Clock.hh" +#include "Network.hh" namespace sta { @@ -56,14 +57,14 @@ DataCheck::removeMargin(const RiseFallBoth *from_rf, const RiseFallBoth *to_rf, const SetupHoldAll *setup_hold) { - for (auto from_rf_index : from_rf->rangeIndex()) + for (int from_rf_index : from_rf->rangeIndex()) margins_[from_rf_index].removeValue(to_rf, setup_hold); } bool DataCheck::empty() const { - for (auto tr_index : RiseFall::rangeIndex()) { + for (int tr_index : RiseFall::rangeIndex()) { if (!margins_[tr_index].empty()) return false; } @@ -90,7 +91,7 @@ DataCheck::marginIsOneValue(SetupHold *setup_hold, //////////////////////////////////////////////////////////////// DataCheckLess::DataCheckLess(const Network *network) : - pin_less_(network) + network_(network) { } @@ -104,12 +105,11 @@ DataCheckLess::operator()(const DataCheck *check1, const Pin *to2 = check2->to(); const Clock *clk1 = check1->clk(); const Clock *clk2 = check2->clk(); - int clk_cmp = clkCmp(clk1, clk2); - return pin_less_(from1, from2) + return network_->id(from1) < network_->id(from2) || (from1 == from2 - && (pin_less_(to1, to2) + && (network_->id(to1) < network_->id(to2) || (to1 == to2 - && clk_cmp < 0))); + && clkCmp(clk1, clk2) < 0))); } } // namespace diff --git a/sdc/DisabledPorts.cc b/sdc/DisabledPorts.cc index a5fd3bd9..8965e1c9 100644 --- a/sdc/DisabledPorts.cc +++ b/sdc/DisabledPorts.cc @@ -37,10 +37,7 @@ DisabledPorts::~DisabledPorts() { delete from_; delete to_; - if (from_to_) { - from_to_->deleteContents(); - delete from_to_; - } + delete from_to_; } void @@ -92,10 +89,7 @@ DisabledPorts::setDisabledFromTo(LibertyPort *from, if (from_to_ == nullptr) from_to_ = new LibertyPortPairSet; LibertyPortPair pair(from, to); - if (!from_to_->hasKey(&pair)) { - LibertyPortPair *pair = new LibertyPortPair(from, to); - from_to_->insert(pair); - } + from_to_->insert(pair); } void @@ -103,12 +97,8 @@ DisabledPorts::removeDisabledFromTo(LibertyPort *from, LibertyPort *to) { if (from_to_) { - LibertyPortPair probe(from, to); - LibertyPortPair *pair = from_to_->findKey(&probe); - if (pair) { - from_to_->erase(pair); - delete pair; - } + LibertyPortPair from_to(from, to); + from_to_->erase(from_to); } } @@ -117,12 +107,12 @@ DisabledPorts::isDisabled(LibertyPort *from, LibertyPort *to, const TimingRole *role) { - LibertyPortPair pair(from, to); + LibertyPortPair from_to(from, to); // set_disable_timing instance does not disable timing checks. return (all_ && !role->isTimingCheck()) || (from_ && from_->hasKey(from)) || (to_ && to_->hasKey(to)) - || (from_to_ && from_to_->hasKey(&pair)); + || (from_to_ && from_to_->hasKey(from_to)); } //////////////////////////////////////////////////////////////// @@ -182,14 +172,16 @@ DisabledCellPortsLess::operator()(const DisabledCellPorts *disable1, disable2->cell()->name()); } -void -sortDisabledCellPortsMap(DisabledCellPortsMap *cell_map, - DisabledCellPortsSeq &disables) +DisabledCellPortsSeq +sortByName(DisabledCellPortsMap *cell_map) { - DisabledCellPortsMap::Iterator disabled_iter(cell_map); - while (disabled_iter.hasNext()) - disables.push_back(disabled_iter.next()); + DisabledCellPortsSeq disables; + for (auto cell_disable : *cell_map) { + DisabledCellPorts *disable = cell_disable.second; + disables.push_back(disable); + } sort(disables, DisabledCellPortsLess()); + return disables; } //////////////////////////////////////////////////////////////// @@ -203,36 +195,38 @@ DisabledInstancePorts::DisabledInstancePorts(Instance *inst) : class DisabledInstPortsLess { public: - explicit DisabledInstPortsLess(Network *network); + explicit DisabledInstPortsLess(const Network *network); bool operator()(const DisabledInstancePorts *disable1, const DisabledInstancePorts *disable2); private: - Network *network_; + const Network *network_; }; -DisabledInstPortsLess::DisabledInstPortsLess(Network *network) : +DisabledInstPortsLess::DisabledInstPortsLess(const Network *network) : network_(network) { } bool DisabledInstPortsLess::operator()(const DisabledInstancePorts *disable1, - const DisabledInstancePorts *disable2) + const DisabledInstancePorts *disable2) { return stringLess(network_->pathName(disable1->instance()), network_->pathName(disable2->instance())); } -void -sortDisabledInstancePortsMap(DisabledInstancePortsMap *inst_map, - Network *network, - DisabledInstancePortsSeq &disables) +DisabledInstancePortsSeq +sortByPathName(const DisabledInstancePortsMap *inst_map, + const Network *network) { - DisabledInstancePortsMap::Iterator disabled_iter(inst_map); - while (disabled_iter.hasNext()) - disables.push_back(disabled_iter.next()); + DisabledInstancePortsSeq disables; + for (auto inst_disable : *inst_map) { + DisabledInstancePorts *disable = inst_disable.second; + disables.push_back(disable); + } sort(disables, DisabledInstPortsLess(network)); + return disables; } //////////////////////////////////////////////////////////////// @@ -240,30 +234,30 @@ sortDisabledInstancePortsMap(DisabledInstancePortsMap *inst_map, class LibertyPortPairNameLess { public: - bool operator()(const LibertyPortPair *pair1, - const LibertyPortPair *pair2); + bool operator()(const LibertyPortPair &pair1, + const LibertyPortPair &pair2); }; bool -LibertyPortPairNameLess::operator()(const LibertyPortPair *pair1, - const LibertyPortPair *pair2) +LibertyPortPairNameLess::operator()(const LibertyPortPair &pair1, + const LibertyPortPair &pair2) { - const char *from1 = pair1->first->name(); - const char *from2 = pair2->first->name(); - const char *to1 = pair1->second->name(); - const char *to2 = pair2->second->name(); + const char *from1 = pair1.first->name(); + const char *from2 = pair2.first->name(); + const char *to1 = pair1.second->name(); + const char *to2 = pair2.second->name(); return stringLess(from1, from2) || (stringEq(from1, from2) && stringLess(to1, to2)); } -void -sortLibertyPortPairSet(LibertyPortPairSet *sets, - LibertyPortPairSeq &pairs) +LibertyPortPairSeq +sortByName(const LibertyPortPairSet *set) { - LibertyPortPairSet::Iterator pair_iter(sets); - while (pair_iter.hasNext()) - pairs.push_back(pair_iter.next()); + LibertyPortPairSeq pairs; + for (const LibertyPortPair &pair : *set) + pairs.push_back(pair); sort(pairs, LibertyPortPairNameLess()); + return pairs; } } diff --git a/sdc/ExceptionPath.cc b/sdc/ExceptionPath.cc index 56abfe60..b0616b37 100644 --- a/sdc/ExceptionPath.cc +++ b/sdc/ExceptionPath.cc @@ -37,113 +37,13 @@ insertPinPairsThruHierPin(const Pin *hpin, const Network *network, PinPairSet *pairs); static void -insertPinPairsThruNet(Net *net, +insertPinPairsThruNet(const Net *net, const Network *network, PinPairSet *pairs); static void deletePinPairsThruHierPin(const Pin *hpin, const Network *network, PinPairSet *pairs); -static int -setNameCmp(PinSet *set1, - PinSet *set2, - const Network *network) -{ - size_t size1 = set1 ? set1->size() : 0; - size_t size2 = set2 ? set2->size() : 0; - if (size1 == size2) { - PinSet::ConstIterator iter1(set1); - PinSet::ConstIterator iter2(set2); - while (iter1.hasNext() && iter2.hasNext()) { - Pin *pin1 = iter1.next(); - Pin *pin2 = iter2.next(); - const char *name1 = network->pathName(pin1); - const char *name2 = network->pathName(pin2); - int cmp = strcmp(name1, name2); - if (cmp != 0) - return cmp; - } - // Sets are equal. - return 0; - } - else - return (size1 > size2) ? 1 : -1; -} - -static int -setNameCmp(ClockSet *set1, - ClockSet *set2) -{ - size_t size1 = set1 ? set1->size() : 0; - size_t size2 = set2 ? set2->size() : 0; - if (size1 == size2) { - ClockSet::ConstIterator iter1(set1); - ClockSet::ConstIterator iter2(set2); - while (iter1.hasNext() && iter2.hasNext()) { - Clock *clk1 = iter1.next(); - Clock *clk2 = iter2.next(); - int cmp = clk1->index() - clk2->index(); - if (cmp != 0) - return cmp; - } - // Sets are equal. - return 0; - } - else - return (size1 > size2) ? 1 : -1; -} - -static int -setNameCmp(InstanceSet *set1, - InstanceSet *set2, - const Network *network) -{ - size_t size1 = set1 ? set1->size() : 0; - size_t size2 = set2 ? set2->size() : 0; - if (size1 == size2) { - InstanceSet::ConstIterator iter1(set1); - InstanceSet::ConstIterator iter2(set2); - while (iter1.hasNext() && iter2.hasNext()) { - Instance *inst1 = iter1.next(); - Instance *inst2 = iter2.next(); - const char *name1 = network->pathName(inst1); - const char *name2 = network->pathName(inst2); - int cmp = strcmp(name1, name2); - if (cmp != 0) - return cmp; - } - // Sets are equal. - return 0; - } - else - return (size1 > size2) ? 1 : -1; -} - -static int -setNameCmp(NetSet *set1, - NetSet *set2, - const Network *network) -{ - size_t size1 = set1 ? set1->size() : 0; - size_t size2 = set2 ? set2->size() : 0; - if (size1 == size2) { - NetSet::ConstIterator iter1(set1); - NetSet::ConstIterator iter2(set2); - while (iter1.hasNext() && iter2.hasNext()) { - Net *net1 = iter1.next(); - Net *net2 = iter2.next(); - const char *name1 = network->pathName(net1); - const char *name2 = network->pathName(net2); - int cmp = strcmp(name1, name2); - if (cmp != 0) - return cmp; - } - // Sets are equal. - return 0; - } - else - return (size1 > size2) ? 1 : -1; -} //////////////////////////////////////////////////////////////// @@ -166,9 +66,7 @@ checkFromThrusTo(ExceptionFrom *from, && (to->endTransition() == RiseFallBoth::riseFall())))); if (thrus) { - ExceptionThruSeq::Iterator thru_iter(thrus); - while (thru_iter.hasNext()) { - ExceptionThru *thru = thru_iter.next(); + for (ExceptionThru *thru : *thrus) { if (!thru->hasObjects()) found_empty = true; } @@ -414,15 +312,15 @@ ExceptionPath::fromThruToString(const Network *network) const if (thrus_) { str += " -thru"; bool first_thru = true; - ExceptionThruSeq::Iterator thru_iter(thrus_); - while (thru_iter.hasNext()) { - ExceptionThru *thru = thru_iter.next(); - if (!first_thru) - str += " &&"; - str += " {"; - str += thru->asString(network); - str += "}"; - first_thru = false; + if (thrus_) { + for (ExceptionThru *thru : *thrus_) { + if (!first_thru) + str += " &&"; + str += " {"; + str += thru->asString(network); + str += "}"; + first_thru = false; + } } } @@ -445,19 +343,17 @@ ExceptionPath::makeStates() { if (thrus_) { ExceptionState *prev_state = nullptr; - ExceptionThruSeq::Iterator thru_iter(thrus_); bool first = true; int index = 0; - while (thru_iter.hasNext()) { - ExceptionThru *thru = thru_iter.next(); + for (ExceptionThru *thru : *thrus_) { // No state for first -thru if no -from,since it kicks off the exception. if (!(from_ == nullptr && first)) { - ExceptionState *state = new ExceptionState(this, thru, index); - if (prev_state) - prev_state->setNextState(state); - else - states_ = state; - prev_state = state; + ExceptionState *state = new ExceptionState(this, thru, index); + if (prev_state) + prev_state->setNextState(state); + else + states_ = state; + prev_state = state; } first = false; index++; @@ -936,7 +832,8 @@ GroupPath::tighterThan(ExceptionPath *) const bool GroupPath::mergeable(ExceptionPath *exception) const { - return ExceptionPath::mergeable(exception) + return stringEqIf(name_, exception->name()) + && ExceptionPath::mergeable(exception) && overrides(exception); } @@ -972,7 +869,8 @@ ExceptionFromTo::ExceptionFromTo(PinSet *pins, ClockSet *clks, InstanceSet *insts, const RiseFallBoth *rf, - bool own_pts) : + bool own_pts, + const Network *network) : ExceptionPt(rf, own_pts), pins_(pins), clks_(clks), @@ -994,7 +892,7 @@ ExceptionFromTo::ExceptionFromTo(PinSet *pins, delete insts_; insts_ = nullptr; } - findHash(); + findHash(network); } ExceptionFromTo::~ExceptionFromTo() @@ -1035,19 +933,14 @@ ExceptionFromTo::allPins(const Network *network, PinSet *pins) { if (pins_) { - PinSet::Iterator pin_iter(pins_); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : *pins_) pins->insert(pin); - } } if (insts_) { - InstanceSet::Iterator inst_iter(insts_); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); + for (const Instance *inst : *insts_) { InstancePinIterator *pin_iter = network->pinIterator(inst); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); pins->insert(pin); } delete pin_iter; @@ -1056,34 +949,25 @@ ExceptionFromTo::allPins(const Network *network, } void -ExceptionFromTo::findHash() +ExceptionFromTo::findHash(const Network *network) { hash_ = 0; if (pins_) { size_t hash = 0; - PinSet::Iterator pin_iter(pins_); - while (pin_iter.hasNext()) { - const Pin *pin = pin_iter.next(); - hash += hashPtr(pin); - } + for (const Pin *pin : *pins_) + hash += network->id(pin); hash_ += hash * hash_pin; } if (clks_) { size_t hash = 0; - ClockSet::Iterator clk_iter(clks_); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); + for (Clock *clk : *clks_) hash += clk->index(); - } hash_ += hash * hash_clk; } if (insts_) { size_t hash = 0; - InstanceSet::Iterator inst_iter(insts_); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - hash += hashPtr(inst); - } + for (const Instance *inst : *insts_) + hash += network->id(inst); hash_ += hash * hash_inst; } } @@ -1098,16 +982,16 @@ ExceptionFromTo::equal(ExceptionFromTo *from_to) const } int -ExceptionFromTo::nameCmp(ExceptionPt *pt2, +ExceptionFromTo::compare(ExceptionPt *pt2, const Network *network) const { int priority_cmp = typePriority() - pt2->typePriority(); if (priority_cmp == 0) { - int pin_cmp = setNameCmp(pins_, pt2->pins(), network); + int pin_cmp = PinSet::compare(pins_, pt2->pins(), network); if (pin_cmp == 0) { - int clk_cmp = setNameCmp(clks_, pt2->clks()); + int clk_cmp = sta::compare(clks_, pt2->clks()); if (clk_cmp == 0) { - int inst_cmp = setNameCmp(insts_, pt2->instances(), network); + int inst_cmp = InstanceSet::compare(insts_, pt2->instances(), network); if (inst_cmp == 0) return rf_->index() - pt2->transition()->index(); else @@ -1124,69 +1008,54 @@ ExceptionFromTo::nameCmp(ExceptionPt *pt2, } void -ExceptionFromTo::mergeInto(ExceptionPt *pt) +ExceptionFromTo::mergeInto(ExceptionPt *pt, + const Network *network) { if (pins_) { - PinSet::Iterator pin_iter(pins_); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - pt->addPin(pin); - } + for (const Pin *pin : *pins_) + pt->addPin(pin, network); } if (clks_) { - ClockSet::Iterator clk_iter(clks_); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); + for (Clock *clk : *clks_) pt->addClock(clk); - } } if (insts_) { - InstanceSet::Iterator inst_iter(insts_); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - pt->addInstance(inst); - } + for (const Instance *inst : *insts_) + pt->addInstance(inst, network); } } void -ExceptionFromTo::deleteObjects(ExceptionFromTo *pt) +ExceptionFromTo::deleteObjects(ExceptionFromTo *pt, + const Network *network) { PinSet *pins = pt->pins(); if (pins && pins_) { - PinSet::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - deletePin(pin); - } + for (const Pin *pin : *pins) + deletePin(pin, network); } ClockSet *clks = pt->clks(); if (clks && clks_) { - ClockSet::Iterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); + for (Clock *clk : *clks) deleteClock(clk); - } } InstanceSet *insts = pt->instances(); if (insts && insts_) { - InstanceSet::Iterator inst_iter(insts); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - deleteInstance(inst); - } + for (const Instance *inst : *insts) + deleteInstance(inst, network); } } void -ExceptionFromTo::addPin(Pin *pin) +ExceptionFromTo::addPin(const Pin *pin, + const Network *network) { if (pins_ == nullptr) - pins_ = new PinSet; + pins_ = new PinSet(network); if (!pins_->hasKey(pin)) { pins_->insert(pin); // Incrementally update hash. - hash_ += hashPtr(pin) * hash_pin; + hash_ += network->id(pin) * hash_pin; } } @@ -1203,24 +1072,26 @@ ExceptionFromTo::addClock(Clock *clk) } void -ExceptionFromTo::addInstance(Instance *inst) +ExceptionFromTo::addInstance(const Instance *inst, + const Network *network) { if (insts_ == nullptr) - insts_ = new InstanceSet; + insts_ = new InstanceSet(network); if (!insts_->hasKey(inst)) { insts_->insert(inst); // Incrementally update hash. - hash_ += hashPtr(inst) * hash_inst; + hash_ += network->id(inst) * hash_inst; } } void -ExceptionFromTo::deletePin(Pin *pin) +ExceptionFromTo::deletePin(const Pin *pin, + const Network *network) { if (pins_) { pins_->erase(pin); // Incrementally update hash. - hash_ -= hashPtr(pin) * hash_pin; + hash_ -= network->id(pin) * hash_pin; } } @@ -1235,12 +1106,13 @@ ExceptionFromTo::deleteClock(Clock *clk) } void -ExceptionFromTo::deleteInstance(Instance *inst) +ExceptionFromTo::deleteInstance(const Instance *inst, + const Network *network) { if (insts_) { insts_->erase(inst); // Incrementally update hash. - hash_ -= hashPtr(inst) * hash_inst; + hash_ -= network->id(inst) * hash_inst; } } @@ -1255,45 +1127,39 @@ ExceptionFromTo::asString(const Network *network) const int obj_count = 0; bool first = true; if (pins_) { - PinSeq pins; - sortPinSet(pins_, network, pins); - PinSeq::Iterator pin_iter(pins); - while (pin_iter.hasNext() - && obj_count < as_string_max_objects_) { - const Pin *pin = pin_iter.next(); + PinSeq pins = sortByPathName(pins_, network); + for (const Pin *pin : pins) { if (!first) str += ", "; str += network->pathName(pin); first = false; obj_count++; + if (obj_count > as_string_max_objects_) + break; } } if (clks_) { - ClockSeq clks; - sortClockSet(clks_, clks); - ClockSeq::Iterator clk_iter(clks); - while (clk_iter.hasNext() - && obj_count < as_string_max_objects_) { - Clock *clk = clk_iter.next(); + ClockSeq clks = sortByName(clks_); + for (Clock *clk : clks) { if (!first) str += ", "; str += clk->name(); first = false; obj_count++; + if (obj_count > as_string_max_objects_) + break; } } if (insts_) { - InstanceSeq insts; - sortInstanceSet(insts_, network, insts); - InstanceSeq::Iterator inst_iter(insts); - while (inst_iter.hasNext() - && obj_count < as_string_max_objects_) { + InstanceSeq insts = sortByPathName(insts_, network); + for (const Instance *inst : insts) { if (!first) str += ", "; - Instance *inst = inst_iter.next(); str += network->pathName(inst); first = false; obj_count++; + if (obj_count > as_string_max_objects_) + break; } } if (obj_count == as_string_max_objects_) @@ -1325,20 +1191,21 @@ ExceptionFrom::ExceptionFrom(PinSet *pins, ClockSet *clks, InstanceSet *insts, const RiseFallBoth *rf, - bool own_pts) : - ExceptionFromTo(pins, clks, insts, rf, own_pts) + bool own_pts, + const Network *network) : + ExceptionFromTo(pins, clks, insts, rf, own_pts, network) { } void -ExceptionFrom::findHash() +ExceptionFrom::findHash(const Network *network) { - ExceptionFromTo::findHash(); + ExceptionFromTo::findHash(network); hash_ += rf_->index() * 31 + 29; } ExceptionFrom * -ExceptionFrom::clone() +ExceptionFrom::clone(const Network *network) { PinSet *pins = nullptr; if (pins_) @@ -1349,7 +1216,7 @@ ExceptionFrom::clone() InstanceSet *insts = nullptr; if (insts_) insts = new InstanceSet(*insts_); - return new ExceptionFrom(pins, clks, insts, rf_, true); + return new ExceptionFrom(pins, clks, insts, rf_, true, network); } bool @@ -1379,14 +1246,15 @@ ExceptionTo::ExceptionTo(PinSet *pins, InstanceSet *insts, const RiseFallBoth *rf, const RiseFallBoth *end_rf, - bool own_pts) : - ExceptionFromTo(pins, clks, insts, rf, own_pts), + bool own_pts, + const Network *network) : + ExceptionFromTo(pins, clks, insts, rf, own_pts, network), end_rf_(end_rf) { } ExceptionTo * -ExceptionTo::clone() +ExceptionTo::clone(const Network *network) { PinSet *pins = nullptr; if (pins_) @@ -1397,7 +1265,7 @@ ExceptionTo::clone() InstanceSet *insts = nullptr; if (insts_) insts = new InstanceSet(*insts_); - return new ExceptionTo(pins, clks, insts, rf_, end_rf_, true); + return new ExceptionTo(pins, clks, insts, rf_, end_rf_, true, network); } const char * @@ -1526,11 +1394,11 @@ ExceptionTo::cmdKeyword() const } int -ExceptionTo::nameCmp(ExceptionPt *pt2, +ExceptionTo::compare(ExceptionPt *pt2, const Network *network) const { ExceptionTo *to2 = dynamic_cast(pt2); - int cmp = ExceptionFromTo::nameCmp(pt2, network); + int cmp = ExceptionFromTo::compare(pt2, network); if (cmp == 0) return end_rf_->index() - to2->endTransition()->index(); else @@ -1568,7 +1436,7 @@ ExceptionThru::ExceptionThru(PinSet *pins, insts_ = nullptr; } makeAllEdges(network); - findHash(); + findHash(network); } void @@ -1585,9 +1453,7 @@ ExceptionThru::makeAllEdges(const Network *network) void ExceptionThru::makePinEdges(const Network *network) { - PinSet::Iterator pin_iter(pins_); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : *pins_) { if (network->isHierarchical(pin)) makeHpinEdges(pin, network); } @@ -1596,7 +1462,7 @@ ExceptionThru::makePinEdges(const Network *network) // Call after the pin has been deleted from pins_, // but before the pin has been deleted from the netlist. void -ExceptionThru::deletePinEdges(Pin *pin, +ExceptionThru::deletePinEdges(const Pin *pin, Network *network) { // Incrementally delete only edges through (hier) or from/to (leaf) the pin. @@ -1608,25 +1474,23 @@ ExceptionThru::deletePinEdges(Pin *pin, if (drvrs) { // Some edges originating at drvrs may not actually go through pin, so // still must use deletePinPairsThruHierPin to identify specific edges. - EdgePinsSet::Iterator edge_iter(edges_); - while (edge_iter.hasNext()) { - EdgePins *edge_pins = edge_iter.next(); - Pin *p_first = edge_pins->first; - if (drvrs->hasKey(p_first)) { - deletePinPairsThruHierPin(pin, network, edges_); - break; - } - } + if (edges_) { + for (const EdgePins &edge_pins : *edges_) { + const Pin *p_first = edge_pins.first; + if (drvrs->hasKey(p_first)) { + deletePinPairsThruHierPin(pin, network, edges_); + break; + } + } + } } } else { - EdgePinsSet::Iterator edge_iter(edges_); - while (edge_iter.hasNext()) { - EdgePins *edge_pins = edge_iter.next(); - if (edge_pins->first == pin - || edge_pins->second == pin) { + // erase prevents range iteration. + for (const EdgePins &edge_pins : *edges_) { + if (edge_pins.first == pin + || edge_pins.second == pin) { edges_->erase(edge_pins); - delete edge_pins; } } } @@ -1638,7 +1502,7 @@ ExceptionThru::makeHpinEdges(const Pin *pin, const Network *network) { if (edges_ == nullptr) - edges_ = new EdgePinsSet; + edges_ = new EdgePinsSet(network); // Add edges thru pin to edges_. insertPinPairsThruHierPin(pin, network, edges_); } @@ -1646,22 +1510,20 @@ ExceptionThru::makeHpinEdges(const Pin *pin, void ExceptionThru::makeNetEdges(const Network *network) { - NetSet::Iterator net_iter(nets_); - while (net_iter.hasNext()) { - Net *net = net_iter.next(); + for (const Net *net : *nets_) { if (edges_ == nullptr) - edges_ = new EdgePinsSet; + edges_ = new EdgePinsSet(network); // Add edges thru pin to edges_. insertPinPairsThruNet(net, network, edges_); } } void -ExceptionThru::makeNetEdges(Net *net, +ExceptionThru::makeNetEdges(const Net *net, const Network *network) { if (edges_ == nullptr) - edges_ = new EdgePinsSet; + edges_ = new EdgePinsSet(network); // Add edges thru pin to edges_. insertPinPairsThruNet(net, network, edges_); } @@ -1669,9 +1531,7 @@ ExceptionThru::makeNetEdges(Net *net, void ExceptionThru::makeInstEdges(const Network *network) { - InstanceSet::Iterator inst_iter(insts_); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); + for (const Instance *inst : *insts_) { if (network->isHierarchical(inst)) { InstancePinIterator *pin_iter = network->pinIterator(inst); while (pin_iter->hasNext()) { @@ -1720,10 +1580,7 @@ ExceptionThru::~ExceptionThru() delete pins_; delete nets_; delete insts_; - if (edges_) { - edges_->deleteContents(); - delete edges_; - } + delete edges_; } } @@ -1734,45 +1591,39 @@ ExceptionThru::asString(const Network *network) const bool first = true; int obj_count = 0; if (pins_) { - PinSeq pins; - sortPinSet(pins_, network, pins); - PinSeq::Iterator pin_iter(pins); - while (pin_iter.hasNext() - && obj_count < as_string_max_objects_) { - const Pin *pin = pin_iter.next(); + PinSeq pins = sortByPathName(pins_, network); + for (const Pin *pin : pins) { if (!first) str += ", "; str += network->pathName(pin); first = false; obj_count++; + if (obj_count > as_string_max_objects_) + break; } } if (nets_) { - NetSeq nets; - sortNetSet(nets_, network, nets); - NetSeq::Iterator net_iter(nets); - while (net_iter.hasNext() - && obj_count < as_string_max_objects_) { - const Net *net = net_iter.next(); + NetSeq nets = sortByPathName(nets_, network); + for (const Net *net : nets) { if (!first) str += ", "; str += network->pathName(net); first = false; obj_count++; + if (obj_count > as_string_max_objects_) + break; } } if (insts_) { - InstanceSeq insts; - sortInstanceSet(insts_, network, insts); - InstanceSeq::Iterator inst_iter(insts); - while (inst_iter.hasNext() - && obj_count < as_string_max_objects_) { + InstanceSeq insts = sortByPathName(insts_, network); + for (const Instance *inst : insts) { if (!first) str += ", "; - Instance *inst = inst_iter.next(); str += network->pathName(inst); first = false; obj_count++; + if (obj_count > as_string_max_objects_) + break; } } if (obj_count == as_string_max_objects_) @@ -1793,9 +1644,7 @@ exceptionThrusClone(ExceptionThruSeq *thrus, { if (thrus) { ExceptionThruSeq *thrus_cpy = new ExceptionThruSeq; - ExceptionThruSeq::Iterator thru_iter(thrus); - while (thru_iter.hasNext()) { - ExceptionThru *thru = thru_iter.next(); + for (ExceptionThru *thru : *thrus) { ExceptionThru *thru_cpy = thru->clone(network); thrus_cpy->push_back(thru_cpy); } @@ -1830,87 +1679,93 @@ ExceptionThru::hasObjects() const void -ExceptionThru::addPin(Pin *pin) +ExceptionThru::addPin(const Pin *pin, + const Network *network) { if (pins_ == nullptr) - pins_ = new PinSet; + pins_ = new PinSet(network); if (!pins_->hasKey(pin)) { pins_->insert(pin); // Incrementally update hash. - hash_ += hashPtr(pin) * hash_pin; + hash_ += network->id(pin) * hash_pin; } } void -ExceptionThru::addNet(Net *net) +ExceptionThru::addNet(const Net *net, + const Network *network) { if (nets_ == nullptr) - nets_ = new NetSet; + nets_ = new NetSet(network); if (!nets_->hasKey(net)) { nets_->insert(net); // Incrementally update hash. - hash_ += hashPtr(net) * hash_net; + hash_ += network->id(net) * hash_net; } } void -ExceptionThru::addInstance(Instance *inst) +ExceptionThru::addInstance(const Instance *inst, + const Network *network) { if (insts_ == nullptr) - insts_ = new InstanceSet; + insts_ = new InstanceSet(network); if (!insts_->hasKey(inst)) { insts_->insert(inst); // Incrementally update hash. - hash_ += hashPtr(inst) * hash_inst; + hash_ += network->id(inst) * hash_inst; } } void -ExceptionThru::addEdge(EdgePins *edge) +ExceptionThru::addEdge(const EdgePins &edge, + const Network *network) { if (edges_ == nullptr) - edges_ = new EdgePinsSet; + edges_ = new EdgePinsSet(network); edges_->insert(edge); // Hash is unchanged because edges are derived from hierarchical pins. } void -ExceptionThru::deletePin(Pin *pin) +ExceptionThru::deletePin(const Pin *pin, + const Network *network) { if (pins_) { pins_->erase(pin); // Incrementally update hash. - hash_ -= hashPtr(pin) * hash_pin; + hash_ -= network->id(pin) * hash_pin; } } void -ExceptionThru::deleteNet(Net *net) +ExceptionThru::deleteNet(const Net *net, + const Network *network) { if (nets_) { nets_->erase(net); // Incrementally update hash. - hash_ -= hashPtr(net) * hash_net; + hash_ -= network->id(net) * hash_net; } } void -ExceptionThru::deleteInstance(Instance *inst) +ExceptionThru::deleteInstance(const Instance *inst, + const Network *network) { if (insts_) { insts_->erase(inst); // Incrementally update hash. - hash_ -= hashPtr(inst) * hash_inst; + hash_ -= network->id(inst) * hash_inst; } } void -ExceptionThru::deleteEdge(EdgePins *edge) +ExceptionThru::deleteEdge(const EdgePins &edge) { - if (edges_) { - edges_->erase(edge); + if (edges_) // Hash is unchanged because edges are derived from hierarchical pins. - } + edges_->erase(edge); } void @@ -1918,16 +1773,11 @@ ExceptionThru::allPins(const Network *network, PinSet *pins) { if (pins_) { - PinSet::Iterator pin_iter(pins_); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : *pins_) pins->insert(pin); - } } if (insts_) { - InstanceSet::Iterator inst_iter(insts_); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); + for (const Instance *inst : *insts_) { InstancePinIterator *pin_iter = network->pinIterator(inst); while (pin_iter->hasNext()) { Pin *pin = pin_iter->next(); @@ -1937,12 +1787,10 @@ ExceptionThru::allPins(const Network *network, } } if (nets_) { - NetSet::Iterator net_iter(nets_); - while (net_iter.hasNext()) { - Net *net = net_iter.next(); + for (const Net *net : *nets_) { NetConnectedPinIterator *pin_iter = network->connectedPinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); pins->insert(pin); } delete pin_iter; @@ -1956,43 +1804,34 @@ ExceptionThru::matches(const Pin *from_pin, const RiseFall *to_rf, const Network *network) { - EdgePins edge_pins(const_cast(from_pin), const_cast(to_pin)); - return ((pins_ && pins_->hasKey(const_cast(to_pin))) - || (edges_ && edges_->hasKey(&edge_pins)) + EdgePins edge_pins(from_pin, to_pin); + return ((pins_ && pins_->hasKey(to_pin)) + || (edges_ && edges_->hasKey(edge_pins)) || (nets_ && to_pin && nets_->hasKey(network->net(to_pin))) || (insts_ && to_pin && insts_->hasKey(network->instance(to_pin)))) && rf_->matches(to_rf); } void -ExceptionThru::findHash() +ExceptionThru::findHash(const Network *network) { hash_ = 0; if (pins_) { size_t hash = 0; - PinSet::Iterator pin_iter(pins_); - while (pin_iter.hasNext()) { - const Pin *pin = pin_iter.next(); - hash += hashPtr(pin); - } + for (const Pin *pin : *pins_) + hash += network->id(pin); hash_ += hash * hash_pin; } if (nets_) { size_t hash = 0; - NetSet::Iterator net_iter(nets_); - while (net_iter.hasNext()) { - Net *net = net_iter.next(); - hash += hashPtr(net); - } + for (const Net *net : *nets_) + hash += network->id(net); hash_ += hash * hash_net; } if (insts_) { size_t hash = 0; - InstanceSet::Iterator inst_iter(insts_); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - hash += hashPtr(inst); - } + for (const Instance *inst : *insts_) + hash += network->id(inst); hash_ += hash * hash_inst; } hash_ += rf_->index() * 13; @@ -2009,16 +1848,16 @@ ExceptionThru::equal(ExceptionThru *thru) const } int -ExceptionThru::nameCmp(ExceptionPt *pt2, +ExceptionThru::compare(ExceptionPt *pt2, const Network *network) const { int priority_cmp = typePriority() - pt2->typePriority(); if (priority_cmp == 0) { - int pin_cmp = setNameCmp(pins_, pt2->pins(), network); + int pin_cmp = PinSet::compare(pins_, pt2->pins(), network); if (pin_cmp == 0) { - int net_cmp = setNameCmp(nets_, pt2->nets(), network); + int net_cmp = NetSet::compare(nets_, pt2->nets(), network); if (net_cmp == 0) { - int inst_cmp = setNameCmp(insts_, pt2->instances(), network); + int inst_cmp = InstanceSet::compare(insts_, pt2->instances(), network); if (inst_cmp == 0) return rf_->index() - pt2->transition()->index(); else @@ -2035,74 +1874,52 @@ ExceptionThru::nameCmp(ExceptionPt *pt2, } void -ExceptionThru::mergeInto(ExceptionPt *pt) +ExceptionThru::mergeInto(ExceptionPt *pt, + const Network *network) { if (pins_) { - PinSet::Iterator pin_iter(pins_); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - pt->addPin(pin); - } + for (const Pin *pin : *pins_) + pt->addPin(pin, network); } if (edges_) { - EdgePinsSet::Iterator edge_iter(edges_); - while (edge_iter.hasNext()) { - EdgePins *edge = edge_iter.next(); - pt->addEdge(edge); - } + for (const EdgePins &edge : *edges_) + pt->addEdge(edge, network); // EdgePins are now owned by acquirer. edges_->clear(); } if (nets_) { - NetSet::Iterator net_iter(nets_); - while (net_iter.hasNext()) { - Net *net = net_iter.next(); - pt->addNet(net); - } + for (const Net *net : *nets_) + pt->addNet(net, network); } if (insts_) { - InstanceSet::Iterator inst_iter(insts_); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - pt->addInstance(inst); - } + for (const Instance *inst : *insts_) + pt->addInstance(inst, network); } } void -ExceptionThru::deleteObjects(ExceptionThru *pt) +ExceptionThru::deleteObjects(ExceptionThru *pt, + const Network *network) { PinSet *pins = pt->pins(); if (pins && pins_) { - PinSet::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - deletePin(pin); - } + for (const Pin *pin : *pins) + deletePin(pin, network); } EdgePinsSet *edges = pt->edges(); if (edges && edges_) { - EdgePinsSet::Iterator edge_iter(edges); - while (edge_iter.hasNext()) { - EdgePins *edge = edge_iter.next(); + for (const EdgePins &edge : *edges) deleteEdge(edge); - } } NetSet *nets = pt->nets(); if (nets && nets_) { - NetSet::Iterator net_iter(nets); - while (net_iter.hasNext()) { - Net *net = net_iter.next(); - deleteNet(net); - } + for (const Net *net : *nets) + deleteNet(net, network); } InstanceSet *insts = pt->instances(); if (insts && insts_) { - InstanceSet::Iterator inst_iter(insts); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - deleteInstance(inst); - } + for (const Instance *inst : *insts) + deleteInstance(inst, network); } } @@ -2150,41 +1967,41 @@ ExceptionThru::connectPinAfter(PinSet *drvrs, // No enabled edges if no driver. if (drvrs && !drvrs->empty()) { - PinSet::Iterator pin_iter(pins_); - while (pin_iter.hasNext()) { - Pin *thru_pin = pin_iter.next(); - if (network->isHierarchical(thru_pin)) { - PinSet *thru_pin_drvrs = network->drivers(thru_pin); - if (PinSet::intersects(drvrs, thru_pin_drvrs)) - makePinEdges(thru_pin, network); + if (pins_) { + for (const Pin *thru_pin : *pins_) { + if (network->isHierarchical(thru_pin)) { + PinSet *thru_pin_drvrs = network->drivers(thru_pin); + if (PinSet::intersects(drvrs, thru_pin_drvrs)) + makePinEdges(thru_pin, network); + } } } - InstanceSet::Iterator inst_iter(insts_); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - if (network->isHierarchical(inst)) { - InstancePinIterator *inst_pin_iter = network->pinIterator(inst); - while (inst_pin_iter->hasNext()) { - Pin *inst_pin = inst_pin_iter->next(); - PinSet *inst_pin_drvrs = network->drivers(inst_pin); - if (PinSet::intersects(drvrs, inst_pin_drvrs)) - makePinEdges(inst_pin, network); - } - delete inst_pin_iter; + if (insts_) { + for (const Instance *inst : *insts_) { + if (network->isHierarchical(inst)) { + InstancePinIterator *inst_pin_iter = network->pinIterator(inst); + while (inst_pin_iter->hasNext()) { + Pin *inst_pin = inst_pin_iter->next(); + PinSet *inst_pin_drvrs = network->drivers(inst_pin); + if (PinSet::intersects(drvrs, inst_pin_drvrs)) + makePinEdges(inst_pin, network); + } + delete inst_pin_iter; + } } } - NetSet::Iterator net_iter(nets_); - while (net_iter.hasNext()) { - Net *net = net_iter.next(); - PinSet *net_drvrs = network->drivers(net); - if (PinSet::intersects(drvrs, net_drvrs)) - makeNetEdges(net, network); + if (nets_) { + for (const Net *net : *nets_) { + PinSet *net_drvrs = network->drivers(net); + if (PinSet::intersects(drvrs, net_drvrs)) + makeNetEdges(net, network); + } } } } void -ExceptionThru::makePinEdges(Pin *pin, +ExceptionThru::makePinEdges(const Pin *pin, const Network *network) { if (network->isHierarchical(pin)) @@ -2192,7 +2009,7 @@ ExceptionThru::makePinEdges(Pin *pin, } void -ExceptionThru::disconnectPinBefore(Pin *pin, +ExceptionThru::disconnectPinBefore(const Pin *pin, Network *network) { // Remove edges from/to leaf pin and through hier pin. @@ -2249,29 +2066,29 @@ ExpandedExceptionVisitor::visitExpansions() ExceptionFrom *from = exception_->from(); if (from) { const RiseFallBoth *rf = from->transition(); - PinSet::Iterator pin_iter(from->pins()); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - PinSet pins; - pins.insert(pin); - ExceptionFrom expanded_from(&pins, nullptr, nullptr, rf, false); - expandThrus(&expanded_from); + if (from->pins()) { + for (const Pin *pin : *from->pins()) { + PinSet pins(network_); + pins.insert(pin); + ExceptionFrom expanded_from(&pins, nullptr, nullptr, rf, false, network_); + expandThrus(&expanded_from); + } } - ClockSet::Iterator clk_iter(from->clks()); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); - ClockSet clks; - clks.insert(clk); - ExceptionFrom expanded_from(nullptr, &clks, nullptr, rf, false); - expandThrus(&expanded_from); + if (from->clks()) { + for (Clock *clk : *from->clks()) { + ClockSet clks; + clks.insert(clk); + ExceptionFrom expanded_from(nullptr, &clks, nullptr, rf, false, network_); + expandThrus(&expanded_from); + } } - InstanceSet::Iterator inst_iter(from->instances()); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - InstanceSet insts; - insts.insert(inst); - ExceptionFrom expanded_from(nullptr, nullptr, &insts, rf, false); - expandThrus(&expanded_from); + if (from->instances()) { + for (const Instance *inst : *from->instances()) { + InstanceSet insts(network_); + insts.insert(inst); + ExceptionFrom expanded_from(nullptr, nullptr, &insts, rf, false, network_); + expandThrus(&expanded_from); + } } } else @@ -2300,35 +2117,35 @@ ExpandedExceptionVisitor::expandThru(ExceptionFrom *expanded_from, if (thru_iter.hasNext()) { ExceptionThru *thru = thru_iter.next(); const RiseFallBoth *rf = thru->transition(); - PinSet::Iterator pin_iter(thru->pins()); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - PinSet pins; - pins.insert(pin); - ExceptionThru expanded_thru(&pins, nullptr, nullptr, rf, false, network_); - expanded_thrus->push_back(&expanded_thru); - expandThru(expanded_from, thru_iter, expanded_thrus); - expanded_thrus->pop_back(); + if (thru->pins()) { + for (const Pin *pin : *thru->pins()) { + PinSet pins(network_); + pins.insert(pin); + ExceptionThru expanded_thru(&pins, nullptr, nullptr, rf, false, network_); + expanded_thrus->push_back(&expanded_thru); + expandThru(expanded_from, thru_iter, expanded_thrus); + expanded_thrus->pop_back(); + } } - NetSet::Iterator net_iter(thru->nets()); - while (net_iter.hasNext()) { - Net *net = net_iter.next(); - NetSet nets; - nets.insert(net); - ExceptionThru expanded_thru(nullptr, &nets, nullptr, rf, false, network_); - expanded_thrus->push_back(&expanded_thru); - expandThru(expanded_from, thru_iter, expanded_thrus); - expanded_thrus->pop_back(); + if (thru->nets()) { + for (const Net *net : *thru->nets()) { + NetSet nets(network_); + nets.insert(net); + ExceptionThru expanded_thru(nullptr, &nets, nullptr, rf, false, network_); + expanded_thrus->push_back(&expanded_thru); + expandThru(expanded_from, thru_iter, expanded_thrus); + expanded_thrus->pop_back(); + } } - InstanceSet::Iterator inst_iter(thru->instances()); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - InstanceSet insts; - insts.insert(inst); - ExceptionThru expanded_thru(nullptr, nullptr, &insts, rf, false, network_); - expanded_thrus->push_back(&expanded_thru); - expandThru(expanded_from, thru_iter, expanded_thrus); - expanded_thrus->pop_back(); + if (thru->instances()) { + for (const Instance *inst : *thru->instances()) { + InstanceSet insts(network_); + insts.insert(inst); + ExceptionThru expanded_thru(nullptr, nullptr, &insts, rf, false, network_); + expanded_thrus->push_back(&expanded_thru); + expandThru(expanded_from, thru_iter, expanded_thrus); + expanded_thrus->pop_back(); + } } } else @@ -2344,29 +2161,29 @@ ExpandedExceptionVisitor::expandTo(ExceptionFrom *expanded_from, if (to) { const RiseFallBoth *rf = to->transition(); const RiseFallBoth *end_rf = to->endTransition(); - PinSet::Iterator pin_iter(to->pins()); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - PinSet pins; - pins.insert(pin); - ExceptionTo expanded_to(&pins, nullptr, nullptr, rf, end_rf, false); - visit(expanded_from, expanded_thrus, &expanded_to); + if (to->pins()) { + for (const Pin *pin : *to->pins()) { + PinSet pins(network_); + pins.insert(pin); + ExceptionTo expanded_to(&pins, nullptr, nullptr, rf, end_rf, false, network_); + visit(expanded_from, expanded_thrus, &expanded_to); + } } - ClockSet::Iterator clk_iter(to->clks()); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); - ClockSet clks; - clks.insert(clk); - ExceptionTo expanded_to(nullptr, &clks, nullptr, rf, end_rf, false); - visit(expanded_from, expanded_thrus, &expanded_to); + if (to->clks()) { + for (Clock *clk : *to->clks()) { + ClockSet clks; + clks.insert(clk); + ExceptionTo expanded_to(nullptr, &clks, nullptr, rf, end_rf, false, network_); + visit(expanded_from, expanded_thrus, &expanded_to); + } } - InstanceSet::Iterator inst_iter(to->instances()); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - InstanceSet insts; - insts.insert(inst); - ExceptionTo expanded_to(nullptr, nullptr, &insts, rf, end_rf, false); - visit(expanded_from, expanded_thrus, &expanded_to); + if (to->instances()) { + for (const Instance *inst : *to->instances()) { + InstanceSet insts(network_); + insts.insert(inst); + ExceptionTo expanded_to(nullptr, nullptr, &insts, rf, end_rf, false, network_); + visit(expanded_from, expanded_thrus, &expanded_to); + } } } else @@ -2417,27 +2234,33 @@ ExceptionState::hash() const return hashSum(exception_->hash(), index_); } -//////////////////////////////////////////////////////////////// - -class ExceptionLess -{ -public: - explicit ExceptionLess(const Network *network); - bool operator()(ExceptionPath *except1, - ExceptionPath *except2); - -private: - const Network *network_; -}; - -ExceptionLess::ExceptionLess(const Network *network) : +ExceptionStateLess::ExceptionStateLess(const Network *network) : network_(network) { } bool -ExceptionLess::operator()(ExceptionPath *except1, - ExceptionPath *except2) +ExceptionStateLess::operator()(const ExceptionState *state1, + const ExceptionState *state2) const +{ + const ExceptionPath *except1 = state1->exception(); + const ExceptionPath *except2 = state2->exception(); + ExceptionPathLess except_less(network_); + return except_less(except1, except2) + || (except1 == except2 + && state1->index() < state2->index()); +} + +//////////////////////////////////////////////////////////////// + +ExceptionPathLess::ExceptionPathLess(const Network *network) : + network_(network) +{ +} + +bool +ExceptionPathLess::operator()(const ExceptionPath *except1, + const ExceptionPath *except2) const { int priority1 = except1->typePriority() + except1->minMax()->index(); int priority2 = except2->typePriority() + except2->minMax()->index(); @@ -2447,7 +2270,7 @@ ExceptionLess::operator()(ExceptionPath *except1, while (pt_iter1.hasNext() && pt_iter2.hasNext()) { ExceptionPt *pt1 = pt_iter1.next(); ExceptionPt *pt2 = pt_iter2.next(); - int cmp = pt1->nameCmp(pt2, network_); + int cmp = pt1->compare(pt2, network_); if (cmp != 0) return cmp < 0; } @@ -2458,19 +2281,6 @@ ExceptionLess::operator()(ExceptionPath *except1, return (priority1 < priority2); } -void -sortExceptions(ExceptionPathSet *set, - ExceptionPathSeq &exceptions, - Network *network) -{ - ExceptionPathSet::Iterator except_iter(set); - while (except_iter.hasNext()) { - ExceptionPath *exception = except_iter.next(); - exceptions.push_back(exception); - } - sort(exceptions, ExceptionLess(network)); -} - //////////////////////////////////////////////////////////////// class InsertPinPairsThru : public HierPinThruVisitor @@ -2480,8 +2290,8 @@ public: const Network *network); protected: - virtual void visit(Pin *drvr, - Pin *load); + virtual void visit(const Pin *drvr, + const Pin *load); PinPairSet *pairs_; const Network *network_; @@ -2496,14 +2306,11 @@ InsertPinPairsThru::InsertPinPairsThru(PinPairSet *pairs, } void -InsertPinPairsThru::visit(Pin *drvr, - Pin *load) +InsertPinPairsThru::visit(const Pin *drvr, + const Pin *load) { - PinPair probe(drvr, load); - if (!pairs_->hasKey(&probe)) { - PinPair *pair = new PinPair(drvr, load); - pairs_->insert(pair); - } + PinPair pair(drvr, load); + pairs_->insert(pair); } static void @@ -2516,7 +2323,7 @@ insertPinPairsThruHierPin(const Pin *hpin, } static void -insertPinPairsThruNet(Net *net, +insertPinPairsThruNet(const Net *net, const Network *network, PinPairSet *pairs) { @@ -2531,8 +2338,8 @@ public: const Network *network); protected: - virtual void visit(Pin *drvr, - Pin *load); + virtual void visit(const Pin *drvr, + const Pin *load); PinPairSet *pairs_; const Network *network_; @@ -2547,11 +2354,11 @@ DeletePinPairsThru::DeletePinPairsThru(PinPairSet *pairs, } void -DeletePinPairsThru::visit(Pin *drvr, - Pin *load) +DeletePinPairsThru::visit(const Pin *drvr, + const Pin *load) { - PinPair probe(drvr, load); - pairs_->erase(&probe); + PinPair pair(drvr, load); + pairs_->erase(pair); } static void diff --git a/sdc/InputDrive.cc b/sdc/InputDrive.cc index 7b65bd94..66601855 100644 --- a/sdc/InputDrive.cc +++ b/sdc/InputDrive.cc @@ -78,11 +78,11 @@ InputDrive::driveResistanceMinMaxEqual(const RiseFall *rf) } void -InputDrive::setDriveCell(LibertyLibrary *library, - LibertyCell *cell, - LibertyPort *from_port, +InputDrive::setDriveCell(const LibertyLibrary *library, + const LibertyCell *cell, + const LibertyPort *from_port, float *from_slews, - LibertyPort *to_port, + const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max) { @@ -109,10 +109,10 @@ void InputDrive::driveCell(const RiseFall *rf, const MinMax *min_max, // Return values. - LibertyCell *&cell, - LibertyPort *&from_port, + const LibertyCell *&cell, + const LibertyPort *&from_port, float *&from_slews, - LibertyPort *&to_port) + const LibertyPort *&to_port) { InputDriveCell *drive = drive_cells_[rf->index()][min_max->index()]; if (drive) { @@ -170,11 +170,11 @@ InputDrive::slew(const RiseFall *rf, //////////////////////////////////////////////////////////////// -InputDriveCell::InputDriveCell(LibertyLibrary *library, - LibertyCell *cell, - LibertyPort *from_port, +InputDriveCell::InputDriveCell(const LibertyLibrary *library, + const LibertyCell *cell, + const LibertyPort *from_port, float *from_slews, - LibertyPort *to_port) : + const LibertyPort *to_port) : library_(library), cell_(cell), from_port_(from_port), @@ -184,25 +184,25 @@ InputDriveCell::InputDriveCell(LibertyLibrary *library, } void -InputDriveCell::setLibrary(LibertyLibrary *library) +InputDriveCell::setLibrary(const LibertyLibrary *library) { library_ = library; } void -InputDriveCell::setCell(LibertyCell *cell) +InputDriveCell::setCell(const LibertyCell *cell) { cell_ = cell; } void -InputDriveCell::setFromPort(LibertyPort *from_port) +InputDriveCell::setFromPort(const LibertyPort *from_port) { from_port_ = from_port; } void -InputDriveCell::setToPort(LibertyPort *to_port) +InputDriveCell::setToPort(const LibertyPort *to_port) { to_port_ = to_port; } @@ -215,7 +215,7 @@ InputDriveCell::setFromSlews(float *from_slews) } bool -InputDriveCell::equal(InputDriveCell *drive) const +InputDriveCell::equal(const InputDriveCell *drive) const { int rise_index = RiseFall::riseIndex(); int fall_index = RiseFall::fallIndex(); diff --git a/sdc/PinPair.cc b/sdc/PinPair.cc index 5d6bf7ca..88b72706 100644 --- a/sdc/PinPair.cc +++ b/sdc/PinPair.cc @@ -16,32 +16,57 @@ #include "PinPair.hh" +#include "Network.hh" + namespace sta { -bool -PinPairLess::operator()(const PinPair *pair1, - const PinPair *pair2) const +PinPairLess::PinPairLess(const Network *network) : + network_(network) { - return pair1->first < pair2->first - || (pair1->first == pair2->first - && pair1->second < pair2->second); } bool -PinPairEqual::operator()(const PinPair *pair1, - const PinPair *pair2) const +PinPairLess::operator()(const PinPair &pair1, + const PinPair &pair2) const +{ + const Pin *pair1_pin1 = pair1.first; + const Pin *pair1_pin2 = pair1.second; + const Pin *pair2_pin1 = pair2.first; + const Pin *pair2_pin2 = pair2.second; + return (pair1_pin1 == nullptr && pair2_pin1) + || (pair1_pin1 && pair2_pin1 + && (network_->id(pair1_pin1) < network_->id(pair2_pin1) + || (pair1_pin1 == pair2_pin1 + && ((pair1_pin2 == nullptr && pair2_pin2) + || (pair1_pin2 && pair2_pin2 + && network_->id(pair1_pin2) < network_->id(pair2_pin2)))))); +} + +bool +PinPairEqual::operator()(const PinPair &pair1, + const PinPair &pair2) const +{ + return pair1.first == pair2.first + && pair1.second == pair2.second; +} + +PinPairHash::PinPairHash(const Network *network) : + network_(network) { - return pair1->first == pair2->first - && pair1->second == pair2->second; } size_t -PinPairHash::operator()(const PinPair *pair) const +PinPairHash::operator()(const PinPair &pair) const { size_t hash = hash_init_value; - hashIncr(hash, hashPtr(pair->first)); - hashIncr(hash, hashPtr(pair->second)); + hashIncr(hash, network_->id(pair.first)); + hashIncr(hash, network_->id(pair.second)); return hash; } +PinPairSet::PinPairSet(const Network *network) : + Set(PinPairLess(network)) +{ +} + } // namespace diff --git a/sdc/PortDelay.cc b/sdc/PortDelay.cc index e5f6c243..50739df8 100644 --- a/sdc/PortDelay.cc +++ b/sdc/PortDelay.cc @@ -21,15 +21,16 @@ namespace sta { -PortDelay::PortDelay(Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin) : +PortDelay::PortDelay(const Pin *pin, + const ClockEdge *clk_edge, + const Network *network) : pin_(pin), clk_edge_(clk_edge), source_latency_included_(false), network_latency_included_(false), - ref_pin_(ref_pin), - delays_() + ref_pin_(nullptr), + delays_(), + leaf_pins_(network) { } @@ -42,6 +43,12 @@ PortDelay::clock() const return nullptr; } +void +PortDelay::setRefPin(const Pin *ref_pin) +{ + ref_pin_ = ref_pin; +} + bool PortDelay::sourceLatencyIncluded() const { @@ -76,22 +83,20 @@ PortDelay::refTransition() const return RiseFall::rise(); } -InputDelay::InputDelay(Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin, +InputDelay::InputDelay(const Pin *pin, + const ClockEdge *clk_edge, int index, - Network *network) : - PortDelay(pin, clk_edge, ref_pin), + const Network *network) : + PortDelay(pin, clk_edge, network), index_(index) { findLeafLoadPins(pin, network, &leaf_pins_); } -OutputDelay::OutputDelay(Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin, - Network *network) : - PortDelay(pin, clk_edge, ref_pin) +OutputDelay::OutputDelay(const Pin *pin, + const ClockEdge *clk_edge, + const Network *network) : + PortDelay(pin, clk_edge, network) { if (network) findLeafDriverPins(pin, network, &leaf_pins_); @@ -106,10 +111,10 @@ PortDelayLess::PortDelayLess(const Network *network) : bool PortDelayLess::operator() (const PortDelay *delay1, - const PortDelay *delay2) const + const PortDelay *delay2) const { - Pin *pin1 = delay1->pin(); - Pin *pin2 = delay2->pin(); + const Pin *pin1 = delay1->pin(); + const Pin *pin2 = delay2->pin(); int pin_cmp = network_->pathNameCmp(pin1, pin2); if (pin_cmp < 0) return true; diff --git a/sdc/PortExtCap.cc b/sdc/PortExtCap.cc index df7f7b02..1ef146f6 100644 --- a/sdc/PortExtCap.cc +++ b/sdc/PortExtCap.cc @@ -18,7 +18,7 @@ namespace sta { -PortExtCap::PortExtCap(Port *port) : +PortExtCap::PortExtCap(const Port *port) : port_(port) { } diff --git a/sdc/Sdc.cc b/sdc/Sdc.cc index f31f29f0..e5cf8dbb 100644 --- a/sdc/Sdc.cc +++ b/sdc/Sdc.cc @@ -82,41 +82,45 @@ clone(ExceptionThruSeq *thrus, Sdc::Sdc(StaState *sta) : StaState(sta), derating_factors_(nullptr), - net_derating_factors_(nullptr), - inst_derating_factors_(nullptr), - cell_derating_factors_(nullptr), clk_index_(0), - clk_insertions_(nullptr), - clk_group_exclusions_(nullptr), - clk_group_same_(nullptr), + clock_pin_map_(PinIdHash(network_)), + clock_leaf_pin_map_(PinIdHash(network_)), + clk_hpin_disables_(network_), + propagated_clk_pins_(network_), + clk_latencies_(network_), + clk_insertions_(network_), clk_sense_map_(network_), clk_gating_check_(nullptr), cycle_acctings_(this), + + input_delay_pin_map_(PinIdLess(network_)), + input_delay_ref_pin_map_(PinIdLess(network_)), + input_delay_leaf_pin_map_(PinIdLess(network_)), + input_delay_internal_pin_map_(PinIdLess(network_)), input_delay_index_(0), - port_cap_map_(nullptr), - net_wire_cap_map_(nullptr), - drvr_pin_wire_cap_map_(nullptr), + + output_delay_pin_map_(PinIdLess(network_)), + output_delay_ref_pin_map_(PinIdLess(network_)), + output_delay_leaf_pin_map_(PinIdLess(network_)), + + disabled_pins_(network_), + disabled_ports_(network_), + disabled_wire_edges_(network_), + disabled_clk_gating_checks_inst_(network_), + disabled_clk_gating_checks_pin_(network_), have_thru_hpin_exceptions_(false), - first_from_pin_exceptions_(nullptr), - first_from_clk_exceptions_(nullptr), - first_from_inst_exceptions_(nullptr), - first_thru_pin_exceptions_(nullptr), - first_thru_inst_exceptions_(nullptr), - first_thru_net_exceptions_(nullptr), - first_to_pin_exceptions_(nullptr), - first_to_clk_exceptions_(nullptr), - first_to_inst_exceptions_(nullptr), - first_thru_edge_exceptions_(nullptr), - path_delay_internal_startpoints_(nullptr), - path_delay_internal_endpoints_(nullptr) + first_thru_edge_exceptions_(0, PinPairHash(network_), PinPairEqual()), + path_delay_internal_startpoints_(network_), + path_delay_internal_endpoints_(network_) { - initVariables(); sdc_ = this; + initVariables(); + if (corners_) + makeCornersAfter(corners_); setWireload(nullptr, MinMaxAll::all()); setWireloadSelection(nullptr, MinMaxAll::all()); setOperatingConditions(nullptr, MinMaxAll::all()); makeDefaultArrivalClock(); - initInstancePvtMaps(); } void @@ -125,7 +129,7 @@ Sdc::makeDefaultArrivalClock() FloatSeq *waveform = new FloatSeq; waveform->push_back(0.0); waveform->push_back(0.0); - default_arrival_clk_ = new Clock("input port clock", clk_index_++); + default_arrival_clk_ = new Clock("input port clock", clk_index_++, network_); default_arrival_clk_->initClk(0, false, 0.0, waveform, nullptr, network_); } @@ -148,8 +152,7 @@ Sdc::clear() clock_leaf_pin_map_.clear(); clk_latencies_.clear(); edge_clk_latency_.clear(); - if (clk_insertions_) - clk_insertions_->clear(); + clk_insertions_.clear(); pin_clk_uncertainty_map_.clear(); inter_clk_uncertainties_.clear(); @@ -247,11 +250,7 @@ Sdc::deleteConstraints() clock_pin_map_.deleteContents(); clock_leaf_pin_map_.deleteContents(); clk_latencies_.deleteContents(); - if (clk_insertions_) { - clk_insertions_->deleteContents(); - delete clk_insertions_; - clk_insertions_ = nullptr; - } + clk_insertions_.deleteContents(); clk_groups_name_map_.deleteContents(); clearClkGroupExclusions(); @@ -270,28 +269,24 @@ Sdc::deleteConstraints() inst_min_pulse_width_map_.deleteContentsClear(); clk_min_pulse_width_map_.deleteContentsClear(); - DataChecksMap::Iterator data_checks_iter1(data_checks_from_map_); - while (data_checks_iter1.hasNext()) { - DataCheckSet *checks = data_checks_iter1.next(); + for (auto pin_data_check : data_checks_from_map_) { + DataCheckSet *checks = pin_data_check.second; checks->deleteContents(); delete checks; } - DataChecksMap::Iterator data_checks_iter2(data_checks_to_map_); - while (data_checks_iter2.hasNext()) { - DataCheckSet *checks = data_checks_iter2.next(); + for (auto pin_data_check : data_checks_from_map_) { + DataCheckSet *checks = pin_data_check.second; delete checks; } - for (InputDelay *input_delay : input_delays_) - delete input_delay; + input_delays_.deleteContents(); input_delay_pin_map_.deleteContents(); input_delay_leaf_pin_map_.deleteContents(); input_delay_ref_pin_map_.deleteContents(); input_delay_internal_pin_map_.deleteContents(); - for (OutputDelay *output_delay : output_delays_) - delete output_delay; + output_delays_.deleteContents(); output_delay_pin_map_.deleteContents(); output_delay_ref_pin_map_.deleteContents(); output_delay_leaf_pin_map_.deleteContents(); @@ -302,115 +297,81 @@ Sdc::deleteConstraints() clearCycleAcctings(); deleteExceptions(); clearGroupPathMap(); - deleteInstancePvts(); deleteDeratingFactors(); - removeLoadCaps(); + + for (int corner_index = 0; corner_index < corners_->count(); corner_index++) { + port_ext_cap_maps_[corner_index].deleteContentsClear(); + net_wire_cap_maps_[corner_index].clear(); + } + port_ext_cap_maps_.clear(); + net_wire_cap_maps_.clear(); + clk_sense_map_.clear(); -} -void -Sdc::deleteInstancePvts() -{ - // Multiple instances can share a pvt, so put them in a set - // so they are only deleted once. - PvtSet pvts; - for (auto mm_index : MinMax::rangeIndex()) { - InstancePvtMap *pvt_map = instance_pvt_maps_[mm_index]; - InstancePvtMap::Iterator pvt_iter(pvt_map); - while (pvt_iter.hasNext()) { - Pvt *pvt = pvt_iter.next(); - pvts.insert(pvt); - } - delete pvt_map; - } - pvts.deleteContents(); -} - -void -Sdc::removeNetLoadCaps() -{ - delete [] net_wire_cap_map_; - net_wire_cap_map_ = nullptr; - - delete [] drvr_pin_wire_cap_map_; - drvr_pin_wire_cap_map_ = nullptr; -} - -void -Sdc::removeLoadCaps() -{ - if (port_cap_map_) { - port_cap_map_->deleteContents(); - delete port_cap_map_; - port_cap_map_ = nullptr; - } - removeNetLoadCaps(); + for (int mm_index : MinMax::rangeIndex()) + instance_pvt_maps_[mm_index].deleteContentsClear(); } void Sdc::removeLibertyAnnotations() { - DisabledCellPortsMap::Iterator disabled_iter(disabled_cell_ports_); - while (disabled_iter.hasNext()) { - DisabledCellPorts *disable = disabled_iter.next(); + for (auto cell_port : disabled_cell_ports_) { + DisabledCellPorts *disable = cell_port.second; LibertyCell *cell = disable->cell(); if (disable->all()) cell->setIsDisabledConstraint(false); - LibertyPortSet::Iterator from_iter(disable->from()); - while (from_iter.hasNext()) { - LibertyPort *from = from_iter.next(); - from->setIsDisabledConstraint(false); + if (disable->from()) { + for (LibertyPort *from : *disable->from()) + from->setIsDisabledConstraint(false); } - LibertyPortSet::Iterator to_iter(disable->to()); - while (to_iter.hasNext()) { - LibertyPort *to = to_iter.next(); - to->setIsDisabledConstraint(false); + if (disable->to()) { + for (LibertyPort *to : *disable->to()) + to->setIsDisabledConstraint(false); } if (disable->timingArcSets()) { - TimingArcSetSet::Iterator arc_iter(disable->timingArcSets()); - while (arc_iter.hasNext()) { - TimingArcSet *arc_set = arc_iter.next(); + for (TimingArcSet *arc_set : *disable->timingArcSets()) arc_set->setIsDisabledConstraint(false); + } + + + if (disable->fromTo()) { + for (const LibertyPortPair &pair : *disable->fromTo()) { + const LibertyPort *from = pair.first; + const LibertyPort *to = pair.second; + for (TimingArcSet *arc_set : cell->timingArcSets(from, to)) + arc_set->setIsDisabledConstraint(false); } } - - LibertyPortPairSet::Iterator from_to_iter(disable->fromTo()); - while (from_to_iter.hasNext()) { - LibertyPortPair *pair = from_to_iter.next(); - const LibertyPort *from = pair->first; - const LibertyPort *to = pair->second; - for (TimingArcSet *arc_set : cell->timingArcSets(from, to)) - arc_set->setIsDisabledConstraint(false); - } } - LibertyPortSet::Iterator port_iter(disabled_lib_ports_); - while (port_iter.hasNext()) { - LibertyPort *port = port_iter.next(); + for (LibertyPort *port : disabled_lib_ports_) port->setIsDisabledConstraint(false); +} + +void +Sdc::deleteNetBefore(const Net *net) +{ + for (int corner_index = 0; corner_index < corners_->count(); corner_index++) { + net_wire_cap_maps_[corner_index].erase(net); + for (const Pin *pin : *network_->drivers(net)) + drvr_pin_wire_cap_maps_[corner_index].erase(pin); } } void -Sdc::initInstancePvtMaps() +Sdc::makeCornersAfter(Corners *corners) { - for (auto mm_index : MinMax::rangeIndex()) - instance_pvt_maps_[mm_index] = nullptr; -} + corners_ = corners; + port_ext_cap_maps_.clear(); + net_wire_cap_maps_.clear(); + drvr_pin_wire_cap_maps_.clear(); -void -Sdc::deleteNetBefore(Net *net) -{ - if (net_wire_cap_map_) { - for (int corner_index = 0; corner_index < corners_->count(); corner_index++) { - net_wire_cap_map_[corner_index].erase(net); - for (Pin *pin : *network_->drivers(net)) - drvr_pin_wire_cap_map_[corner_index].erase(pin); - } - } + port_ext_cap_maps_.resize(corners_->count(), PortExtCapMap(PortIdLess(network_))); + net_wire_cap_maps_.resize(corners_->count(), NetWireCapMap(NetIdLess(network_))); + drvr_pin_wire_cap_maps_.resize(corners_->count(), PinWireCapMap(PinIdLess(network_))); } //////////////////////////////////////////////////////////////// @@ -438,12 +399,9 @@ Sdc::isConstrained(const Pin *pin) const || disabled_pins_.hasKey(pin1) || disabled_ports_.hasKey(port) || disabled_clk_gating_checks_pin_.hasKey(pin1) - || (first_from_pin_exceptions_ - && first_from_pin_exceptions_->hasKey(pin)) - || (first_thru_pin_exceptions_ - && first_thru_pin_exceptions_->hasKey(pin)) - || (first_to_pin_exceptions_ - && first_to_pin_exceptions_->hasKey(pin)) + || first_from_pin_exceptions_.hasKey(pin) + || first_thru_pin_exceptions_.hasKey(pin) + || first_to_pin_exceptions_.hasKey(pin) || input_drive_map_.hasKey(port) || logic_value_map_.hasKey(pin) || case_value_map_.hasKey(pin) @@ -455,20 +413,14 @@ bool Sdc::isConstrained(const Instance *inst) const { Instance *inst1 = const_cast(inst); - return (instance_pvt_maps_[MinMax::minIndex()] - && instance_pvt_maps_[MinMax::minIndex()]->hasKey(inst1)) - || (instance_pvt_maps_[MinMax::maxIndex()] - && instance_pvt_maps_[MinMax::maxIndex()]->hasKey(inst1)) - || (inst_derating_factors_ - && inst_derating_factors_->hasKey(inst)) + return instance_pvt_maps_[MinMax::minIndex()].hasKey(inst1) + || instance_pvt_maps_[MinMax::maxIndex()].hasKey(inst1) + || inst_derating_factors_.hasKey(inst) || inst_clk_gating_check_map_.hasKey(inst) || disabled_inst_ports_.hasKey(inst1) - || (first_from_inst_exceptions_ - && first_from_inst_exceptions_->hasKey(inst)) - || (first_thru_inst_exceptions_ - && first_thru_inst_exceptions_->hasKey(inst)) - || (first_to_inst_exceptions_ - && first_to_inst_exceptions_->hasKey(inst)) + || first_from_inst_exceptions_.hasKey(inst) + || first_thru_inst_exceptions_.hasKey(inst) + || first_to_inst_exceptions_.hasKey(inst) || inst_latch_borrow_limit_map_.hasKey(inst) || inst_min_pulse_width_map_.hasKey(inst); } @@ -477,12 +429,10 @@ bool Sdc::isConstrained(const Net *net) const { Net *net1 = const_cast(net); - return (net_derating_factors_ - && net_derating_factors_->hasKey(net)) + return net_derating_factors_.hasKey(net) || hasNetWireCap(net1) || net_res_map_.hasKey(net1) - || (first_thru_net_exceptions_ - && first_thru_net_exceptions_->hasKey(net)); + || first_thru_net_exceptions_.hasKey(net); } //////////////////////////////////////////////////////////////// @@ -516,29 +466,22 @@ Sdc::operatingConditions(const MinMax *min_max) return operating_conditions_[mm_index]; } -Pvt * +const Pvt * Sdc::pvt(Instance *inst, const MinMax *min_max) const { - InstancePvtMap *pvt_map = instance_pvt_maps_[min_max->index()]; - if (pvt_map) - return pvt_map->findKey(inst); - else - return nullptr; + const InstancePvtMap &pvt_map = instance_pvt_maps_[min_max->index()]; + return pvt_map.findKey(inst); } void -Sdc::setPvt(Instance *inst, const - MinMaxAll *min_max, - Pvt *pvt) +Sdc::setPvt(const Instance *inst, + const MinMaxAll *min_max, + const Pvt &pvt) { for (auto mm_index : min_max->rangeIndex()) { - InstancePvtMap *pvt_map = instance_pvt_maps_[mm_index]; - if (pvt_map == nullptr) { - pvt_map = new InstancePvtMap; - instance_pvt_maps_[mm_index] = pvt_map; - } - (*pvt_map)[inst] = pvt; + InstancePvtMap &pvt_map = instance_pvt_maps_[mm_index]; + pvt_map[inst] = new Pvt(pvt); } } @@ -563,12 +506,10 @@ Sdc::setTimingDerate(const Net *net, const EarlyLate *early_late, float derate) { - if (net_derating_factors_ == nullptr) - net_derating_factors_ = new NetDeratingFactorsMap; - DeratingFactorsNet *factors = net_derating_factors_->findKey(net); + DeratingFactorsNet *factors = net_derating_factors_.findKey(net); if (factors == nullptr) { factors = new DeratingFactorsNet; - (*net_derating_factors_)[net] = factors; + net_derating_factors_[net] = factors; } factors->setFactor(clk_data, rf, early_late, derate); } @@ -581,12 +522,10 @@ Sdc::setTimingDerate(const Instance *inst, const EarlyLate *early_late, float derate) { - if (inst_derating_factors_ == nullptr) - inst_derating_factors_ = new InstDeratingFactorsMap; - DeratingFactorsCell *factors = inst_derating_factors_->findKey(inst); + DeratingFactorsCell *factors = inst_derating_factors_.findKey(inst); if (factors == nullptr) { factors = new DeratingFactorsCell; - (*inst_derating_factors_)[inst] = factors; + inst_derating_factors_[inst] = factors; } factors->setFactor(type, clk_data, rf, early_late, derate); } @@ -599,12 +538,10 @@ Sdc::setTimingDerate(const LibertyCell *cell, const EarlyLate *early_late, float derate) { - if (cell_derating_factors_ == nullptr) - cell_derating_factors_ = new CellDeratingFactorsMap; - DeratingFactorsCell *factors = cell_derating_factors_->findKey(cell); + DeratingFactorsCell *factors = cell_derating_factors_.findKey(cell); if (factors == nullptr) { factors = new DeratingFactorsCell; - (*cell_derating_factors_)[cell] = factors; + cell_derating_factors_[cell] = factors; } factors->setFactor(type, clk_data, rf, early_late, derate); } @@ -616,32 +553,28 @@ Sdc::timingDerateInstance(const Pin *pin, const RiseFall *rf, const EarlyLate *early_late) const { - if (inst_derating_factors_) { - const Instance *inst = network_->instance(pin); - DeratingFactorsCell *factors = inst_derating_factors_->findKey(inst); + const Instance *inst = network_->instance(pin); + DeratingFactorsCell *factors = inst_derating_factors_.findKey(inst); + if (factors) { + float factor; + bool exists; + factors->factor(type, clk_data, rf, early_late, factor, exists); + if (exists) + return factor; + } + + const LibertyCell *cell = network_->libertyCell(inst); + if (cell) { + DeratingFactorsCell *factors = cell_derating_factors_.findKey(cell); + float factor; + bool exists; if (factors) { - float factor; - bool exists; factors->factor(type, clk_data, rf, early_late, factor, exists); if (exists) - return factor; + return factor; } } - if (cell_derating_factors_) { - const Instance *inst = network_->instance(pin); - const LibertyCell *cell = network_->libertyCell(inst); - if (cell) { - DeratingFactorsCell *factors = cell_derating_factors_->findKey(cell); - float factor; - bool exists; - if (factors) { - factors->factor(type, clk_data, rf, early_late, factor, exists); - if (exists) - return factor; - } - } - } if (derating_factors_) { float factor; bool exists; @@ -658,17 +591,16 @@ Sdc::timingDerateNet(const Pin *pin, const RiseFall *rf, const EarlyLate *early_late) const { - if (net_derating_factors_) { - const Net *net = network_->net(pin); - DeratingFactorsNet *factors = net_derating_factors_->findKey(net); - if (factors) { - float factor; - bool exists; - factors->factor(clk_data, rf, early_late, factor, exists); - if (exists) - return factor; - } + const Net *net = network_->net(pin); + DeratingFactorsNet *factors = net_derating_factors_.findKey(net); + if (factors) { + float factor; + bool exists; + factors->factor(clk_data, rf, early_late, factor, exists); + if (exists) + return factor; } + if (derating_factors_) { float factor; bool exists; @@ -694,40 +626,26 @@ Sdc::moveDeratingFactors(Sdc *from, to->derating_factors_ = from->derating_factors_; from->derating_factors_ = nullptr; } - if (from->net_derating_factors_) { - to->net_derating_factors_ = from->net_derating_factors_; - from->net_derating_factors_ = nullptr; - } - if (from->inst_derating_factors_) { - to->inst_derating_factors_ = from->inst_derating_factors_; - from->inst_derating_factors_ = nullptr; - } - if (from->cell_derating_factors_) { - to->cell_derating_factors_ = from->cell_derating_factors_; - from->cell_derating_factors_ = nullptr; - } + + to->net_derating_factors_.deleteContents(); + to->net_derating_factors_ = from->net_derating_factors_; + from->net_derating_factors_.clear(); + + to->inst_derating_factors_.deleteContents(); + to->inst_derating_factors_ = from->inst_derating_factors_; + from->inst_derating_factors_.clear(); + + to->cell_derating_factors_.deleteContents(); + to->cell_derating_factors_ = from->cell_derating_factors_; + from->cell_derating_factors_.clear(); } void Sdc::deleteDeratingFactors() { - if (net_derating_factors_) { - net_derating_factors_->deleteContents(); - delete net_derating_factors_; - net_derating_factors_ = nullptr; - } - - if (inst_derating_factors_) { - inst_derating_factors_->deleteContents(); - delete inst_derating_factors_; - inst_derating_factors_ = nullptr; - } - - if (cell_derating_factors_) { - cell_derating_factors_->deleteContents(); - delete cell_derating_factors_; - cell_derating_factors_ = nullptr; - } + net_derating_factors_.deleteContents(); + inst_derating_factors_.deleteContents(); + cell_derating_factors_.deleteContents(); delete derating_factors_; derating_factors_ = nullptr; @@ -736,12 +654,12 @@ Sdc::deleteDeratingFactors() //////////////////////////////////////////////////////////////// void -Sdc::setDriveCell(LibertyLibrary *library, - LibertyCell *cell, - Port *port, - LibertyPort *from_port, +Sdc::setDriveCell(const LibertyLibrary *library, + const LibertyCell *cell, + const Port *port, + const LibertyPort *from_port, float *from_slews, - LibertyPort *to_port, + const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max) { @@ -750,7 +668,7 @@ Sdc::setDriveCell(LibertyLibrary *library, } void -Sdc::setInputSlew(Port *port, +Sdc::setInputSlew(const Port *port, const RiseFallBoth *rf, const MinMaxAll *min_max, float slew) @@ -759,7 +677,7 @@ Sdc::setInputSlew(Port *port, } void -Sdc::setDriveResistance(Port *port, +Sdc::setDriveResistance(const Port *port, const RiseFallBoth *rf, const MinMaxAll *min_max, float res) @@ -768,7 +686,7 @@ Sdc::setDriveResistance(Port *port, } InputDrive * -Sdc::ensureInputDrive(Port *port) +Sdc::ensureInputDrive(const Port *port) { InputDrive *drive = input_drive_map_.findKey(port); if (drive == nullptr) { @@ -995,7 +913,7 @@ Sdc::makeClock(const char *name, deleteClkPinMappings(clk); else { // Fresh clock definition. - clk = new Clock(name, clk_index_++); + clk = new Clock(name, clk_index_++, network_); clk->setIsPropagated(propagate_all_clks_); clocks_.push_back(clk); // Use the copied name in the map. @@ -1030,7 +948,7 @@ Sdc::makeGeneratedClock(const char *name, if (clk) deleteClkPinMappings(clk); else { - clk = new Clock(name, clk_index_++); + clk = new Clock(name, clk_index_++, network_); clocks_.push_back(clk); clock_name_map_[clk->name()] = clk; } @@ -1065,27 +983,19 @@ Sdc::deletePinClocks(Clock *defining_clk, // Find all the clocks defined on pins to avoid finding the clock's // vertex pins multiple times. ClockSet clks; - PinSet::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - ClockSet *pin_clks = clock_pin_map_.findKey(pin); - if (pin_clks) { - ClockSet::Iterator clk_iter(pin_clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); - clks.insert(clk); + if (pins) { + for (const Pin *pin : *pins) { + ClockSet *pin_clks = clock_pin_map_.findKey(pin); + if (pin_clks) { + for (Clock *clk : *pin_clks) + clks.insert(clk); } } } - ClockSet::Iterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); + for (Clock *clk : clks) { deleteClkPinMappings(clk); - PinSet::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : *pins) clk->deletePin(pin); - } if (clk != defining_clk) { if (clk->pins().empty()) removeClock(clk); @@ -1102,7 +1012,7 @@ Sdc::deletePinClocks(Clock *defining_clk, void Sdc::deleteClkPinMappings(Clock *clk) { - for (Pin *pin : clk->pins()) { + for (const Pin *pin : clk->pins()) { ClockSet *pin_clks = clock_pin_map_.findKey(pin); if (pin_clks) { pin_clks->erase(clk); @@ -1128,7 +1038,7 @@ Sdc::deleteClkPinMappings(Clock *clk) void Sdc::makeClkPinMappings(Clock *clk) { - for (Pin *pin : clk->pins()) { + for (const Pin *pin : clk->pins()) { ClockSet *pin_clks = clock_pin_map_.findKey(pin); if (pin_clks == nullptr) { pin_clks = new ClockSet; @@ -1218,9 +1128,7 @@ Sdc::isLeafPinNonGeneratedClock(const Pin *pin) const { ClockSet *clks = findLeafPinClocks(pin); if (clks) { - ClockSet::Iterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); + for (Clock *clk : *clks) { if (!clk->isGenerated()) return true; } @@ -1242,21 +1150,22 @@ Sdc::findClocks(const Pin *pin) const return clock_pin_map_.findKey(pin); } -void -Sdc::findClocksMatching(PatternMatch *pattern, - ClockSeq *clks) const +ClockSeq +Sdc::findClocksMatching(PatternMatch *pattern) const { + ClockSeq matches; if (!pattern->hasWildcards()) { Clock *clk = findClock(pattern->pattern()); if (clk) - clks->push_back(clk); + matches.push_back(clk); } else { for (auto clk : clocks_) { if (pattern->match(clk->name())) - clks->push_back(clk); + matches.push_back(clk); } } + return matches; } void @@ -1294,25 +1203,26 @@ ClkHpinDisable::ClkHpinDisable(const Clock *clk, { } +ClkHpinDisableLess::ClkHpinDisableLess(const Network *network) : + network_(network) +{ +} + bool ClkHpinDisableLess::operator()(const ClkHpinDisable *disable1, const ClkHpinDisable *disable2) const { int clk_index1 = disable1->clk()->index(); int clk_index2 = disable2->clk()->index(); - if (clk_index1 == clk_index2) { - const Pin *from_pin1 = disable1->fromPin(); - const Pin *from_pin2 = disable2->fromPin(); - if (from_pin1 == from_pin2) { - const Pin *to_pin1 = disable1->toPin(); - const Pin *to_pin2 = disable2->toPin(); - return to_pin1 < to_pin2; - } - else - return from_pin1 < from_pin2; - } - else - return clk_index1 < clk_index2; + const Pin *from_pin1 = disable1->fromPin(); + const Pin *from_pin2 = disable2->fromPin(); + const Pin *to_pin1 = disable1->toPin(); + const Pin *to_pin2 = disable2->toPin(); + return clk_index1 < clk_index2 + || (clk_index1 == clk_index2 + && (network_->id(to_pin1) < network_->id(to_pin2) + || (from_pin1 == from_pin2 + && network_->id(from_pin1) < network_->id(from_pin2)))); } class FindClkHpinDisables : public HpinDrvrLoadVisitor @@ -1321,15 +1231,14 @@ public: FindClkHpinDisables(Clock *clk, const Network *network, Sdc *sdc); - ~FindClkHpinDisables(); - bool drvrLoadExists(Pin *drvr, - Pin *load); + bool drvrLoadExists(const Pin *drvr, + const Pin *load); protected: virtual void visit(HpinDrvrLoad *drvr_load); - void makeClkHpinDisables(Pin *clk_src, - Pin *drvr, - Pin *load); + void makeClkHpinDisables(const Pin *clk_src, + const Pin *drvr, + const Pin *load); Clock *clk_; PinPairSet drvr_loads_; @@ -1342,56 +1251,49 @@ FindClkHpinDisables::FindClkHpinDisables(Clock *clk, Sdc *sdc) : HpinDrvrLoadVisitor(), clk_(clk), + drvr_loads_(network), network_(network), sdc_(sdc) { } -FindClkHpinDisables::~FindClkHpinDisables() -{ - drvr_loads_.deleteContents(); -} - void FindClkHpinDisables::visit(HpinDrvrLoad *drvr_load) { - Pin *drvr = drvr_load->drvr(); - Pin *load = drvr_load->load(); + const Pin *drvr = drvr_load->drvr(); + const Pin *load = drvr_load->load(); makeClkHpinDisables(drvr, drvr, load); PinSet *hpins_from_drvr = drvr_load->hpinsFromDrvr(); - PinSet::Iterator hpin_iter(hpins_from_drvr); - while (hpin_iter.hasNext()) { - Pin *hpin = hpin_iter.next(); + for (const Pin *hpin : *hpins_from_drvr) makeClkHpinDisables(hpin, drvr, load); - } - drvr_loads_.insert(new PinPair(drvr, load)); + drvr_loads_.insert(PinPair(drvr, load)); } void -FindClkHpinDisables::makeClkHpinDisables(Pin *clk_src, - Pin *drvr, - Pin *load) +FindClkHpinDisables::makeClkHpinDisables(const Pin *clk_src, + const Pin *drvr, + const Pin *load) { ClockSet *clks = sdc_->findClocks(clk_src); - ClockSet::Iterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); - if (clk != clk_) - // Do not propagate clock from source pin if another - // clock is defined on a hierarchical pin between the - // driver and load. - sdc_->makeClkHpinDisable(clk, drvr, load); + if (clks) { + for (Clock *clk : *clks) { + if (clk != clk_) + // Do not propagate clock from source pin if another + // clock is defined on a hierarchical pin between the + // driver and load. + sdc_->makeClkHpinDisable(clk, drvr, load); + } } } bool -FindClkHpinDisables::drvrLoadExists(Pin *drvr, - Pin *load) +FindClkHpinDisables::drvrLoadExists(const Pin *drvr, + const Pin *load) { PinPair probe(drvr, load); - return drvr_loads_.hasKey(&probe); + return drvr_loads_.hasKey(probe); } void @@ -1400,19 +1302,19 @@ Sdc::ensureClkHpinDisables() if (!clk_hpin_disables_valid_) { clk_hpin_disables_.deleteContentsClear(); for (auto clk : clocks_) { - for (Pin *src : clk->pins()) { + for (const Pin *src : clk->pins()) { if (network_->isHierarchical(src)) { FindClkHpinDisables visitor1(clk, network_, this); visitHpinDrvrLoads(src, network_, &visitor1); PinSeq loads, drvrs; - PinSet visited_drvrs; + PinSet visited_drvrs(network_); FindNetDrvrLoads visitor2(nullptr, visited_drvrs, loads, drvrs, network_); network_->visitConnectedPins(src, visitor2); // Disable fanouts from the src driver pins that do // not go thru the hierarchical src pin. - for (Pin *drvr : drvrs) { - for (Pin *load : loads) { + for (const Pin *drvr : drvrs) { + for (const Pin *load : loads) { if (!visitor1.drvrLoadExists(drvr, load)) makeClkHpinDisable(clk, drvr, load); } @@ -1425,9 +1327,9 @@ Sdc::ensureClkHpinDisables() } void -Sdc::makeClkHpinDisable(Clock *clk, - Pin *drvr, - Pin *load) +Sdc::makeClkHpinDisable(const Clock *clk, + const Pin *drvr, + const Pin *load) { ClkHpinDisable probe(clk, drvr, load); if (!clk_hpin_disables_.hasKey(&probe)) { @@ -1550,11 +1452,15 @@ Sdc::deleteClockLatency(ClockLatency *latency) void Sdc::deleteClockLatenciesReferencing(Clock *clk) { - ClockLatencies::Iterator latency_iter(clk_latencies_); - while (latency_iter.hasNext()) { - ClockLatency *latency = latency_iter.next(); - if (latency->clock() == clk) - deleteClockLatency(latency); + for (auto iter = clk_latencies_.cbegin(); + iter != clk_latencies_.cend(); ) { + ClockLatency *latency = *iter; + if (latency->clock() == clk) { + iter = clk_latencies_.erase(iter); + delete latency; + } + else + iter++; } } @@ -1734,12 +1640,16 @@ Sdc::deleteInterClockUncertainty(InterClockUncertainty *uncertainties) void Sdc::deleteInterClockUncertaintiesReferencing(Clock *clk) { - InterClockUncertaintySet::Iterator inter_iter(inter_clk_uncertainties_); - while (inter_iter.hasNext()) { - InterClockUncertainty *uncertainties = inter_iter.next(); + for (auto iter = inter_clk_uncertainties_.cbegin(); + iter != inter_clk_uncertainties_.cend(); ) { + InterClockUncertainty *uncertainties = *iter; if (uncertainties->src() == clk - || uncertainties->target() == clk) - deleteInterClockUncertainty(uncertainties); + || uncertainties->target() == clk) { + iter = inter_clk_uncertainties_.erase(iter); + delete uncertainties; + } + else + iter++; } } @@ -1753,13 +1663,11 @@ Sdc::setClockInsertion(const Clock *clk, const EarlyLateAll *early_late, float delay) { - if (clk_insertions_ == nullptr) - clk_insertions_ = new ClockInsertions; ClockInsertion probe(clk, pin); - ClockInsertion *insertion = clk_insertions_->findKey(&probe); + ClockInsertion *insertion = clk_insertions_.findKey(&probe); if (insertion == nullptr) { insertion = new ClockInsertion(clk, pin); - clk_insertions_->insert(insertion); + clk_insertions_.insert(insertion); } insertion->setDelay(rf, min_max, early_late, delay); } @@ -1772,13 +1680,11 @@ Sdc::setClockInsertion(const Clock *clk, const EarlyLate *early_late, float delay) { - if (clk_insertions_ == nullptr) - clk_insertions_ = new ClockInsertions; ClockInsertion probe(clk, pin); - ClockInsertion *insertion = clk_insertions_->findKey(&probe); + ClockInsertion *insertion = clk_insertions_.findKey(&probe); if (insertion == nullptr) { insertion = new ClockInsertion(clk, pin); - clk_insertions_->insert(insertion); + clk_insertions_.insert(insertion); } insertion->setDelay(rf, min_max, early_late, delay); } @@ -1787,29 +1693,31 @@ void Sdc::removeClockInsertion(const Clock *clk, const Pin *pin) { - if (clk_insertions_) { - ClockInsertion probe(clk, pin); - ClockInsertion *insertion = clk_insertions_->findKey(&probe); - if (insertion != nullptr) - deleteClockInsertion(insertion); - } + ClockInsertion probe(clk, pin); + ClockInsertion *insertion = clk_insertions_.findKey(&probe); + if (insertion != nullptr) + deleteClockInsertion(insertion); } void Sdc::deleteClockInsertion(ClockInsertion *insertion) { - clk_insertions_->erase(insertion); + clk_insertions_.erase(insertion); delete insertion; } void Sdc::deleteClockInsertionsReferencing(Clock *clk) { - ClockInsertions::Iterator insertion_iter(clk_insertions_); - while (insertion_iter.hasNext()) { - ClockInsertion *insertion = insertion_iter.next(); - if (insertion->clock() == clk) - deleteClockInsertion(insertion); + for (auto iter = clk_insertions_.cbegin(); + iter != clk_insertions_.cend(); ) { + ClockInsertion *insertion = *iter; + if (insertion->clock() == clk) { + iter = clk_insertions_.erase(iter); + delete insertion; + } + else + iter++; } } @@ -1828,12 +1736,8 @@ Sdc::clockInsertion(const Clock *clk, bool Sdc::hasClockInsertion(const Pin *pin) const { - if (clk_insertions_) { - ClockInsertion probe(nullptr, pin); - return clk_insertions_->hasKey(&probe); - } - else - return false; + ClockInsertion probe(nullptr, pin); + return clk_insertions_.hasKey(&probe); } void @@ -1847,20 +1751,19 @@ Sdc::clockInsertion(const Clock *clk, bool &exists) const { ClockInsertion *insert = nullptr; - if (clk_insertions_) { - if (clk && pin) { - ClockInsertion probe(clk, pin); - insert = clk_insertions_->findKey(&probe); - } - if (insert == nullptr && pin) { - ClockInsertion probe(nullptr, pin); - insert = clk_insertions_->findKey(&probe); - } - if (insert == nullptr && clk) { - ClockInsertion probe(clk, nullptr); - insert = clk_insertions_->findKey(&probe); - } + if (clk && pin) { + ClockInsertion probe(clk, pin); + insert = clk_insertions_.findKey(&probe); } + if (insert == nullptr && pin) { + ClockInsertion probe(nullptr, pin); + insert = clk_insertions_.findKey(&probe); + } + if (insert == nullptr && clk) { + ClockInsertion probe(clk, nullptr); + insert = clk_insertions_.findKey(&probe); + } + if (insert) insert->delay(rf, min_max, early_late, insertion, exists); else { @@ -1871,39 +1774,46 @@ Sdc::clockInsertion(const Clock *clk, //////////////////////////////////////////////////////////////// +ClockLatencyLess::ClockLatencyLess(const Network *network) : + network_(network) +{ +} + bool -ClockLatencyPinClkLess::operator()(const ClockLatency *latency1, - const ClockLatency *latency2) const +ClockLatencyLess::operator()(const ClockLatency *latency1, + const ClockLatency *latency2) const { const Clock *clk1 = latency1->clock(); const Clock *clk2 = latency2->clock(); const Pin *pin1 = latency1->pin(); const Pin *pin2 = latency2->pin(); - return clk1 < clk2 - || (clk1 == clk2 - && pin1 < pin2); + return (clk1 == nullptr && clk2) + || ((clk1 && clk2 && clk1->index() < clk2->index()) + || (clk1 == clk2 + && ((pin1 == nullptr && pin2) + || (pin1 && pin2 && network_->id(pin1) < network_->id(pin2))))); } //////////////////////////////////////////////////////////////// +ClockInsertionkLess::ClockInsertionkLess(const Network *network) : + network_(network) +{ +} + bool -ClockInsertionPinClkLess::operator()(const ClockInsertion *insert1, - const ClockInsertion *insert2)const +ClockInsertionkLess::operator()(const ClockInsertion *insert1, + const ClockInsertion *insert2) const { const Clock *clk1 = insert1->clock(); const Clock *clk2 = insert2->clock(); const Pin *pin1 = insert1->pin(); const Pin *pin2 = insert2->pin(); - return (clk1 && clk2 - && (clk1 < clk2 - || (clk1 == clk2 - && pin1 && pin2 - && pin1 < pin2))) - || (clk1 == nullptr && clk2) - || (clk1 == nullptr && clk2 == nullptr - && ((pin1 && pin2 - && pin1 < pin2) - || (pin1 == nullptr && pin2))); + return (clk1 == nullptr && clk2) + || ((clk1 && clk2 && clk1->index() < clk2->index()) + || (clk1 == clk2 + && ((pin1 == nullptr && pin2) + || (pin1 && pin2 && network_->id(pin1) < network_->id(pin2))))); } //////////////////////////////////////////////////////////////// @@ -1957,12 +1867,8 @@ Sdc::makeClockGroup(ClockGroups *clk_groups, void Sdc::ensureClkGroupExclusions() { - if (clk_group_exclusions_ == nullptr) { - clk_group_exclusions_ = new ClockPairSet; - clk_group_same_ = new ClockPairSet; - for (auto name_clk_groups : clk_groups_name_map_) - makeClkGroupExclusions(name_clk_groups.second); - } + for (auto name_clk_groups : clk_groups_name_map_) + makeClkGroupExclusions(name_clk_groups.second); } void @@ -1985,12 +1891,11 @@ Sdc::makeClkGroupExclusions1(ClockGroupSet *groups) { ClockGroupSet::Iterator group_iter1(groups); ClockGroup *group1 = group_iter1.next(); - ClockSet *clks1 = group1->clks(); - for (auto clk1 : *clks1) { + for (auto clk1 : *group1) { for (Clock *clk2 : clocks_) { if (clk2 != clk1 - && !group1->isMember(clk2)) - clk_group_exclusions_->insert(ClockPair(clk1, clk2)); + && !group1->hasKey(clk2)) + clk_group_exclusions_.insert(ClockPair(clk1, clk2)); } } makeClkGroupSame(group1); @@ -2000,15 +1905,13 @@ void Sdc::makeClkGroupExclusions(ClockGroupSet *groups) { for (auto group1 : *groups) { - ClockSet *clks1 = group1->clks(); for (auto group2 : *groups) { if (group1 != group2) { - ClockSet *clks2 = group2->clks(); - for (auto clk1 : *clks1) { - for (auto clk2 : *clks2) { + for (auto clk1 : *group1) { + for (auto clk2 : *group2) { // ClockPair is symmetric so only add one clk1/clk2 pair. if (clk1->index() < clk2->index()) { - clk_group_exclusions_->insert(ClockPair(clk1, clk2)); + clk_group_exclusions_.insert(ClockPair(clk1, clk2)); } } } @@ -2021,13 +1924,12 @@ Sdc::makeClkGroupExclusions(ClockGroupSet *groups) void Sdc::makeClkGroupSame(ClockGroup *group) { - ClockSet *clks = group->clks(); - for (auto clk1 : *clks) { - for (auto clk2 : *clks) { + for (auto clk1 : *group) { + for (auto clk2 : *group) { if (clk1->index() <= clk2->index()) { ClockPair clk_pair(clk1, clk2); - if (!clk_group_same_->hasKey(clk_pair)) - clk_group_same_->insert(clk_pair); + if (!clk_group_same_.hasKey(clk_pair)) + clk_group_same_.insert(clk_pair); } } } @@ -2036,12 +1938,8 @@ Sdc::makeClkGroupSame(ClockGroup *group) void Sdc::clearClkGroupExclusions() { - if (clk_group_exclusions_) { - delete clk_group_exclusions_; - delete clk_group_same_; - clk_group_exclusions_ = nullptr; - clk_group_same_ = nullptr; - } + clk_group_exclusions_.clear(); + clk_group_same_.clear(); } bool @@ -2050,7 +1948,7 @@ Sdc::sameClockGroup(const Clock *clk1, { if (clk1 && clk2) { ClockPair clk_pair(clk1, clk2); - bool excluded = clk_group_exclusions_->hasKey(clk_pair); + bool excluded = clk_group_exclusions_.hasKey(clk_pair); return !excluded; } else @@ -2062,7 +1960,7 @@ Sdc::sameClockGroupExplicit(const Clock *clk1, const Clock *clk2) { ClockPair clk_pair(clk1, clk2); - return clk_group_same_->hasKey(clk_pair); + return clk_group_same_.hasKey(clk_pair); } void @@ -2082,9 +1980,8 @@ Sdc::removeClockGroupsLogicallyExclusive(const char *name) removeClockGroups(groups); } else { - ClockGroupsNameMap::Iterator groups_iter(clk_groups_name_map_); - while (groups_iter.hasNext()) { - ClockGroups *groups = groups_iter.next(); + for (auto name_group : clk_groups_name_map_) { + ClockGroups *groups = name_group.second; if (groups->logicallyExclusive()) removeClockGroups(groups); } @@ -2100,9 +1997,8 @@ Sdc::removeClockGroupsPhysicallyExclusive(const char *name) removeClockGroups(groups); } else { - ClockGroupsNameMap::Iterator groups_iter(clk_groups_name_map_); - while (groups_iter.hasNext()) { - ClockGroups *groups = groups_iter.next(); + for (auto name_group : clk_groups_name_map_) { + ClockGroups *groups = name_group.second; if (groups->physicallyExclusive()) removeClockGroups(groups); } @@ -2118,9 +2014,8 @@ Sdc::removeClockGroupsAsynchronous(const char *name) removeClockGroups(groups); } else { - ClockGroupsNameMap::Iterator groups_iter(clk_groups_name_map_); - while (groups_iter.hasNext()) { - ClockGroups *groups = groups_iter.next(); + for (auto name_group : clk_groups_name_map_) { + ClockGroups *groups = name_group.second; if (groups->asynchronous()) removeClockGroups(groups); } @@ -2140,9 +2035,8 @@ Sdc::removeClockGroups(ClockGroups *groups) void Sdc::clockGroupsDeleteClkRefs(Clock *clk) { - ClockGroupsNameMap::Iterator groups_iter(clk_groups_name_map_); - while (groups_iter.hasNext()) { - ClockGroups *groups = groups_iter.next(); + for (auto name_group : clk_groups_name_map_) { + ClockGroups *groups = name_group.second; groups->removeClock(clk); } clearClkGroupExclusions(); @@ -2159,15 +2053,10 @@ Sdc::setClockSense(PinSet *pins, delete clks; clks = nullptr; } - PinSet::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : *pins) { if (clks) { - ClockSet::Iterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); + for (const Clock *clk : *clks) setClockSense(pin, clk, sense); - } } else setClockSense(pin, nullptr, sense); @@ -2178,8 +2067,8 @@ Sdc::setClockSense(PinSet *pins, void Sdc::setClockSense(const Pin *pin, - const Clock *clk, - ClockSense sense) + const Clock *clk, + ClockSense sense) { PinClockPair probe(pin, clk); if (clk_sense_map_.hasKey(probe)) @@ -2499,22 +2388,22 @@ Sdc::dataChecksTo(const Pin *to) const //////////////////////////////////////////////////////////////// void -Sdc::setLatchBorrowLimit(Pin *pin, +Sdc::setLatchBorrowLimit(const Pin *pin, float limit) { pin_latch_borrow_limit_map_[pin] = limit; } void -Sdc::setLatchBorrowLimit(Instance *inst, +Sdc::setLatchBorrowLimit(const Instance *inst, float limit) { inst_latch_borrow_limit_map_[inst] = limit; } void -Sdc::setLatchBorrowLimit(Clock *clk, - float limit) +Sdc::setLatchBorrowLimit(const Clock *clk, + float limit) { clk_latch_borrow_limit_map_[clk] = limit; } @@ -2526,9 +2415,9 @@ Sdc::deleteLatchBorrowLimitsReferencing(Clock *clk) } void -Sdc::latchBorrowLimit(Pin *data_pin, - Pin *enable_pin, - Clock *clk, +Sdc::latchBorrowLimit(const Pin *data_pin, + const Pin *enable_pin, + const Clock *clk, // Return values. float &limit, bool &exists) @@ -2640,11 +2529,11 @@ Sdc::findInputDrive(Port *port) } void -Sdc::setInputDelay(Pin *pin, +Sdc::setInputDelay(const Pin *pin, const RiseFallBoth *rf, - Clock *clk, + const Clock *clk, const RiseFall *clk_rf, - Pin *ref_pin, + const Pin *ref_pin, bool source_latency_included, bool network_latency_included, const MinMaxAll *min_max, @@ -2652,9 +2541,9 @@ Sdc::setInputDelay(Pin *pin, float delay) { ClockEdge *clk_edge = clk ? clk->edge(clk_rf) : nullptr; - InputDelay *input_delay = findInputDelay(pin, clk_edge, ref_pin); + InputDelay *input_delay = findInputDelay(pin, clk_edge); if (input_delay == nullptr) - input_delay = makeInputDelay(pin, clk_edge, ref_pin); + input_delay = makeInputDelay(pin, clk_edge); if (add) { RiseFallMinMax *delays = input_delay->delays(); delays->mergeValue(rf, min_max, delay); @@ -2664,25 +2553,6 @@ Sdc::setInputDelay(Pin *pin, RiseFallMinMax *delays = input_delay->delays(); delays->setValue(rf, min_max, delay); } - input_delay->setSourceLatencyIncluded(source_latency_included); - input_delay->setNetworkLatencyIncluded(network_latency_included); -} - -InputDelay * -Sdc::makeInputDelay(Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin) -{ - InputDelay *input_delay = new InputDelay(pin, clk_edge, ref_pin, - input_delay_index_++, - network_); - input_delays_.insert(input_delay); - InputDelaySet *inputs = input_delay_pin_map_.findKey(pin); - if (inputs == nullptr) { - inputs = new InputDelaySet; - input_delay_pin_map_[pin] = inputs; - } - inputs->insert(input_delay); if (ref_pin) { InputDelaySet *ref_inputs = input_delay_ref_pin_map_.findKey(ref_pin); @@ -2692,8 +2562,27 @@ Sdc::makeInputDelay(Pin *pin, } ref_inputs->insert(input_delay); } + input_delay->setRefPin(ref_pin); - for (Pin *lpin : input_delay->leafPins()) { + input_delay->setSourceLatencyIncluded(source_latency_included); + input_delay->setNetworkLatencyIncluded(network_latency_included); +} + +InputDelay * +Sdc::makeInputDelay(const Pin *pin, + const ClockEdge *clk_edge) +{ + InputDelay *input_delay = new InputDelay(pin, clk_edge, input_delay_index_++, + network_); + input_delays_.insert(input_delay); + InputDelaySet *inputs = input_delay_pin_map_.findKey(pin); + if (inputs == nullptr) { + inputs = new InputDelaySet; + input_delay_pin_map_[pin] = inputs; + } + inputs->insert(input_delay); + + for (const Pin *lpin : input_delay->leafPins()) { InputDelaySet *leaf_inputs = input_delay_leaf_pin_map_[lpin]; if (leaf_inputs == nullptr) { leaf_inputs = new InputDelaySet; @@ -2715,14 +2604,12 @@ Sdc::makeInputDelay(Pin *pin, InputDelay * Sdc::findInputDelay(const Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin) + const ClockEdge *clk_edge) { InputDelaySet *inputs = input_delay_pin_map_.findKey(pin); if (inputs) { for (InputDelay *input_delay : *inputs) { - if (input_delay->clkEdge() == clk_edge - && input_delay->refPin() == ref_pin) + if (input_delay->clkEdge() == clk_edge) return input_delay; } } @@ -2730,14 +2617,14 @@ Sdc::findInputDelay(const Pin *pin, } void -Sdc::removeInputDelay(Pin *pin, +Sdc::removeInputDelay(const Pin *pin, const RiseFallBoth *rf, - Clock *clk, - RiseFall *clk_rf, - MinMaxAll *min_max) + const Clock *clk, + const RiseFall *clk_rf, + const MinMaxAll *min_max) { ClockEdge *clk_edge = clk ? clk->edge(clk_rf) : nullptr; - InputDelay *input_delay = findInputDelay(pin, clk_edge, nullptr); + InputDelay *input_delay = findInputDelay(pin, clk_edge); if (input_delay) { RiseFallMinMax *delays = input_delay->delays(); delays->removeValue(rf, min_max); @@ -2747,7 +2634,7 @@ Sdc::removeInputDelay(Pin *pin, } void -Sdc::deleteInputDelays(Pin *pin, +Sdc::deleteInputDelays(const Pin *pin, InputDelay *except) { InputDelaySet *input_delays = input_delay_pin_map_[pin]; @@ -2785,7 +2672,7 @@ Sdc::isInputDelayInternal(const Pin *pin) const } void -Sdc::deleteInputDelaysReferencing(Clock *clk) +Sdc::deleteInputDelaysReferencing(const Clock *clk) { InputDelaySet::Iterator iter(input_delays_); while (iter.hasNext()) { @@ -2800,11 +2687,11 @@ Sdc::deleteInputDelay(InputDelay *input_delay) { input_delays_.erase(input_delay); - Pin *pin = input_delay->pin(); + const Pin *pin = input_delay->pin(); InputDelaySet *inputs = input_delay_pin_map_[pin]; inputs->erase(input_delay); - for (Pin *lpin : input_delay->leafPins()) { + for (const Pin *lpin : input_delay->leafPins()) { InputDelaySet *inputs = input_delay_leaf_pin_map_[lpin]; inputs->erase(input_delay); } @@ -2816,25 +2703,44 @@ void Sdc::movePortDelays(Sdc *from, Sdc *to) { + to->input_delays_.deleteContents(); to->input_delays_ = from->input_delays_; from->input_delays_.clear(); + + to->input_delay_pin_map_.deleteContents(); to->input_delay_pin_map_ = from->input_delay_pin_map_; from->input_delay_pin_map_.clear(); - to->input_delay_index_ = from->input_delay_index_; - from->input_delay_index_ = 0; + + to->input_delay_ref_pin_map_.deleteContents(); to->input_delay_ref_pin_map_ = from->input_delay_ref_pin_map_; from->input_delay_ref_pin_map_.clear(); + + to->input_delay_leaf_pin_map_.deleteContents(); to->input_delay_leaf_pin_map_ = from->input_delay_leaf_pin_map_; from->input_delay_leaf_pin_map_.clear(); + + to->input_delay_internal_pin_map_.deleteContents(); to->input_delay_internal_pin_map_ = from->input_delay_internal_pin_map_; from->input_delay_internal_pin_map_.clear(); + to->input_delay_index_ = from->input_delay_index_; + from->input_delay_index_ = 0; + + //////////////// + + to->output_delays_.deleteContents(); to->output_delays_ = from->output_delays_; from->output_delays_.clear(); + + to->output_delay_pin_map_.deleteContents(); to->output_delay_pin_map_ = from->output_delay_pin_map_; from->output_delay_pin_map_.clear(); + + to->output_delay_ref_pin_map_.deleteContents(); to->output_delay_ref_pin_map_ = from->output_delay_ref_pin_map_; from->output_delay_ref_pin_map_.clear(); + + to->output_delay_leaf_pin_map_.deleteContents(); to->output_delay_leaf_pin_map_ = from->output_delay_leaf_pin_map_; from->output_delay_leaf_pin_map_.clear(); } @@ -2842,11 +2748,11 @@ Sdc::movePortDelays(Sdc *from, //////////////////////////////////////////////////////////////// void -Sdc::setOutputDelay(Pin *pin, +Sdc::setOutputDelay(const Pin *pin, const RiseFallBoth *rf, - Clock *clk, + const Clock *clk, const RiseFall *clk_rf, - Pin *ref_pin, + const Pin *ref_pin, bool source_latency_included, bool network_latency_included, const MinMaxAll *min_max, @@ -2854,9 +2760,9 @@ Sdc::setOutputDelay(Pin *pin, float delay) { ClockEdge *clk_edge = clk ? clk->edge(clk_rf) : nullptr; - OutputDelay *output_delay = findOutputDelay(pin, clk_edge, ref_pin); + OutputDelay *output_delay = findOutputDelay(pin, clk_edge); if (output_delay == nullptr) - output_delay = makeOutputDelay(pin, clk_edge, ref_pin); + output_delay = makeOutputDelay(pin, clk_edge); if (add) { RiseFallMinMax *delays = output_delay->delays(); delays->mergeValue(rf, min_max, delay); @@ -2866,40 +2772,6 @@ Sdc::setOutputDelay(Pin *pin, RiseFallMinMax *delays = output_delay->delays(); delays->setValue(rf, min_max, delay); } - output_delay->setSourceLatencyIncluded(source_latency_included); - output_delay->setNetworkLatencyIncluded(network_latency_included); -} - -OutputDelay * -Sdc::findOutputDelay(const Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin) -{ - OutputDelaySet *outputs = output_delay_pin_map_.findKey(pin); - if (outputs) { - for (OutputDelay *output_delay : *outputs) { - if (output_delay->clkEdge() == clk_edge - && output_delay->refPin() == ref_pin) - return output_delay; - } - } - return nullptr; -} - -OutputDelay * -Sdc::makeOutputDelay(Pin *pin, - ClockEdge *clk_edge, - Pin *ref_pin) -{ - OutputDelay *output_delay = new OutputDelay(pin, clk_edge, ref_pin, - network_); - output_delays_.insert(output_delay); - OutputDelaySet *outputs = output_delay_pin_map_.findKey(pin); - if (outputs == nullptr) { - outputs = new OutputDelaySet; - output_delay_pin_map_[pin] = outputs; - } - outputs->insert(output_delay); if (ref_pin) { OutputDelaySet *ref_outputs = output_delay_ref_pin_map_.findKey(ref_pin); @@ -2909,8 +2781,40 @@ Sdc::makeOutputDelay(Pin *pin, } ref_outputs->insert(output_delay); } + output_delay->setRefPin(ref_pin); - for (Pin *lpin : output_delay->leafPins()) { + output_delay->setSourceLatencyIncluded(source_latency_included); + output_delay->setNetworkLatencyIncluded(network_latency_included); +} + +OutputDelay * +Sdc::findOutputDelay(const Pin *pin, + const ClockEdge *clk_edge) +{ + OutputDelaySet *outputs = output_delay_pin_map_.findKey(pin); + if (outputs) { + for (OutputDelay *output_delay : *outputs) { + if (output_delay->clkEdge() == clk_edge) + return output_delay; + } + } + return nullptr; +} + +OutputDelay * +Sdc::makeOutputDelay(const Pin *pin, + const ClockEdge *clk_edge) +{ + OutputDelay *output_delay = new OutputDelay(pin, clk_edge, network_); + output_delays_.insert(output_delay); + OutputDelaySet *outputs = output_delay_pin_map_.findKey(pin); + if (outputs == nullptr) { + outputs = new OutputDelaySet; + output_delay_pin_map_[pin] = outputs; + } + outputs->insert(output_delay); + + for (const Pin *lpin : output_delay->leafPins()) { OutputDelaySet *leaf_outputs = output_delay_leaf_pin_map_[lpin]; if (leaf_outputs == nullptr) { leaf_outputs = new OutputDelaySet; @@ -2922,14 +2826,14 @@ Sdc::makeOutputDelay(Pin *pin, } void -Sdc::removeOutputDelay(Pin *pin, - RiseFallBoth *rf, - Clock *clk, - RiseFall *clk_rf, - MinMaxAll *min_max) +Sdc::removeOutputDelay(const Pin *pin, + const RiseFallBoth *rf, + const Clock *clk, + const RiseFall *clk_rf, + const MinMaxAll *min_max) { ClockEdge *clk_edge = clk ? clk->edge(clk_rf) : nullptr; - OutputDelay *output_delay = findOutputDelay(pin, clk_edge, nullptr); + OutputDelay *output_delay = findOutputDelay(pin, clk_edge); if (output_delay) { RiseFallMinMax *delays = output_delay->delays(); delays->removeValue(rf, min_max); @@ -2937,7 +2841,7 @@ Sdc::removeOutputDelay(Pin *pin, } void -Sdc::deleteOutputDelays(Pin *pin, +Sdc::deleteOutputDelays(const Pin *pin, OutputDelay *except) { OutputDelaySet *output_delays = output_delay_pin_map_[pin]; @@ -2962,7 +2866,7 @@ Sdc::hasOutputDelay(const Pin *leaf_pin) const } void -Sdc::deleteOutputDelaysReferencing(Clock *clk) +Sdc::deleteOutputDelaysReferencing(const Clock *clk) { OutputDelaySet::Iterator iter(output_delays_); while (iter.hasNext()) { @@ -2977,11 +2881,11 @@ Sdc::deleteOutputDelay(OutputDelay *output_delay) { output_delays_.erase(output_delay); - Pin *pin = output_delay->pin(); - OutputDelaySet *outputs = output_delay_pin_map_[pin]; + const Pin *pin = output_delay->pin(); + OutputDelaySet *outputs = output_delay_pin_map_[pin]; outputs->erase(output_delay); - for (Pin *lpin : output_delay->leafPins()) { + for (const Pin *lpin : output_delay->leafPins()) { OutputDelaySet *outputs = output_delay_leaf_pin_map_[lpin]; outputs->erase(output_delay); } @@ -2992,24 +2896,25 @@ Sdc::deleteOutputDelay(OutputDelay *output_delay) //////////////////////////////////////////////////////////////// void -Sdc::setPortExtPinCap(Port *port, +Sdc::setPortExtPinCap(const Port *port, const RiseFall *rf, + const Corner *corner, const MinMax *min_max, float cap) { - PortExtCap *port_cap = ensurePortExtPinCap(port); + PortExtCap *port_cap = ensurePortExtPinCap(port, corner); port_cap->setPinCap(cap, rf, min_max); } void -Sdc::setPortExtWireCap(Port *port, +Sdc::setPortExtWireCap(const Port *port, bool subtract_pin_cap, const RiseFall *rf, const Corner *corner, const MinMax *min_max, float cap) { - PortExtCap *port_cap = ensurePortExtPinCap(port); + PortExtCap *port_cap = ensurePortExtPinCap(port, corner); if (subtract_pin_cap) { Pin *pin = network_->findPin(network_->name(port)); const OperatingConditions *op_cond = operatingConditions(min_max); @@ -3021,26 +2926,26 @@ Sdc::setPortExtWireCap(Port *port, } PortExtCap * -Sdc::portExtCap(Port *port) const +Sdc::portExtCap(const Port *port, + const Corner *corner) const { - if (port_cap_map_) - return port_cap_map_->findKey(port); - else - return nullptr; + return port_ext_cap_maps_[corner->index()].findKey(port); } bool -Sdc::hasPortExtCap(Port *port) const +Sdc::hasPortExtCap(const Port *port) const { - if (port_cap_map_) - return port_cap_map_->hasKey(port); - else - return false; + for (int corner_index = 0; corner_index < corners_->count(); corner_index++) { + if (port_ext_cap_maps_[corner_index].hasKey(port)) + return true; + } + return false; } void -Sdc::portExtCap(Port *port, +Sdc::portExtCap(const Port *port, const RiseFall *rf, + const Corner *corner, const MinMax *min_max, // Return values. float &pin_cap, @@ -3050,32 +2955,32 @@ Sdc::portExtCap(Port *port, int &fanout, bool &has_fanout) const { - if (port_cap_map_) { - PortExtCap *port_cap = port_cap_map_->findKey(port); - if (port_cap) { - port_cap->pinCap(rf, min_max, pin_cap, has_pin_cap); - port_cap->wireCap(rf, min_max, wire_cap, has_wire_cap); - port_cap->fanout(min_max, fanout, has_fanout); - return; - } + PortExtCap *port_cap = port_ext_cap_maps_[corner->index()].findKey(port); + if (port_cap) { + port_cap->pinCap(rf, min_max, pin_cap, has_pin_cap); + port_cap->wireCap(rf, min_max, wire_cap, has_wire_cap); + port_cap->fanout(min_max, fanout, has_fanout); + } + else { + pin_cap = 0.0F; + has_pin_cap = false; + wire_cap = 0.0F; + has_wire_cap = false; + fanout = 0.0F; + has_fanout = false; } - pin_cap = 0.0F; - has_pin_cap = false; - wire_cap = 0.0F; - has_wire_cap = false; - fanout = 0.0F; - has_fanout = false; } float -Sdc::portExtCap(Port *port, +Sdc::portExtCap(const Port *port, const RiseFall *rf, + const Corner *corner, const MinMax *min_max) const { float pin_cap, wire_cap; int fanout; bool has_pin_cap, has_wire_cap, has_fanout; - portExtCap(port, rf, min_max, + portExtCap(port, rf, corner, min_max, pin_cap, has_pin_cap, wire_cap, has_wire_cap, fanout, has_fanout); @@ -3088,10 +2993,10 @@ Sdc::portExtCap(Port *port, } bool -Sdc::drvrPinHasWireCap(const Pin *pin) +Sdc::drvrPinHasWireCap(const Pin *pin, + const Corner *corner) { - return drvr_pin_wire_cap_map_ - && drvr_pin_wire_cap_map_->hasKey(const_cast(pin)); + return drvr_pin_wire_cap_maps_[corner->index()].hasKey(pin); } void @@ -3102,18 +3007,15 @@ Sdc::drvrPinWireCap(const Pin *pin, float &cap, bool &exists) const { - if (drvr_pin_wire_cap_map_) { - MinMaxFloatValues *values = - drvr_pin_wire_cap_map_[corner->index()].findKey(const_cast(pin)); - if (values) - return values->value(min_max, cap, exists); - } + MinMaxFloatValues *values = drvr_pin_wire_cap_maps_[corner->index()].findKey(pin); + if (values) + return values->value(min_max, cap, exists); cap = 0.0; exists = false; } void -Sdc::setNetWireCap(Net *net, +Sdc::setNetWireCap(const Net *net, bool subtract_pin_cap, const Corner *corner, const MinMax *min_max, @@ -3124,7 +3026,7 @@ Sdc::setNetWireCap(Net *net, OperatingConditions *op_cond = operatingConditions(min_max); NetConnectedPinIterator *pin_iter = network_->connectedPinIterator(net); if (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); float pin_cap_rise = connectedPinCap(pin, RiseFall::rise(), op_cond, corner, min_max); float pin_cap_fall = connectedPinCap(pin, RiseFall::fall(), @@ -3136,30 +3038,24 @@ Sdc::setNetWireCap(Net *net, delete pin_iter; } } - if (net_wire_cap_map_ == nullptr) - net_wire_cap_map_ = new NetWireCapMap[corners_->count()]; - bool make_drvr_entry = !net_wire_cap_map_[corner->index()].hasKey(net); - MinMaxFloatValues &values = net_wire_cap_map_[corner->index()][net]; + bool make_drvr_entry = !net_wire_cap_maps_[corner->index()].hasKey(net); + MinMaxFloatValues &values = net_wire_cap_maps_[corner->index()][net]; values.setValue(min_max, wire_cap); - // Only need to do this when there is new net_wire_cap_map_ entry. + // Only need to do this when there is new net_wire_cap_maps_ entry. if (make_drvr_entry) { - for (Pin *pin : *network_->drivers(net)) { - if (drvr_pin_wire_cap_map_ == nullptr) - drvr_pin_wire_cap_map_ = new PinWireCapMap[corners_->count()]; - drvr_pin_wire_cap_map_[corner->index()][pin] = &values; + for (const Pin *pin : *network_->drivers(net)) { + drvr_pin_wire_cap_maps_[corner->index()][pin] = &values; } } } bool -Sdc::hasNetWireCap(Net *net) const +Sdc::hasNetWireCap(const Net *net) const { - if (net_wire_cap_map_) { - for (int i = 0; i < corners_->count(); i++) { - if (net_wire_cap_map_[i].hasKey(net)) - return true; - } + for (int i = 0; i < corners_->count(); i++) { + if (net_wire_cap_maps_[i].hasKey(net)) + return true; } return false; } @@ -3215,7 +3111,7 @@ public: float &fanout, bool &has_set_load, const Sdc *sdc); - virtual void operator()(Pin *pin); + virtual void operator()(const Pin *pin); protected: const RiseFall *rf_; @@ -3252,7 +3148,7 @@ FindNetCaps::FindNetCaps(const RiseFall *rf, } void -FindNetCaps::operator()(Pin *pin) +FindNetCaps::operator()(const Pin *pin) { sdc_->pinCaps(pin, rf_, op_cond_, corner_, min_max_, pin_cap_, wire_cap_, fanout_, has_set_load_); @@ -3298,7 +3194,7 @@ Sdc::pinCaps(const Pin *pin, float port_pin_cap, port_wire_cap; int port_fanout; bool has_pin_cap, has_wire_cap, has_fanout; - portExtCap(port, rf, min_max, + portExtCap(port, rf, corner, min_max, port_pin_cap, has_pin_cap, port_wire_cap, has_wire_cap, port_fanout, has_fanout); @@ -3333,7 +3229,7 @@ Sdc::portCapacitance(Instance *inst, const Corner *corner, const MinMax *min_max) const { - Pvt *inst_pvt = nullptr; + const Pvt *inst_pvt = nullptr; if (inst) inst_pvt = pvt(inst, min_max); LibertyPort *corner_port = port->cornerPort(corner, min_max); @@ -3359,7 +3255,7 @@ Sdc::pinCapacitance(const Pin *pin, //////////////////////////////////////////////////////////////// void -Sdc::setResistance(Net *net, +Sdc::setResistance(const Net *net, const MinMaxAll *min_max, float res) { @@ -3368,7 +3264,7 @@ Sdc::setResistance(Net *net, } void -Sdc::resistance(Net *net, +Sdc::resistance(const Net *net, const MinMax *min_max, float &res, bool &exists) @@ -3381,22 +3277,24 @@ Sdc::resistance(Net *net, } void -Sdc::setPortExtFanout(Port *port, +Sdc::setPortExtFanout(const Port *port, + const Corner *corner, const MinMax *min_max, int fanout) { - PortExtCap *port_cap = ensurePortExtPinCap(port); + PortExtCap *port_cap = ensurePortExtPinCap(port, corner); port_cap->setFanout(fanout, min_max); } void -Sdc::portExtFanout(Port *port, +Sdc::portExtFanout(const Port *port, + const Corner *corner, const MinMax *min_max, // Return values. int &fanout, bool &exists) { - PortExtCap *port_cap = portExtCap(port); + PortExtCap *port_cap = portExtCap(port, corner); if (port_cap) port_cap->fanout(min_max, fanout, exists); else { @@ -3407,11 +3305,12 @@ Sdc::portExtFanout(Port *port, int Sdc::portExtFanout(Port *port, + const Corner *corner, const MinMax *min_max) { int fanout; bool exists; - portExtFanout(port, min_max, fanout, exists); + portExtFanout(port, corner, min_max, fanout, exists); if (exists) return fanout; else @@ -3419,14 +3318,13 @@ Sdc::portExtFanout(Port *port, } PortExtCap * -Sdc::ensurePortExtPinCap(Port *port) +Sdc::ensurePortExtPinCap(const Port *port, + const Corner *corner) { - if (port_cap_map_ == nullptr) - port_cap_map_ = new PortExtCapMap; - PortExtCap *port_cap = port_cap_map_->findKey(port); + PortExtCap *port_cap = port_ext_cap_maps_[corner->index()].findKey(port); if (port_cap == nullptr) { port_cap = new PortExtCap(port); - (*port_cap_map_)[port] = port_cap; + port_ext_cap_maps_[corner->index()][port] = port_cap; } return port_cap; } @@ -3435,14 +3333,12 @@ void Sdc::movePortExtCaps(Sdc *from, Sdc *to) { - if (from->port_cap_map_) { - to->port_cap_map_ = from->port_cap_map_; - from->port_cap_map_ = nullptr; - } + for (int corner_index = 0; corner_index < from->corners()->count(); corner_index++) { + to->port_ext_cap_maps_[corner_index] = from->port_ext_cap_maps_[corner_index]; + from->port_ext_cap_maps_[corner_index].clear(); - if (from->net_wire_cap_map_) { - to->net_wire_cap_map_ = from->net_wire_cap_map_; - from->net_wire_cap_map_ = nullptr; + to->net_wire_cap_maps_[corner_index] = from->net_wire_cap_maps_[corner_index]; + from->net_wire_cap_maps_[corner_index].clear(); } } @@ -3596,11 +3492,8 @@ void Sdc::disable(Pin *from, Pin *to) { - PinPair probe(from, to); - if (!disabled_wire_edges_.hasKey(&probe)) { - PinPair *pair = new PinPair(from, to); - disabled_wire_edges_.insert(pair); - } + PinPair pair(from, to); + disabled_wire_edges_.insert(pair); } void @@ -3608,7 +3501,7 @@ Sdc::removeDisable(Pin *from, Pin *to) { PinPair probe(from, to); - disabled_wire_edges_.erase(&probe); + disabled_wire_edges_.erase(probe); } void @@ -3638,8 +3531,8 @@ public: Graph *graph); protected: - virtual void visit(Pin *drvr, - Pin *load); + virtual void visit(const Pin *drvr, + const Pin *load); PinPairSet *pairs_; Graph *graph_; @@ -3654,18 +3547,15 @@ DisableEdgesThruHierPin::DisableEdgesThruHierPin(PinPairSet *pairs, } void -DisableEdgesThruHierPin::visit(Pin *drvr, - Pin *load) +DisableEdgesThruHierPin::visit(const Pin *drvr, + const Pin *load) { - PinPair probe(drvr, load); - if (!pairs_->hasKey(&probe)) { - PinPair *pair = new PinPair(drvr, load); - pairs_->insert(pair); - } + PinPair pair(drvr, load); + pairs_->insert(pair); } void -Sdc::disable(Pin *pin) +Sdc::disable(const Pin *pin) { if (network_->isHierarchical(pin)) { // Add leaf pins thru hierarchical pin to disabled_edges_. @@ -3683,7 +3573,8 @@ public: Graph *graph); protected: - virtual void visit(Pin *drvr, Pin *load); + virtual void visit(const Pin *drvr, + const Pin *load); PinPairSet *pairs_; Graph *graph_; @@ -3698,15 +3589,11 @@ RemoveDisableEdgesThruHierPin::RemoveDisableEdgesThruHierPin(PinPairSet *pairs, } void -RemoveDisableEdgesThruHierPin::visit(Pin *drvr, - Pin *load) +RemoveDisableEdgesThruHierPin::visit(const Pin *drvr, + const Pin *load) { - PinPair probe(drvr, load); - PinPair *pair = pairs_->findKey(&probe); - if (pair) { - pairs_->erase(pair); - delete pair; - } + PinPair pair(drvr, load); + pairs_->erase(pair); } void @@ -3739,8 +3626,8 @@ Sdc::isDisabled(const Instance *inst, { if (role == TimingRole::wire()) { // Hierarchical thru pin disables. - PinPair pair(const_cast(from_pin), const_cast(to_pin)); - return disabled_wire_edges_.hasKey(&pair); + PinPair pair(from_pin, to_pin); + return disabled_wire_edges_.hasKey(pair); } else { LibertyCell *cell = network_->libertyCell(inst); @@ -3769,8 +3656,8 @@ Sdc::isDisabled(TimingArcSet *arc_set) const return false; } -DisabledInstancePortsMap * -Sdc::disabledInstancePorts() +const DisabledInstancePortsMap * +Sdc::disabledInstancePorts() const { return &disabled_inst_ports_; } @@ -3820,8 +3707,8 @@ Sdc::isDisableClockGatingCheck(const Pin *pin) //////////////////////////////////////////////////////////////// void -Sdc::setLogicValue(Pin *pin, - LogicValue value) +Sdc::setLogicValue(const Pin *pin, + LogicValue value) { logic_value_map_[pin] = value; } @@ -3835,14 +3722,14 @@ Sdc::logicValue(const Pin *pin, } void -Sdc::setCaseAnalysis(Pin *pin, +Sdc::setCaseAnalysis(const Pin *pin, LogicValue value) { case_value_map_[pin] = value; } void -Sdc::removeCaseAnalysis(Pin *pin) +Sdc::removeCaseAnalysis(const Pin *pin) { case_value_map_.erase(pin); } @@ -3873,7 +3760,8 @@ Sdc::makeExceptionFrom(PinSet *from_pins, if ((from_pins && !from_pins->empty()) || (from_clks && !from_clks->empty()) || (from_insts && !from_insts->empty())) - return new ExceptionFrom(from_pins, from_clks, from_insts, from_rf, true); + return new ExceptionFrom(from_pins, from_clks, from_insts, from_rf, + true, network_); else return nullptr; } @@ -3904,7 +3792,7 @@ Sdc::makeExceptionTo(PinSet *pins, || (insts && !insts->empty()) || (rf != RiseFallBoth::riseFall()) || (end_rf != RiseFallBoth::riseFall())) - return new ExceptionTo(pins, clks, insts, rf, end_rf, true); + return new ExceptionTo(pins, clks, insts, rf, end_rf, true, network_); else return nullptr; } @@ -3991,14 +3879,10 @@ Sdc::recordPathDelayInternalStartpoints(ExceptionPath *exception) ExceptionFrom *from = exception->from(); if (from && from->hasPins()) { - PinSet::Iterator pin_iter(from->pins()); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : *from->pins()) { if (!(network_->isRegClkPin(pin) || network_->isTopLevelPort(pin))) { - if (path_delay_internal_startpoints_ == nullptr) - path_delay_internal_startpoints_ = new PinSet; - path_delay_internal_startpoints_->insert(pin); + path_delay_internal_startpoints_.insert(pin); } } } @@ -4009,14 +3893,12 @@ Sdc::unrecordPathDelayInternalStartpoints(ExceptionFrom *from) { if (from && from->hasPins() - && path_delay_internal_startpoints_) { - PinSet::Iterator pin_iter(from->pins()); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + && !path_delay_internal_startpoints_.empty()) { + for (const Pin *pin : *from->pins()) { if (!(network_->isRegClkPin(pin) || network_->isTopLevelPort(pin)) && !pathDelayFrom(pin)) - path_delay_internal_startpoints_->erase(pin); + path_delay_internal_startpoints_.erase(pin); } } } @@ -4024,14 +3906,10 @@ Sdc::unrecordPathDelayInternalStartpoints(ExceptionFrom *from) bool Sdc::pathDelayFrom(const Pin *pin) { - if (first_from_pin_exceptions_) { - ExceptionPathSet *exceptions = first_from_pin_exceptions_->findKey(pin); - ExceptionPathSet::ConstIterator exception_iter(exceptions); - while (exception_iter.hasNext()) { - ExceptionPath *exception = exception_iter.next(); - if (exception->isPathDelay()) - return true; - } + ExceptionPathSet *exceptions = first_from_pin_exceptions_.findKey(pin); + for (ExceptionPath *exception : *exceptions) { + if (exception->isPathDelay()) + return true; } return false; } @@ -4039,11 +3917,10 @@ Sdc::pathDelayFrom(const Pin *pin) bool Sdc::isPathDelayInternalStartpoint(const Pin *pin) const { - return path_delay_internal_startpoints_ - && path_delay_internal_startpoints_->hasKey(const_cast(pin)); + return path_delay_internal_startpoints_.hasKey(pin); } -PinSet * +const PinSet & Sdc::pathDelayInternalStartpoints() const { return path_delay_internal_startpoints_; @@ -4055,14 +3932,10 @@ Sdc::recordPathDelayInternalEndpoints(ExceptionPath *exception) ExceptionTo *to = exception->to(); if (to && to->hasPins()) { - PinSet::Iterator pin_iter(to->pins()); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : *to->pins()) { if (!(hasLibertyChecks(pin) || network_->isTopLevelPort(pin))) { - if (path_delay_internal_endpoints_ == nullptr) - path_delay_internal_endpoints_ = new PinSet; - path_delay_internal_endpoints_->insert(pin); + path_delay_internal_endpoints_.insert(pin); } } } @@ -4074,14 +3947,12 @@ Sdc::unrecordPathDelayInternalEndpoints(ExceptionPath *exception) ExceptionTo *to = exception->to(); if (to && to->hasPins() - && path_delay_internal_endpoints_) { - PinSet::Iterator pin_iter(to->pins()); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + && !path_delay_internal_endpoints_.empty()) { + for (const Pin *pin : *to->pins()) { if (!(hasLibertyChecks(pin) || network_->isTopLevelPort(pin)) && !pathDelayTo(pin)) - path_delay_internal_endpoints_->erase(pin); + path_delay_internal_endpoints_.erase(pin); } } } @@ -4106,14 +3977,10 @@ Sdc::hasLibertyChecks(const Pin *pin) bool Sdc::pathDelayTo(const Pin *pin) { - if (first_to_pin_exceptions_) { - ExceptionPathSet *exceptions = first_to_pin_exceptions_->findKey(pin); - ExceptionPathSet::ConstIterator exception_iter(exceptions); - while (exception_iter.hasNext()) { - ExceptionPath *exception = exception_iter.next(); - if (exception->isPathDelay()) - return true; - } + ExceptionPathSet *exceptions = first_to_pin_exceptions_.findKey(pin); + for (ExceptionPath *exception : *exceptions) { + if (exception->isPathDelay()) + return true; } return false; } @@ -4121,8 +3988,7 @@ Sdc::pathDelayTo(const Pin *pin) bool Sdc::isPathDelayInternalEndpoint(const Pin *pin) const { - return path_delay_internal_endpoints_ - && path_delay_internal_endpoints_->hasKey(const_cast(pin)); + return path_delay_internal_endpoints_.hasKey(pin); } //////////////////////////////////////////////////////////////// @@ -4132,12 +3998,11 @@ Sdc::clearGroupPathMap() { // GroupPath exceptions are deleted with other exceptions. // Delete group_path name strings. - GroupPathIterator group_path_iter(group_path_map_); - while (group_path_iter.hasNext()) { - const char *name; - GroupPathSet *groups; - group_path_iter.next(name, groups); + for (auto name_groups : group_path_map_) { + const char *name = name_groups.first; + GroupPathSet *groups = name_groups.second; stringDelete(name); + groups->deleteContents(); delete groups; } group_path_map_.clear(); @@ -4157,14 +4022,25 @@ Sdc::makeGroupPath(const char *name, else if (name) { GroupPath *group_path = new GroupPath(name, is_default, from, thrus, to, true, comment); - addException(group_path); + // Clone the group_path because it may get merged and hence deleted + // by addException. + ExceptionFrom *from1 = group_path->from() + ? group_path->from()->clone(network_):nullptr; + ExceptionThruSeq *thrus1 = exceptionThrusClone(group_path->thrus(), network_); + ExceptionTo *to1 = group_path->to() ? group_path->to()->clone(network_) : nullptr; + ExceptionPath *clone = group_path->clone(from1, thrus1, to1, true); + addException(clone); // A named group path can have multiple exceptions. GroupPathSet *groups = group_path_map_.findKey(name); if (groups == nullptr) { - groups = new GroupPathSet; + groups = new GroupPathSet(network_); group_path_map_[stringCopy(name)] = groups; } - groups->insert(group_path); + if (groups->hasKey(group_path)) + // Exact copy of existing group path. + delete group_path; + else + groups->insert(group_path); } else { // is_default @@ -4180,12 +4056,6 @@ Sdc::isGroupPathName(const char *group_name) return group_path_map_.hasKey(group_name); } -GroupPathIterator * -Sdc::groupPathIterator() -{ - return new GroupPathIterator(group_path_map_); -} - //////////////////////////////////////////////////////////////// FilterPath * @@ -4206,11 +4076,8 @@ Sdc::makeFilterPath(ExceptionFrom *from, void Sdc::makeLoopExceptions() { - GraphLoopSeq::Iterator loop_iter(levelize_->loops()); - while (loop_iter.hasNext()) { - GraphLoop *loop = loop_iter.next(); + for (GraphLoop *loop : *levelize_->loops()) makeLoopExceptions(loop); - } } // Make a -thru pin false path from every edge entering the loop @@ -4219,9 +4086,7 @@ void Sdc::makeLoopExceptions(GraphLoop *loop) { debugPrint(debug_, "loop", 2, "Loop false path"); - EdgeSeq::Iterator loop_edge_iter(loop->edges()); - while (loop_edge_iter.hasNext()) { - Edge *edge = loop_edge_iter.next(); + for (Edge *edge : *loop->edges()) { Vertex *from_vertex = edge->from(graph_); Vertex *to_vertex = edge->to(graph_); Pin *from_pin = from_vertex->pin(); @@ -4241,9 +4106,9 @@ Sdc::makeLoopExceptions(GraphLoop *loop) } void -Sdc::makeLoopException(Pin *loop_input_pin, - Pin *loop_pin, - Pin *loop_prev_pin) +Sdc::makeLoopException(const Pin *loop_input_pin, + const Pin *loop_pin, + const Pin *loop_prev_pin) { ExceptionThruSeq *thrus = new ExceptionThruSeq; makeLoopExceptionThru(loop_input_pin, thrus); @@ -4261,11 +4126,11 @@ Sdc::makeLoopPath(ExceptionThruSeq *thrus) } void -Sdc::makeLoopExceptionThru(Pin *pin, +Sdc::makeLoopExceptionThru(const Pin *pin, ExceptionThruSeq *thrus) { debugPrint(debug_, "levelize", 2, " %s", network_->pathName(pin)); - PinSet *pins = new PinSet; + PinSet *pins = new PinSet(network_); pins->insert(pin); ExceptionThru *thru = makeExceptionThru(pins, nullptr, nullptr, RiseFallBoth::riseFall()); @@ -4275,6 +4140,7 @@ Sdc::makeLoopExceptionThru(Pin *pin, void Sdc::deleteLoopExceptions() { + // erase prevents range iteration. ExceptionPathSet::Iterator except_iter(exceptions_); while (except_iter.hasNext()) { ExceptionPath *except = except_iter.next(); @@ -4309,10 +4175,10 @@ Sdc::addException(ExceptionPath *exception) InstanceSet *insts1 = from->instances() ? new InstanceSet(*from->instances()) : nullptr; ExceptionFrom *from1 = new ExceptionFrom(pins1, nullptr, insts1, - from->transition(), true); + from->transition(), true, network_); ExceptionThruSeq *thrus1 = exceptionThrusClone(exception->thrus(), network_); ExceptionTo *to = exception->to(); - ExceptionTo *to1 = to ? to->clone() : nullptr; + ExceptionTo *to1 = to ? to->clone(network_) : nullptr; ExceptionPath *exception1 = exception->clone(from1, thrus1, to1, true); debugPrint(debug_, "exception_merge", 1, " split exception for %s", exception1->asString(network_)); @@ -4320,9 +4186,9 @@ Sdc::addException(ExceptionPath *exception) ClockSet *clks2 = new ClockSet(*from->clks()); ExceptionFrom *from2 = new ExceptionFrom(nullptr, clks2, nullptr, - from->transition(), true); + from->transition(), true, network_); ExceptionThruSeq *thrus2 = exceptionThrusClone(exception->thrus(), network_); - ExceptionTo *to2 = to ? to->clone() : nullptr; + ExceptionTo *to2 = to ? to->clone(network_) : nullptr; ExceptionPath *exception2 = exception->clone(from2, thrus2, to2, true); debugPrint(debug_, "exception_merge", 1, " split exception for %s", exception2->asString(network_)); @@ -4341,23 +4207,22 @@ Sdc::addException1(ExceptionPath *exception) if (to && (to->hasPins() || to->hasInstances()) && to->hasClocks()) { - ExceptionFrom *from1 = exception->from() ? exception->from()->clone() : nullptr; + ExceptionFrom *from1 = exception->from() ? exception->from()->clone(network_):nullptr; ExceptionThruSeq *thrus1 = exceptionThrusClone(exception->thrus(), network_); PinSet *pins1 = to->pins() ? new PinSet(*to->pins()) : nullptr; InstanceSet *insts1 = to->instances() ? new InstanceSet(*to->instances()) : nullptr; - ExceptionTo *to1 = new ExceptionTo(pins1, nullptr, insts1, - to->transition(), - to->endTransition(), true); + ExceptionTo *to1 = new ExceptionTo(pins1, nullptr, insts1, to->transition(), + to->endTransition(), true, network_); ExceptionPath *exception1 = exception->clone(from1, thrus1, to1, true); debugPrint(debug_, "exception_merge", 1, " split exception for %s", exception1->asString(network_)); addException2(exception1); - ExceptionFrom *from2 = exception->from() ? exception->from()->clone() : nullptr; + ExceptionFrom *from2 = exception->from() ? exception->from()->clone(network_):nullptr; ExceptionThruSeq *thrus2 = exceptionThrusClone(exception->thrus(), network_); ClockSet *clks2 = new ClockSet(*to->clks()); ExceptionTo *to2 = new ExceptionTo(nullptr, clks2, nullptr, to->transition(), - to->endTransition(), true); + to->endTransition(), true, network_); ExceptionPath *exception2 = exception->clone(from2, thrus2, to2, true); debugPrint(debug_, "exception_merge", 1, " split exception for %s", exception2->asString(network_)); @@ -4428,26 +4293,17 @@ Sdc::deleteMatchingExceptions(ExceptionPath *exception) findMatchingExceptions(exception, matches); ExceptionPathSet expanded_matches; - ExceptionPathSet::Iterator match_iter1(matches); - while (match_iter1.hasNext()) { - ExceptionPath *match = match_iter1.next(); + for (ExceptionPath *match : matches) // Expand the matching exception into a set of exceptions that // that do not cover the new exception. Do not record them // to prevent merging with the match, which will be deleted. expandExceptionExcluding(match, exception, expanded_matches); - } - ExceptionPathSet::Iterator match_iter2(matches); - while (match_iter2.hasNext()) { - ExceptionPath *match = match_iter2.next(); + for (ExceptionPath *match : matches) deleteException(match); - } - ExceptionPathSet::Iterator expanded_iter(expanded_matches); - while (expanded_iter.hasNext()) { - ExceptionPath *expand = expanded_iter.next(); - addException(expand); - } + for (ExceptionPath *match : expanded_matches) + addException(match); } void @@ -4467,17 +4323,14 @@ Sdc::findMatchingExceptionsFirstFrom(ExceptionPath *exception, ExceptionPathSet &matches) { ExceptionFrom *from = exception->from(); - if (first_from_pin_exceptions_) - findMatchingExceptionsPins(exception, from->pins(), - first_from_pin_exceptions_, - matches); - if (first_from_inst_exceptions_) - findMatchingExceptionsInsts(exception, from->instances(), - first_from_inst_exceptions_, matches); - if (first_from_clk_exceptions_) - findMatchingExceptionsClks(exception, from->clks(), - first_from_clk_exceptions_, - matches); + findMatchingExceptionsPins(exception, from->pins(), + first_from_pin_exceptions_, + matches); + findMatchingExceptionsInsts(exception, from->instances(), + first_from_inst_exceptions_, matches); + findMatchingExceptionsClks(exception, from->clks(), + first_from_clk_exceptions_, + matches); } void @@ -4491,18 +4344,14 @@ Sdc::findMatchingExceptionsFirstThru(ExceptionPath *exception, findMatchingExceptionsInsts(exception, thru->instances(), first_thru_inst_exceptions_, matches); - if (first_thru_net_exceptions_) { - NetSet::Iterator net_iter(thru->nets()); - if (net_iter.hasNext()) { - Net *net = net_iter.next(); + if (!first_thru_net_exceptions_.empty()) { + for (const Net *net : *thru->nets()) { // Potential matches includes exceptions that match net that are not // the first exception point. ExceptionPathSet *potential_matches = - first_thru_net_exceptions_->findKey(net); + first_thru_net_exceptions_.findKey(net); if (potential_matches) { - ExceptionPathSet::Iterator match_iter(potential_matches); - while (match_iter.hasNext()) { - ExceptionPath *match = match_iter.next(); + for (ExceptionPath *match : *potential_matches) { ExceptionThru *match_thru = (*match->thrus())[0]; if (match_thru->nets()->hasKey(net) && match->overrides(exception) @@ -4531,16 +4380,13 @@ Sdc::findMatchingExceptionsFirstTo(ExceptionPath *exception, void Sdc::findMatchingExceptionsClks(ExceptionPath *exception, ClockSet *clks, - ClockExceptionsMap *exception_map, + ClockExceptionsMap &exception_map, ExceptionPathSet &matches) { - if (exception_map) { + if (clks) { ExceptionPathSet clks_matches; - ClockSet::Iterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); - clks_matches.insertSet(exception_map->findKey(clk)); - } + for (Clock *clk : *clks) + clks_matches.insertSet(exception_map.findKey(clk)); findMatchingExceptions(exception, &clks_matches, matches); } } @@ -4548,16 +4394,13 @@ Sdc::findMatchingExceptionsClks(ExceptionPath *exception, void Sdc::findMatchingExceptionsPins(ExceptionPath *exception, PinSet *pins, - PinExceptionsMap *exception_map, + PinExceptionsMap &exception_map, ExceptionPathSet &matches) { - if (exception_map) { + if (pins) { ExceptionPathSet pins_matches; - PinSet::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - const Pin *pin = pin_iter.next(); - pins_matches.insertSet(exception_map->findKey(pin)); - } + for (const Pin *pin : *pins) + pins_matches.insertSet(exception_map.findKey(pin)); findMatchingExceptions(exception, &pins_matches, matches); } } @@ -4565,16 +4408,13 @@ Sdc::findMatchingExceptionsPins(ExceptionPath *exception, void Sdc::findMatchingExceptionsInsts(ExceptionPath *exception, InstanceSet *insts, - InstanceExceptionsMap *exception_map, + InstanceExceptionsMap &exception_map, ExceptionPathSet &matches) { - if (exception_map) { + if (insts) { ExceptionPathSet insts_matches; - InstanceSet::Iterator inst_iter(insts); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - insts_matches.insertSet(exception_map->findKey(inst)); - } + for (const Instance *inst : *insts) + insts_matches.insertSet(exception_map.findKey(inst)); findMatchingExceptions(exception, &insts_matches, matches); } } @@ -4585,9 +4425,7 @@ Sdc::findMatchingExceptions(ExceptionPath *exception, ExceptionPathSet &matches) { if (potential_matches) { - ExceptionPathSet::Iterator match_iter(potential_matches); - while (match_iter.hasNext()) { - ExceptionPath *match = match_iter.next(); + for (ExceptionPath *match : *potential_matches) { if (match->overrides(exception) && match->intersectsPts(exception)) matches.insert(match); @@ -4604,15 +4442,15 @@ Sdc::expandExceptionExcluding(ExceptionPath *exception, ExceptionThruSeq *thrus = exception->thrus(); ExceptionTo *to = exception->to(); if (from) { - ExceptionFrom *from_cpy = from->clone(); - from_cpy->deleteObjects(excluding->from()); + ExceptionFrom *from_cpy = from->clone(network_); + from_cpy->deleteObjects(excluding->from(), network_); if (from_cpy->hasObjects()) { ExceptionThruSeq *thrus_cpy = nullptr; if (thrus) thrus_cpy = clone(thrus, network_); ExceptionTo *to_cpy = nullptr; if (to) - to_cpy = to->clone(); + to_cpy = to->clone(network_); ExceptionPath *expand = exception->clone(from_cpy,thrus_cpy,to_cpy,true); expansions.insert(expand); } @@ -4627,15 +4465,13 @@ Sdc::expandExceptionExcluding(ExceptionPath *exception, ExceptionThru *thru = thru_iter.next(); ExceptionThru *thru2 = thru_iter2.next(); ExceptionThru *thru_cpy = thru->clone(network_); - thru_cpy->deleteObjects(thru2); + thru_cpy->deleteObjects(thru2, network_); if (thru_cpy->hasObjects()) { ExceptionFrom *from_cpy = nullptr; if (from) - from_cpy = from->clone(); + from_cpy = from->clone(network_); ExceptionThruSeq *thrus_cpy = new ExceptionThruSeq; - ExceptionThruSeq::Iterator thru_iter1(thrus); - while (thru_iter1.hasNext()) { - ExceptionThru *thru1 = thru_iter1.next(); + for (ExceptionThru *thru1 : *thrus) { if (thru1 == thru) thrus_cpy->push_back(thru_cpy); else { @@ -4645,7 +4481,7 @@ Sdc::expandExceptionExcluding(ExceptionPath *exception, } ExceptionTo *to_cpy = nullptr; if (to) - to_cpy = to->clone(); + to_cpy = to->clone(network_); ExceptionPath *expand = exception->clone(from_cpy, thrus_cpy, to_cpy, true); expansions.insert(expand); @@ -4655,12 +4491,12 @@ Sdc::expandExceptionExcluding(ExceptionPath *exception, } } if (to) { - ExceptionTo *to_cpy = to->clone(); - to_cpy->deleteObjects(excluding->to()); + ExceptionTo *to_cpy = to->clone(network_); + to_cpy->deleteObjects(excluding->to(), network_); if (to_cpy->hasObjects()) { ExceptionFrom *from_cpy = nullptr; if (from) - from_cpy = from->clone(); + from_cpy = from->clone(network_); ExceptionThruSeq *thrus_cpy = nullptr; if (thrus) thrus_cpy = clone(thrus, network_); @@ -4673,12 +4509,11 @@ Sdc::expandExceptionExcluding(ExceptionPath *exception, } static ExceptionThruSeq * -clone(ExceptionThruSeq *thrus, Network *network) +clone(ExceptionThruSeq *thrus, + Network *network) { ExceptionThruSeq *thrus_cpy = new ExceptionThruSeq; - ExceptionThruSeq::Iterator thru_iter(thrus); - while (thru_iter.hasNext()) { - ExceptionThru *thru = thru_iter.next(); + for (ExceptionThru *thru : *thrus) { ExceptionThru *thru_cpy = thru->clone(network); thrus_cpy->push_back(thru_cpy); } @@ -4771,11 +4606,8 @@ Sdc::recordExceptionFirstThru(ExceptionPath *exception) recordExceptionInsts(exception, thru->instances(), first_thru_inst_exceptions_); recordExceptionEdges(exception, thru->edges(), first_thru_edge_exceptions_); - ExceptionThruSeq::Iterator thru_iter(exception->thrus()); - while (thru_iter.hasNext()) { - ExceptionThru *thru = thru_iter.next(); + for (ExceptionThru *thru : *exception->thrus()) recordExceptionNets(exception, thru->nets(), first_thru_net_exceptions_); - } } void @@ -4790,81 +4622,63 @@ Sdc::recordExceptionFirstTo(ExceptionPath *exception) void Sdc::recordExceptionClks(ExceptionPath *exception, ClockSet *clks, - ClockExceptionsMap *&exception_map) + ClockExceptionsMap &exception_map) { - ClockSet::Iterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); - ExceptionPathSet *set = nullptr; - if (exception_map == nullptr) - exception_map = new ClockExceptionsMap; - else - set = exception_map->findKey(clk); - if (set == nullptr) { - set = new ExceptionPathSet; - (*exception_map)[clk] = set; + if (clks) { + for (Clock *clk : *clks) { + ExceptionPathSet *set = exception_map.findKey(clk); + if (set == nullptr) { + set = new ExceptionPathSet; + exception_map[clk] = set; + } + set->insert(exception); } - set->insert(exception); } } void Sdc::recordExceptionEdges(ExceptionPath *exception, EdgePinsSet *edges, - EdgeExceptionsMap *&exception_map) + EdgeExceptionsMap &exception_map) { - EdgePinsSet::Iterator edge_iter(edges); - while (edge_iter.hasNext()) { - EdgePins *edge = edge_iter.next(); - ExceptionPathSet *set = nullptr; - if (exception_map == nullptr) - exception_map = new EdgeExceptionsMap; - else - set = exception_map->findKey(edge); - if (set == nullptr) { - set = new ExceptionPathSet; - // Copy the EdgePins so it is owned by the map. - edge = new EdgePins(*edge); - exception_map->insert(edge, set); + if (edges) { + for (const EdgePins &edge : *edges) { + ExceptionPathSet *set = exception_map.findKey(edge); + if (set == nullptr) { + set = new ExceptionPathSet; + exception_map.insert(edge, set); + } + set->insert(exception); } - set->insert(exception); } } void Sdc::recordExceptionPins(ExceptionPath *exception, PinSet *pins, - PinExceptionsMap *&exception_map) + PinExceptionsMap &exception_map) { - PinSet::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - const Pin *pin = pin_iter.next(); - ExceptionPathSet *set = nullptr; - if (exception_map == nullptr) - exception_map = new PinExceptionsMap; - else - set = exception_map->findKey(pin); - if (set == nullptr) { - set = new ExceptionPathSet; - exception_map->insert(pin, set); + if (pins) { + for (const Pin *pin : *pins) { + ExceptionPathSet *set = exception_map.findKey(pin); + if (set == nullptr) { + set = new ExceptionPathSet; + exception_map.insert(pin, set); + } + set->insert(exception); } - set->insert(exception); } } void Sdc::recordExceptionHpin(ExceptionPath *exception, Pin *pin, - PinExceptionsMap *&exception_map) + PinExceptionsMap &exception_map) { - ExceptionPathSet *set = nullptr; - if (exception_map == nullptr) - exception_map = new PinExceptionsMap; - else - set = exception_map->findKey(pin); + ExceptionPathSet *set = exception_map.findKey(pin); if (set == nullptr) { set = new ExceptionPathSet; - exception_map->insert(pin, set); + exception_map.insert(pin, set); } set->insert(exception); } @@ -4872,42 +4686,34 @@ Sdc::recordExceptionHpin(ExceptionPath *exception, void Sdc::recordExceptionInsts(ExceptionPath *exception, InstanceSet *insts, - InstanceExceptionsMap *&exception_map) + InstanceExceptionsMap &exception_map) { - InstanceSet::Iterator inst_iter(insts); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - ExceptionPathSet *set = nullptr; - if (exception_map == nullptr) - exception_map = new InstanceExceptionsMap; - else - set = exception_map->findKey(inst); - if (set == nullptr) { - set = new ExceptionPathSet; - (*exception_map)[inst] = set; + if (insts) { + for (const Instance *inst : *insts) { + ExceptionPathSet *set = exception_map.findKey(inst); + if (set == nullptr) { + set = new ExceptionPathSet; + exception_map[inst] = set; + } + set->insert(exception); } - set->insert(exception); } } void Sdc::recordExceptionNets(ExceptionPath *exception, NetSet *nets, - NetExceptionsMap *&exception_map) + NetExceptionsMap &exception_map) { - NetSet::Iterator net_iter(nets); - while (net_iter.hasNext()) { - const Net *net = net_iter.next(); - ExceptionPathSet *set = nullptr; - if (exception_map == nullptr) - exception_map = new NetExceptionsMap; - else - set = exception_map->findKey(net); - if (set == nullptr) { - set = new ExceptionPathSet; - (*exception_map)[net] = set; + if (nets) { + for (const Net *net : *nets) { + ExceptionPathSet *set = exception_map.findKey(net); + if (set == nullptr) { + set = new ExceptionPathSet; + exception_map[net] = set; + } + set->insert(exception); } - set->insert(exception); } } @@ -4942,9 +4748,7 @@ Sdc::findMergeMatch(ExceptionPath *exception) size_t hash = exception->hash(missing_pt); ExceptionPathSet *matches = exception_merge_hash_.findKey(hash); if (matches) { - ExceptionPathSet::Iterator match_iter(matches); - while (match_iter.hasNext()) { - ExceptionPath *match = match_iter.next(); + for (ExceptionPath *match : *matches) { ExceptionPt *match_missing_pt; if (match != exception // Exceptions are not merged if their priorities are @@ -4959,7 +4763,7 @@ Sdc::findMergeMatch(ExceptionPath *exception) // Unrecord the exception that is being merged away. unrecordException(exception); unrecordMergeHashes(match); - missing_pt->mergeInto(match_missing_pt); + missing_pt->mergeInto(match_missing_pt, network_); recordMergeHashes(match); // First point maps only change if the exception point that // is being merged is the first exception point. @@ -4982,28 +4786,21 @@ Sdc::findMergeMatch(ExceptionPath *exception) void Sdc::deleteExceptions() { - ExceptionPathSet::Iterator except_iter(exceptions_); - while (except_iter.hasNext()) { - delete except_iter.next(); - } - exceptions_.clear(); + exceptions_.deleteContentsClear(); - deleteExceptionMap(first_from_pin_exceptions_); - deleteExceptionMap(first_from_clk_exceptions_); - deleteExceptionMap(first_from_inst_exceptions_); - deleteExceptionMap(first_to_pin_exceptions_); - deleteExceptionMap(first_to_clk_exceptions_); - deleteExceptionMap(first_to_inst_exceptions_); - deleteExceptionMap(first_thru_pin_exceptions_); - deleteExceptionMap(first_thru_inst_exceptions_); - deleteExceptionMap(first_thru_net_exceptions_); - deleteExceptionMap(first_thru_edge_exceptions_); - - delete path_delay_internal_startpoints_; - path_delay_internal_startpoints_ = nullptr; - - delete path_delay_internal_endpoints_; - path_delay_internal_endpoints_ = nullptr; + first_from_pin_exceptions_.deleteContentsClear(); + first_from_clk_exceptions_.deleteContentsClear(); + first_from_inst_exceptions_.deleteContentsClear(); + first_to_pin_exceptions_.deleteContentsClear(); + first_to_clk_exceptions_.deleteContentsClear(); + first_to_inst_exceptions_.deleteContentsClear(); + first_thru_pin_exceptions_.deleteContentsClear(); + first_thru_inst_exceptions_.deleteContentsClear(); + first_thru_net_exceptions_.deleteContentsClear(); + first_thru_edge_exceptions_.deleteContentsClear(); + first_thru_edge_exceptions_.clear(); + path_delay_internal_startpoints_.clear(); + path_delay_internal_endpoints_.clear(); deleteExceptionPtHashMapSets(exception_merge_hash_); exception_merge_hash_.clear(); @@ -5013,80 +4810,7 @@ Sdc::deleteExceptions() void Sdc::deleteExceptionPtHashMapSets(ExceptionPathPtHash &map) { - ExceptionPathPtHash::Iterator set_iter(map); - while (set_iter.hasNext()) - delete set_iter.next(); -} - -void -Sdc::deleteExceptionMap(PinExceptionsMap *&exception_map) -{ - PinExceptionsMap::Iterator set_iter(exception_map); - while (set_iter.hasNext()) { - const Pin *pin; - ExceptionPathSet *set; - set_iter.next(pin, set); - delete set; - } - delete exception_map; - exception_map = nullptr; -} - -void -Sdc::deleteExceptionMap(InstanceExceptionsMap *&exception_map) -{ - InstanceExceptionsMap::Iterator set_iter(exception_map); - while (set_iter.hasNext()) { - const Instance *inst; - ExceptionPathSet *set; - set_iter.next(inst, set); - delete set; - } - delete exception_map; - exception_map = nullptr; -} - -void -Sdc::deleteExceptionMap(NetExceptionsMap *&exception_map) -{ - NetExceptionsMap::Iterator set_iter(exception_map); - while (set_iter.hasNext()) { - const Net *net; - ExceptionPathSet *set; - set_iter.next(net, set); - delete set; - } - delete exception_map; - exception_map = nullptr; -} - -void -Sdc::deleteExceptionMap(ClockExceptionsMap *&exception_map) -{ - ClockExceptionsMap::Iterator set_iter(exception_map); - while (set_iter.hasNext()) { - const Clock *clk; - ExceptionPathSet *set; - set_iter.next(clk, set); - delete set; - } - delete exception_map; - exception_map = nullptr; -} - -void -Sdc::deleteExceptionMap(EdgeExceptionsMap *&exception_map) -{ - EdgeExceptionsMap::Iterator set_iter(exception_map); - while (set_iter.hasNext()) { - const EdgePins *edge_pins; - ExceptionPathSet *set; - set_iter.next(edge_pins, set); - delete set; - delete edge_pins; - } - delete exception_map; - exception_map = nullptr; + map.deleteContents(); } //////////////////////////////////////////////////////////////// @@ -5094,6 +4818,7 @@ Sdc::deleteExceptionMap(EdgeExceptionsMap *&exception_map) void Sdc::deleteExceptionsReferencing(Clock *clk) { + // erase prevents range iteration. ExceptionPathSet::ConstIterator exception_iter(exceptions_); while (exception_iter.hasNext()) { ExceptionPath *exception = exception_iter.next(); @@ -5181,8 +4906,7 @@ Sdc::unrecordExceptionFirstPts(ExceptionPath *exception) if (from) { unrecordExceptionPins(exception, from->pins(), first_from_pin_exceptions_); unrecordExceptionClks(exception, from->clks(), first_from_clk_exceptions_); - unrecordExceptionInsts(exception, from->instances(), - first_from_inst_exceptions_); + unrecordExceptionInsts(exception, from->instances(), first_from_inst_exceptions_); } else if (thrus) { ExceptionThru *thru = (*thrus)[0]; @@ -5204,79 +4928,79 @@ Sdc::unrecordExceptionFirstPts(ExceptionPath *exception) void Sdc::unrecordExceptionClks(ExceptionPath *exception, ClockSet *clks, - ClockExceptionsMap *exception_map) + ClockExceptionsMap &exception_map) { - ClockSet::Iterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); - ExceptionPathSet *set = exception_map->findKey(clk); - if (set) - set->erase(exception); + if (clks) { + for (Clock *clk : *clks) { + ExceptionPathSet *set = exception_map.findKey(clk); + if (set) + set->erase(exception); + } } } void Sdc::unrecordExceptionPins(ExceptionPath *exception, PinSet *pins, - PinExceptionsMap *exception_map) + PinExceptionsMap &exception_map) { - PinSet::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - const Pin *pin = pin_iter.next(); - ExceptionPathSet *set = exception_map->findKey(pin); - if (set) - set->erase(exception); + if (pins) { + for (const Pin *pin : *pins) { + ExceptionPathSet *set = exception_map.findKey(pin); + if (set) + set->erase(exception); + } } } void Sdc::unrecordExceptionInsts(ExceptionPath *exception, InstanceSet *insts, - InstanceExceptionsMap *exception_map) + InstanceExceptionsMap &exception_map) { - InstanceSet::Iterator inst_iter(insts); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - ExceptionPathSet *set = exception_map->findKey(inst); - if (set) - set->erase(exception); + if (insts) { + for (const Instance *inst : *insts) { + ExceptionPathSet *set = exception_map.findKey(inst); + if (set) + set->erase(exception); + } } } void Sdc::unrecordExceptionEdges(ExceptionPath *exception, EdgePinsSet *edges, - EdgeExceptionsMap *exception_map) + EdgeExceptionsMap &exception_map) { - EdgePinsSet::Iterator edge_iter(edges); - while (edge_iter.hasNext()) { - EdgePins *edge = edge_iter.next(); - ExceptionPathSet *set = exception_map->findKey(edge); - if (set) - set->erase(exception); + if (edges) { + for (const EdgePins &edge : *edges) { + ExceptionPathSet *set = exception_map.findKey(edge); + if (set) + set->erase(exception); + } } } void Sdc::unrecordExceptionNets(ExceptionPath *exception, NetSet *nets, - NetExceptionsMap *exception_map) + NetExceptionsMap &exception_map) { - NetSet::Iterator net_iter(nets); - while (net_iter.hasNext()) { - const Net *net = net_iter.next(); - ExceptionPathSet *set = exception_map->findKey(net); - if (set) - set->erase(exception); + if (nets) { + for (const Net *net : *nets) { + ExceptionPathSet *set = exception_map.findKey(net); + if (set) + set->erase(exception); + } } } void Sdc::unrecordExceptionHpin(ExceptionPath *exception, Pin *pin, - PinExceptionsMap *&exception_map) + PinExceptionsMap &exception_map) { - ExceptionPathSet *set = exception_map->findKey(pin); + ExceptionPathSet *set = exception_map.findKey(pin); if (set) set->erase(exception); } @@ -5311,19 +5035,16 @@ ExpandException::visit(ExceptionFrom *from, { ExceptionFrom *from_clone = nullptr; if (from) - from_clone = from->clone(); + from_clone = from->clone(network_); ExceptionThruSeq *thrus_clone = nullptr; if (thrus) { thrus_clone = new ExceptionThruSeq; - ExceptionThruSeq::Iterator thru_iter(thrus); - while (thru_iter.hasNext()) { - ExceptionThru *thru = thru_iter.next(); + for (ExceptionThru *thru : *thrus) thrus_clone->push_back(thru->clone(network_)); - } } ExceptionTo *to_clone = nullptr; if (to) - to_clone = to->clone(); + to_clone = to->clone(network_); ExceptionPath *expand = exception_->clone(from_clone, thrus_clone, to_clone, true); expansions_.insert(expand); @@ -5396,30 +5117,31 @@ Sdc::exceptionFromStates(const Pin *pin, { bool srch_from = true; if (pin) { - if (srch_from && first_from_pin_exceptions_) - srch_from &= exceptionFromStates(first_from_pin_exceptions_->findKey(pin), + if (srch_from && !first_from_pin_exceptions_.empty()) + srch_from &= exceptionFromStates(first_from_pin_exceptions_.findKey(pin), pin, rf, min_max, include_filter, states); - if (srch_from && first_thru_pin_exceptions_) - srch_from &= exceptionFromStates(first_thru_pin_exceptions_->findKey(pin), + if (srch_from && !first_thru_pin_exceptions_.empty()) + srch_from &= exceptionFromStates(first_thru_pin_exceptions_.findKey(pin), pin, rf, min_max, include_filter, states); if (srch_from - && (first_from_inst_exceptions_ || first_thru_inst_exceptions_)) { + && (!first_from_inst_exceptions_.empty() + || !first_thru_inst_exceptions_.empty())) { Instance *inst = network_->instance(pin); - if (srch_from && first_from_inst_exceptions_) - srch_from &= exceptionFromStates(first_from_inst_exceptions_->findKey(inst), + if (srch_from && !first_from_inst_exceptions_.empty()) + srch_from &= exceptionFromStates(first_from_inst_exceptions_.findKey(inst), pin, rf, min_max, include_filter, states); - if (srch_from && first_thru_inst_exceptions_) - srch_from &= exceptionFromStates(first_thru_inst_exceptions_->findKey(inst), + if (srch_from && !first_thru_inst_exceptions_.empty()) + srch_from &= exceptionFromStates(first_thru_inst_exceptions_.findKey(inst), pin, rf, min_max, include_filter, states); } } - if (srch_from && clk && first_from_clk_exceptions_) - srch_from &= exceptionFromStates(first_from_clk_exceptions_->findKey(clk), + if (srch_from && clk && !first_from_clk_exceptions_.empty()) + srch_from &= exceptionFromStates(first_from_clk_exceptions_.findKey(clk), pin, clk_rf, min_max, include_filter, states); if (!srch_from) { @@ -5438,9 +5160,7 @@ Sdc::exceptionFromStates(const ExceptionPathSet *exceptions, ExceptionStateSet *&states) const { if (exceptions) { - ExceptionPathSet::ConstIterator exception_iter(exceptions); - while (exception_iter.hasNext()) { - ExceptionPath *exception = exception_iter.next(); + for (ExceptionPath *exception : *exceptions) { if (exception->matches(min_max, false) && (exception->from() == nullptr || exception->from()->transition()->matches(rf)) @@ -5457,7 +5177,7 @@ Sdc::exceptionFromStates(const ExceptionPathSet *exceptions, // but flush all other exception states because they are lower // priority. if (states == nullptr) - states = new ExceptionStateSet; + states = new ExceptionStateSet(network_); states->clear(); states->insert(state); // No need to examine other exceptions from this @@ -5465,7 +5185,7 @@ Sdc::exceptionFromStates(const ExceptionPathSet *exceptions, return false; } if (states == nullptr) - states = new ExceptionStateSet; + states = new ExceptionStateSet(network_); states->insert(state); } } @@ -5482,17 +5202,17 @@ Sdc::exceptionFromClkStates(const Pin *pin, ExceptionStateSet *&states) const { if (pin) { - if (first_from_pin_exceptions_) - exceptionFromStates(first_from_pin_exceptions_->findKey(pin), + if (!first_from_pin_exceptions_.empty()) + exceptionFromStates(first_from_pin_exceptions_.findKey(pin), nullptr, rf, min_max, true, states); - if (first_from_inst_exceptions_) { + if (!first_from_inst_exceptions_.empty()) { Instance *inst = network_->instance(pin); - exceptionFromStates(first_from_inst_exceptions_->findKey(inst), + exceptionFromStates(first_from_inst_exceptions_.findKey(inst), pin, rf, min_max, true, states); } } - if (first_from_clk_exceptions_) - exceptionFromStates(first_from_clk_exceptions_->findKey(clk), + if (!first_from_clk_exceptions_.empty()) + exceptionFromStates(first_from_clk_exceptions_.findKey(clk), pin, clk_rf, min_max, true, states); } @@ -5502,19 +5222,17 @@ Sdc::filterRegQStates(const Pin *to_pin, const MinMax *min_max, ExceptionStateSet *&states) const { - if (first_from_pin_exceptions_) { + if (!first_from_pin_exceptions_.empty()) { const ExceptionPathSet *exceptions = - first_from_pin_exceptions_->findKey(to_pin); + first_from_pin_exceptions_.findKey(to_pin); if (exceptions) { - ExceptionPathSet::ConstIterator exception_iter(exceptions); - while (exception_iter.hasNext()) { - ExceptionPath *exception = exception_iter.next(); + for (ExceptionPath *exception : *exceptions) { // Hack for filter -from reg/Q. if (exception->isFilter() && exception->matchesFirstPt(to_rf, min_max)) { ExceptionState *state = exception->firstState(); if (states == nullptr) - states = new ExceptionStateSet; + states = new ExceptionStateSet(network_); states->insert(state); } } @@ -5529,19 +5247,18 @@ Sdc::exceptionThruStates(const Pin *from_pin, const MinMax *min_max) const { ExceptionStateSet *states = nullptr; - if (first_thru_pin_exceptions_) - exceptionThruStates(first_thru_pin_exceptions_->findKey(to_pin), - to_rf, min_max, states); - if (first_thru_edge_exceptions_) { - EdgePins edge_pins(const_cast(from_pin), const_cast(to_pin)); - exceptionThruStates(first_thru_edge_exceptions_->findKey(&edge_pins), + exceptionThruStates(first_thru_pin_exceptions_.findKey(to_pin), + to_rf, min_max, states); + if (!first_thru_edge_exceptions_.empty()) { + EdgePins edge_pins(from_pin, to_pin); + exceptionThruStates(first_thru_edge_exceptions_.findKey(edge_pins), to_rf, min_max, states); } - if (first_thru_inst_exceptions_ + if (!first_thru_inst_exceptions_.empty() && (network_->direction(to_pin)->isAnyOutput() || network_->isLatchData(to_pin))) { const Instance *to_inst = network_->instance(to_pin); - exceptionThruStates(first_thru_inst_exceptions_->findKey(to_inst), + exceptionThruStates(first_thru_inst_exceptions_.findKey(to_inst), to_rf, min_max, states); } return states; @@ -5555,13 +5272,11 @@ Sdc::exceptionThruStates(const ExceptionPathSet *exceptions, ExceptionStateSet *&states) const { if (exceptions) { - ExceptionPathSet::ConstIterator exception_iter(exceptions); - while (exception_iter.hasNext()) { - ExceptionPath *exception = exception_iter.next(); + for (ExceptionPath *exception : *exceptions) { if (exception->matchesFirstPt(to_rf, min_max)) { ExceptionState *state = exception->firstState(); if (states == nullptr) - states = new ExceptionStateSet; + states = new ExceptionStateSet(network_); states->insert(state); } } @@ -5579,18 +5294,18 @@ Sdc::exceptionTo(ExceptionPathType type, ExceptionPath *&hi_priority_exception, int &hi_priority) const { - if (first_to_inst_exceptions_) { + if (!first_to_inst_exceptions_.empty()) { Instance *inst = network_->instance(pin); - exceptionTo(first_to_inst_exceptions_->findKey(inst), type, pin, rf, + exceptionTo(first_to_inst_exceptions_.findKey(inst), type, pin, rf, clk_edge, min_max, match_min_max_exactly, hi_priority_exception, hi_priority); } - if (first_to_pin_exceptions_) - exceptionTo(first_to_pin_exceptions_->findKey(pin), type, pin, rf, + if (!first_to_pin_exceptions_.empty()) + exceptionTo(first_to_pin_exceptions_.findKey(pin), type, pin, rf, clk_edge, min_max, match_min_max_exactly, hi_priority_exception, hi_priority); - if (clk_edge && first_to_clk_exceptions_) - exceptionTo(first_to_clk_exceptions_->findKey(clk_edge->clock()), + if (clk_edge && !first_to_clk_exceptions_.empty()) + exceptionTo(first_to_clk_exceptions_.findKey(clk_edge->clock()), type, pin, rf, clk_edge, min_max, match_min_max_exactly, hi_priority_exception, hi_priority); } @@ -5608,9 +5323,7 @@ Sdc::exceptionTo(const ExceptionPathSet *to_exceptions, int &hi_priority) const { if (to_exceptions) { - ExceptionPathSet::ConstIterator exception_iter(to_exceptions); - while (exception_iter.hasNext()) { - ExceptionPath *exception = exception_iter.next(); + for (ExceptionPath *exception : *to_exceptions) { exceptionTo(exception, type, pin, rf, clk_edge, min_max, match_min_max_exactly, hi_priority_exception, hi_priority); @@ -5944,17 +5657,13 @@ Sdc::setUseDefaultArrivalClock(bool enable) //////////////////////////////////////////////////////////////// void -Sdc::connectPinAfter(Pin *pin) +Sdc::connectPinAfter(const Pin *pin) { if (have_thru_hpin_exceptions_) { PinSet *drvrs = network_->drivers(pin); - ExceptionPathSet::Iterator except_iter(exceptions_); - while (except_iter.hasNext()) { - ExceptionPath *exception = except_iter.next(); + for (ExceptionPath *exception : exceptions_) { ExceptionPt *first_pt = exception->firstPt(); - ExceptionThruSeq::Iterator thru_iter(exception->thrus()); - while (thru_iter.hasNext()) { - ExceptionThru *thru = thru_iter.next(); + for (ExceptionThru *thru : *exception->thrus()) { if (thru->edges()) { thru->connectPinAfter(drvrs, network_); if (first_pt == thru) @@ -5967,16 +5676,12 @@ Sdc::connectPinAfter(Pin *pin) } void -Sdc::disconnectPinBefore(Pin *pin) +Sdc::disconnectPinBefore(const Pin *pin) { if (have_thru_hpin_exceptions_) { - ExceptionPathSet::Iterator except_iter(exceptions_); - while (except_iter.hasNext()) { - ExceptionPath *exception = except_iter.next(); + for (ExceptionPath *exception : exceptions_) { ExceptionPt *first_pt = exception->firstPt(); - ExceptionThruSeq::Iterator thru_iter(exception->thrus()); - while (thru_iter.hasNext()) { - ExceptionThru *thru = thru_iter.next(); + for (ExceptionThru *thru : *exception->thrus()) { if (thru->edges()) { thru->disconnectPinBefore(pin, network_); if (thru == first_pt) @@ -5989,7 +5694,7 @@ Sdc::disconnectPinBefore(Pin *pin) } void -Sdc::clkHpinDisablesChanged(Pin *pin) +Sdc::clkHpinDisablesChanged(const Pin *pin) { if (isLeafPinClock(pin)) clkHpinDisablesInvalid(); @@ -6002,7 +5707,7 @@ Sdc::clkHpinDisablesChanged(Pin *pin) // hierarchical input - load pins inside the hierarchical instance // hierarchical output - load pins outside the hierarchical instance void -findLeafLoadPins(Pin *pin, +findLeafLoadPins(const Pin *pin, const Network *network, PinSet *leaf_pins) { @@ -6013,7 +5718,7 @@ findLeafLoadPins(Pin *pin, const Instance *hinst = network->instance(pin); PinConnectedPinIterator *pin_iter = network->connectedPinIterator(pin); while (pin_iter->hasNext()) { - Pin *pin1 = pin_iter->next(); + const Pin *pin1 = pin_iter->next(); bool is_inside = network->isInside(pin1, hinst); if (((is_input && is_inside) || (is_output && !is_inside)) @@ -6031,7 +5736,7 @@ findLeafLoadPins(Pin *pin, // hierarchical input - driver pins outside the hierarchical instance // hierarchical output - driver pins inside the hierarchical instance void -findLeafDriverPins(Pin *pin, +findLeafDriverPins(const Pin *pin, const Network *network, PinSet *leaf_pins) { @@ -6042,7 +5747,7 @@ findLeafDriverPins(Pin *pin, const Instance *hinst = network->instance(pin); PinConnectedPinIterator *pin_iter = network->connectedPinIterator(pin); while (pin_iter->hasNext()) { - Pin *pin1 = pin_iter->next(); + const Pin *pin1 = pin_iter->next(); bool is_inside = network->isInside(pin1, hinst); if (((is_input && !is_inside) || (is_output && is_inside)) @@ -6055,28 +5760,4 @@ findLeafDriverPins(Pin *pin, leaf_pins->insert(pin); } -//////////////////////////////////////////////////////////////// - -ClockIterator::ClockIterator(Sdc *sdc) : - ClockSeq::Iterator(sdc->clocks()) -{ -} - -ClockIterator::ClockIterator(ClockSeq &clocks) : - ClockSeq::Iterator(clocks) -{ -} - -//////////////////////////////////////////////////////////////// - -GroupPathIterator::GroupPathIterator(Sdc *sdc) : - GroupPathIterator(sdc->group_path_map_) -{ -} - -GroupPathIterator::GroupPathIterator(GroupPathMap &group_path_map) : - GroupPathMap::Iterator(group_path_map) -{ -} - } // namespace diff --git a/sdc/SdcGraph.cc b/sdc/SdcGraph.cc index f69f5302..983856a3 100644 --- a/sdc/SdcGraph.cc +++ b/sdc/SdcGraph.cc @@ -26,8 +26,8 @@ namespace sta { static void -annotateGraphDisabledWireEdge(Pin *from_pin, - Pin *to_pin, +annotateGraphDisabledWireEdge(const Pin *from_pin, + const Pin *to_pin, Graph *graph); // Annotate constraints to the timing graph. @@ -64,7 +64,7 @@ Sdc::annotateDisables() { PinSet::Iterator pin_iter(disabled_pins_); while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + const Pin *pin = pin_iter.next(); annotateGraphDisabled(pin); } @@ -82,22 +82,16 @@ Sdc::annotateDisables() Instance *top_inst = network_->topInstance(); PortSet::Iterator port_iter(disabled_ports_); while (port_iter.hasNext()) { - Port *port = port_iter.next(); + const Port *port = port_iter.next(); Pin *pin = network_->findPin(top_inst, port); annotateGraphDisabled(pin); } - PinPairSet::Iterator pair_iter(disabled_wire_edges_); - while (pair_iter.hasNext()) { - PinPair *pair = pair_iter.next(); - annotateGraphDisabledWireEdge(pair->first, pair->second, graph_); - } + for (const PinPair &pair : disabled_wire_edges_) + annotateGraphDisabledWireEdge(pair.first, pair.second, graph_); - EdgeSet::Iterator edge_iter(disabled_edges_); - while (edge_iter.hasNext()) { - Edge *edge = edge_iter.next(); + for (Edge *edge : disabled_edges_) edge->setIsDisabledConstraint(true); - } DisabledInstancePortsMap::Iterator disable_inst_iter(disabled_inst_ports_); while (disable_inst_iter.hasNext()) { @@ -110,8 +104,8 @@ class DisableHpinEdgeVisitor : public HierPinThruVisitor { public: DisableHpinEdgeVisitor(Graph *graph); - virtual void visit(Pin *from_pin, - Pin *to_pin); + virtual void visit(const Pin *from_pin, + const Pin *to_pin); protected: bool annotate_; @@ -125,15 +119,15 @@ DisableHpinEdgeVisitor::DisableHpinEdgeVisitor(Graph *graph) : } void -DisableHpinEdgeVisitor::visit(Pin *from_pin, - Pin *to_pin) +DisableHpinEdgeVisitor::visit(const Pin *from_pin, + const Pin *to_pin) { annotateGraphDisabledWireEdge(from_pin, to_pin, graph_); } static void -annotateGraphDisabledWireEdge(Pin *from_pin, - Pin *to_pin, +annotateGraphDisabledWireEdge(const Pin *from_pin, + const Pin *to_pin, Graph *graph) { Vertex *from_vertex = graph->pinDrvrVertex(from_pin); @@ -208,24 +202,24 @@ Sdc::setEdgeDisabledInstPorts(DisabledPorts *disabled_port, } // Disable from/to pins. - LibertyPortPairSet::Iterator from_to_iter(disabled_port->fromTo()); - while (from_to_iter.hasNext()) { - LibertyPortPair *pair = from_to_iter.next(); - const LibertyPort *from_port = pair->first; - const LibertyPort *to_port = pair->second; - Pin *from_pin = network_->findPin(inst, from_port); - Pin *to_pin = network_->findPin(inst, to_port); - if (from_pin && network_->direction(from_pin)->isAnyInput() - && to_pin) { - Vertex *from_vertex = graph_->pinLoadVertex(from_pin); - Vertex *to_vertex = graph_->pinDrvrVertex(to_pin); - if (from_vertex && to_vertex) { - VertexOutEdgeIterator edge_iter(from_vertex, graph_); - while (edge_iter.hasNext()) { - Edge *edge = edge_iter.next(); - if (edge->to(graph_) == to_vertex) - edge->setIsDisabledConstraint(true); - } + if (disabled_port->fromTo()) { + for (const LibertyPortPair &from_to : *disabled_port->fromTo()) { + const LibertyPort *from_port = from_to.first; + const LibertyPort *to_port = from_to.second; + Pin *from_pin = network_->findPin(inst, from_port); + Pin *to_pin = network_->findPin(inst, to_port); + if (from_pin && network_->direction(from_pin)->isAnyInput() + && to_pin) { + Vertex *from_vertex = graph_->pinLoadVertex(from_pin); + Vertex *to_vertex = graph_->pinDrvrVertex(to_pin); + if (from_vertex && to_vertex) { + VertexOutEdgeIterator edge_iter(from_vertex, graph_); + while (edge_iter.hasNext()) { + Edge *edge = edge_iter.next(); + if (edge->to(graph_) == to_vertex) + edge->setIsDisabledConstraint(true); + } + } } } } @@ -253,7 +247,7 @@ void Sdc::annotateGraphOutputDelays() { for (OutputDelay *output_delay : output_delays_) { - for (Pin *lpin : output_delay->leafPins()) + for (const Pin *lpin : output_delay->leafPins()) annotateGraphConstrained(lpin); } } diff --git a/sdc/WriteSdc.cc b/sdc/WriteSdc.cc index 0c2042fb..a4537a85 100644 --- a/sdc/WriteSdc.cc +++ b/sdc/WriteSdc.cc @@ -46,6 +46,7 @@ #include "Sdc.hh" #include "Fuzzy.hh" #include "StaState.hh" +#include "Corner.hh" #include "WriteSdcPvt.hh" namespace sta { @@ -465,9 +466,9 @@ WriteSdc::writeGeneratedClock(Clock *clk) const } void -WriteSdc::writeClockPins(Clock *clk) const +WriteSdc::writeClockPins(const Clock *clk) const { - PinSet &pins = clk->pins(); + const PinSet &pins = clk->pins(); if (!pins.empty()) { if (pins.size() > 1) gzprintf(stream_, "\\\n "); @@ -476,16 +477,16 @@ WriteSdc::writeClockPins(Clock *clk) const } void -WriteSdc::writeClockSlews(Clock *clk) const +WriteSdc::writeClockSlews(const Clock *clk) const { WriteGetClock write_clk(clk, this); - RiseFallMinMax *slews = clk->slews(); - if (slews->hasValue()) - writeRiseFallMinMaxTimeCmd("set_clock_transition", slews, write_clk); + const RiseFallMinMax slews = clk->slews(); + if (slews.hasValue()) + writeRiseFallMinMaxTimeCmd("set_clock_transition", &slews, write_clk); } void -WriteSdc::writeClockUncertainty(Clock *clk) const +WriteSdc::writeClockUncertainty(const Clock *clk) const { float setup; bool setup_exists; @@ -504,7 +505,7 @@ WriteSdc::writeClockUncertainty(Clock *clk) const } void -WriteSdc::writeClockUncertainty(Clock *clk, +WriteSdc::writeClockUncertainty(const Clock *clk, const char *setup_hold, float value) const { @@ -586,9 +587,7 @@ WriteSdc::writeClockLatencies() const void WriteSdc::writeClockInsertions() const { - ClockInsertions::Iterator insert_iter(sdc_->clockInsertions()); - while (insert_iter.hasNext()) { - ClockInsertion *insert = insert_iter.next(); + for (ClockInsertion *insert : sdc_->clockInsertions()) { const Pin *pin = insert->pin(); const Clock *clk = insert->clock(); if (pin && clk) { @@ -719,14 +718,10 @@ WriteSdc::writeOutputDelays() const for (OutputDelay *output_delay : sdc_->outputDelays()) delays.push_back(output_delay); - PortDelayLess port_delay_less(sdc_network_); - sort(delays, port_delay_less); + sort(delays, PortDelayLess(sdc_network_)); - PortDelaySeq::Iterator delay_iter(delays); - while (delay_iter.hasNext()) { - PortDelay *output_delay = delay_iter.next(); + for (PortDelay *output_delay : delays) writePortDelay(output_delay, false, "set_output_delay"); - } } void @@ -803,7 +798,7 @@ WriteSdc::writePortDelay(PortDelay *port_delay, { gzprintf(stream_, "%s ", sdc_cmd); writeTime(delay); - ClockEdge *clk_edge = port_delay->clkEdge(); + const ClockEdge *clk_edge = port_delay->clkEdge(); if (clk_edge) { writeClockKey(clk_edge->clock()); if (clk_edge->transition() == RiseFall::fall()) @@ -812,7 +807,7 @@ WriteSdc::writePortDelay(PortDelay *port_delay, gzprintf(stream_, "%s%s -add_delay ", transRiseFallFlag(rf), minMaxFlag(min_max)); - Pin *ref_pin = port_delay->refPin(); + const Pin *ref_pin = port_delay->refPin(); if (ref_pin) { gzprintf(stream_, "-reference_pin "); writeGetPin(ref_pin, true); @@ -906,24 +901,21 @@ bool ClockGroupLess::operator()(const ClockGroup *clk_group1, const ClockGroup *clk_group2) const { - ClockSet *clk_set1 = clk_group1->clks(); - ClockSet *clk_set2 = clk_group2->clks(); - size_t size1 = clk_set1->size(); - size_t size2 = clk_set2->size(); + size_t size1 = clk_group1->size(); + size_t size2 = clk_group2->size(); if (size1 < size2) return true; else if (size1 > size2) return false; else { - ClockSeq clks1, clks2; - ClockSet::Iterator clk_iter1(clk_set1); - while (clk_iter1.hasNext()) - clks1.push_back(clk_iter1.next()); + ClockSeq clks1; + for (Clock *clk1 : *clk_group1) + clks1.push_back(clk1); sort(clks1, ClockNameLess()); - ClockSet::Iterator clk_iter2(clk_set2); - while (clk_iter2.hasNext()) - clks2.push_back(clk_iter2.next()); + ClockSeq clks2; + for (Clock *clk2 : *clk_group2) + clks2.push_back(clk2); sort(clks2, ClockNameLess()); ClockSeq::Iterator clk_iter3(clks1); @@ -977,7 +969,7 @@ WriteSdc::writeClockGroups(ClockGroups *clk_groups) const if (!first) gzprintf(stream_, "\\\n"); gzprintf(stream_, " -group "); - writeGetClocks(clk_group->clks()); + writeGetClocks(clk_group); first = false; } writeCmdComment(clk_groups); @@ -1000,25 +992,19 @@ WriteSdc::writeDisables() const void WriteSdc::writeDisabledCells() const { - DisabledCellPortsSeq disables; - sortDisabledCellPortsMap(sdc_->disabledCellPorts(), disables); - DisabledCellPortsSeq::Iterator disabled_iter(disables); - while (disabled_iter.hasNext()) { - DisabledCellPorts *disable = disabled_iter.next(); - LibertyCell *cell = disable->cell(); + DisabledCellPortsSeq disables = sortByName(sdc_->disabledCellPorts()); + for (const DisabledCellPorts *disable : disables) { + const LibertyCell *cell = disable->cell(); if (disable->all()) { gzprintf(stream_, "set_disable_timing "); writeGetLibCell(cell); gzprintf(stream_, "\n"); } if (disable->fromTo()) { - LibertyPortPairSeq pairs; - sortLibertyPortPairSet(disable->fromTo(), pairs); - LibertyPortPairSeq::Iterator pair_iter(pairs); - while (pair_iter.hasNext()) { - LibertyPortPair *from_to = pair_iter.next(); - const LibertyPort *from = from_to->first; - const LibertyPort *to = from_to->second; + LibertyPortPairSeq from_tos = sortByName(disable->fromTo()); + for (const LibertyPortPair &from_to : from_tos) { + const LibertyPort *from = from_to.first; + const LibertyPort *to = from_to.second; gzprintf(stream_, "set_disable_timing -from {%s} -to {%s} ", from->name(), to->name()); @@ -1027,11 +1013,8 @@ WriteSdc::writeDisabledCells() const } } if (disable->from()) { - LibertyPortSeq from; - sortLibertyPortSet(disable->from(), from); - LibertyPortSeq::Iterator from_iter(from); - while (from_iter.hasNext()) { - LibertyPort *from_port = from_iter.next(); + LibertyPortSeq from = sortByName(disable->from()); + for (const LibertyPort *from_port : from) { gzprintf(stream_, "set_disable_timing -from {%s} ", from_port->name()); writeGetLibCell(cell); @@ -1039,11 +1022,8 @@ WriteSdc::writeDisabledCells() const } } if (disable->to()) { - LibertyPortSeq to; - sortLibertyPortSet(disable->to(), to); - LibertyPortSeq::Iterator to_iter(to); - while (to_iter.hasNext()) { - LibertyPort *to_port = to_iter.next(); + LibertyPortSeq to = sortByName(disable->to()); + for (const LibertyPort *to_port : to) { gzprintf(stream_, "set_disable_timing -to {%s} ", to_port->name()); writeGetLibCell(cell); @@ -1063,11 +1043,8 @@ WriteSdc::writeDisabledCells() const void WriteSdc::writeDisabledPorts() const { - PortSeq ports; - sortPortSet(sdc_->disabledPorts(), sdc_network_, ports); - PortSeq::Iterator port_iter(ports); - while (port_iter.hasNext()) { - Port *port = port_iter.next(); + const PortSeq ports = sortByName(sdc_->disabledPorts(), sdc_network_); + for (const Port *port : ports) { gzprintf(stream_, "set_disable_timing "); writeGetPort(port); gzprintf(stream_, "\n"); @@ -1077,11 +1054,8 @@ WriteSdc::writeDisabledPorts() const void WriteSdc::writeDisabledLibPorts() const { - LibertyPortSeq ports; - sortLibertyPortSet(sdc_->disabledLibPorts(), ports); - LibertyPortSeq::Iterator port_iter(ports); - while (port_iter.hasNext()) { - LibertyPort *port = port_iter.next(); + LibertyPortSeq ports = sortByName(sdc_->disabledLibPorts()); + for (LibertyPort *port : ports) { gzprintf(stream_, "set_disable_timing "); writeGetLibPin(port); gzprintf(stream_, "\n"); @@ -1091,12 +1065,9 @@ WriteSdc::writeDisabledLibPorts() const void WriteSdc::writeDisabledInstances() const { - DisabledInstancePortsSeq disables; - sortDisabledInstancePortsMap(sdc_->disabledInstancePorts(), - sdc_network_, disables); - DisabledInstancePortsSeq::Iterator disabled_iter(disables); - while (disabled_iter.hasNext()) { - DisabledInstancePorts *disable = disabled_iter.next(); + DisabledInstancePortsSeq disables = sortByPathName(sdc_->disabledInstancePorts(), + sdc_network_); + for (DisabledInstancePorts *disable : disables) { Instance *inst = disable->instance(); if (disable->all()) { gzprintf(stream_, "set_disable_timing "); @@ -1104,13 +1075,10 @@ WriteSdc::writeDisabledInstances() const gzprintf(stream_, "\n"); } else if (disable->fromTo()) { - LibertyPortPairSeq pairs; - sortLibertyPortPairSet(disable->fromTo(), pairs); - LibertyPortPairSeq::Iterator pair_iter(pairs); - while (pair_iter.hasNext()) { - LibertyPortPair *from_to = pair_iter.next(); - const LibertyPort *from_port = from_to->first; - const LibertyPort *to_port = from_to->second; + LibertyPortPairSeq from_tos = sortByName(disable->fromTo()); + for (LibertyPortPair &from_to : from_tos) { + const LibertyPort *from_port = from_to.first; + const LibertyPort *to_port = from_to.second; gzprintf(stream_, "set_disable_timing -from {%s} -to {%s} ", from_port->name(), to_port->name()); @@ -1119,11 +1087,8 @@ WriteSdc::writeDisabledInstances() const } } if (disable->from()) { - LibertyPortSeq from; - sortLibertyPortSet(disable->from(), from); - LibertyPortSeq::Iterator from_iter(from); - while (from_iter.hasNext()) { - LibertyPort *from_port = from_iter.next(); + LibertyPortSeq from = sortByName(disable->from()); + for (const LibertyPort *from_port : from) { gzprintf(stream_, "set_disable_timing -from {%s} ", from_port->name()); writeGetInstance(inst); @@ -1131,11 +1096,8 @@ WriteSdc::writeDisabledInstances() const } } if (disable->to()) { - LibertyPortSeq to; - sortLibertyPortSet(disable->to(), to); - LibertyPortSeq::Iterator to_iter(to); - while (to_iter.hasNext()) { - LibertyPort *to_port = to_iter.next(); + LibertyPortSeq to = sortByName(disable->to()); + for (const LibertyPort *to_port : to) { gzprintf(stream_, "set_disable_timing -to {%s} ", to_port->name()); writeGetInstance(inst); @@ -1148,11 +1110,8 @@ WriteSdc::writeDisabledInstances() const void WriteSdc::writeDisabledPins() const { - PinSeq pins; - sortPinSet(sdc_->disabledPins(), sdc_network_, pins); - PinSeq::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + PinSeq pins = sortByPathName(sdc_->disabledPins(), sdc_network_); + for (const Pin *pin : pins) { gzprintf(stream_, "set_disable_timing "); writeGetPin(pin, false); gzprintf(stream_, "\n"); @@ -1163,15 +1122,10 @@ void WriteSdc::writeDisabledEdges() const { EdgeSeq edges; - EdgeSet::Iterator edge_iter(sdc_->disabledEdges()); - while (edge_iter.hasNext()) { - Edge *edge = edge_iter.next(); + for (Edge *edge : *sdc_->disabledEdges()) edges.push_back(edge); - } sortEdges(&edges, sdc_network_, graph_); - EdgeSeq::Iterator edge_iter2(edges); - while (edge_iter2.hasNext()) { - Edge *edge = edge_iter2.next(); + for (Edge *edge : edges) { EdgeSet matches; findMatchingEdges(edge, matches); if (matches.size() == 1) @@ -1200,9 +1154,7 @@ bool WriteSdc::edgeSenseIsUnique(Edge *edge, EdgeSet &matches) const { - EdgeSet::Iterator match_iter(matches); - while (match_iter.hasNext()) { - Edge *match = match_iter.next(); + for (Edge *match : matches) { if (match != edge && match->sense() == edge->sense()) return false; @@ -1235,10 +1187,10 @@ void WriteSdc::writeExceptions() const { ExceptionPathSeq exceptions; - sortExceptions(sdc_->exceptions(), exceptions, sdc_network_); - ExceptionPathSeq::Iterator except_iter(exceptions); - while (except_iter.hasNext()) { - ExceptionPath *exception = except_iter.next(); + for (ExceptionPath *exception : *sdc_->exceptions()) + exceptions.push_back(exception); + sort(exceptions, ExceptionPathLess(network_)); + for (ExceptionPath *exception : exceptions) { if (!exception->isFilter() && !exception->isLoop()) writeException(exception); @@ -1252,11 +1204,8 @@ WriteSdc::writeException(ExceptionPath *exception) const if (exception->from()) writeExceptionFrom(exception->from()); if (exception->thrus()) { - ExceptionThruSeq::Iterator thru_iter(exception->thrus()); - while (thru_iter.hasNext()) { - ExceptionThru *thru = thru_iter.next(); + for (ExceptionThru *thru : *exception->thrus()) writeExceptionThru(thru); - } } if (exception->to()) writeExceptionTo(exception->to()); @@ -1353,11 +1302,8 @@ WriteSdc::writeExceptionFromTo(ExceptionFromTo *from_to, gzprintf(stream_, "[list "); bool first = true; if (from_to->pins()) { - PinSeq pins; - sortPinSet(from_to->pins(), sdc_network_, pins); - PinSeq::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + PinSeq pins = sortByPathName(from_to->pins(), sdc_network_); + for (const Pin *pin : pins) { if (multi_objs && !first) gzprintf(stream_, "\\\n "); writeGetPin(pin, map_hpin_to_drvr); @@ -1367,11 +1313,8 @@ WriteSdc::writeExceptionFromTo(ExceptionFromTo *from_to, if (from_to->clks()) writeGetClocks(from_to->clks(), multi_objs, first); if (from_to->instances()) { - InstanceSeq insts; - sortInstanceSet(from_to->instances(), sdc_network_, insts); - InstanceSeq::Iterator inst_iter(insts); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); + InstanceSeq insts = sortByPathName(from_to->instances(), sdc_network_); + for (const Instance *inst : insts) { if (multi_objs && !first) gzprintf(stream_, "\\\n "); writeGetInstance(inst); @@ -1402,9 +1345,7 @@ WriteSdc::writeExceptionThru(ExceptionThru *thru) const gzprintf(stream_, "[list "); bool first = true; sort(pins, PinPathNameLess(network_)); - PinSeq::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : pins) { if (multi_objs && !first) gzprintf(stream_, "\\\n "); writeGetPin(pin); @@ -1412,11 +1353,8 @@ WriteSdc::writeExceptionThru(ExceptionThru *thru) const } if (thru->nets()) { - NetSeq nets; - sortNetSet(thru->nets(), sdc_network_, nets); - NetSeq::Iterator net_iter(nets); - while (net_iter.hasNext()) { - Net *net = net_iter.next(); + NetSeq nets = sortByPathName(thru->nets(), sdc_network_); + for (const Net *net : nets) { if (multi_objs && !first) gzprintf(stream_, "\\\n "); writeGetNet(net); @@ -1424,11 +1362,8 @@ WriteSdc::writeExceptionThru(ExceptionThru *thru) const } } if (thru->instances()) { - InstanceSeq insts; - sortInstanceSet(thru->instances(), sdc_network_, insts); - InstanceSeq::Iterator inst_iter(insts); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); + InstanceSeq insts = sortByPathName(thru->instances(), sdc_network_); + for (const Instance *inst : insts) { if (multi_objs && !first) gzprintf(stream_, "\\\n "); writeGetInstance(inst); @@ -1444,14 +1379,14 @@ WriteSdc::mapThruHpins(ExceptionThru *thru, PinSeq &pins) const { if (thru->pins()) { - for (Pin *pin : *thru->pins()) { + for (const Pin *pin : *thru->pins()) { // Map hierarical pins to load pins outside of outputs or inside of inputs. if (network_->isHierarchical(pin)) { Instance *hinst = network_->instance(pin); bool hpin_is_output = network_->direction(pin)->isAnyOutput(); PinConnectedPinIterator *cpin_iter = network_->connectedPinIterator(pin); while (cpin_iter->hasNext()) { - Pin *cpin = cpin_iter->next(); + const Pin *cpin = cpin_iter->next(); if (network_->isLoad(cpin) && ((hpin_is_output && !network_->isInside(network_->instance(cpin), hinst)) @@ -1473,21 +1408,14 @@ void WriteSdc::writeDataChecks() const { Vector checks; - DataChecksMap::Iterator checks_iter(sdc_->data_checks_to_map_); - while (checks_iter.hasNext()) { - DataCheckSet *checks1 = checks_iter.next(); - DataCheckSet::Iterator check_iter(checks1); - while (check_iter.hasNext()) { - DataCheck *check = check_iter.next(); + for (auto pin_checks : sdc_->data_checks_to_map_) { + DataCheckSet *checks1 = pin_checks.second; + for (DataCheck *check : *checks1) checks.push_back(check); - } } sort(checks, DataCheckLess(sdc_network_)); - Vector::Iterator check_iter(checks); - while (check_iter.hasNext()) { - DataCheck *check = check_iter.next(); + for (DataCheck *check : checks) writeDataCheck(check); - } } void @@ -1582,29 +1510,28 @@ WriteSdc::writeWireload() const void WriteSdc::writeNetLoads() const { - if (sdc_->net_wire_cap_map_) { - for (auto net_cap : *sdc_->net_wire_cap_map_) { - Net *net = net_cap.first; - MinMaxFloatValues &caps = net_cap.second; - float min_cap, max_cap; - bool min_exists, max_exists; - caps.value(MinMax::min(), min_cap, min_exists); - caps.value(MinMax::max(), max_cap, max_exists); - if (min_exists && max_exists - && min_cap == max_cap) - writeNetLoad(net, MinMaxAll::all(), min_cap); - else { - if (min_exists) - writeNetLoad(net, MinMaxAll::min(), min_cap); - if (max_exists) - writeNetLoad(net, MinMaxAll::max(), max_cap); - } + int corner_index = 0; // missing corner arg + for (auto net_cap : sdc_->net_wire_cap_maps_[corner_index]) { + const Net *net = net_cap.first; + MinMaxFloatValues &caps = net_cap.second; + float min_cap, max_cap; + bool min_exists, max_exists; + caps.value(MinMax::min(), min_cap, min_exists); + caps.value(MinMax::max(), max_cap, max_exists); + if (min_exists && max_exists + && min_cap == max_cap) + writeNetLoad(net, MinMaxAll::all(), min_cap); + else { + if (min_exists) + writeNetLoad(net, MinMaxAll::min(), min_cap); + if (max_exists) + writeNetLoad(net, MinMaxAll::max(), max_cap); } } } void -WriteSdc::writeNetLoad(Net *net, +WriteSdc::writeNetLoad(const Net *net, const MinMaxAll *min_max, float cap) const { @@ -1628,9 +1555,10 @@ WriteSdc::writePortLoads() const } void -WriteSdc::writePortLoads(Port *port) const +WriteSdc::writePortLoads(const Port *port) const { - PortExtCap *ext_cap = sdc_->portExtCap(port); + const Corner *corner = corners_->findCorner(0); // missing corner arg + PortExtCap *ext_cap = sdc_->portExtCap(port, corner); if (ext_cap) { WriteGetPort write_port(port, this); writeRiseFallMinMaxCapCmd("set_load -pin_load", @@ -1748,11 +1676,11 @@ WriteSdc::writeDrivingCell(Port *port, const RiseFall *rf, const MinMax *min_max) const { - LibertyCell *cell = drive_cell->cell(); - LibertyPort *from_port = drive_cell->fromPort(); - LibertyPort *to_port = drive_cell->toPort(); + const LibertyCell *cell = drive_cell->cell(); + const LibertyPort *from_port = drive_cell->fromPort(); + const LibertyPort *to_port = drive_cell->toPort(); float *from_slews = drive_cell->fromSlews(); - LibertyLibrary *lib = drive_cell->library(); + const LibertyLibrary *lib = drive_cell->library(); gzprintf(stream_, "set_driving_cell"); if (rf) gzprintf(stream_, " %s", transRiseFallFlag(rf)); @@ -1795,19 +1723,13 @@ WriteSdc::writeInputTransitions() const void WriteSdc::writeNetResistances() const { - NetResistanceMap *net_res_map = sdc_->netResistances(); NetSeq nets; - NetResistanceMap::Iterator res_iter(net_res_map); - while (res_iter.hasNext()) { - Net *net; - MinMaxFloatValues values; - res_iter.next(net, values); + for (auto net_res : sdc_->netResistances()) { + const Net *net = net_res.first; nets.push_back(net); } sort(nets, NetPathNameLess(sdc_network_)); - NetSeq::Iterator net_iter(nets); - while (net_iter.hasNext()) { - Net *net = net_iter.next(); + for (const Net *net : nets) { float min_res, max_res; bool min_exists, max_exists; sdc_->resistance(net, MinMax::min(), min_res, min_exists); @@ -1825,7 +1747,7 @@ WriteSdc::writeNetResistances() const } void -WriteSdc::writeNetResistance(Net *net, +WriteSdc::writeNetResistance(const Net *net, const MinMaxAll *min_max, float res) const { @@ -1841,15 +1763,12 @@ WriteSdc::writeConstants() const { PinSeq pins; sortedLogicValuePins(sdc_->logicValues(), pins); - PinSeq::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : pins) writeConstant(pin); - } } void -WriteSdc::writeConstant(Pin *pin) const +WriteSdc::writeConstant(const Pin *pin) const { const char *cmd = setConstantCmd(pin); gzprintf(stream_, "%s ", cmd); @@ -1858,7 +1777,7 @@ WriteSdc::writeConstant(Pin *pin) const } const char * -WriteSdc::setConstantCmd(Pin *pin) const +WriteSdc::setConstantCmd(const Pin *pin) const { LogicValue value; bool exists; @@ -1883,16 +1802,13 @@ WriteSdc::writeCaseAnalysis() const { PinSeq pins; sortedLogicValuePins(sdc_->caseLogicValues(), pins); - PinSeq::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : pins) writeCaseAnalysis(pin); - } } void -WriteSdc::writeCaseAnalysis(Pin *pin) const +WriteSdc::writeCaseAnalysis(const Pin *pin) const { const char *value_str = caseAnalysisValueStr(pin); gzprintf(stream_, "set_case_analysis %s ", value_str); @@ -1901,7 +1817,7 @@ WriteSdc::writeCaseAnalysis(Pin *pin) const } const char * -WriteSdc::caseAnalysisValueStr(Pin *pin) const +WriteSdc::caseAnalysisValueStr(const Pin *pin) const { LogicValue value; bool exists; @@ -1923,15 +1839,12 @@ WriteSdc::caseAnalysisValueStr(Pin *pin) const } void -WriteSdc::sortedLogicValuePins(LogicValueMap *value_map, +WriteSdc::sortedLogicValuePins(LogicValueMap &value_map, PinSeq &pins) const { - LogicValueMap::ConstIterator value_iter(value_map); - while (value_iter.hasNext()) { - LogicValue value; - const Pin *pin; - value_iter.next(pin, value); - pins.push_back(const_cast(pin)); + for (auto pin_value : value_map) { + const Pin *pin = pin_value.first; + pins.push_back(pin); } // Sort pins. sort(pins, PinPathNameLess(sdc_network_)); @@ -1946,11 +1859,9 @@ WriteSdc::writeDeratings() const if (factors) writeDerating(factors); - NetDeratingFactorsMap::Iterator net_iter(sdc_->net_derating_factors_); - while (net_iter.hasNext()) { - const Net *net; - DeratingFactorsNet *factors; - net_iter.next(net, factors); + for (auto net_derating : sdc_->net_derating_factors_) { + const Net *net = net_derating.first; + DeratingFactorsNet *factors = net_derating.second; WriteGetNet write_net(net, this); for (auto early_late : EarlyLate::range()) { writeDerating(factors, TimingDerateType::net_delay, early_late, @@ -1958,20 +1869,16 @@ WriteSdc::writeDeratings() const } } - InstDeratingFactorsMap::Iterator inst_iter(sdc_->inst_derating_factors_); - while (inst_iter.hasNext()) { - const Instance *inst; - DeratingFactorsCell *factors; - inst_iter.next(inst, factors); + for (auto inst_derating : sdc_->inst_derating_factors_) { + const Instance *inst = inst_derating.first; + DeratingFactorsCell *factors = inst_derating.second; WriteGetInstance write_inst(inst, this); writeDerating(factors, &write_inst); } - CellDeratingFactorsMap::Iterator cell_iter(sdc_->cell_derating_factors_); - while (cell_iter.hasNext()) { - const LibertyCell *cell; - DeratingFactorsCell *factors; - cell_iter.next(cell, factors); + for (auto cell_derating : sdc_->cell_derating_factors_) { + const LibertyCell *cell = cell_derating.first; + DeratingFactorsCell *factors = cell_derating.second; WriteGetLibCell write_cell(cell, this); writeDerating(factors, &write_cell); } @@ -2120,30 +2027,23 @@ WriteSdc::writeDesignRules() const void WriteSdc::writeMinPulseWidths() const { - PinMinPulseWidthMap::Iterator - pin_iter(sdc_->pin_min_pulse_width_map_); - while (pin_iter.hasNext()) { - const Pin *pin; - RiseFallValues *min_widths; - pin_iter.next(pin, min_widths); + for (auto pin_widths : sdc_->pin_min_pulse_width_map_) { + const Pin *pin = pin_widths.first; + RiseFallValues *min_widths = pin_widths.second; WriteGetPin write_obj(pin, false, this); writeMinPulseWidths(min_widths, write_obj); } - InstMinPulseWidthMap::Iterator - inst_iter(sdc_->inst_min_pulse_width_map_); - while (inst_iter.hasNext()) { - const Instance *inst; - RiseFallValues *min_widths; - inst_iter.next(inst, min_widths); + + for (auto inst_widths : sdc_->inst_min_pulse_width_map_) { + const Instance *inst = inst_widths.first; + RiseFallValues *min_widths = inst_widths.second; WriteGetInstance write_obj(inst, this); writeMinPulseWidths(min_widths, write_obj); } - ClockMinPulseWidthMap::Iterator - clk_iter(sdc_->clk_min_pulse_width_map_); - while (clk_iter.hasNext()) { - const Clock *clk; - RiseFallValues *min_widths; - clk_iter.next(clk, min_widths); + + for (auto clk_widths : sdc_->clk_min_pulse_width_map_) { + const Clock *clk = clk_widths.first; + RiseFallValues *min_widths = clk_widths.second; WriteGetClock write_obj(clk, this); writeMinPulseWidths(min_widths, write_obj); } @@ -2185,36 +2085,29 @@ WriteSdc::writeMinPulseWidth(const char *hi_low, void WriteSdc::writeLatchBorowLimits() const { - PinLatchBorrowLimitMap::Iterator - pin_iter(sdc_->pin_latch_borrow_limit_map_); - while (pin_iter.hasNext()) { - const Pin *pin; - float limit; - pin_iter.next(pin, limit); + for (auto pin_borrow : sdc_->pin_latch_borrow_limit_map_) { + const Pin *pin = pin_borrow.first; + float limit = pin_borrow.second; gzprintf(stream_, "set_max_time_borrow "); writeTime(limit); gzprintf(stream_, " "); writeGetPin(pin, false); gzprintf(stream_, "\n"); } - InstLatchBorrowLimitMap::Iterator - inst_iter(sdc_->inst_latch_borrow_limit_map_); - while (inst_iter.hasNext()) { - const Instance *inst; - float limit; - inst_iter.next(inst, limit); + + for (auto inst_borrow : sdc_->inst_latch_borrow_limit_map_) { + const Instance *inst = inst_borrow.first; + float limit = inst_borrow.second; gzprintf(stream_, "set_max_time_borrow "); writeTime(limit); gzprintf(stream_, " "); writeGetInstance(inst); gzprintf(stream_, "\n"); } - ClockLatchBorrowLimitMap::Iterator - clk_iter(sdc_->clk_latch_borrow_limit_map_); - while (clk_iter.hasNext()) { - const Clock *clk; - float limit; - clk_iter.next(clk, limit); + + for (auto clk_borrow : sdc_->clk_latch_borrow_limit_map_) { + const Clock *clk = clk_borrow.first; + float limit = clk_borrow.second; gzprintf(stream_, "set_max_time_borrow "); writeTime(limit); gzprintf(stream_, " "); @@ -2261,9 +2154,7 @@ WriteSdc::writeClkSlewLimits() const const MinMax *min_max = MinMax::max(); ClockSeq clks; sdc_->sortedClocks(clks); - ClockSeq::Iterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); + for (const Clock *clk : clks) { float rise_clk_limit, fall_clk_limit, rise_data_limit, fall_data_limit; bool rise_clk_exists, fall_clk_exists, rise_data_exists, fall_data_exists; clk->slewLimit(RiseFall::rise(), PathClkOrData::clk, min_max, @@ -2337,11 +2228,9 @@ WriteSdc::writeCapLimits(const MinMax *min_max, gzprintf(stream_, " [current_design]\n"); } - PortCapLimitMap::Iterator port_iter(sdc_->port_cap_limit_map_); - while (port_iter.hasNext()) { - Port *port; - MinMaxFloatValues values; - port_iter.next(port, values); + for (auto port_limit : sdc_->port_cap_limit_map_) { + const Port *port = port_limit.first; + MinMaxFloatValues values = port_limit.second; float cap; bool exists; values.value(min_max, cap, exists); @@ -2354,11 +2243,9 @@ WriteSdc::writeCapLimits(const MinMax *min_max, } } - PinCapLimitMap::Iterator pin_iter(sdc_->pin_cap_limit_map_); - while (pin_iter.hasNext()) { - Pin *pin; - MinMaxFloatValues values; - pin_iter.next(pin, values); + for (auto pin_limit : sdc_->pin_cap_limit_map_) { + const Pin *pin = pin_limit.first; + MinMaxFloatValues values = pin_limit.second; float cap; bool exists; values.value(min_max, cap, exists); @@ -2441,7 +2328,7 @@ WriteSdc::writeVariables() const //////////////////////////////////////////////////////////////// void -WriteSdc::writeGetTimingArcsOfOjbects(LibertyCell *cell) const +WriteSdc::writeGetTimingArcsOfOjbects(const LibertyCell *cell) const { gzprintf(stream_, "[%s -of_objects ", getTimingArcsCmd()); writeGetLibCell(cell); @@ -2513,11 +2400,8 @@ WriteSdc::writeGetClocks(ClockSet *clks, bool multiple, bool &first) const { - ClockSeq clks1; - sortClockSet(clks, clks1); - ClockSeq::Iterator clk_iter(clks1); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); + ClockSeq clks1 = sortByName(clks); + for (const Clock *clk : clks1) { if (multiple && !first) gzprintf(stream_, "\\\n "); writeGetClock(clk); @@ -2539,13 +2423,12 @@ WriteSdc::writeGetPort(const Port *port) const } void -WriteSdc::writeGetPins(PinSet *pins, +WriteSdc::writeGetPins(const PinSet *pins, bool map_hpin_to_drvr) const { - PinSeq pins1; if (map_hpins_) { - PinSet leaf_pins; - for (Pin *pin : *pins) { + PinSet leaf_pins(network_);; + for (const Pin *pin : *pins) { if (network_->isHierarchical(pin)) { if (map_hpin_to_drvr) findLeafDriverPins(const_cast(pin), network_, &leaf_pins); @@ -2555,11 +2438,13 @@ WriteSdc::writeGetPins(PinSet *pins, else leaf_pins.insert(pin); } - sortPinSet(&leaf_pins, sdc_network_, pins1); + PinSeq pins1 = sortByPathName(&leaf_pins, sdc_network_); + writeGetPins1(&pins1); + } + else { + PinSeq pins1 = sortByPathName(pins, sdc_network_); + writeGetPins1(&pins1); } - else - sortPinSet(pins, sdc_network_, pins1); - writeGetPins1(&pins1); } void @@ -2568,10 +2453,8 @@ WriteSdc::writeGetPins1(PinSeq *pins) const bool multiple = pins->size() > 1; if (multiple) gzprintf(stream_, "[list "); - PinSeq::Iterator pin_iter(pins); bool first = true; - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : *pins) { if (multiple && !first) gzprintf(stream_, "\\\n "); writeGetPin(pin); @@ -2595,7 +2478,7 @@ WriteSdc::writeGetPin(const Pin *pin, bool map_hpin_to_drvr) const { if (map_hpins_ && network_->isHierarchical(pin)) { - PinSet pins; + PinSet pins(network_); pins.insert(const_cast(pin)); writeGetPins(&pins, map_hpin_to_drvr); } @@ -2663,7 +2546,7 @@ WriteSdc::writeCommentSeparator() const void WriteSdc::writeRiseFallMinMaxTimeCmd(const char *sdc_cmd, - RiseFallMinMax *values, + const RiseFallMinMax *values, WriteSdcObject &write_object) const { writeRiseFallMinMaxCmd(sdc_cmd, values, units_->timeUnit()->scale(), @@ -2672,7 +2555,7 @@ WriteSdc::writeRiseFallMinMaxTimeCmd(const char *sdc_cmd, void WriteSdc::writeRiseFallMinMaxCapCmd(const char *sdc_cmd, - RiseFallMinMax *values, + const RiseFallMinMax *values, WriteSdcObject &write_object) const { writeRiseFallMinMaxCmd(sdc_cmd, values, units_->capacitanceUnit()->scale(), @@ -2681,7 +2564,7 @@ WriteSdc::writeRiseFallMinMaxCapCmd(const char *sdc_cmd, void WriteSdc::writeRiseFallMinMaxCmd(const char *sdc_cmd, - RiseFallMinMax *values, + const RiseFallMinMax *values, float scale, WriteSdcObject &write_object) const { @@ -2897,10 +2780,8 @@ WriteSdc::writeFloatSeq(FloatSeq *floats, float scale) const { gzprintf(stream_, "{"); - FloatSeq::ConstIterator iter(floats); bool first = true; - while (iter.hasNext()) { - float flt = iter.next(); + for (float flt : *floats) { if (!first) gzprintf(stream_, " "); writeFloat(flt * scale); @@ -2913,10 +2794,8 @@ void WriteSdc::writeIntSeq(IntSeq *ints) const { gzprintf(stream_, "{"); - IntSeq::ConstIterator iter(ints); bool first = true; - while (iter.hasNext()) { - int i = iter.next(); + for (int i : *ints) { if (!first) gzprintf(stream_, " "); gzprintf(stream_, "%d", i); diff --git a/sdc/WriteSdcPvt.hh b/sdc/WriteSdcPvt.hh index f9cbc716..c531e826 100644 --- a/sdc/WriteSdcPvt.hh +++ b/sdc/WriteSdcPvt.hh @@ -60,13 +60,13 @@ public: void writeClocks() const; void writeClock(Clock *clk) const; void writeGeneratedClock(Clock *clk) const; - void writeClockPins(Clock *clk) const; + void writeClockPins(const Clock *clk) const; void writeFloatSeq(FloatSeq *floats, float scale) const; void writeIntSeq(IntSeq *ints) const; - void writeClockSlews(Clock *clk) const; - void writeClockUncertainty(Clock *clk) const; - void writeClockUncertainty(Clock *clk, + void writeClockSlews(const Clock *clk) const; + void writeClockUncertainty(const Clock *clk) const; + void writeClockUncertainty(const Clock *clk, const char *setup_hold, float value) const; void writeClockUncertaintyPins() const; @@ -121,12 +121,12 @@ public: void writeOperatingConditions() const; void writeWireload() const; virtual void writeNetLoads() const; - void writeNetLoad(Net *net, + void writeNetLoad(const Net *net, const MinMaxAll *min_max, float cap) const; void writePortLoads() const; - void writePortLoads(Port *port) const; - void writePortFanout(Port *port) const; + void writePortLoads(const Port *port) const; + void writePortFanout(const Port *port) const; void writeDriveResistances() const; void writeDrivingCells() const; void writeInputTransitions() const; @@ -135,15 +135,15 @@ public: const RiseFall *rf, const MinMax *min_max) const; void writeConstants() const; - virtual void writeConstant(Pin *pin) const; - const char *setConstantCmd(Pin *pin) const; + virtual void writeConstant(const Pin *pin) const; + const char *setConstantCmd(const Pin *pin) const; void writeCaseAnalysis() const; - virtual void writeCaseAnalysis(Pin *pin) const; - const char *caseAnalysisValueStr(Pin *pin) const; - void sortedLogicValuePins(LogicValueMap *value_map, + virtual void writeCaseAnalysis(const Pin *pin) const; + const char *caseAnalysisValueStr(const Pin *pin) const; + void sortedLogicValuePins(LogicValueMap &value_map, PinSeq &pins) const; void writeNetResistances() const; - void writeNetResistance(Net *net, + void writeNetResistance(const Net *net, const MinMaxAll *min_max, float res) const; void writeDesignRules() const; @@ -177,7 +177,7 @@ public: void writeCommentSection(const char *line) const; void writeCommentSeparator() const; - void writeGetTimingArcsOfOjbects(LibertyCell *cell) const; + void writeGetTimingArcsOfOjbects(const LibertyCell *cell) const; void writeGetTimingArcs(Edge *edge) const; void writeGetTimingArcs(Edge *edge, const char *filter) const; @@ -195,7 +195,7 @@ public: virtual void writeGetPin(const Pin *pin) const; void writeGetPin(const Pin *pin, bool map_hpin_to_drvr) const; - void writeGetPins(PinSet *pins, + void writeGetPins(const PinSet *pins, bool map_hpin_to_drvr) const; void writeGetPins1(PinSeq *pins) const; void writeClockKey(const Clock *clk) const; @@ -213,13 +213,13 @@ public: const Clock *clk, float limit) const; void writeRiseFallMinMaxTimeCmd(const char *sdc_cmd, - RiseFallMinMax *values, + const RiseFallMinMax *values, WriteSdcObject &write_object) const; void writeRiseFallMinMaxCapCmd(const char *sdc_cmd, - RiseFallMinMax *values, + const RiseFallMinMax *values, WriteSdcObject &write_object) const; void writeRiseFallMinMaxCmd(const char *sdc_cmd, - RiseFallMinMax *values, + const RiseFallMinMax *values, float scale, WriteSdcObject &write_object) const; void writeRiseFallMinMaxCmd(const char *sdc_cmd, diff --git a/sdf/ReportAnnotation.cc b/sdf/ReportAnnotation.cc index e495515f..2af7147b 100644 --- a/sdf/ReportAnnotation.cc +++ b/sdf/ReportAnnotation.cc @@ -78,7 +78,7 @@ protected: void reportArcs(Vertex *vertex, bool report_annotated, int &i); - void reportWidthPeriodArcs(Pin *pin, + void reportWidthPeriodArcs(const Pin *pin, bool report_annotated, int &i); void reportCount(const char *title, @@ -140,7 +140,9 @@ ReportAnnotated::ReportAnnotated(bool report_cells, max_lines_(max_lines), list_annotated_(list_annotated), list_unannotated_(list_unannotated), - report_constant_arcs_(report_constant_arcs) + report_constant_arcs_(report_constant_arcs), + unannotated_pins_(sta->network()), + annotated_pins_(sta->network()) { init(); report_role_[TimingRole::sdfIopath()->index()] = report_cells; @@ -224,7 +226,9 @@ ReportAnnotated::ReportAnnotated(bool report_setup, max_lines_(max_lines), list_annotated_(list_annotated), list_unannotated_(list_unannotated), - report_constant_arcs_(report_constant_arcs) + report_constant_arcs_(report_constant_arcs), + unannotated_pins_(sta->network()), + annotated_pins_(sta->network()) { init(); report_role_[TimingRole::setup()->index()] = report_setup; @@ -464,19 +468,17 @@ ReportAnnotated::reportArcs(const char *header, { report_->reportBlankLine(); report_->reportLineString(header); - PinSeq sorted_pins; - sortPinSet(&pins, network_, sorted_pins); + PinSeq pins1 = sortByPathName(&pins, network_); int i = 0; - PinSeq::Iterator pin_iter(sorted_pins); - while (pin_iter.hasNext() - && (max_lines_ == 0 || i < max_lines_)) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : pins1) { Vertex *vertex, *bidirect_drvr_vertex; graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); reportArcs(vertex, report_annotated, i); if (bidirect_drvr_vertex) reportArcs(bidirect_drvr_vertex, report_annotated, i); reportWidthPeriodArcs(pin, report_annotated, i); + if (max_lines_ != 0 && i > max_lines_) + break; } } @@ -519,7 +521,7 @@ ReportAnnotated::reportArcs(Vertex *vertex, } void -ReportAnnotated::reportWidthPeriodArcs(Pin *pin, +ReportAnnotated::reportWidthPeriodArcs(const Pin *pin, bool report_annotated, int &i) { diff --git a/sdf/Sdf.tcl b/sdf/Sdf.tcl index 83a20efc..71778cfe 100644 --- a/sdf/Sdf.tcl +++ b/sdf/Sdf.tcl @@ -59,11 +59,11 @@ proc_redirect read_sdf { ################################################################ define_cmd_args "report_annotated_delay" \ - {[-cell] [-net] [-from_in_ports] [-to_out_ports] [-max_line lines]\ + {[-cell] [-net] [-from_in_ports] [-to_out_ports] [-max_lines liness]\ [-list_annotated] [-list_not_annotated] [-constant_arcs]} proc_redirect report_annotated_delay { - parse_key_args "report_annotated_delay" args keys {-max_line} \ + parse_key_args "report_annotated_delay" args keys {-max_lines} \ flags {-cell -net -from_in_ports -to_out_ports -list_annotated \ -list_not_annotated -constant_arcs} if { [info exists flags(-cell)] || [info exists flags(-net)] \ @@ -80,26 +80,26 @@ proc_redirect report_annotated_delay { set report_out_nets 1 } - set max_line 0 - if { [info exists keys(-max_line)] } { - set max_line $keys(-max_line) - check_positive_integer "-max_line" $max_line + set max_lines 0 + if { [info exists keys(-max_lines)] } { + set max_lines $keys(-max_lines) + check_positive_integer "-max_lines" $max_lines } report_annotated_delay_cmd $report_cells $report_nets \ $report_in_nets $report_out_nets \ - $max_line [info exists flags(-list_annotated)] \ + $max_lines [info exists flags(-list_annotated)] \ [info exists flags(-list_not_annotated)] \ [info exists flags(-constant_arcs)] } define_cmd_args "report_annotated_check" \ {[-setup] [-hold] [-recovery] [-removal] [-nochange] [-width] [-period]\ - [-max_skew] [-max_line lines] [-list_annotated] [-list_not_annotated]\ + [-max_skew] [-max_lines liness] [-list_annotated] [-list_not_annotated]\ [-constant_arcs]} proc_redirect report_annotated_check { - parse_key_args "report_annotated_check" args keys {-max_line} \ + parse_key_args "report_annotated_check" args keys {-max_lines} \ flags {-setup -hold -recovery -removal -nochange -width -period \ -max_skew -list_annotated -list_not_annotated -constant_arcs} if { [info exists flags(-setup)] || [info exists flags(-hold)] \ @@ -125,16 +125,16 @@ proc_redirect report_annotated_check { set report_max_skew 1 } - set max_line 0 - if { [info exists keys(-max_line)] } { - set max_line $keys(-max_line) - check_positive_integer "-max_line" $max_line + set max_lines 0 + if { [info exists keys(-max_lines)] } { + set max_lines $keys(-max_lines) + check_positive_integer "-max_lines" $max_lines } report_annotated_check_cmd $report_setup $report_hold \ $report_recovery $report_removal $report_nochange \ $report_width $report_period $report_max_skew \ - $max_line [info exists flags(-list_annotated)] \ + $max_lines [info exists flags(-list_annotated)] \ [info exists flags(-list_not_annotated)] \ [info exists flags(-constant_arcs)] } diff --git a/sdf/SdfWriter.cc b/sdf/SdfWriter.cc index 19c1edfb..39c0ba7a 100644 --- a/sdf/SdfWriter.cc +++ b/sdf/SdfWriter.cc @@ -740,10 +740,10 @@ SdfWriter::sdfPathName(const Pin *pin) char * SdfWriter::sdfPathName(const Instance *instance) { - ConstInstanceSeq inst_path; + InstanceSeq inst_path; network_->path(instance, inst_path); size_t name_length = 0; - ConstInstanceSeq::Iterator path_iter1(inst_path); + InstanceSeq::Iterator path_iter1(inst_path); while (path_iter1.hasNext()) { const Instance *inst = path_iter1.next(); name_length += strlen(sdfName(inst)) + 1; diff --git a/search/CheckCapacitanceLimits.cc b/search/CheckCapacitanceLimits.cc index 0d915e3b..5233b6ce 100644 --- a/search/CheckCapacitanceLimits.cc +++ b/search/CheckCapacitanceLimits.cc @@ -39,8 +39,8 @@ public: const MinMax *min_max, CheckCapacitanceLimits *check_capacitance_limit, const StaState *sta); - bool operator()(Pin *pin1, - Pin *pin2) const; + bool operator()(const Pin *pin1, + const Pin *pin2) const; private: const Corner *corner_; @@ -62,8 +62,8 @@ PinCapacitanceLimitSlackLess::PinCapacitanceLimitSlackLess(const Corner *corner, } bool -PinCapacitanceLimitSlackLess::operator()(Pin *pin1, - Pin *pin2) const +PinCapacitanceLimitSlackLess::operator()(const Pin *pin1, + const Pin *pin2) const { const Corner *corner1, *corner2; const RiseFall *rf1, *rf2; @@ -168,13 +168,13 @@ CheckCapacitanceLimits::findLimit(const Pin *pin, InputDrive *drive = sdc->findInputDrive(port); if (drive) { for (auto rf : RiseFall::range()) { - LibertyCell *cell; - LibertyPort *from_port; + const LibertyCell *cell; + const LibertyPort *from_port; float *from_slews; - LibertyPort *to_port; + const LibertyPort *to_port; drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port); if (to_port) { - LibertyPort *corner_port = to_port->cornerPort(corner, min_max); + const LibertyPort *corner_port = to_port->cornerPort(corner, min_max); corner_port->capacitanceLimit(min_max, limit1, exists1); if (!exists1 && corner_port->direction()->isAnyOutput() @@ -250,19 +250,19 @@ CheckCapacitanceLimits::checkCapacitance(const Pin *pin, //////////////////////////////////////////////////////////////// -PinSeq * -CheckCapacitanceLimits::checkCapacitanceLimits(Net *net, +PinSeq +CheckCapacitanceLimits::checkCapacitanceLimits(const Net *net, bool violators, const Corner *corner, const MinMax *min_max) { const Network *network = sta_->network(); - PinSeq *cap_pins = new PinSeq; + PinSeq cap_pins; float min_slack = MinMax::min()->initValue(); if (net) { NetPinIterator *pin_iter = network->pinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); checkCapLimits(pin, violators, corner, min_max, cap_pins, min_slack); } delete pin_iter; @@ -280,17 +280,17 @@ CheckCapacitanceLimits::checkCapacitanceLimits(Net *net, } sort(cap_pins, PinCapacitanceLimitSlackLess(corner, min_max, this, sta_)); // Keep the min slack pin unless all violators or net pins. - if (!cap_pins->empty() && !violators && net == nullptr) - cap_pins->resize(1); + if (!cap_pins.empty() && !violators && net == nullptr) + cap_pins.resize(1); return cap_pins; } void -CheckCapacitanceLimits::checkCapLimits(Instance *inst, +CheckCapacitanceLimits::checkCapLimits(const Instance *inst, bool violators, const Corner *corner, const MinMax *min_max, - PinSeq *cap_pins, + PinSeq &cap_pins, float &min_slack) { const Network *network = sta_->network(); @@ -303,11 +303,11 @@ CheckCapacitanceLimits::checkCapLimits(Instance *inst, } void -CheckCapacitanceLimits::checkCapLimits(Pin *pin, +CheckCapacitanceLimits::checkCapLimits(const Pin *pin, bool violators, const Corner *corner, const MinMax *min_max, - PinSeq *cap_pins, + PinSeq &cap_pins, float &min_slack) { if (checkPin(pin)) { @@ -318,12 +318,12 @@ CheckCapacitanceLimits::checkCapLimits(Pin *pin, if (!fuzzyInf(slack)) { if (violators) { if (slack < 0.0) - cap_pins->push_back(pin); + cap_pins.push_back(pin); } else { - if (cap_pins->empty() + if (cap_pins.empty() || slack < min_slack) { - cap_pins->push_back(pin); + cap_pins.push_back(pin); min_slack = slack; } } @@ -332,7 +332,7 @@ CheckCapacitanceLimits::checkCapLimits(Pin *pin, } bool -CheckCapacitanceLimits::checkPin(Pin *pin) +CheckCapacitanceLimits::checkPin(const Pin *pin) { const Network *network = sta_->network(); const Sim *sim = sta_->sim(); diff --git a/search/CheckCapacitanceLimits.hh b/search/CheckCapacitanceLimits.hh index cf382921..6c982881 100644 --- a/search/CheckCapacitanceLimits.hh +++ b/search/CheckCapacitanceLimits.hh @@ -45,10 +45,10 @@ public: // Return pins with the min/max cap limit slack. // net=null check all nets // corner=nullptr checks all corners. - PinSeq *checkCapacitanceLimits(Net *net, - bool violators, - const Corner *corner, - const MinMax *min_max); + PinSeq checkCapacitanceLimits(const Net *net, + bool violators, + const Corner *corner, + const MinMax *min_max); protected: void checkCapacitance(const Pin *pin, @@ -77,19 +77,19 @@ protected: // Return values. float &limit, bool &limit_exists) const; - void checkCapLimits(Instance *inst, + void checkCapLimits(const Instance *inst, bool violators, const Corner *corner, const MinMax *min_max, - PinSeq *cap_pins, + PinSeq &cap_pins, float &min_slack); - void checkCapLimits(Pin *pin, + void checkCapLimits(const Pin *pin, bool violators, const Corner *corner, const MinMax *min_max, - PinSeq *cap_pins, + PinSeq &cap_pins, float &min_slack); - bool checkPin(Pin *pin); + bool checkPin(const Pin *pin); const Sta *sta_; }; diff --git a/search/CheckFanoutLimits.cc b/search/CheckFanoutLimits.cc index ede6954e..b3d6c429 100644 --- a/search/CheckFanoutLimits.cc +++ b/search/CheckFanoutLimits.cc @@ -34,8 +34,8 @@ public: PinFanoutLimitSlackLess(const MinMax *min_max, CheckFanoutLimits *check_fanout_limit, const StaState *sta); - bool operator()(Pin *pin1, - Pin *pin2) const; + bool operator()(const Pin *pin1, + const Pin *pin2) const; private: const MinMax *min_max_; @@ -54,8 +54,8 @@ PinFanoutLimitSlackLess::PinFanoutLimitSlackLess(const MinMax *min_max, } bool -PinFanoutLimitSlackLess::operator()(Pin *pin1, - Pin *pin2) const +PinFanoutLimitSlackLess::operator()(const Pin *pin1, + const Pin *pin2) const { float fanout1, fanout2; float limit1, limit2, slack1, slack2; @@ -130,10 +130,10 @@ CheckFanoutLimits::findLimit(const Pin *pin, InputDrive *drive = sdc->findInputDrive(port); if (drive) { for (auto rf : RiseFall::range()) { - LibertyCell *cell; - LibertyPort *from_port; + const LibertyCell *cell; + const LibertyPort *from_port; float *from_slews; - LibertyPort *to_port; + const LibertyPort *to_port; drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port); if (to_port) { to_port->fanoutLimit(min_max, limit1, exists1); @@ -205,7 +205,7 @@ CheckFanoutLimits::fanoutLoad(const Pin *pin) const const Network *network = sta_->network(); NetConnectedPinIterator *pin_iter = network->connectedPinIterator(pin); while (pin_iter->hasNext()) { - Pin *fanout_pin = pin_iter->next(); + const Pin *fanout_pin = pin_iter->next(); if (network->isLoad(fanout_pin) && !network->isTopLevelPort(fanout_pin)) { LibertyPort *port = network->libertyPort(fanout_pin); @@ -230,18 +230,18 @@ CheckFanoutLimits::fanoutLoad(const Pin *pin) const //////////////////////////////////////////////////////////////// -PinSeq * -CheckFanoutLimits::checkFanoutLimits(Net *net, +PinSeq +CheckFanoutLimits::checkFanoutLimits(const Net *net, bool violators, const MinMax *min_max) { const Network *network = sta_->network(); - PinSeq *fanout_pins = new PinSeq; + PinSeq fanout_pins; float min_slack = MinMax::min()->initValue(); if (net) { NetPinIterator *pin_iter = network->pinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); checkFanoutLimits(pin, violators, min_max, fanout_pins, min_slack); } delete pin_iter; @@ -249,7 +249,7 @@ CheckFanoutLimits::checkFanoutLimits(Net *net, else { LeafInstanceIterator *inst_iter = network->leafInstanceIterator(); while (inst_iter->hasNext()) { - Instance *inst = inst_iter->next(); + const Instance *inst = inst_iter->next(); checkFanoutLimits(inst, violators, min_max, fanout_pins, min_slack); } delete inst_iter; @@ -259,32 +259,32 @@ CheckFanoutLimits::checkFanoutLimits(Net *net, } sort(fanout_pins, PinFanoutLimitSlackLess(min_max, this, sta_)); // Keep the min slack pin unless all violators or net pins. - if (!fanout_pins->empty() && !violators && net == nullptr) - fanout_pins->resize(1); + if (!fanout_pins.empty() && !violators && net == nullptr) + fanout_pins.resize(1); return fanout_pins; } void -CheckFanoutLimits::checkFanoutLimits(Instance *inst, +CheckFanoutLimits::checkFanoutLimits(const Instance *inst, bool violators, const MinMax *min_max, - PinSeq *fanout_pins, + PinSeq &fanout_pins, float &min_slack) { const Network *network = sta_->network(); InstancePinIterator *pin_iter = network->pinIterator(inst); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); checkFanoutLimits(pin, violators, min_max, fanout_pins, min_slack); } delete pin_iter; } void -CheckFanoutLimits::checkFanoutLimits(Pin *pin, +CheckFanoutLimits::checkFanoutLimits(const Pin *pin, bool violators, const MinMax *min_max, - PinSeq *fanout_pins, + PinSeq &fanout_pins, float &min_slack) { if (checkPin(pin)) { @@ -294,12 +294,12 @@ CheckFanoutLimits::checkFanoutLimits(Pin *pin, if (!fuzzyInf(slack)) { if (violators) { if (slack < 0.0) - fanout_pins->push_back(pin); + fanout_pins.push_back(pin); } else { - if (fanout_pins->empty() + if (fanout_pins.empty() || slack < min_slack) { - fanout_pins->push_back(pin); + fanout_pins.push_back(pin); min_slack = slack; } } @@ -308,7 +308,7 @@ CheckFanoutLimits::checkFanoutLimits(Pin *pin, } bool -CheckFanoutLimits::checkPin(Pin *pin) +CheckFanoutLimits::checkPin(const Pin *pin) { const Network *network = sta_->network(); const Sim *sim = sta_->sim(); diff --git a/search/CheckFanoutLimits.hh b/search/CheckFanoutLimits.hh index b531b933..ca7cdc4e 100644 --- a/search/CheckFanoutLimits.hh +++ b/search/CheckFanoutLimits.hh @@ -38,9 +38,9 @@ public: // Return pins with the min/max fanout limit slack. // net=null check all nets // corner=nullptr checks all corners. - PinSeq *checkFanoutLimits(Net *net, - bool violators, - const MinMax *min_max); + PinSeq checkFanoutLimits(const Net *net, + bool violators, + const MinMax *min_max); protected: void checkFanout(const Pin *pin, @@ -56,17 +56,17 @@ protected: float &limit, bool &limit_exists) const; float fanoutLoad(const Pin *pin) const; - void checkFanoutLimits(Instance *inst, + void checkFanoutLimits(const Instance *inst, bool violators, const MinMax *min_max, - PinSeq *fanout_pins, + PinSeq &fanout_pins, float &min_slack); - void checkFanoutLimits(Pin *pin, + void checkFanoutLimits(const Pin *pin, bool violators, const MinMax *min_max, - PinSeq *fanout_pins, + PinSeq &fanout_pins, float &min_slack); - bool checkPin(Pin *pin); + bool checkPin(const Pin *pin); const Sta *sta_; }; diff --git a/search/CheckMinPeriods.cc b/search/CheckMinPeriods.cc index a812fd37..9fedfcc9 100644 --- a/search/CheckMinPeriods.cc +++ b/search/CheckMinPeriods.cc @@ -110,9 +110,8 @@ CheckMinPeriods::visitMinPeriodChecks(Vertex *vertex, bool exists; graph_dcalc->minPeriod(pin, min_period, exists); if (exists) { - ClockSet clks; - search->clocks(vertex, clks); - ClockSet::Iterator clk_iter(clks); + const ClockSet clks = search->clocks(vertex); + ClockSet::ConstIterator clk_iter(clks); while (clk_iter.hasNext()) { Clock *clk = clk_iter.next(); MinPeriodCheck check(pin, clk); diff --git a/search/CheckMinPulseWidths.cc b/search/CheckMinPulseWidths.cc index 0097fa8a..72370818 100644 --- a/search/CheckMinPulseWidths.cc +++ b/search/CheckMinPulseWidths.cc @@ -124,7 +124,7 @@ CheckMinPulseWidths::check(PinSeq *pins, MinPulseWidthChecksVisitor visitor(corner, checks_); PinSeq::Iterator pin_iter(pins); while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + const Pin *pin = pin_iter.next(); Vertex *vertex = graph->pinLoadVertex(pin); visitMinPulseWidthChecks(vertex, &visitor); } @@ -381,13 +381,13 @@ MinPulseWidthCheck::closeDelay(const StaState *sta) const return closeArrival(sta) - closeClkEdge(sta)->time(); } -ClockEdge * +const ClockEdge * MinPulseWidthCheck::openClkEdge(const StaState *sta) const { return open_path_.clkEdge(sta->search()); } -ClockEdge * +const ClockEdge * MinPulseWidthCheck::closeClkEdge(const StaState *sta) const { Tag *open_tag = open_path_.tag(sta); @@ -398,8 +398,8 @@ MinPulseWidthCheck::closeClkEdge(const StaState *sta) const float MinPulseWidthCheck::closeOffset(const StaState *sta) const { - ClockEdge *open_clk_edge = openClkEdge(sta); - ClockEdge *close_clk_edge = closeClkEdge(sta); + const ClockEdge *open_clk_edge = openClkEdge(sta); + const ClockEdge *close_clk_edge = closeClkEdge(sta); if (open_clk_edge->time() > close_clk_edge->time()) return open_clk_edge->clock()->period(); else @@ -435,7 +435,7 @@ minPulseWidth(const Path *path, bool &exists) { Pin *pin = path->pin(sta); - Clock *clk = path->clock(sta); + const Clock *clk = path->clock(sta); const RiseFall *rf = path->transition(sta); Sdc *sdc = sta->sdc(); // set_min_pulse_width command. diff --git a/search/CheckMinPulseWidths.hh b/search/CheckMinPulseWidths.hh index c48e9aa4..e82c3277 100644 --- a/search/CheckMinPulseWidths.hh +++ b/search/CheckMinPulseWidths.hh @@ -78,8 +78,8 @@ public: Arrival openDelay(const StaState *sta) const; Arrival closeDelay(const StaState *sta) const; float closeOffset(const StaState *sta) const; - ClockEdge *openClkEdge(const StaState *sta) const; - ClockEdge *closeClkEdge(const StaState *sta) const; + const ClockEdge *openClkEdge(const StaState *sta) const; + const ClockEdge *closeClkEdge(const StaState *sta) const; Crpr commonClkPessimism(const StaState *sta) const; protected: diff --git a/search/CheckSlewLimits.cc b/search/CheckSlewLimits.cc index 609f5584..4f6451ed 100644 --- a/search/CheckSlewLimits.cc +++ b/search/CheckSlewLimits.cc @@ -40,8 +40,8 @@ public: const MinMax *min_max, CheckSlewLimits *check_slew_limit, const StaState *sta); - bool operator()(Pin *pin1, - Pin *pin2) const; + bool operator()(const Pin *pin1, + const Pin *pin2) const; private: const Corner *corner_; @@ -63,8 +63,8 @@ PinSlewLimitSlackLess::PinSlewLimitSlackLess(const Corner *corner, } bool -PinSlewLimitSlackLess::operator()(Pin *pin1, - Pin *pin2) const +PinSlewLimitSlackLess::operator()(const Pin *pin1, + const Pin *pin2) const { const Corner *corner1, *corner2; const RiseFall *rf1, *rf2; @@ -218,13 +218,13 @@ CheckSlewLimits::findLimit(const Pin *pin, InputDrive *drive = sdc->findInputDrive(port); if (drive) { for (auto rf : RiseFall::range()) { - LibertyCell *cell; - LibertyPort *from_port; + const LibertyCell *cell; + const LibertyPort *from_port; float *from_slews; - LibertyPort *to_port; + const LibertyPort *to_port; drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port); if (to_port) { - LibertyPort *corner_port = to_port->cornerPort(corner, min_max); + const LibertyPort *corner_port = to_port->cornerPort(corner, min_max); corner_port->slewLimit(min_max, limit1, exists1); if (!exists1 && corner_port->direction()->isAnyOutput() @@ -292,9 +292,9 @@ CheckSlewLimits::clockDomains(const Vertex *vertex, VertexPathIterator path_iter(const_cast(vertex), sta_); while (path_iter.hasNext()) { Path *path = path_iter.next(); - Clock *clk = path->clock(sta_); + const Clock *clk = path->clock(sta_); if (clk) - clks.insert(clk); + clks.insert(const_cast(clk)); } } @@ -331,19 +331,19 @@ CheckSlewLimits::checkSlew(Vertex *vertex, //////////////////////////////////////////////////////////////// -PinSeq * -CheckSlewLimits::checkSlewLimits(Net *net, +PinSeq +CheckSlewLimits::checkSlewLimits(const Net *net, bool violators, const Corner *corner, const MinMax *min_max) { const Network *network = sta_->network(); - PinSeq *slew_pins = new PinSeq; + PinSeq slew_pins; float min_slack = MinMax::min()->initValue(); if (net) { NetPinIterator *pin_iter = network->pinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); checkSlewLimits(pin, violators, corner, min_max, slew_pins, min_slack); } delete pin_iter; @@ -351,7 +351,7 @@ CheckSlewLimits::checkSlewLimits(Net *net, else { LeafInstanceIterator *inst_iter = network->leafInstanceIterator(); while (inst_iter->hasNext()) { - Instance *inst = inst_iter->next(); + const Instance *inst = inst_iter->next(); checkSlewLimits(inst, violators,corner, min_max, slew_pins, min_slack); } delete inst_iter; @@ -361,17 +361,17 @@ CheckSlewLimits::checkSlewLimits(Net *net, } sort(slew_pins, PinSlewLimitSlackLess(corner, min_max, this, sta_)); // Keep the min slack pin unless all violators or net pins. - if (!slew_pins->empty() && !violators && net == nullptr) - slew_pins->resize(1); + if (!slew_pins.empty() && !violators && net == nullptr) + slew_pins.resize(1); return slew_pins; } void -CheckSlewLimits::checkSlewLimits(Instance *inst, +CheckSlewLimits::checkSlewLimits(const Instance *inst, bool violators, const Corner *corner, const MinMax *min_max, - PinSeq *slew_pins, + PinSeq &slew_pins, float &min_slack) { const Network *network = sta_->network(); @@ -384,11 +384,11 @@ CheckSlewLimits::checkSlewLimits(Instance *inst, } void -CheckSlewLimits::checkSlewLimits(Pin *pin, +CheckSlewLimits::checkSlewLimits(const Pin *pin, bool violators, const Corner *corner, const MinMax *min_max, - PinSeq *slew_pins, + PinSeq &slew_pins, float &min_slack) { const Corner *corner1; @@ -399,12 +399,12 @@ CheckSlewLimits::checkSlewLimits(Pin *pin, if (!fuzzyInf(slack)) { if (violators) { if (slack < 0.0) - slew_pins->push_back(pin); + slew_pins.push_back(pin); } else { - if (slew_pins->empty() + if (slew_pins.empty() || slack < min_slack) { - slew_pins->push_back(pin); + slew_pins.push_back(pin); min_slack = slack; } } diff --git a/search/CheckSlewLimits.hh b/search/CheckSlewLimits.hh index 35926003..3365de4d 100644 --- a/search/CheckSlewLimits.hh +++ b/search/CheckSlewLimits.hh @@ -48,10 +48,10 @@ public: // Return pins with the min/max slew limit slack. // net=null check all nets // corner=nullptr checks all corners. - PinSeq *checkSlewLimits(Net *net, - bool violators, - const Corner *corner, - const MinMax *min_max); + PinSeq checkSlewLimits(const Net *net, + bool violators, + const Corner *corner, + const MinMax *min_max); void findLimit(const LibertyPort *port, const Corner *corner, const MinMax *min_max, @@ -100,17 +100,17 @@ protected: // Return values. float &limit, bool &limit_exists) const; - void checkSlewLimits(Instance *inst, + void checkSlewLimits(const Instance *inst, bool violators, const Corner *corner, const MinMax *min_max, - PinSeq *slew_pins, + PinSeq &slew_pins, float &min_slack); - void checkSlewLimits(Pin *pin, + void checkSlewLimits(const Pin *pin, bool violators, const Corner *corner, const MinMax *min_max, - PinSeq *slew_pins, + PinSeq &slew_pins, float &min_slack); void clockDomains(const Vertex *vertex, // Return value. diff --git a/search/CheckTiming.cc b/search/CheckTiming.cc index 343d9be1..57501c86 100644 --- a/search/CheckTiming.cc +++ b/search/CheckTiming.cc @@ -93,11 +93,11 @@ CheckTiming::check(bool no_input_delay, void CheckTiming::checkNoInputDelay() { - PinSet no_arrival; + PinSet no_arrival(network_); Instance *top_inst = network_->topInstance(); InstancePinIterator *pin_iter = network_->pinIterator(top_inst); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (!sdc_->isClock(pin)) { PortDirection *dir = network_->direction(pin); if (dir->isAnyInput() @@ -113,7 +113,7 @@ CheckTiming::checkNoInputDelay() void CheckTiming::checkNoOutputDelay() { - PinSet no_departure; + PinSet no_departure(network_); checkNoOutputDelay(no_departure); pushPinErrors("Warning: There %is %d output port%s missing set_output_delay.", no_departure); @@ -125,7 +125,7 @@ CheckTiming::checkNoOutputDelay(PinSet &no_departure) Instance *top_inst = network_->topInstance(); InstancePinIterator *pin_iter = network_->pinIterator(top_inst); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); PortDirection *dir = network_->direction(pin); if (dir->isAnyOutput() && !sdc_->hasOutputDelay(pin)) @@ -152,11 +152,11 @@ void CheckTiming::checkRegClks(bool reg_multiple_clks, bool reg_no_clks) { - PinSet no_clk_pins, multiple_clk_pins; + PinSet no_clk_pins(network_); + PinSet multiple_clk_pins(network_); for (Vertex *vertex : *graph_->regClkVertices()) { - Pin *pin = vertex->pin(); - ClockSet clks; - search_->clocks(vertex, clks); + const Pin *pin = vertex->pin(); + ClockSet clks = search_->clocks(vertex); if (reg_no_clks && clks.empty()) no_clk_pins.insert(pin); if (reg_multiple_clks && clks.size() > 1) @@ -220,7 +220,7 @@ CheckTiming::checkLoops() void CheckTiming::checkUnconstrainedEndpoints() { - PinSet unconstrained_ends; + PinSet unconstrained_ends(network_); checkUnconstraintedOutputs(unconstrained_ends); checkUnconstrainedSetups(unconstrained_ends); pushPinErrors("Warning: There %is %d unconstrained endpoint%s.", @@ -355,11 +355,8 @@ CheckTiming::pushPinErrors(const char *msg, error->push_back(stringCopy(error_msg.c_str())); // Sort the error pins so the output is independent of the order // the the errors are discovered. - PinSeq pin_seq; - sortPinSet(&pins, network_, pin_seq); - PinSeq::Iterator pin_iter(pin_seq); - while (pin_iter.hasNext()) { - const Pin *pin = pin_iter.next(); + PinSeq pins1 = sortByPathName(&pins, network_); + for (const Pin *pin : pins1) { const char *pin_name = stringCopy(sdc_network_->pathName(pin)); error->push_back(pin_name); } @@ -380,11 +377,8 @@ CheckTiming::pushClkErrors(const char *msg, error->push_back(stringCopy(error_msg.c_str())); // Sort the error clks so the output is independent of the order // the the errors are discovered. - ClockSeq clk_seq; - sortClockSet(&clks, clk_seq); - ClockSeq::Iterator clk_iter(clk_seq); - while (clk_iter.hasNext()) { - const Clock *clk = clk_iter.next(); + ClockSeq clks1 = sortByName(&clks); + for (const Clock *clk : clks1) { const char *clk_name = stringCopy(clk->name()); error->push_back(clk_name); } diff --git a/search/ClkInfo.cc b/search/ClkInfo.cc index 38d60a0a..a4d834f5 100644 --- a/search/ClkInfo.cc +++ b/search/ClkInfo.cc @@ -35,7 +35,7 @@ clkInfoCmp(const ClkInfo *clk_info1, const ClkInfo *clk_info2, const StaState *sta); -ClkInfo::ClkInfo(ClockEdge *clk_edge, +ClkInfo::ClkInfo(const ClockEdge *clk_edge, const Pin *clk_src, bool is_propagated, const Pin *gen_clk_src, @@ -143,7 +143,7 @@ ClkInfo::asString(const StaState *sta) const return result; } -Clock * +const Clock * ClkInfo::clock() const { if (clk_edge_) @@ -237,8 +237,8 @@ clkInfoCmp(const ClkInfo *clk_info1, const ClkInfo *clk_info2, const StaState *sta) { - ClockEdge *clk_edge1 = clk_info1->clkEdge(); - ClockEdge *clk_edge2 = clk_info2->clkEdge(); + const ClockEdge *clk_edge1 = clk_info1->clkEdge(); + const ClockEdge *clk_edge2 = clk_info2->clkEdge(); int edge_index1 = clk_edge1 ? clk_edge1->index() : -1; int edge_index2 = clk_edge2 ? clk_edge2->index() : -1; if (edge_index1 < edge_index2) diff --git a/search/ClkInfo.hh b/search/ClkInfo.hh index eaf62ca3..6a27ec80 100644 --- a/search/ClkInfo.hh +++ b/search/ClkInfo.hh @@ -27,7 +27,7 @@ class PathVertex; class ClkInfo { public: - ClkInfo(ClockEdge *clk_edge, + ClkInfo(const ClockEdge *clk_edge, const Pin *clk_src, bool is_propagated, const Pin *gen_clk_src, @@ -41,8 +41,8 @@ public: const StaState *sta); ~ClkInfo(); const char *asString(const StaState *sta) const; - ClockEdge *clkEdge() const { return clk_edge_; } - Clock *clock() const; + const ClockEdge *clkEdge() const { return clk_edge_; } + const Clock *clock() const; const Pin *clkSrc() const { return clk_src_; } bool isPropagated() const { return is_propagated_; } const Pin *genClkSrc() const { return gen_clk_src_; } @@ -69,7 +69,7 @@ protected: void findHash(const StaState *sta); private: - ClockEdge *clk_edge_; + const ClockEdge *clk_edge_; const Pin *clk_src_; const Pin *gen_clk_src_; PathVertexRep crpr_clk_path_; diff --git a/search/ClkNetwork.cc b/search/ClkNetwork.cc index 12e69018..7e3dae21 100644 --- a/search/ClkNetwork.cc +++ b/search/ClkNetwork.cc @@ -32,6 +32,11 @@ ClkNetwork::ClkNetwork(StaState *sta) : { } +ClkNetwork::~ClkNetwork() +{ + clk_pins_map_.deleteContentsClear(); +} + void ClkNetwork::ensureClkNetwork() { @@ -44,7 +49,7 @@ ClkNetwork::clear() { clk_pins_valid_ = false; pin_clks_map_.clear(); - clk_pins_map_.clear(); + clk_pins_map_.deleteContentsClear(); pin_ideal_clks_map_.clear(); } @@ -114,8 +119,12 @@ ClkNetwork::findClkPins(bool ideal_only, for (Clock *clk : sdc_->clks()) { if (!ideal_only || !clk->isPropagated()) { - PinSet &clk_pins = clk_pins_map_[clk]; - for (Pin *pin : clk->leafPins()) { + PinSet *clk_pins = clk_pins_map_[clk]; + if (clk_pins == nullptr) { + clk_pins = new PinSet(network_); + clk_pins_map_[clk] = clk_pins; + } + for (const Pin *pin : clk->leafPins()) { if (!ideal_only || !sdc_->isPropagatedClock(pin)) { Vertex *vertex, *bidirect_drvr_vertex; @@ -127,12 +136,12 @@ ClkNetwork::findClkPins(bool ideal_only, } while (bfs.hasNext()) { Vertex *vertex = bfs.next(); - Pin *pin = vertex->pin(); + const Pin *pin = vertex->pin(); if (!ideal_only || !sdc_->isPropagatedClock(pin)) { - clk_pins.insert(pin); + clk_pins->insert(pin); ClockSet &pin_clks = pin_clks_map[pin]; - pin_clks.insert(clk); + pin_clks.insert(clk); bfs.enqueueAdjacentVertices(vertex); } } @@ -153,7 +162,7 @@ ClkNetwork::isClock(const Net *net) const bool is_clk = false; NetConnectedPinIterator *pin_iter = network_->pinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (isClock(pin)) { is_clk = true; break; @@ -198,7 +207,7 @@ const PinSet * ClkNetwork::pins(const Clock *clk) { if (clk_pins_map_.hasKey(clk)) - return &clk_pins_map_[clk]; + return clk_pins_map_[clk]; else return nullptr; } diff --git a/search/ClkSkew.cc b/search/ClkSkew.cc index b885d4c3..e142b1dc 100644 --- a/search/ClkSkew.cc +++ b/search/ClkSkew.cc @@ -174,19 +174,15 @@ ClkSkews::findWorstClkSkew(const Corner *corner, clks.insert(clk); ClkSkewMap skews; findClkSkew(&clks, corner, setup_hold, skews); - if (!skews.empty()) { - float worst_skew = 0.0; - for (auto clk_skew_itr : skews) { - ClkSkew *clk_skew = clk_skew_itr.second; - float skew = clk_skew->skew(); - if (abs(skew) > abs(worst_skew)) - worst_skew = skew; - } - return worst_skew; + float worst_skew = 0.0; + for (auto clk_skew_itr : skews) { + ClkSkew *clk_skew = clk_skew_itr.second; + float skew = clk_skew->skew(); + if (abs(skew) > abs(worst_skew)) + worst_skew = skew; } - else - // Degenerate design without launch/capture registers. - return 0.0; + skews.deleteContents(); + return worst_skew; } void @@ -221,8 +217,8 @@ ClkSkews::hasClkPaths(Vertex *vertex, VertexPathIterator path_iter(vertex, this); while (path_iter.hasNext()) { PathVertex *path = path_iter.next(); - Clock *path_clk = path->clock(this); - if (clks->hasKey(path_clk)) + const Clock *path_clk = path->clock(this); + if (clks->hasKey(const_cast(path_clk))) return true; } return false; @@ -277,24 +273,24 @@ ClkSkews::findClkSkew(Vertex *src_vertex, VertexPathIterator src_iter(src_vertex, this); while (src_iter.hasNext()) { PathVertex *src_path = src_iter.next(); - Clock *src_clk = src_path->clock(this); + const Clock *src_clk = src_path->clock(this); if (src_rf->matches(src_path->transition(this)) && src_path->minMax(this) == setup_hold - && clks->hasKey(src_clk)) { + && clks->hasKey(const_cast(src_clk))) { Corner *src_corner = src_path->pathAnalysisPt(this)->corner(); if (corner == nullptr || src_corner == corner) { VertexPathIterator tgt_iter(tgt_vertex, this); while (tgt_iter.hasNext()) { PathVertex *tgt_path = tgt_iter.next(); - Clock *tgt_clk = tgt_path->clock(this); + const Clock *tgt_clk = tgt_path->clock(this); if (tgt_clk == src_clk && tgt_path->isClock(this) && tgt_rf->matches(tgt_path->transition(this)) && tgt_path->minMax(this) == tgt_min_max && tgt_path->pathAnalysisPt(this)->corner() == src_corner) { ClkSkew probe(src_path, tgt_path, this); - ClkSkew *clk_skew = skews.findKey(src_clk); + ClkSkew *clk_skew = skews.findKey(const_cast(src_clk)); debugPrint(debug_, "clk_skew", 2, "%s %s %s -> %s %s %s crpr = %s skew = %s", network_->pathName(src_path->pin(this)), diff --git a/search/ClkSkew.hh b/search/ClkSkew.hh index b4e8c256..9c21ecda 100644 --- a/search/ClkSkew.hh +++ b/search/ClkSkew.hh @@ -25,7 +25,7 @@ namespace sta { class ClkSkew; -typedef Map ClkSkewMap; +typedef Map ClkSkewMap; // Find and report min clock skews. class ClkSkews : public StaState diff --git a/search/Crpr.cc b/search/Crpr.cc index dc55d15f..dc5566f8 100644 --- a/search/Crpr.cc +++ b/search/Crpr.cc @@ -154,8 +154,8 @@ CheckCrpr::checkCrpr1(const Path *src_path, crpr_pin = nullptr; ClkInfo *src_clk_info = src_path->tag(this)->clkInfo(); ClkInfo *tgt_clk_info = tgt_clk_path->tag(this)->clkInfo(); - Clock *src_clk = src_clk_info->clock(); - Clock *tgt_clk = tgt_clk_info->clock(); + const Clock *src_clk = src_clk_info->clock(); + const Clock *tgt_clk = tgt_clk_info->clock(); const PathVertex src_clk_path1(src_clk_info->crprClkPath(), this); const PathVertex *src_clk_path = src_clk_path1.isNull() ? nullptr : &src_clk_path1; @@ -270,7 +270,7 @@ CheckCrpr::genClkSrcPaths(const PathVertex *path, PathVertexSeq &gclk_paths) { ClkInfo *clk_info = path->clkInfo(this); - ClockEdge *clk_edge = clk_info->clkEdge(); + const ClockEdge *clk_edge = clk_info->clkEdge(); const Pin *clk_src = clk_info->clkSrc(); PathAnalysisPt *path_ap = path->pathAnalysisPt(this); gclk_paths.push_back(path); @@ -373,8 +373,8 @@ CheckCrpr::outputDelayCrpr1(const Path *src_path, crpr = 0.0; crpr_pin = nullptr; ClkInfo *src_clk_info = src_path->tag(this)->clkInfo(); - Clock *tgt_clk = tgt_clk_edge->clock(); - Clock *src_clk = src_path->clock(this); + const Clock *tgt_clk = tgt_clk_edge->clock(); + const Clock *src_clk = src_path->clock(this); if (src_clk && tgt_clk && src_clk_info->isPropagated() && tgt_clk->isGenerated() @@ -391,8 +391,8 @@ CheckCrpr::outputDelayCrpr1(const Path *src_path, } bool -CheckCrpr::crprPossible(Clock *clk1, - Clock *clk2) +CheckCrpr::crprPossible(const Clock *clk1, + const Clock *clk2) { return clk1 && clk2 && !clk1->isVirtual() diff --git a/search/Crpr.hh b/search/Crpr.hh index 80bc6dac..b9701524 100644 --- a/search/Crpr.hh +++ b/search/Crpr.hh @@ -72,8 +72,8 @@ private: // Return values. Crpr &crpr, Pin *&crpr_pin); - bool crprPossible(Clock *clk1, - Clock *clk2); + bool crprPossible(const Clock *clk1, + const Clock *clk2); void genClkSrcPaths(const PathVertex *path, PathVertexSeq &gclk_paths); void findCrpr(const PathVertex *src_clk_path, diff --git a/search/FindRegister.cc b/search/FindRegister.cc index c58bc2d3..a9384323 100644 --- a/search/FindRegister.cc +++ b/search/FindRegister.cc @@ -140,7 +140,7 @@ FindRegVisitor::visitRegs(ClockSet *clks, Clock *clk = clk_iter.next(); FindRegClkPred clk_pred(clk, this); VertexSet visited_vertices(graph_); - for (Pin *pin : clk->leafPins()) { + for (const Pin *pin : clk->leafPins()) { Vertex *vertex, *bidirect_drvr_vertex; graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); visitFanoutRegs(vertex, TimingSense::positive_unate, @@ -309,32 +309,31 @@ class FindRegInstances : public FindRegVisitor { public: explicit FindRegInstances(StaState *sta); - InstanceSet *findRegs(ClockSet *clks, - const RiseFallBoth *clk_rf, - bool edge_triggered, - bool latches); + InstanceSet findRegs(ClockSet *clks, + const RiseFallBoth *clk_rf, + bool edge_triggered, + bool latches); private: virtual void visitReg(Instance *inst); virtual void visitSequential(Instance *inst, Sequential *seq); - InstanceSet *regs_; + InstanceSet regs_; }; FindRegInstances::FindRegInstances(StaState *sta) : FindRegVisitor(sta), - regs_(nullptr) + regs_(network_) { } -InstanceSet * +InstanceSet FindRegInstances::findRegs(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, bool latches) { - regs_ = new InstanceSet; visitRegs(clks, clk_rf, edge_triggered, latches); return regs_; } @@ -348,10 +347,10 @@ FindRegInstances::visitSequential(Instance *, void FindRegInstances::visitReg(Instance *inst) { - regs_->insert(inst); + regs_.insert(inst); } -InstanceSet * +InstanceSet findRegInstances(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, @@ -367,11 +366,11 @@ findRegInstances(ClockSet *clks, class FindRegPins : public FindRegVisitor { public: - explicit FindRegPins(StaState *sta); - PinSet *findPins(ClockSet *clks, - const RiseFallBoth *clk_rf, - bool edge_triggered, - bool latches); + FindRegPins(StaState *sta); + PinSet findPins(ClockSet *clks, + const RiseFallBoth *clk_rf, + bool edge_triggered, + bool latches); protected: virtual void visitReg(Instance *inst); @@ -385,22 +384,21 @@ protected: virtual FuncExpr *seqExpr1(Sequential *seq) = 0; virtual FuncExpr *seqExpr2(Sequential *seq) = 0; - PinSet *pins_; + PinSet pins_; }; FindRegPins::FindRegPins(StaState *sta) : FindRegVisitor(sta), - pins_(nullptr) + pins_(network_) { } -PinSet * +PinSet FindRegPins::findPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, bool latches) { - pins_ = new PinSet; visitRegs(clks, clk_rf, edge_triggered, latches); return pins_; } @@ -424,7 +422,7 @@ FindRegPins::visitExpr(FuncExpr *expr, LibertyPort *port = port_iter.next(); Pin *pin = network_->findPin(inst, port); if (pin) - pins_->insert(pin); + pins_.insert(pin); } } } @@ -436,7 +434,7 @@ FindRegPins::visitReg(Instance *inst) while (pin_iter->hasNext()) { Pin *pin = pin_iter->next(); if (matchPin(pin)) - pins_->insert(pin); + pins_.insert(pin); } delete pin_iter; } @@ -500,7 +498,7 @@ hasMinPulseWidthCheck(LibertyPort *port) return exists; } -PinSet * +PinSet findRegDataPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, @@ -555,7 +553,7 @@ FindRegClkPins::seqExpr2(Sequential *) return nullptr; } -PinSet * +PinSet findRegClkPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, @@ -597,7 +595,7 @@ FindRegAsyncPins::matchPin(Pin *pin) return false; } -PinSet * +PinSet findRegAsyncPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, @@ -670,7 +668,7 @@ FindRegOutputPins::visitOutput(LibertyPort *port, if (func && func->port() && func->port() == port) - pins_->insert(pin); + pins_.insert(pin); } delete pin_iter; } @@ -688,7 +686,7 @@ FindRegOutputPins::seqExpr2(Sequential *) return nullptr; } -PinSet * +PinSet findRegOutputPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, diff --git a/search/FindRegister.hh b/search/FindRegister.hh index 9ffcdd07..aa2f047b 100644 --- a/search/FindRegister.hh +++ b/search/FindRegister.hh @@ -23,19 +23,19 @@ namespace sta { -InstanceSet * +InstanceSet findRegInstances(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, bool latches, StaState *sta); -PinSet * +PinSet findRegDataPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, bool latches, StaState *sta); -PinSet * +PinSet findRegClkPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, bool latches, StaState *sta); -PinSet * +PinSet findRegAsyncPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, bool latches, StaState *sta); -PinSet * +PinSet findRegOutputPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, bool latches, StaState *sta); diff --git a/search/Genclks.cc b/search/Genclks.cc index 5c0f10cb..1fb66de3 100644 --- a/search/Genclks.cc +++ b/search/Genclks.cc @@ -146,7 +146,7 @@ Level Genclks::clkPinMaxLevel(const Clock *clk) const { Level max_level = 0; - for (Pin *pin : clk->leafPins()) { + for (const Pin *pin : clk->leafPins()) { Vertex *vertex = srcPathVertex(pin); max_level = max(max_level, vertex->level()); } @@ -422,7 +422,7 @@ Genclks::seedClkVertices(Clock *clk, BfsBkwdIterator &iter, VertexSet *fanins) { - for (Pin *pin : clk->leafPins()) { + for (const Pin *pin : clk->leafPins()) { Vertex *vertex, *bidirect_drvr_vertex; graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); fanins->insert(vertex); @@ -592,7 +592,7 @@ Genclks::findLatchFdbkEdges(const Clock *gclk, { Level gclk_level = genclk_info->gclkLevel(); EdgeSet *fdbk_edges = nullptr; - for (Pin *pin : gclk->masterClk()->leafPins()) { + for (const Pin *pin : gclk->masterClk()->leafPins()) { Vertex *vertex = graph_->pinDrvrVertex(pin); VertexSet path_vertices(graph_); VertexSet visited_vertices(graph_); @@ -645,7 +645,7 @@ Genclks::makeSrcFilter(Clock *gclk) const RiseFallBoth *rf = RiseFallBoth::riseFall(); ExceptionFrom *from = sdc_->makeExceptionFrom(nullptr,from_clks,nullptr,rf); - PinSet *thru_pins = new PinSet; + PinSet *thru_pins = new PinSet(network_); thru_pins->insert(gclk->srcPin()); ExceptionThru *thru = sdc_->makeExceptionThru(thru_pins,nullptr,nullptr,rf); ExceptionThruSeq *thrus = new ExceptionThruSeq; @@ -664,7 +664,7 @@ Genclks::seedSrcPins(Clock *gclk, BfsFwdIterator &insert_iter) { Clock *master_clk = gclk->masterClk(); - for (Pin *master_pin : master_clk->leafPins()) { + for (const Pin *master_pin : master_clk->leafPins()) { Vertex *vertex = graph_->pinDrvrVertex(master_pin); if (vertex) { debugPrint(debug_, "genclk", 2, " seed src pin %s", @@ -702,7 +702,7 @@ Genclks::makeTag(const Clock *gclk, // from the get go. if (master_pin == gclk->srcPin()) state = state->nextState(); - ExceptionStateSet *states = new ExceptionStateSet; + ExceptionStateSet *states = new ExceptionStateSet(network_); states->insert(state); ClkInfo *clk_info = search_->findClkInfo(master_clk->edge(master_rf), master_pin, true, nullptr, true, @@ -893,7 +893,7 @@ Genclks::recordSrcPaths(Clock *gclk) bool invert = gclk->invert(); bool has_edges = gclk->edges() != nullptr; - for (Pin *gclk_pin : gclk->leafPins()) { + for (const Pin *gclk_pin : gclk->leafPins()) { PathVertexRep *src_paths = new PathVertexRep[path_count]; genclk_src_paths_.insert(ClockPinPair(gclk, gclk_pin), src_paths); @@ -902,7 +902,7 @@ Genclks::recordSrcPaths(Clock *gclk) VertexPathIterator path_iter(gclk_vertex, this); while (path_iter.hasNext()) { PathVertex *path = path_iter.next(); - ClockEdge *src_clk_edge = path->clkEdge(this); + const ClockEdge *src_clk_edge = path->clkEdge(this); if (src_clk_edge && matchesSrcFilter(path, gclk)) { const EarlyLate *early_late = path->minMax(this); @@ -970,7 +970,7 @@ Genclks::srcPath(Path *clk_path, PathVertex &src_path) const { const Pin *src_pin = clk_path->pin(this); - ClockEdge *clk_edge = clk_path->clkEdge(this); + const ClockEdge *clk_edge = clk_path->clkEdge(this); const PathAnalysisPt *path_ap = clk_path->pathAnalysisPt(this); const EarlyLate *early_late = clk_path->minMax(this); PathAnalysisPt *insert_ap = path_ap->insertionAnalysisPt(early_late); @@ -1044,13 +1044,22 @@ ClockPinPairLess::operator()(const ClockPinPair &pair1, class ClockPinPairHash { public: + ClockPinPairHash(const Network *network); size_t operator()(const ClockPinPair &pair) const; + +private: + const Network *network_; }; +ClockPinPairHash::ClockPinPairHash(const Network *network) : + network_(network) +{ +} + size_t ClockPinPairHash::operator()(const ClockPinPair &pair) const { - return hashSum(pair.first->index(), hashPtr(pair.second)); + return hashSum(pair.first->index(), network_->id(pair.second)); } class ClockPinPairEqual diff --git a/search/Latches.cc b/search/Latches.cc index 1e4d0ea8..9719df1b 100644 --- a/search/Latches.cc +++ b/search/Latches.cc @@ -242,8 +242,8 @@ Latches::latchEnableOtherPath(Path *path, PathVertex &other_path) { Vertex *vertex = path->vertex(this); - ClockEdge *clk_edge = path->clkEdge(this); - ClockEdge *other_clk_edge = + const ClockEdge *clk_edge = path->clkEdge(this); + const ClockEdge *other_clk_edge = path->clkInfo(this)->isPulseClk() ? clk_edge:clk_edge->opposite(); RiseFall *other_rf = path->transition(this)->opposite(); VertexPathIterator path_iter(vertex, other_rf, tgt_clk_path_ap, this); @@ -328,7 +328,7 @@ Latches::latchOutArrival(Path *data_path, while (enable_iter.hasNext()) { PathVertex *enable_path = enable_iter.next(); ClkInfo *en_clk_info = enable_path->clkInfo(this); - ClockEdge *en_clk_edge = en_clk_info->clkEdge(); + const ClockEdge *en_clk_edge = en_clk_info->clkEdge(); if (enable_path->isClock(this)) { ExceptionPath *excpt = exceptionTo(data_path, en_clk_edge); // D->Q is disabled when if there is a path delay -to D or EN clk. @@ -391,7 +391,7 @@ Latches::latchOutArrival(Path *data_path, ExceptionPath * Latches::exceptionTo(Path *data_path, - ClockEdge *en_clk_edge) + const ClockEdge *en_clk_edge) { // Look for exceptions -to data or -to enable clk. return search_->exceptionTo(ExceptionPathType::any, diff --git a/search/Latches.hh b/search/Latches.hh index 0965d298..597d6d25 100644 --- a/search/Latches.hh +++ b/search/Latches.hh @@ -101,7 +101,7 @@ protected: const Path *disable_path, const PathAnalysisPt *path_ap); ExceptionPath *exceptionTo(Path *data_path, - ClockEdge *en_clk_edge); + const ClockEdge *en_clk_edge); }; } // namespace diff --git a/search/MakeTimingModel.cc b/search/MakeTimingModel.cc index 196378dc..388fd830 100644 --- a/search/MakeTimingModel.cc +++ b/search/MakeTimingModel.cc @@ -82,8 +82,8 @@ MakeTimingModel::makeTimingModel(const char *lib_name, findClkedOutputPaths(); cell_->finish(false, report_, debug_); - saveSdc(); - + restoreSdc(); + return library_; } @@ -104,8 +104,8 @@ MakeTimingModel::restoreSdc() Sdc::movePortDelays(sdc_backup_, sdc_); Sdc::movePortExtCaps(sdc_backup_, sdc_); Sdc::moveDeratingFactors(sdc_backup_, sdc_); - sta_->delaysInvalid(); delete sdc_backup_; + sta_->delaysInvalid(); } void @@ -243,8 +243,8 @@ void MakeEndTimingArcs::visit(PathEnd *path_end) { Path *src_path = path_end->path(); - Clock *src_clk = src_path->clock(sta_); - ClockEdge *tgt_clk_edge = path_end->targetClkEdge(sta_); + const Clock *src_clk = src_path->clock(sta_); + const ClockEdge *tgt_clk_edge = path_end->targetClkEdge(sta_); if (src_clk == sta_->sdc()->defaultArrivalClock() && tgt_clk_edge) { Network *network = sta_->network(); @@ -301,7 +301,7 @@ MakeTimingModel::findTimingFromInputs() sdc_->defaultArrivalClockEdge()->transition(), nullptr, false, false, MinMaxAll::all(), true, 0.0); - PinSet *from_pins = new PinSet; + PinSet *from_pins = new PinSet(network_); from_pins->insert(input_pin); ExceptionFrom *from = sta_->makeExceptionFrom(from_pins, nullptr, nullptr, input_rf1); @@ -357,7 +357,7 @@ MakeTimingModel::makeSetupHoldTimingArcs(const Pin *input_pin, const ClockEdgeDelays &clk_margins) { for (auto clk_edge_margins : clk_margins) { - ClockEdge *clk_edge = clk_edge_margins.first; + const ClockEdge *clk_edge = clk_edge_margins.first; RiseFallMinMax &margins = clk_edge_margins.second; for (MinMax *min_max : MinMax::range()) { bool setup = (min_max == MinMax::max()); @@ -451,7 +451,7 @@ MakeTimingModel::findClkedOutputPaths() VertexPathIterator path_iter(output_vertex, this); while (path_iter.hasNext()) { PathVertex *path = path_iter.next(); - ClockEdge *clk_edge = path->clkEdge(sta_); + const ClockEdge *clk_edge = path->clkEdge(sta_); if (clk_edge) { const RiseFall *output_rf = path->transition(sta_); const MinMax *min_max = path->minMax(sta_); @@ -462,7 +462,7 @@ MakeTimingModel::findClkedOutputPaths() } } for (auto clk_edge_delay : clk_delays) { - ClockEdge *clk_edge = clk_edge_delay.first; + const ClockEdge *clk_edge = clk_edge_delay.first; RiseFallMinMax &delays = clk_edge_delay.second; for (const Pin *clk_pin : clk_edge->clock()->pins()) { LibertyPort *clk_port = modelPort(clk_pin); diff --git a/search/MakeTimingModel.hh b/search/MakeTimingModel.hh index e22b60d6..863df54c 100644 --- a/search/MakeTimingModel.hh +++ b/search/MakeTimingModel.hh @@ -40,7 +40,7 @@ public: bool rf_path_exists[RiseFall::index_count][RiseFall::index_count]; }; -typedef std::map ClockEdgeDelays; +typedef std::map ClockEdgeDelays; typedef std::map OutputPinDelays; class MakeTimingModel : public StaState diff --git a/search/Path.cc b/search/Path.cc index 84e3e992..adb0aa92 100644 --- a/search/Path.cc +++ b/search/Path.cc @@ -66,13 +66,13 @@ Path::clkInfo(const StaState *sta) const return tag(sta)->clkInfo(); } -ClockEdge * +const ClockEdge * Path::clkEdge(const StaState *sta) const { return tag(sta)->clkEdge(); } -Clock * +const Clock * Path::clock(const StaState *sta) const { return tag(sta)->clock(); @@ -221,8 +221,8 @@ Path::cmpClk(const Path *path1, const Path *path2, const StaState *sta) { - ClockEdge *clk_edge1 = path1->clkEdge(sta); - ClockEdge *clk_edge2 = path2->clkEdge(sta); + const ClockEdge *clk_edge1 = path1->clkEdge(sta); + const ClockEdge *clk_edge2 = path2->clkEdge(sta); if (clk_edge1 && clk_edge2) { int index1 = clk_edge1->index(); int index2 = clk_edge2->index(); diff --git a/search/PathEnd.cc b/search/PathEnd.cc index e9366492..885ac45b 100644 --- a/search/PathEnd.cc +++ b/search/PathEnd.cc @@ -99,7 +99,7 @@ PathEnd::pathAnalysisPt(const StaState *sta) const return path_.pathAnalysisPt(sta); } -ClockEdge * +const ClockEdge * PathEnd::sourceClkEdge(const StaState *sta) const { return path_.clkEdge(sta); @@ -130,7 +130,7 @@ PathEnd::targetClkEndTrans(const StaState *sta) const if (clk_path) return clk_path->transition(sta); else { - ClockEdge *clk_edge = targetClkEdge(sta); + const ClockEdge *clk_edge = targetClkEdge(sta); if (clk_edge) return clk_edge->transition(); else @@ -156,13 +156,13 @@ PathEnd::sourceClkInsertionDelay(const StaState *) const return delay_zero; } -Clock * +const Clock * PathEnd::targetClk(const StaState *) const { return nullptr; } -ClockEdge * +const ClockEdge * PathEnd::targetClkEdge(const StaState *) const { return nullptr; @@ -624,7 +624,7 @@ PathEndClkConstrained::targetClkOffset(const StaState *sta) const return acct->targetTimeOffset(check_role); } -ClockEdge * +const ClockEdge * PathEndClkConstrained::targetClkEdge(const StaState *sta) const { if (!clk_path_.isNull()) @@ -633,10 +633,10 @@ PathEndClkConstrained::targetClkEdge(const StaState *sta) const return nullptr; } -Clock * +const Clock * PathEndClkConstrained::targetClk(const StaState *sta) const { - ClockEdge *clk_edge = targetClkEdge(sta); + const ClockEdge *clk_edge = targetClkEdge(sta); if (clk_edge) return clk_edge->clock(); else @@ -1243,7 +1243,7 @@ PathEndLatchCheck::targetClkWidth(const StaState *sta) const return disable_arrival - enable_arrival; else { if (delayGreater(enable_arrival, disable_arrival, sta)) { - Clock *disable_clk = enable_clk_info->clock(); + const Clock *disable_clk = enable_clk_info->clock(); if (disable_clk) disable_arrival += disable_clk->period(); } @@ -1357,7 +1357,7 @@ PathEndOutputDelay::checkRole(const StaState *sta) const return TimingRole::outputHold(); } -ClockEdge * +const ClockEdge * PathEndOutputDelay::targetClkEdge(const StaState *sta) const { if (!clk_path_.isNull()) @@ -1607,7 +1607,7 @@ PathEndDataCheck::typeName() const return "data_check"; } -ClockEdge * +const ClockEdge * PathEndDataCheck::targetClkEdge(const StaState *sta) const { // clk_path_ can be null if data_clk_path is from an input port. @@ -1831,7 +1831,7 @@ PathEnd::pathDelaySrcClkOffset(const PathRef &path, const StaState *sta) { float offset = 0.0; - ClockEdge *clk_edge = path.clkEdge(sta); + const ClockEdge *clk_edge = path.clkEdge(sta); if (clk_edge) { if (path_delay->ignoreClkLatency()) offset = -delayAsFloat(src_clk_arrival); @@ -1843,7 +1843,7 @@ PathEnd::pathDelaySrcClkOffset(const PathRef &path, return offset; } -ClockEdge * +const ClockEdge * PathEndPathDelay::targetClkEdge(const StaState *sta) const { if (!clk_path_.isNull()) @@ -1867,7 +1867,7 @@ PathEndPathDelay::targetClkTime(const StaState *sta) const Arrival PathEndPathDelay::targetClkArrivalNoCrpr(const StaState *sta) const { - ClockEdge *tgt_clk_edge = targetClkEdge(sta); + const ClockEdge *tgt_clk_edge = targetClkEdge(sta); if (tgt_clk_edge) return targetClkDelay(sta) + targetClkUncertainty(sta); diff --git a/search/PathExpanded.cc b/search/PathExpanded.cc index 76b8b600..ab327b70 100644 --- a/search/PathExpanded.cc +++ b/search/PathExpanded.cc @@ -105,7 +105,7 @@ void PathExpanded::expandGenclk(PathRef *clk_path) { if (!clk_path->isNull()) { - Clock *src_clk = clk_path->clock(sta_); + const Clock *src_clk = clk_path->clock(sta_); if (src_clk && src_clk->isGenerated()) { PathVertex src_path; sta_->search()->genclks()->srcPath(clk_path, src_path); diff --git a/search/PathGroup.cc b/search/PathGroup.cc index 3a29e67c..d58eb71e 100644 --- a/search/PathGroup.cc +++ b/search/PathGroup.cc @@ -255,11 +255,8 @@ PathGroups::makeGroups(int group_count, { int mm_index = min_max->index(); if (setup_hold) { - GroupPathIterator group_path_iter(sdc_); - while (group_path_iter.hasNext()) { - const char *name; - GroupPathSet *groups; - group_path_iter.next(name, groups); + for (auto name_group : sdc_->groupPaths()) { + const char *name = name_group.first; if (reportGroup(name, group_names)) { PathGroup *group = PathGroup::makePathGroupSlack(name, group_count, endpoint_count, unique_pins, @@ -389,7 +386,7 @@ PathGroups::pathGroup(const PathEnd *path_end) const // Path delays that end at timing checks are part of the target clk group // unless -ignore_clock_latency is true. PathDelay *path_delay = path_end->pathDelay(); - Clock *tgt_clk = path_end->targetClk(this); + const Clock *tgt_clk = path_end->targetClk(this); if (tgt_clk && !path_delay->ignoreClkLatency()) return findPathGroup(tgt_clk, min_max); @@ -422,11 +419,8 @@ PathGroups::pushGroupPathEnds(PathEndSeq *path_ends) { for (auto min_max : MinMax::range()) { int mm_index = min_max->index(); - GroupPathIterator group_path_iter(sdc_); - while (group_path_iter.hasNext()) { - const char *name; - GroupPathSet *groups; - group_path_iter.next(name, groups); + for (auto name_group : sdc_->groupPaths()) { + const char *name = name_group.first; PathGroup *path_group = findPathGroup(name, min_max); if (path_group) path_group->pushEnds(path_ends); @@ -737,14 +731,11 @@ PathGroups::makeGroupPathEnds(ExceptionTo *to, for (auto path_min_max : MinMax::range()) { int mm_index = path_min_max->index(); - GroupPathIterator group_path_iter(sdc_); - while (group_path_iter.hasNext()) { - const char *name; - GroupPathSet *groups; - group_path_iter.next(name, groups); - PathGroup *group = findPathGroup(name, path_min_max); - if (group) - enumPathEnds(group, group_count, endpoint_count, unique_pins, true); + for (auto name_group : sdc_->groupPaths()) { + const char *name = name_group.first; + PathGroup *group = findPathGroup(name, path_min_max); + if (group) + enumPathEnds(group, group_count, endpoint_count, unique_pins, true); } for (auto clk : sdc_->clks()) { @@ -809,7 +800,7 @@ PathGroups::makeGroupPathEnds(ExceptionTo *to, else { // Only visit -to filter pins. VertexSet endpoints(graph_); - PinSet pins; + PinSet pins(network); to->allPins(network, &pins); PinSet::Iterator pin_iter(pins); while (pin_iter.hasNext()) { diff --git a/search/PathVertex.cc b/search/PathVertex.cc index daa38c7e..d75c4afc 100644 --- a/search/PathVertex.cc +++ b/search/PathVertex.cc @@ -428,7 +428,7 @@ PrevPathVisitor::unfilteredTag(const Tag *tag) const ExceptionPath *except = state->exception(); if (!except->isFilter()) { if (unfiltered_states == nullptr) - unfiltered_states = new ExceptionStateSet; + unfiltered_states = new ExceptionStateSet(network_); unfiltered_states->insert(state); } } diff --git a/search/Property.cc b/search/Property.cc index 15a5f5d5..fe9f371d 100644 --- a/search/Property.cc +++ b/search/Property.cc @@ -156,56 +156,56 @@ PropertyValue::PropertyValue(bool value) : { } -PropertyValue::PropertyValue(LibertyLibrary *value) : +PropertyValue::PropertyValue(const LibertyLibrary *value) : type_(type_liberty_library), liberty_library_(value), unit_(nullptr) { } -PropertyValue::PropertyValue(LibertyCell *value) : +PropertyValue::PropertyValue(const LibertyCell *value) : type_(type_liberty_cell), liberty_cell_(value), unit_(nullptr) { } -PropertyValue::PropertyValue(LibertyPort *value) : +PropertyValue::PropertyValue(const LibertyPort *value) : type_(type_liberty_port), liberty_port_(value), unit_(nullptr) { } -PropertyValue::PropertyValue(Library *value) : +PropertyValue::PropertyValue(const Library *value) : type_(type_library), library_(value), unit_(nullptr) { } -PropertyValue::PropertyValue(Cell *value) : +PropertyValue::PropertyValue(const Cell *value) : type_(type_cell), cell_(value), unit_(nullptr) { } -PropertyValue::PropertyValue(Port *value) : +PropertyValue::PropertyValue(const Port *value) : type_(type_port), port_(value), unit_(nullptr) { } -PropertyValue::PropertyValue(Instance *value) : +PropertyValue::PropertyValue(const Instance *value) : type_(type_instance), inst_(value), unit_(nullptr) { } -PropertyValue::PropertyValue(Pin *value) : +PropertyValue::PropertyValue(const Pin *value) : type_(type_pin), pin_(value), unit_(nullptr) @@ -226,19 +226,31 @@ PropertyValue::PropertyValue(PinSet *value) : { PinSet::Iterator pin_iter(value); while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + const Pin *pin = pin_iter.next(); pins_->push_back( pin); } } -PropertyValue::PropertyValue(Net *value) : +PropertyValue::PropertyValue(const PinSet &value) : + type_(type_pins), + pins_(new PinSeq), + unit_(nullptr) +{ + PinSet::ConstIterator pin_iter(value); + while (pin_iter.hasNext()) { + const Pin *pin = pin_iter.next(); + pins_->push_back( pin); + } +} + +PropertyValue::PropertyValue(const Net *value) : type_(type_net), net_(value), unit_(nullptr) { } -PropertyValue::PropertyValue(Clock *value) : +PropertyValue::PropertyValue(const Clock *value) : type_(type_clk), clk_(value), unit_(nullptr) @@ -862,8 +874,7 @@ getProperty(const Pin *pin, return PropertyValue(port && port->isRegClk()); } else if (stringEqual(property, "clocks")) { - ClockSet clks; - sta->clocks(pin, clks); + ClockSet clks = sta->clocks(pin); return PropertyValue(&clks); } else if (stringEqual(property, "activity")) { @@ -1077,7 +1088,7 @@ getProperty(Clock *clk, else if (stringEqual(property, "period")) return PropertyValue(clk->period(), sta->units()->timeUnit()); else if (stringEqual(property, "sources")) - return PropertyValue(&clk->pins()); + return PropertyValue(clk->pins()); else if (stringEqual(property, "propagated")) return PropertyValue(clk->isPropagated()); else if (stringEqual(property, "is_generated")) diff --git a/search/ReportPath.cc b/search/ReportPath.cc index 39e75d45..725efb4f 100644 --- a/search/ReportPath.cc +++ b/search/ReportPath.cc @@ -712,7 +712,7 @@ ReportPath::reportFull(const PathEndPathDelay *end) float delay = path_delay->delay(); reportLine(delay_msg.c_str(), delay, delay, early_late); if (!path_delay->ignoreClkLatency()) { - Clock *tgt_clk = end->targetClk(this); + const Clock *tgt_clk = end->targetClk(this); if (tgt_clk) { const Path *tgt_clk_path = end->targetClkPath(); if (reportClkPath() @@ -744,7 +744,7 @@ ReportPath::isPropagated(const Path *clk_path) bool ReportPath::isPropagated(const Path *clk_path, - Clock *clk) + const Clock *clk) { if (clk_path) return clk_path->clkInfo(search_)->isPropagated(); @@ -802,7 +802,7 @@ ReportPath::reportEndpointOutputDelay(const PathEndClkConstrained *end) Vertex *vertex = end->vertex(this); Pin *pin = vertex->pin(); const char *pin_name = cmd_network_->pathName(pin); - Clock *tgt_clk = end->targetClk(this); + const Clock *tgt_clk = end->targetClk(this); if (network_->isTopLevelPort(pin)) { // Pin direction is "output" even for bidirects. if (tgt_clk) { @@ -911,7 +911,7 @@ ReportPath::reportFull(const PathEndDataCheck *end) float src_offset = end->sourceClkOffset(this); Delay clk_delay = end->targetClkDelay(this); Arrival clk_arrival = end->targetClkArrival(this); - ClockEdge *tgt_clk_edge = end->targetClkEdge(this); + const ClockEdge *tgt_clk_edge = end->targetClkEdge(this); float prev = delayAsFloat(clk_arrival) + src_offset; float offset = prev - delayAsFloat(clk_delay) - tgt_clk_edge->time(); reportPath5(data_clk_path, clk_expanded, clk_expanded.startIndex(), @@ -1167,8 +1167,8 @@ ReportPath::reportVerbose(MinPulseWidthCheck *check) reportPathHeader(); const EarlyLate *open_el = EarlyLate::late(); - ClockEdge *open_clk_edge = check->openClkEdge(this); - Clock *open_clk = open_clk_edge->clock(); + const ClockEdge *open_clk_edge = check->openClkEdge(this); + const Clock *open_clk = open_clk_edge->clock(); const char *open_clk_name = open_clk->name(); const char *open_rise_fall = asRiseFall(open_clk_edge->transition()); float open_clk_time = open_clk_edge->time(); @@ -1184,8 +1184,8 @@ ReportPath::reportVerbose(MinPulseWidthCheck *check) reportBlankLine(); const EarlyLate *close_el = EarlyLate::late(); - ClockEdge *close_clk_edge = check->closeClkEdge(this); - Clock *close_clk = close_clk_edge->clock(); + const ClockEdge *close_clk_edge = check->closeClkEdge(this); + const Clock *close_clk = close_clk_edge->clock(); const char *close_clk_name = close_clk->name(); const char *close_rise_fall = asRiseFall(close_clk_edge->transition()); float close_offset = check->closeOffset(this); @@ -1438,8 +1438,8 @@ void ReportPath::reportSkewClkPath(const char *arrival_msg, const PathVertex *clk_path) { - ClockEdge *clk_edge = clk_path->clkEdge(this); - Clock *clk = clk_edge->clock(); + const ClockEdge *clk_edge = clk_path->clkEdge(this); + const Clock *clk = clk_edge->clock(); const EarlyLate *early_late = clk_path->minMax(this); const RiseFall *clk_rf = clk_edge->transition(); const RiseFall *clk_end_rf = clk_path->transition(this); @@ -1578,8 +1578,8 @@ ReportPath::reportStartpoint(const PathEnd *end, TimingArc *prev_arc = expanded.startPrevArc(); Edge *prev_edge = start->prevEdge(prev_arc, this); Pin *pin = start->pin(graph_); - ClockEdge *clk_edge = path->clkEdge(this); - Clock *clk = path->clock(search_); + const ClockEdge *clk_edge = path->clkEdge(this); + const Clock *clk = path->clock(search_); const char *pin_name = cmd_network_->pathName(pin); if (pathFromClkPin(path, pin)) { const char *clk_name = clk->name(); @@ -1647,7 +1647,7 @@ bool ReportPath::pathFromClkPin(const Path *path, const Pin *start_pin) { - Clock *clk = path->clock(search_); + const Clock *clk = path->clock(search_); return clk && clk->leafPins().hasKey(const_cast(start_pin)); } @@ -1775,7 +1775,7 @@ ReportPath::checkRoleReason(const PathEnd *end) string ReportPath::tgtClkName(const PathEnd *end) { - ClockEdge *tgt_clk_edge = end->targetClkEdge(this); + const ClockEdge *tgt_clk_edge = end->targetClkEdge(this); const Clock *tgt_clk = tgt_clk_edge->clock(); const RiseFall *clk_rf = tgt_clk_edge->transition(); const RiseFall *clk_end_rf = end->targetClkEndTrans(this); @@ -1856,7 +1856,7 @@ ReportPath::reportSrcClkAndPath(const Path *path, Arrival clk_latency, bool is_path_delay) { - ClockEdge *clk_edge = path->clkEdge(this); + const ClockEdge *clk_edge = path->clkEdge(this); const MinMax *min_max = path->minMax(this); if (clk_edge) { Clock *clk = clk_edge->clock(); @@ -1894,7 +1894,7 @@ ReportPath::reportSrcClkAndPath(const Path *path, InputDelay *input_delay = pathInputDelay(first_path); if (input_delay) { path_from_input = true; - Pin *ref_pin = input_delay->refPin(); + const Pin *ref_pin = input_delay->refPin(); if (ref_pin && clk->isPropagated()) { PathRef ref_path; pathInputDelayRefPath(first_path, input_delay, ref_path); @@ -1983,7 +1983,7 @@ void ReportPath::reportTgtClk(const PathEnd *end, float prev_time) { - Clock *clk = end->targetClk(this); + const Clock *clk = end->targetClk(this); const Path *clk_path = end->targetClkPath(); reportTgtClk(end, prev_time, isPropagated(clk_path, clk)); } @@ -2145,7 +2145,7 @@ ReportPath::reportClkLine(const Clock *clk, bool ReportPath::reportGenClkSrcPath(const Path *clk_path, - Clock *clk, + const Clock *clk, const RiseFall *clk_rf, const MinMax *min_max, const EarlyLate *early_late) @@ -2159,7 +2159,7 @@ ReportPath::reportGenClkSrcPath(const Path *clk_path, void ReportPath::reportGenClkSrcAndPath(const Path *path, - Clock *clk, + const Clock *clk, const RiseFall *clk_rf, const EarlyLate *early_late, const PathAnalysisPt *path_ap, @@ -2182,7 +2182,7 @@ ReportPath::reportGenClkSrcAndPath(const Path *path, } bool -ReportPath::reportGenClkSrcPath1(Clock *clk, +ReportPath::reportGenClkSrcPath1(const Clock *clk, const Pin *clk_pin, const RiseFall *clk_rf, const EarlyLate *early_late, @@ -2197,8 +2197,8 @@ ReportPath::reportGenClkSrcPath1(Clock *clk, search_->genclks()->srcPath(clk, clk_pin, clk_rf, insert_ap, src_path); if (!src_path.isNull()) { ClkInfo *src_clk_info = src_path.clkInfo(search_); - ClockEdge *src_clk_edge = src_clk_info->clkEdge(); - Clock *src_clk = src_clk_info->clock(); + const ClockEdge *src_clk_edge = src_clk_info->clkEdge(); + const Clock *src_clk = src_clk_info->clock(); if (src_clk) { bool skip_first_path = false; const RiseFall *src_clk_rf = src_clk_edge->transition(); @@ -2610,7 +2610,7 @@ ReportPath::reportPath5(const Path *path, incr = 0.0; if (!propagated_clk) { // Ideal clock. - ClockEdge *src_clk_edge = path->clkEdge(this); + const ClockEdge *src_clk_edge = path->clkEdge(this); time = search_->clkPathArrival(path1) + time_offset; if (src_clk_edge) { Clock *src_clk = src_clk_edge->clock(); @@ -2626,8 +2626,8 @@ ReportPath::reportPath5(const Path *path, // Zero the clock network delays for ideal clocks. incr = 0.0; time = prev_time; - ClockEdge *src_clk_edge = path->clkEdge(this); - Clock *src_clk = src_clk_edge->clock(); + const ClockEdge *src_clk_edge = path->clkEdge(this); + const Clock *src_clk = src_clk_edge->clock(); RiseFall *src_clk_rf = src_clk_edge->transition(); slew = src_clk->slew(src_clk_rf, min_max); line_case = "clk_ideal"; @@ -2673,7 +2673,7 @@ ReportPath::reportPath5(const Path *path, else what2 = "(unconnected)"; } - float fanout = drvrFanout(vertex, min_max); + float fanout = drvrFanout(vertex, dcalc_ap->corner(), min_max); reportLine(what2.c_str(), cap, field_blank_, fanout, field_blank_, field_blank_, false, min_max, nullptr, line_case); @@ -2740,6 +2740,7 @@ ReportPath::descriptionField(Vertex *vertex) float ReportPath::drvrFanout(Vertex *drvr, + const Corner *corner, const MinMax *min_max) { float fanout = 0.0; @@ -2751,7 +2752,7 @@ ReportPath::drvrFanout(Vertex *drvr, if (network_->isTopLevelPort(pin)) { // Output port counts as a fanout. Port *port = network_->port(pin); - fanout += sdc_->portExtFanout(port, min_max) + 1; + fanout += sdc_->portExtFanout(port, corner, min_max) + 1; } else fanout++; @@ -2816,7 +2817,7 @@ ReportPath::pathInputDelayRefPath(const Path *path, // Return value. PathRef &ref_path) { - Pin *ref_pin = input_delay->refPin(); + const Pin *ref_pin = input_delay->refPin(); RiseFall *ref_rf = input_delay->refTransition(); Vertex *ref_vertex = graph_->pinDrvrVertex(ref_pin); if (ref_vertex) { diff --git a/search/ReportPath.hh b/search/ReportPath.hh index 0e1a16dd..a319da17 100644 --- a/search/ReportPath.hh +++ b/search/ReportPath.hh @@ -207,19 +207,20 @@ protected: Arrival clk_insertion, Arrival clk_latency, bool is_path_delay); - bool reportGenClkSrcPath(const Path *clk_path, Clock *clk, + bool reportGenClkSrcPath(const Path *clk_path, + const Clock *clk, const RiseFall *clk_rf, const MinMax *min_max, const EarlyLate *early_late); void reportGenClkSrcAndPath(const Path *path, - Clock *clk, + const Clock *clk, const RiseFall *clk_rf, const EarlyLate *early_late, const PathAnalysisPt *path_ap, float time_offset, float path_time_offset, bool clk_used_as_data); - bool reportGenClkSrcPath1(Clock *clk, + bool reportGenClkSrcPath1(const Clock *clk, const Pin *clk_pin, const RiseFall *clk_rf, const EarlyLate *early_late, @@ -386,6 +387,7 @@ protected: const RiseFall *rf, DcalcAnalysisPt *dcalc_ap); float drvrFanout(Vertex *drvr, + const Corner *corner, const MinMax *min_max); const char *mpwCheckHiLow(MinPulseWidthCheck *check); void reportSkewClkPath(const char *arrival_msg, @@ -400,7 +402,7 @@ protected: PathRef &clk_path) const; bool isPropagated(const Path *clk_path); bool isPropagated(const Path *clk_path, - Clock *clk); + const Clock *clk); bool pathFromClkPin(PathExpanded &expanded); bool pathFromClkPin(const Path *path, const Pin *start_pin); diff --git a/search/Search.cc b/search/Search.cc index 509d4189..b1ea83ad 100644 --- a/search/Search.cc +++ b/search/Search.cc @@ -593,8 +593,8 @@ public: Search *search); protected: - virtual void visit(Pin *drvr, - Pin *load); + virtual void visit(const Pin *drvr, + const Pin *load); Graph *graph_; Search *search_; @@ -609,8 +609,8 @@ SeedFaninsThruHierPin::SeedFaninsThruHierPin(Graph *graph, } void -SeedFaninsThruHierPin::visit(Pin *drvr, - Pin *) +SeedFaninsThruHierPin::visit(const Pin *drvr, + const Pin *) { Vertex *vertex, *bidirect_drvr_vertex; graph_->pinVertices(drvr, vertex, bidirect_drvr_vertex); @@ -624,9 +624,9 @@ Search::seedFilterStarts() { ExceptionPt *first_pt = filter_->firstPt(); if (first_pt) { - PinSet first_pins; + PinSet first_pins(network_); first_pt->allPins(network_, &first_pins); - for (Pin *pin : first_pins) { + for (const Pin *pin : first_pins) { if (network_->isHierarchical(pin)) { SeedFaninsThruHierPin visitor(graph_, this); visitDrvrLoadsThruHierPin(pin, network_, &visitor); @@ -757,7 +757,7 @@ Search::arrivalInvalid(const Pin *pin) } void -Search::requiredInvalid(Instance *inst) +Search::requiredInvalid(const Instance *inst) { if (graph_) { InstancePinIterator *pin_iter = network_->pinIterator(inst); @@ -819,9 +819,9 @@ Search::findClkArrivals() void Search::seedClkVertexArrivals() { - PinSet clk_pins; + PinSet clk_pins(network_); findClkVertexPins(clk_pins); - for (Pin *pin : clk_pins) { + for (const Pin *pin : clk_pins) { Vertex *vertex, *bidirect_drvr_vertex; graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); seedClkVertexArrivals(pin, vertex); @@ -886,8 +886,8 @@ Search::visitStartpoints(VertexVisitor *visitor) } } - for (Clock *clk : sdc_->clks()) { - for (Pin *pin : clk->leafPins()) { + for (const Clock *clk : sdc_->clks()) { + for (const Pin *pin : clk->leafPins()) { // Already hit these. if (!network_->isTopLevelPort(pin)) { Vertex *vertex = graph_->pinDrvrVertex(pin); @@ -900,9 +900,9 @@ Search::visitStartpoints(VertexVisitor *visitor) for (Vertex *vertex : *graph_->regClkVertices()) visitor->visit(vertex); - auto startpoints = sdc_->pathDelayInternalStartpoints(); - if (startpoints) { - for (Pin *pin : *startpoints) { + const PinSet &startpoints = sdc_->pathDelayInternalStartpoints(); + if (!startpoints.empty()) { + for (const Pin *pin : startpoints) { Vertex *vertex = graph_->pinDrvrVertex(pin); visitor->visit(vertex); } @@ -1168,9 +1168,9 @@ ArrivalVisitor::constrainedRequiredsInvalid(Vertex *vertex, } // Gated clocks. if (is_clk && sdc_->gatedClkChecksEnabled()) { - PinSet enable_pins; + PinSet enable_pins(network_); search_->gatedClk()->gatedClkEnables(vertex, enable_pins); - for (Pin *enable : enable_pins) + for (const Pin *enable : enable_pins) search_->requiredInvalid(enable); } } @@ -1372,8 +1372,8 @@ Search::seedArrivals() void Search::findClockVertices(VertexSet &vertices) { - for (Clock *clk : sdc_->clks()) { - for (Pin *pin : clk->leafPins()) { + for (const Clock *clk : sdc_->clks()) { + for (const Pin *pin : clk->leafPins()) { Vertex *vertex, *bidirect_drvr_vertex; graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); vertices.insert(vertex); @@ -1445,8 +1445,8 @@ Search::seedArrival(Vertex *vertex) void Search::findClkVertexPins(PinSet &clk_pins) { - for (Clock *clk : sdc_->clks()) { - for (Pin *pin : clk->leafPins()) { + for (const Clock *clk : sdc_->clks()) { + for (const Pin *pin : clk->leafPins()) { clk_pins.insert(pin); } } @@ -1457,13 +1457,13 @@ Search::seedClkArrivals(const Pin *pin, Vertex *vertex, TagGroupBldr *tag_bldr) { - for (Clock *clk : *sdc_->findLeafPinClocks(pin)) { + for (const Clock *clk : *sdc_->findLeafPinClocks(pin)) { debugPrint(debug_, "search", 2, "arrival seed clk %s pin %s", clk->name(), network_->pathName(pin)); for (PathAnalysisPt *path_ap : corners_->pathAnalysisPts()) { const MinMax *min_max = path_ap->pathMinMax(); - for (RiseFall *rf : RiseFall::range()) { - ClockEdge *clk_edge = clk->edge(rf); + for (const RiseFall *rf : RiseFall::range()) { + const ClockEdge *clk_edge = clk->edge(rf); const EarlyLate *early_late = min_max; if (clk->isGenerated() && clk->masterClk() == nullptr) @@ -1484,8 +1484,8 @@ Search::seedClkArrivals(const Pin *pin, void Search::seedClkArrival(const Pin *pin, const RiseFall *rf, - Clock *clk, - ClockEdge *clk_edge, + const Clock *clk, + const ClockEdge *clk_edge, const MinMax *min_max, const PathAnalysisPt *path_ap, Arrival insertion, @@ -1534,8 +1534,8 @@ Search::seedClkArrival(const Pin *pin, void Search::seedClkDataArrival(const Pin *pin, const RiseFall *rf, - Clock *clk, - ClockEdge *clk_edge, + const Clock *clk, + const ClockEdge *clk_edge, const MinMax *min_max, const PathAnalysisPt *path_ap, Arrival insertion, @@ -1551,9 +1551,9 @@ Search::seedClkDataArrival(const Pin *pin, Tag * Search::clkDataTag(const Pin *pin, - Clock *clk, + const Clock *clk, const RiseFall *rf, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, Arrival insertion, const MinMax *min_max, const PathAnalysisPt *path_ap) @@ -1739,7 +1739,7 @@ Search::seedInputDelayArrival(const Pin *pin, ? "arrival seed input arrival %s" : "arrival seed input %s", vertex->name(sdc_network_)); - ClockEdge *clk_edge = nullptr; + const ClockEdge *clk_edge = nullptr; const Pin *ref_pin = nullptr; if (input_delay) { clk_edge = input_delay->clkEdge(); @@ -1754,7 +1754,7 @@ Search::seedInputDelayArrival(const Pin *pin, Vertex *ref_vertex = graph_->pinLoadVertex(ref_pin); for (PathAnalysisPt *path_ap : corners_->pathAnalysisPts()) { const MinMax *min_max = path_ap->pathMinMax(); - RiseFall *ref_rf = input_delay->refTransition(); + const RiseFall *ref_rf = input_delay->refTransition(); const Clock *clk = input_delay->clock(); VertexPathIterator ref_path_iter(ref_vertex, ref_rf, path_ap, this); while (ref_path_iter.hasNext()) { @@ -1789,7 +1789,7 @@ Search::seedInputDelayArrival(const Pin *pin, // from the clock source to the reference pin. void Search::inputDelayRefPinArrival(Path *ref_path, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, const MinMax *min_max, // Return values. float &ref_arrival, @@ -1817,7 +1817,7 @@ Search::inputDelayRefPinArrival(Path *ref_path, void Search::seedInputDelayArrival(const Pin *pin, InputDelay *input_delay, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, float clk_arrival, float clk_insertion, float clk_latency, @@ -1849,7 +1849,7 @@ Search::seedInputDelayArrival(const Pin *pin, const RiseFall *rf, float arrival, InputDelay *input_delay, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, float clk_insertion, float clk_latency, bool is_segment_start, @@ -1865,7 +1865,7 @@ Search::seedInputDelayArrival(const Pin *pin, void Search::inputDelayClkArrival(InputDelay *input_delay, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, const MinMax *min_max, const PathAnalysisPt *path_ap, // Return values. @@ -1897,7 +1897,7 @@ Search::inputDelayClkArrival(InputDelay *input_delay, Tag * Search::inputDelayTag(const Pin *pin, const RiseFall *rf, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, float clk_insertion, float clk_latency, InputDelay *input_delay, @@ -1906,7 +1906,7 @@ Search::inputDelayTag(const Pin *pin, const PathAnalysisPt *path_ap) { Clock *clk = nullptr; - Pin *clk_pin = nullptr; + const Pin *clk_pin = nullptr; RiseFall *clk_rf = nullptr; bool is_propagated = false; ClockUncertainties *clk_uncertainties = nullptr; @@ -2063,8 +2063,8 @@ PathVisitor::visitFromPath(const Pin *from_pin, Tag *from_tag = from_path->tag(this); ClkInfo *from_clk_info = from_tag->clkInfo(); Tag *to_tag = nullptr; - ClockEdge *clk_edge = from_clk_info->clkEdge(); - Clock *clk = from_clk_info->clock(); + const ClockEdge *clk_edge = from_clk_info->clkEdge(); + const Clock *clk = from_clk_info->clock(); Arrival from_arrival = from_path->arrival(this); ArcDelay arc_delay = 0.0; Arrival to_arrival; @@ -2073,7 +2073,7 @@ PathVisitor::visitFromPath(const Pin *from_pin, && (sdc_->clkThruTristateEnabled() || !(role == TimingRole::tristateEnable() || role == TimingRole::tristateDisable()))) { - Clock *gclk = from_tag->genClkSrcPathClk(this); + const Clock *gclk = from_tag->genClkSrcPathClk(this); if (gclk) { Genclks *genclks = search_->genclks(); VertexSet *fanins = genclks->fanins(gclk); @@ -2151,7 +2151,7 @@ PathVisitor::visitFromPath(const Pin *from_pin, // Generated clock source pins have arrivals for the source clock. // Do not propagate them past the generated clock source pin. && !(clks - && !clks->hasKey(from_tag->clock()))) { + && !clks->hasKey(const_cast(from_tag->clock())))) { // Propagate arrival as non-clock at the end of the clock tree. bool to_propagates_clk = !sdc_->clkStopPropagation(clk,from_pin,from_rf,to_pin,to_rf) @@ -2185,7 +2185,7 @@ Arrival Search::clkPathArrival(const Path *clk_path) const { ClkInfo *clk_info = clk_path->clkInfo(this); - ClockEdge *clk_edge = clk_info->clkEdge(); + const ClockEdge *clk_edge = clk_info->clkEdge(); const PathAnalysisPt *path_ap = clk_path->pathAnalysisPt(this); const MinMax *min_max = path_ap->pathMinMax(); return clkPathArrival(clk_path, clk_info, clk_edge, min_max, path_ap); @@ -2194,7 +2194,7 @@ Search::clkPathArrival(const Path *clk_path) const Arrival Search::clkPathArrival(const Path *clk_path, ClkInfo *clk_info, - ClockEdge *clk_edge, + const ClockEdge *clk_edge, const MinMax *min_max, const PathAnalysisPt *path_ap) const { @@ -2225,7 +2225,7 @@ Search::pathClkPathArrival(const Path *path) const return clkPathArrival(&src_clk_path); } // Check for input arrival clock. - ClockEdge *clk_edge = path->clkEdge(this); + const ClockEdge *clk_edge = path->clkEdge(this); if (clk_edge) return clk_edge->time() + clk_info->latency(); return 0.0; @@ -2287,7 +2287,7 @@ Search::fromUnclkedInputTag(const Pin *pin, Tag * Search::fromRegClkTag(const Pin *from_pin, const RiseFall *from_rf, - Clock *clk, + const Clock *clk, const RiseFall *clk_rf, ClkInfo *clk_info, const Pin *to_pin, @@ -2390,7 +2390,7 @@ Search::thruClkInfo(PathVertex *from_path, { ClkInfo *to_clk_info = from_clk_info; bool changed = false; - ClockEdge *from_clk_edge = from_clk_info->clkEdge(); + const ClockEdge *from_clk_edge = from_clk_info->clkEdge(); const RiseFall *clk_rf = from_clk_edge->transition(); bool from_clk_prop = from_clk_info->isPropagated(); @@ -2434,7 +2434,7 @@ Search::thruClkInfo(PathVertex *from_path, changed = true; } - Clock *from_clk = from_clk_info->clock(); + const Clock *from_clk = from_clk_info->clock(); Arrival to_insertion = from_clk_info->insertion(); float to_latency = from_clk_info->latency(); float latency; @@ -2537,7 +2537,7 @@ Search::mutateTag(Tag *from_tag, // Second pass to apply state changes and add updated existing // states to new states. if (new_states == nullptr) - new_states = new ExceptionStateSet; + new_states = new ExceptionStateSet(network_); for (auto state : *from_states) { ExceptionPath *exception = state->exception(); // One edge may traverse multiple hierarchical thru pins. @@ -2896,7 +2896,7 @@ Search::reportClkInfos() const } ClkInfo * -Search::findClkInfo(ClockEdge *clk_edge, +Search::findClkInfo(const ClockEdge *clk_edge, const Pin *clk_src, bool is_propagated, const Pin *gen_clk_src, @@ -2925,7 +2925,7 @@ Search::findClkInfo(ClockEdge *clk_edge, } ClkInfo * -Search::findClkInfo(ClockEdge *clk_edge, +Search::findClkInfo(const ClockEdge *clk_edge, const Pin *clk_src, bool is_propagated, Arrival insertion, @@ -2987,6 +2987,14 @@ Search::timingDerate(Vertex *from_vertex, } } +ClockSet +Search::clocks(const Vertex *vertex) const +{ + ClockSet clks; + clocks(vertex, clks); + return clks; +} + void Search::clocks(const Vertex *vertex, // Return value. @@ -2996,10 +3004,24 @@ Search::clocks(const Vertex *vertex, while (path_iter.hasNext()) { Path *path = path_iter.next(); if (path->isClock(this)) - clks.insert(path->clock(this)); + clks.insert(const_cast(path->clock(this))); } } +ClockSet +Search::clocks(const Pin *pin) const +{ + ClockSet clks; + Vertex *vertex; + Vertex *bidirect_drvr_vertex; + graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); + if (vertex) + clocks(vertex, clks); + if (bidirect_drvr_vertex) + clocks(bidirect_drvr_vertex, clks); + return clks; +} + bool Search::isClock(const Vertex *vertex) const { @@ -3020,20 +3042,6 @@ Search::isGenClkSrc(const Vertex *vertex) const return false; } -void -Search::clocks(const Pin *pin, - // Return value. - ClockSet &clks) const -{ - Vertex *vertex; - Vertex *bidirect_drvr_vertex; - graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); - if (vertex) - clocks(vertex, clks); - if (bidirect_drvr_vertex) - clocks(bidirect_drvr_vertex, clks); -} - //////////////////////////////////////////////////////////////// void @@ -3527,11 +3535,11 @@ Search::matchesFilter(Path *path, && filter_from_->instances() == nullptr && filter_from_->clks()) { // -from clks - ClockEdge *path_clk_edge = path->clkEdge(this); - Clock *path_clk = path_clk_edge ? path_clk_edge->clock() : nullptr; + const ClockEdge *path_clk_edge = path->clkEdge(this); + const Clock *path_clk = path_clk_edge ? path_clk_edge->clock() : nullptr; RiseFall *path_clk_rf = path_clk_edge ? path_clk_edge->transition() : nullptr; - return filter_from_->clks()->hasKey(path_clk) + return filter_from_->clks()->hasKey(const_cast(path_clk)) && filter_from_->transition()->matches(path_clk_rf) && matchesFilterTo(path, to_clk_edge); } diff --git a/search/Sim.cc b/search/Sim.cc index bab44bbd..dc8d59f8 100644 --- a/search/Sim.cc +++ b/search/Sim.cc @@ -44,7 +44,7 @@ namespace sta { static LogicValue logicNot(LogicValue value); -static Pin * +static const Pin * findDrvrPin(const Pin *pin, Network *network); @@ -53,7 +53,13 @@ Sim::Sim(StaState *sta) : observer_(nullptr), valid_(false), incremental_(false), + const_func_pins_(network_), const_func_pins_valid_(false), + invalid_insts_(network_), + invalid_drvr_pins_(network_), + invalid_load_pins_(network_), + instances_with_const_pins_(network_), + instances_to_annotate_(network_), // cacheSize = 2^15 cudd_manager_(Cudd_Init(0, 0, CUDD_UNIQUE_SLOTS, 32768, 0)) { @@ -105,9 +111,8 @@ Sim::functionSense(const FuncExpr *expr, void Sim::clearSymtab() const { - BddSymbolTable::Iterator sym_iter(symtab_); - while (sym_iter.hasNext()) { - DdNode *sym_node = sym_iter.next(); + for (auto name_node : symtab_) { + DdNode *sym_node = name_node.second; Cudd_RecursiveDeref(cudd_manager_, sym_node); } symtab_.clear(); @@ -569,26 +574,21 @@ Sim::findLogicConstants() void Sim::seedInvalidConstants() { - InstanceSet::Iterator inst_iter(invalid_insts_); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); + for (const Instance *inst : invalid_insts_) eval_queue_.push(inst); - } } void Sim::propagateToInvalidLoads() { - PinSet::Iterator load_iter(invalid_load_pins_); - while (load_iter.hasNext()) { - Pin *load_pin = load_iter.next(); - Net *net = network_->net(load_pin); + for (const Pin *load_pin : invalid_load_pins_) { + const Net *net = network_->net(load_pin); if (net && network_->isGround(net)) setPinValue(load_pin, LogicValue::zero); else if (net && network_->isPower(net)) setPinValue(load_pin, LogicValue::one); else { - Pin *drvr_pin = findDrvrPin(load_pin, network_); + const Pin *drvr_pin = findDrvrPin(load_pin, network_); if (drvr_pin) propagateDrvrToLoad(drvr_pin, load_pin); } @@ -599,15 +599,13 @@ Sim::propagateToInvalidLoads() void Sim::propagateFromInvalidDrvrsToLoads() { - PinSet::Iterator drvr_iter(invalid_drvr_pins_); - while (drvr_iter.hasNext()) { - Pin *drvr_pin = drvr_iter.next(); + for (const Pin *drvr_pin : invalid_drvr_pins_) { LogicValue value = const_func_pins_.hasKey(drvr_pin) ? pinConstFuncValue(drvr_pin) : logicValue(drvr_pin); PinConnectedPinIterator *load_iter=network_->connectedPinIterator(drvr_pin); while (load_iter->hasNext()) { - Pin *load_pin = load_iter->next(); + const Pin *load_pin = load_iter->next(); if (load_pin != drvr_pin && network_->isLoad(load_pin)) setPinValue(load_pin, value); @@ -618,8 +616,8 @@ Sim::propagateFromInvalidDrvrsToLoads() } void -Sim::propagateDrvrToLoad(Pin *drvr_pin, - Pin *load_pin) +Sim::propagateDrvrToLoad(const Pin *drvr_pin, + const Pin *load_pin) { LogicValue value = logicValue(drvr_pin); setPinValue(load_pin, value); @@ -641,7 +639,7 @@ Sim::ensureConstantFuncPins() Instance *inst = inst_iter->next(); InstancePinIterator *pin_iter = network_->pinIterator(inst); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); recordConstPinFunc(pin); } delete pin_iter; @@ -652,7 +650,7 @@ Sim::ensureConstantFuncPins() } void -Sim::recordConstPinFunc(Pin *pin) +Sim::recordConstPinFunc(const Pin *pin) { LibertyPort *port = network_->libertyPort(pin); if (port) { @@ -667,21 +665,21 @@ Sim::recordConstPinFunc(Pin *pin) } void -Sim::deleteInstanceBefore(Instance *inst) +Sim::deleteInstanceBefore(const Instance *inst) { instances_with_const_pins_.erase(inst); invalid_insts_.erase(inst); } void -Sim::makePinAfter(Pin *pin) +Sim::makePinAfter(const Pin *pin) { // Incrementally update const_func_pins_. recordConstPinFunc(pin); } void -Sim::deletePinBefore(Pin *pin) +Sim::deletePinBefore(const Pin *pin) { // Incrementally update const_func_pins_. const_func_pins_.erase(pin); @@ -691,7 +689,7 @@ Sim::deletePinBefore(Pin *pin) } void -Sim::connectPinAfter(Pin *pin) +Sim::connectPinAfter(const Pin *pin) { if (incremental_) { recordConstPinFunc(pin); @@ -704,7 +702,7 @@ Sim::connectPinAfter(Pin *pin) } void -Sim::disconnectPinBefore(Pin *pin) +Sim::disconnectPinBefore(const Pin *pin) { if (incremental_) { if (network_->isLoad(pin)) { @@ -717,7 +715,7 @@ Sim::disconnectPinBefore(Pin *pin) } void -Sim::pinSetFuncAfter(Pin *pin) +Sim::pinSetFuncAfter(const Pin *pin) { if (incremental_) { Instance *inst = network_->instance(pin); @@ -754,13 +752,11 @@ Sim::propagateConstants(bool thru_sequentials) } void -Sim::setConstraintConstPins(LogicValueMap *value_map) +Sim::setConstraintConstPins(LogicValueMap &value_map) { - LogicValueMap::ConstIterator value_iter(value_map); - while (value_iter.hasNext()) { - LogicValue value; - const Pin *pin; - value_iter.next(pin, value); + for (auto pin_value : value_map) { + const Pin *pin = pin_value.first; + LogicValue value = pin_value.second; debugPrint(debug_, "sim", 2, "case pin %s = %c", network_->pathName(pin), logicValueString(value)); @@ -769,7 +765,7 @@ Sim::setConstraintConstPins(LogicValueMap *value_map) bool pin_is_output = network_->direction(pin)->isAnyOutput(); PinConnectedPinIterator *pin_iter=network_->connectedPinIterator(pin); while (pin_iter->hasNext()) { - Pin *pin1 = pin_iter->next(); + const Pin *pin1 = pin_iter->next(); if (network_->isLeaf(pin1) && network_->direction(pin1)->isAnyInput() && ((pin_is_output && !network_->isInside(pin1, pin)) @@ -788,9 +784,7 @@ Sim::setConstraintConstPins(LogicValueMap *value_map) void Sim::setConstFuncPins() { - PinSet::Iterator const_pin_iter(const_func_pins_); - while (const_pin_iter.hasNext()) { - Pin *pin = const_pin_iter.next(); + for (const Pin *pin : const_func_pins_) { LogicValue value = pinConstFuncValue(pin); setPinValue(pin, value); debugPrint(debug_, "sim", 2, "func pin %s = %c", @@ -800,7 +794,7 @@ Sim::setConstFuncPins() } LogicValue -Sim::pinConstFuncValue(Pin *pin) +Sim::pinConstFuncValue(const Pin *pin) { LibertyPort *port = network_->libertyPort(pin); if (port) { @@ -819,7 +813,7 @@ Sim::enqueueConstantPinInputs() ConstantPinIterator *const_iter = network_->constantPinIterator(); while (const_iter->hasNext()) { LogicValue value; - Pin *pin; + const Pin *pin; const_iter->next(pin, value); debugPrint(debug_, "sim", 2, "network constant pin %s = %c", network_->pathName(pin), @@ -899,7 +893,7 @@ Sim::setPinValue(const Pin *pin, // Enqueue instances with input pins connected to net. PinConnectedPinIterator *pin_iter=network_->connectedPinIterator(pin); while (pin_iter->hasNext()) { - Pin *pin1 = pin_iter->next(); + const Pin *pin1 = pin_iter->next(); if (pin1 != pin && network_->isLoad(pin1)) setPinValue(pin1, value); @@ -1056,7 +1050,7 @@ Sim::logicValue(const Pin *pin) const return vertex->simValue(); else { if (network_->isHierarchical(pin)) { - Pin *drvr_pin = findDrvrPin(pin, network_); + const Pin *drvr_pin = findDrvrPin(pin, network_); if (drvr_pin) return logicValue(drvr_pin); } @@ -1064,7 +1058,7 @@ Sim::logicValue(const Pin *pin) const } } -static Pin * +static const Pin * findDrvrPin(const Pin *pin, Network *network) { @@ -1098,9 +1092,7 @@ Sim::logicZeroOne(const Vertex *vertex) const void Sim::clearSimValues() { - InstanceSet::Iterator inst_iter(instances_with_const_pins_); - while (inst_iter.hasNext()) { - const Instance *inst = inst_iter.next(); + for (const Instance *inst : instances_with_const_pins_) { // Clear sim values on all pins before evaling functions. clearInstSimValues(inst); annotateVertexEdges(inst, false); @@ -1130,11 +1122,8 @@ Sim::clearInstSimValues(const Instance *inst) void Sim::annotateGraphEdges() { - InstanceSet::Iterator inst_iter(instances_to_annotate_); - while (inst_iter.hasNext()) { - const Instance *inst = inst_iter.next(); + for (const Instance *inst : instances_to_annotate_) annotateVertexEdges(inst, true); - } } void @@ -1295,9 +1284,8 @@ isModeDisabled(Edge *edge, if (cond_value == LogicValue::zero) { // For a mode value to be disabled by having a value of // logic zero one mode value must logic one. - ModeValueMap::Iterator iter(mode_def->values()); - while (iter.hasNext()) { - ModeValueDef *value_def1 = iter.next(); + for (auto name_mode : *mode_def->values()) { + ModeValueDef *value_def1 = name_mode.second; if (value_def1) { FuncExpr *cond1 = value_def1->cond(); if (cond1) { diff --git a/search/Sim.hh b/search/Sim.hh index 86711006..9cc09fd3 100644 --- a/search/Sim.hh +++ b/search/Sim.hh @@ -62,22 +62,22 @@ public: void findLogicConstants(); // Network edits. - void deleteInstanceBefore(Instance *inst); - void makePinAfter(Pin *pin); - void deletePinBefore(Pin *pin); - void connectPinAfter(Pin *pin); - void disconnectPinBefore(Pin *pin); - void pinSetFuncAfter(Pin *pin); + void deleteInstanceBefore(const Instance *inst); + void makePinAfter(const Pin *pin); + void deletePinBefore(const Pin *pin); + void connectPinAfter(const Pin *pin); + void disconnectPinBefore(const Pin *pin); + void pinSetFuncAfter(const Pin *pin); protected: void ensureConstantFuncPins(); - void recordConstPinFunc(Pin *pin); + void recordConstPinFunc(const Pin *pin); virtual void seedConstants(); void seedInvalidConstants(); void propagateConstants(bool thru_sequentials); - void setConstraintConstPins(LogicValueMap *pin_value_map); + void setConstraintConstPins(LogicValueMap &pin_value_map); void setConstFuncPins(); - LogicValue pinConstFuncValue(Pin *pin); + LogicValue pinConstFuncValue(const Pin *pin); void enqueueConstantPinInputs(); virtual void setPinValue(const Pin *pin, LogicValue value); @@ -106,8 +106,8 @@ protected: void removePropagatedValue(const Pin *pin); void propagateFromInvalidDrvrsToLoads(); void propagateToInvalidLoads(); - void propagateDrvrToLoad(Pin *drvr_pin, - Pin *load_pin); + void propagateDrvrToLoad(const Pin *drvr_pin, + const Pin *load_pin); void setSimValue(Vertex *vertex, LogicValue value); diff --git a/search/Sta.cc b/search/Sta.cc index d3529d93..0d58f0d5 100644 --- a/search/Sta.cc +++ b/search/Sta.cc @@ -81,13 +81,13 @@ using std::max; static const ClockEdge *clk_edge_wildcard = reinterpret_cast(1); static bool -libertyPortCapsEqual(LibertyPort *port1, - LibertyPort *port2); +libertyPortCapsEqual(const LibertyPort *port1, + const LibertyPort *port2); static bool hasDisabledArcs(Edge *edge, Graph *graph); -static InstanceSet * -pinInstances(PinSet *pins, +static InstanceSet +pinInstances(PinSet &pins, const Network *network); //////////////////////////////////////////////////////////////// @@ -799,7 +799,7 @@ Sta::setOperatingConditions(OperatingConditions *op_cond, search_->arrivalsInvalid(); } -Pvt * +const Pvt * Sta::pvt(Instance *inst, const MinMax *min_max) { @@ -813,14 +813,14 @@ Sta::setPvt(Instance *inst, float voltage, float temperature) { - Pvt *pvt = new Pvt(process, voltage, temperature); + Pvt pvt(process, voltage, temperature); setPvt(inst, min_max, pvt); } void -Sta::setPvt(Instance *inst, +Sta::setPvt(const Instance *inst, const MinMaxAll *min_max, - Pvt *pvt) + const Pvt &pvt) { sdc_->setPvt(inst, min_max, pvt); delaysInvalidFrom(inst); @@ -890,7 +890,7 @@ Sta::unsetTimingDerate() } void -Sta::setInputSlew(Port *port, +Sta::setInputSlew(const Port *port, const RiseFallBoth *rf, const MinMaxAll *min_max, float slew) @@ -900,12 +900,12 @@ Sta::setInputSlew(Port *port, } void -Sta::setDriveCell(LibertyLibrary *library, - LibertyCell *cell, - Port *port, - LibertyPort *from_port, +Sta::setDriveCell(const LibertyLibrary *library, + const LibertyCell *cell, + const Port *port, + const LibertyPort *from_port, float *from_slews, - LibertyPort *to_port, + const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max) { @@ -915,7 +915,7 @@ Sta::setDriveCell(LibertyLibrary *library, } void -Sta::setDriveResistance(Port *port, +Sta::setDriveResistance(const Port *port, const RiseFallBoth *rf, const MinMaxAll *min_max, float res) @@ -925,7 +925,7 @@ Sta::setDriveResistance(Port *port, } void -Sta::setLatchBorrowLimit(Pin *pin, +Sta::setLatchBorrowLimit(const Pin *pin, float limit) { sdc_->setLatchBorrowLimit(pin, limit); @@ -933,7 +933,7 @@ Sta::setLatchBorrowLimit(Pin *pin, } void -Sta::setLatchBorrowLimit(Instance *inst, +Sta::setLatchBorrowLimit(const Instance *inst, float limit) { sdc_->setLatchBorrowLimit(inst, limit); @@ -941,7 +941,7 @@ Sta::setLatchBorrowLimit(Instance *inst, } void -Sta::setLatchBorrowLimit(Clock *clk, +Sta::setLatchBorrowLimit(const Clock *clk, float limit) { sdc_->setLatchBorrowLimit(clk, limit); @@ -1183,7 +1183,7 @@ Sta::removeClockSlew(Clock *clk) void Sta::clockSlewChanged(Clock *clk) { - for (Pin *pin : clk->pins()) + for (const Pin *pin : clk->pins()) graph_delay_calc_->delayInvalid(pin); search_->arrivalsInvalid(); } @@ -1598,11 +1598,11 @@ Sta::disableAfter() //////////////////////////////////////////////////////////////// -EdgeSeq * +EdgeSeq Sta::disabledEdges() { ensureLevelized(); - EdgeSeq *disabled_edges = new EdgeSeq; + EdgeSeq disabled_edges; VertexIterator vertex_iter(graph_); while (vertex_iter.hasNext()) { Vertex *vertex = vertex_iter.next(); @@ -1614,18 +1614,18 @@ Sta::disabledEdges() || isDisabledConstraint(edge) || edge->isDisabledLoop() || isDisabledPresetClr(edge)) - disabled_edges->push_back(edge); + disabled_edges.push_back(edge); } } return disabled_edges; } -EdgeSeq * +EdgeSeq Sta::disabledEdgesSorted() { - EdgeSeq *disabled_edges = disabledEdges(); - sortEdges(disabled_edges, network_, graph_); + EdgeSeq disabled_edges = disabledEdges(); + sortEdges(&disabled_edges, network_, graph_); return disabled_edges; } @@ -1686,23 +1686,23 @@ Sta::isDisabledCondDefault(Edge *edge) return sdc_->isDisabledCondDefault(edge); } -PinSet * +PinSet Sta::disabledConstantPins(Edge *edge) { sim_->ensureConstantsPropagated(); - PinSet *pins = new PinSet; + PinSet pins(network_); Vertex *from_vertex = edge->from(graph_); Pin *from_pin = from_vertex->pin(); Vertex *to_vertex = edge->to(graph_); - Pin *to_pin = to_vertex->pin(); + const Pin *to_pin = to_vertex->pin(); if (sim_->logicZeroOne(from_vertex)) - pins->insert(from_pin); + pins.insert(from_pin); if (edge->role()->isWire()) { if (sim_->logicZeroOne(to_vertex)) - pins->insert(to_pin); + pins.insert(to_pin); } else { - Instance *inst = network_->instance(to_pin); + const Instance *inst = network_->instance(to_pin); bool is_disabled; FuncExpr *disable_cond; isCondDisabled(edge, inst, from_pin, to_pin, network_, sim_, @@ -1717,7 +1717,7 @@ Sta::disabledConstantPins(Edge *edge) isTestDisabled(inst, from_pin, to_pin, network_, sim_, is_disabled, scan_enable); if (is_disabled) - pins->insert(scan_enable); + pins.insert(scan_enable); if (hasDisabledArcs(edge, graph_)) { LibertyPort *to_port = network_->libertyPort(to_pin); if (to_port) { @@ -1741,7 +1741,9 @@ Sta::simTimingSense(Edge *edge) } void -Sta::exprConstantPins(FuncExpr *expr, Instance *inst, PinSet *pins) +Sta::exprConstantPins(FuncExpr *expr, + const Instance *inst, + PinSet &pins) { FuncExprPortIterator port_iter(expr); while (port_iter.hasNext()) { @@ -1750,7 +1752,7 @@ Sta::exprConstantPins(FuncExpr *expr, Instance *inst, PinSet *pins) if (pin) { LogicValue value = sim_->logicValue(pin); if (value != LogicValue::unknown) - pins->insert(pin); + pins.insert(pin); } } } @@ -2404,6 +2406,7 @@ Sta::makeCorners() corner_names.insert("default"); corners_->makeCorners(&corner_names); cmd_corner_ = corners_->findCorner(0); + sdc_->makeCornersAfter(corners_); } void @@ -2413,6 +2416,8 @@ Sta::makeCorners(StringSet *corner_names) corners_->makeCorners(corner_names); makeParasiticAnalysisPts(); cmd_corner_ = corners_->findCorner(0); + updateComponentsState(); + sdc_->makeCornersAfter(corners_); } Corner * @@ -2657,7 +2662,7 @@ Sta::endpointViolationCount(const MinMax *min_max) return violations; } -PinSet * +PinSet Sta::findGroupPathPins(const char *group_path_name) { if (!(search_->havePathGroups() @@ -2681,7 +2686,7 @@ Sta::findGroupPathPins(const char *group_path_name) PathGroup *path_group = search_->findPathGroup(group_path_name, MinMax::max()); - PinSet *pins = new PinSet; + PinSet pins(network_); VertexPinCollector visitor(pins); visitPathGroupVertices(path_group, &visitor, this); return pins; @@ -2914,7 +2919,7 @@ Sta::netSlack(const Net *net, Slack slack = MinMax::min()->initValue(); NetPinIterator *pin_iter = network_->pinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (network_->isLoad(pin)) { Vertex *vertex = graph_->pinLoadVertex(pin); Slack pin_slack = vertexSlack(vertex, min_max); @@ -3101,8 +3106,8 @@ MinPeriodEndVisitor::visit(PathEnd *path_end) { Network *network = sta_->network(); Path *path = path_end->path(); - ClockEdge *src_edge = path_end->sourceClkEdge(sta_); - ClockEdge *tgt_edge = path_end->targetClkEdge(sta_); + const ClockEdge *src_edge = path_end->sourceClkEdge(sta_); + const ClockEdge *tgt_edge = path_end->targetClkEdge(sta_); PathEnd::Type end_type = path_end->type(); if ((end_type == PathEnd::Type::check || end_type == PathEnd::Type::output_delay) @@ -3617,21 +3622,28 @@ Sta::clearLogicConstants() } void -Sta::setPortExtPinCap(Port *port, +Sta::setPortExtPinCap(const Port *port, const RiseFallBoth *rf, + const Corner *corner, const MinMaxAll *min_max, float cap) { for (RiseFall *rf1 : rf->range()) { for (MinMax *mm : min_max->range()) { - sdc_->setPortExtPinCap(port, rf1, mm, cap); + if (corner == nullptr) { + for (Corner *corner : *corners_) + sdc_->setPortExtPinCap(port, rf1, corner, mm, cap); + } + else + sdc_->setPortExtPinCap(port, rf1, corner, mm, cap); } } delaysInvalidFromFanin(port); } void -Sta::portExtCaps(Port *port, +Sta::portExtCaps(const Port *port, + const Corner *corner, const MinMax *min_max, float &pin_cap, float &wire_cap, @@ -3647,7 +3659,7 @@ Sta::portExtCaps(Port *port, float pin_cap1, wire_cap1; int fanout1; bool pin_exists1, wire_exists1, fanout_exists1; - sdc_->portExtCap(port, rf, min_max, + sdc_->portExtCap(port, rf, corner, min_max, pin_cap1, pin_exists1, wire_cap1, wire_exists1, fanout1, fanout_exists1); @@ -3673,60 +3685,63 @@ Sta::portExtCaps(Port *port, } void -Sta::setPortExtWireCap(Port *port, +Sta::setPortExtWireCap(const Port *port, bool subtract_pin_cap, const RiseFallBoth *rf, + const Corner *corner, const MinMaxAll *min_max, float cap) { - Corner *corner = cmd_corner_; for (RiseFall *rf1 : rf->range()) { for (MinMax *mm : min_max->range()) { - sdc_->setPortExtWireCap(port, subtract_pin_cap, rf1, corner, mm, cap); + if (corner == nullptr) { + for (Corner *corner : *corners_) + sdc_->setPortExtWireCap(port, subtract_pin_cap, rf1, corner, mm, cap); + } + else + sdc_->setPortExtWireCap(port, subtract_pin_cap, rf1, corner, mm, cap); } } delaysInvalidFromFanin(port); } void -Sta::removeNetLoadCaps() const -{ - sdc_->removeNetLoadCaps(); - graph_delay_calc_->delaysInvalid(); -} - -void -Sta::setPortExtFanout(Port *port, +Sta::setPortExtFanout(const Port *port, int fanout, + const Corner *corner, const MinMaxAll *min_max) { - for (MinMax *mm : min_max->range()) - sdc_->setPortExtFanout(port, mm, fanout); + for (MinMax *mm : min_max->range()) { + if (corner == nullptr) { + for (Corner *corner : *corners_) + sdc_->setPortExtFanout(port, corner, mm, fanout); + } + else + sdc_->setPortExtFanout(port, corner, mm, fanout); + } delaysInvalidFromFanin(port); } void -Sta::setNetWireCap(Net *net, +Sta::setNetWireCap(const Net *net, bool subtract_pin_cap, const Corner *corner, const MinMaxAll *min_max, float cap) { - if (corner == nullptr) { - for (Corner *corner : *corners_) { - for (MinMax *mm : min_max->range()) + for (MinMax *mm : min_max->range()) { + if (corner == nullptr) { + for (Corner *corner : *corners_) sdc_->setNetWireCap(net, subtract_pin_cap, corner, mm, cap); } - } - else { - for (MinMax *mm : min_max->range()) + else sdc_->setNetWireCap(net, subtract_pin_cap, corner, mm, cap); } delaysInvalidFromFanin(net); } void -Sta::connectedCap(Pin *drvr_pin, +Sta::connectedCap(const Pin *drvr_pin, const RiseFall *rf, const Corner *corner, const MinMax *min_max, @@ -3752,13 +3767,13 @@ Sta::connectedCap(Pin *drvr_pin, } void -Sta::connectedCap(Net *net, +Sta::connectedCap(const Net *net, Corner *corner, const MinMax *min_max, float &pin_cap, float &wire_cap) const { - Pin *drvr_pin = findNetParasiticDrvrPin(net); + const Pin *drvr_pin = findNetParasiticDrvrPin(net); if (drvr_pin) { pin_cap = min_max->initValue(); wire_cap = min_max->initValue(); @@ -3805,13 +3820,13 @@ Sta::capacitance(const LibertyPort *port, // Look for a driver to find a parasitic if the net has one. // Settle for a load pin if there are no drivers. -Pin * -Sta::findNetParasiticDrvrPin(Net *net) const +const Pin * +Sta::findNetParasiticDrvrPin(const Net *net) const { - Pin *load_pin = nullptr; + const Pin *load_pin = nullptr; NetConnectedPinIterator *pin_iter = network_->connectedPinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (network_->isDriver(pin)) { delete pin_iter; return pin; @@ -3824,7 +3839,7 @@ Sta::findNetParasiticDrvrPin(Net *net) const } void -Sta::setResistance(Net *net, +Sta::setResistance(const Net *net, const MinMaxAll *min_max, float res) { @@ -4111,7 +4126,7 @@ Sta::disconnectPin(Pin *pin) //////////////////////////////////////////////////////////////// void -Sta::makeInstanceAfter(Instance *inst) +Sta::makeInstanceAfter(const Instance *inst) { if (graph_) { LibertyCell *lib_cell = network_->libertyCell(inst); @@ -4133,8 +4148,8 @@ Sta::makeInstanceAfter(Instance *inst) } void -Sta::replaceEquivCellBefore(Instance *inst, - LibertyCell *to_cell) +Sta::replaceEquivCellBefore(const Instance *inst, + const LibertyCell *to_cell) { if (graph_) { InstancePinIterator *pin_iter = network_->pinIterator(inst); @@ -4174,7 +4189,7 @@ Sta::replaceEquivCellBefore(Instance *inst, } void -Sta::replaceEquivCellAfter(Instance *inst) +Sta::replaceEquivCellAfter(const Instance *inst) { if (graph_) { InstancePinIterator *pin_iter = network_->pinIterator(inst); @@ -4188,9 +4203,9 @@ Sta::replaceEquivCellAfter(Instance *inst) } void -Sta::replaceCellPinInvalidate(LibertyPort *from_port, +Sta::replaceCellPinInvalidate(const LibertyPort *from_port, Vertex *vertex, - LibertyCell *to_cell) + const LibertyCell *to_cell) { LibertyPort *to_port = to_cell->findLibertyPort(from_port->name()); if (to_port == nullptr @@ -4217,8 +4232,8 @@ Sta::idealClockMode() } static bool -libertyPortCapsEqual(LibertyPort *port1, - LibertyPort *port2) +libertyPortCapsEqual(const LibertyPort *port1, + const LibertyPort *port2) { return port1->capacitance(RiseFall::rise(), MinMax::min()) == port2->capacitance(RiseFall::rise(), MinMax::min()) @@ -4231,8 +4246,8 @@ libertyPortCapsEqual(LibertyPort *port1, } void -Sta::replaceCellBefore(Instance *inst, - LibertyCell *to_cell) +Sta::replaceCellBefore(const Instance *inst, + const LibertyCell *to_cell) { if (graph_) { // Delete all graph edges between instance pins. @@ -4258,7 +4273,7 @@ Sta::replaceCellBefore(Instance *inst, } void -Sta::replaceCellAfter(Instance *inst) +Sta::replaceCellAfter(const Instance *inst) { if (graph_) { graph_->makeInstanceEdges(inst); @@ -4274,7 +4289,7 @@ Sta::replaceCellAfter(Instance *inst) } void -Sta::connectPinAfter(Pin *pin) +Sta::connectPinAfter(const Pin *pin) { if (graph_) { if (network_->isHierarchical(pin)) { @@ -4360,7 +4375,7 @@ Sta::connectLoadPinAfter(Vertex *vertex) } void -Sta::disconnectPinBefore(Pin *pin) +Sta::disconnectPinBefore(const Pin *pin) { parasitics_->disconnectPinBefore(pin); sdc_->disconnectPinBefore(pin); @@ -4421,12 +4436,12 @@ Sta::deleteEdge(Edge *edge) } void -Sta::deleteNetBefore(Net *net) +Sta::deleteNetBefore(const Net *net) { if (graph_) { NetConnectedPinIterator *pin_iter = network_->connectedPinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (!network_->isHierarchical(pin)) { disconnectPinBefore(pin); // Delete wire edges on net pins. @@ -4447,7 +4462,7 @@ Sta::deleteNetBefore(Net *net) } void -Sta::deleteInstanceBefore(Instance *inst) +Sta::deleteInstanceBefore(const Instance *inst) { if (network_->isLeaf(inst)) { deleteInstancePinsBefore(inst); @@ -4465,13 +4480,13 @@ Sta::deleteInstanceBefore(Instance *inst) } void -Sta::deleteLeafInstanceBefore(Instance *inst) +Sta::deleteLeafInstanceBefore(const Instance *inst) { sim_->deleteInstanceBefore(inst); } void -Sta::deleteInstancePinsBefore(Instance *inst) +Sta::deleteInstancePinsBefore(const Instance *inst) { InstancePinIterator *pin_iter = network_->pinIterator(inst); while (pin_iter->hasNext()) { @@ -4482,7 +4497,7 @@ Sta::deleteInstancePinsBefore(Instance *inst) } void -Sta::deletePinBefore(Pin *pin) +Sta::deletePinBefore(const Pin *pin) { if (graph_) { if (network_->isLoad(pin)) { @@ -4544,7 +4559,7 @@ Sta::deletePinBefore(Pin *pin) } void -Sta::delaysInvalidFrom(Port *port) +Sta::delaysInvalidFrom(const Port *port) { if (graph_) { Instance *top_inst = network_->topInstance(); @@ -4554,7 +4569,7 @@ Sta::delaysInvalidFrom(Port *port) } void -Sta::delaysInvalidFrom(Instance *inst) +Sta::delaysInvalidFrom(const Instance *inst) { if (graph_) { InstancePinIterator *pin_iter = network_->pinIterator(inst); @@ -4567,7 +4582,7 @@ Sta::delaysInvalidFrom(Instance *inst) } void -Sta::delaysInvalidFrom(Pin *pin) +Sta::delaysInvalidFrom(const Pin *pin) { if (graph_) { Vertex *vertex, *bidirect_drvr_vertex; @@ -4587,7 +4602,7 @@ Sta::delaysInvalidFrom(Vertex *vertex) } void -Sta::delaysInvalidFromFanin(Port *port) +Sta::delaysInvalidFromFanin(const Port *port) { if (graph_) { Instance *top_inst = network_->topInstance(); @@ -4601,7 +4616,7 @@ Sta::delaysInvalidFromFanin(Port *port) } void -Sta::delaysInvalidFromFanin(Pin *pin) +Sta::delaysInvalidFromFanin(const Pin *pin) { if (graph_) { Vertex *vertex, *bidirect_drvr_vertex; @@ -4614,12 +4629,12 @@ Sta::delaysInvalidFromFanin(Pin *pin) } void -Sta::delaysInvalidFromFanin(Net *net) +Sta::delaysInvalidFromFanin(const Net *net) { if (graph_) { NetConnectedPinIterator *pin_iter = network_->connectedPinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (!network_->isHierarchical(pin)) { Vertex *vertex, *bidirect_drvr_vertex; graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); @@ -4647,18 +4662,16 @@ Sta::delaysInvalidFromFanin(Vertex *vertex) //////////////////////////////////////////////////////////////// -void -Sta::clocks(const Pin *pin, - // Return value. - ClockSet &clks) +ClockSet +Sta::clocks(const Pin *pin) { ensureClkArrivals(); - search_->clocks(pin, clks); + return search_->clocks(pin); } //////////////////////////////////////////////////////////////// -InstanceSet * +InstanceSet Sta::findRegisterInstances(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, @@ -4668,7 +4681,7 @@ Sta::findRegisterInstances(ClockSet *clks, return findRegInstances(clks, clk_rf, edge_triggered, latches, this); } -PinSet * +PinSet Sta::findRegisterDataPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, @@ -4678,7 +4691,7 @@ Sta::findRegisterDataPins(ClockSet *clks, return findRegDataPins(clks, clk_rf, edge_triggered, latches, this); } -PinSet * +PinSet Sta::findRegisterClkPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, @@ -4688,7 +4701,7 @@ Sta::findRegisterClkPins(ClockSet *clks, return findRegClkPins(clks, clk_rf, edge_triggered, latches, this); } -PinSet * +PinSet Sta::findRegisterAsyncPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, @@ -4698,7 +4711,7 @@ Sta::findRegisterAsyncPins(ClockSet *clks, return findRegAsyncPins(clks, clk_rf, edge_triggered, latches, this); } -PinSet * +PinSet Sta::findRegisterOutputPins(ClockSet *clks, const RiseFallBoth *clk_rf, bool edge_triggered, @@ -4830,7 +4843,7 @@ FaninSrchPred::searchThruRole(Edge *edge) || role == TimingRole::latchEnToQ(); } -PinSet * +PinSet Sta::findFaninPins(PinSeq *to, bool flat, bool startpoints_only, @@ -4841,11 +4854,11 @@ Sta::findFaninPins(PinSeq *to, { ensureGraph(); ensureLevelized(); - PinSet *fanin = new PinSet; + PinSet fanin(network_); FaninSrchPred pred(thru_disabled, thru_constants, this); PinSeq::Iterator to_iter(to); while (to_iter.hasNext()) { - Pin *pin = to_iter.next(); + const Pin *pin = to_iter.next(); if (network_->isHierarchical(pin)) { EdgesThruHierPinIterator edge_iter(pin, network_, graph_); while (edge_iter.hasNext()) { @@ -4869,7 +4882,7 @@ Sta::findFaninPins(Vertex *vertex, bool startpoints_only, int inst_levels, int pin_levels, - PinSet *fanin, + PinSet &fanin, SearchPred &pred) { VertexSet visited(graph_); @@ -4882,7 +4895,7 @@ Sta::findFaninPins(Vertex *vertex, if (!startpoints_only || network_->isRegClkPin(visited_pin) || !hasFanin(visited_vertex, &pred, graph_)) - fanin->insert(visited_pin); + fanin.insert(visited_pin); } } @@ -4926,7 +4939,7 @@ Sta::findFaninPins(Vertex *to, } } -InstanceSet * +InstanceSet Sta::findFaninInstances(PinSeq *to, bool flat, bool startpoints_only, @@ -4935,12 +4948,12 @@ Sta::findFaninInstances(PinSeq *to, bool thru_disabled, bool thru_constants) { - PinSet *pins = findFaninPins(to, flat, startpoints_only, inst_levels, - pin_levels, thru_disabled, thru_constants); + PinSet pins = findFaninPins(to, flat, startpoints_only, inst_levels, + pin_levels, thru_disabled, thru_constants); return pinInstances(pins, network_); } -PinSet * +PinSet Sta::findFanoutPins(PinSeq *from, bool flat, bool endpoints_only, @@ -4951,11 +4964,11 @@ Sta::findFanoutPins(PinSeq *from, { ensureGraph(); ensureLevelized(); - PinSet *fanout = new PinSet; + PinSet fanout(network_); FanInOutSrchPred pred(thru_disabled, thru_constants, this); PinSeq::Iterator from_iter(from); while (from_iter.hasNext()) { - Pin *pin = from_iter.next(); + const Pin *pin = from_iter.next(); if (network_->isHierarchical(pin)) { EdgesThruHierPinIterator edge_iter(pin, network_, graph_); while (edge_iter.hasNext()) { @@ -4979,7 +4992,7 @@ Sta::findFanoutPins(Vertex *vertex, bool endpoints_only, int inst_levels, int pin_levels, - PinSet *fanout, + PinSet &fanout, SearchPred &pred) { VertexSet visited(graph_); @@ -4991,7 +5004,7 @@ Sta::findFanoutPins(Vertex *vertex, Pin *visited_pin = visited_vertex->pin(); if (!endpoints_only || search_->isEndpoint(visited_vertex, &pred)) - fanout->insert(visited_pin); + fanout.insert(visited_pin); } } @@ -5034,7 +5047,7 @@ Sta::findFanoutPins(Vertex *from, } } -InstanceSet * +InstanceSet Sta::findFanoutInstances(PinSeq *from, bool flat, bool endpoints_only, @@ -5043,22 +5056,18 @@ Sta::findFanoutInstances(PinSeq *from, bool thru_disabled, bool thru_constants) { - PinSet *pins = findFanoutPins(from, flat, endpoints_only, inst_levels, - pin_levels, thru_disabled, thru_constants); + PinSet pins = findFanoutPins(from, flat, endpoints_only, inst_levels, + pin_levels, thru_disabled, thru_constants); return pinInstances(pins, network_); } -static InstanceSet * -pinInstances(PinSet *pins, +static InstanceSet +pinInstances(PinSet &pins, const Network *network) { - InstanceSet *insts = new InstanceSet; - PinSet::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - insts->insert(network->instance(pin)); - } - delete pins; + InstanceSet insts(network); + for (const Pin *pin : pins) + insts.insert(network->instance(pin)); return insts; } @@ -5163,7 +5172,7 @@ Sta::checkSlewLimitPreamble() ensureClkNetwork(); } -PinSeq * +PinSeq Sta::checkSlewLimits(Net *net, bool violators, const Corner *corner, @@ -5228,26 +5237,25 @@ Sta::checkSlew(const Pin *pin, void Sta::maxSlewCheck(// Return values. - Pin *&pin, + const Pin *&pin, Slew &slew, float &slack, float &limit) { checkSlewLimitPreamble(); - PinSeq *pins = check_slew_limits_->checkSlewLimits(nullptr, false, nullptr, - MinMax::max()); + PinSeq pins = check_slew_limits_->checkSlewLimits(nullptr, false, nullptr, + MinMax::max()); pin = nullptr; slew = 0.0; slack = INF; limit = INF; - if (!pins->empty()) { - pin = (*pins)[0]; + if (!pins.empty()) { + pin = pins[0]; const Corner *corner; const RiseFall *rf; check_slew_limits_->checkSlew(pin, nullptr, MinMax::max(), true, corner, rf, slew, limit, slack); } - delete pins; } void @@ -5274,7 +5282,7 @@ Sta::checkFanoutLimitPreamble() ensureClkNetwork(); } -PinSeq * +PinSeq Sta::checkFanoutLimits(Net *net, bool violators, const MinMax *min_max) @@ -5326,23 +5334,22 @@ Sta::checkFanout(const Pin *pin, void Sta::maxFanoutCheck(// Return values. - Pin *&pin, + const Pin *&pin, float &fanout, float &slack, float &limit) { checkFanoutLimitPreamble(); - PinSeq *pins = check_fanout_limits_->checkFanoutLimits(nullptr, false, MinMax::max()); + PinSeq pins = check_fanout_limits_->checkFanoutLimits(nullptr, false, MinMax::max()); pin = nullptr; fanout = 0; slack = INF; limit = INF; - if (!pins->empty()) { - pin = (*pins)[0]; + if (!pins.empty()) { + pin = pins[0]; check_fanout_limits_->checkFanout(pin, MinMax::max(), fanout, limit, slack); } - delete pins; } ////////////////////////////////////////////////////////////////' @@ -5355,7 +5362,7 @@ Sta::checkCapacitanceLimitPreamble() ensureClkNetwork(); } -PinSeq * +PinSeq Sta::checkCapacitanceLimits(Net *net, bool violators, const Corner *corner, @@ -5421,27 +5428,26 @@ Sta::checkCapacitance(const Pin *pin, void Sta::maxCapacitanceCheck(// Return values. - Pin *&pin, + const Pin *&pin, float &capacitance, float &slack, float &limit) { checkCapacitanceLimitPreamble(); - PinSeq *pins = check_capacitance_limits_->checkCapacitanceLimits(nullptr, false, - nullptr, - MinMax::max()); + PinSeq pins = check_capacitance_limits_->checkCapacitanceLimits(nullptr, false, + nullptr, + MinMax::max()); pin = nullptr; capacitance = 0.0; slack = INF; limit = INF; - if (!pins->empty()) { - pin = (*pins)[0]; + if (!pins.empty()) { + pin = pins[0]; const Corner *corner; const RiseFall *rf; check_capacitance_limits_->checkCapacitance(pin, nullptr, MinMax::max(), corner, rf, capacitance, limit, slack); } - delete pins; } //////////////////////////////////////////////////////////////// @@ -5631,14 +5637,12 @@ Sta::power(const Corner *corner, power_->power(corner, total, sequential, combinational, macro, pad); } -void +PowerResult Sta::power(const Instance *inst, - const Corner *corner, - // Return values. - PowerResult &result) + const Corner *corner) { powerPreamble(); - power_->power(inst, corner, result); + return power_->power(inst, corner); } PwrActivity diff --git a/search/Tag.cc b/search/Tag.cc index d0b6dbe2..f7a45575 100644 --- a/search/Tag.cc +++ b/search/Tag.cc @@ -65,9 +65,7 @@ Tag::Tag(TagIndex index, findHash(); if (states_) { FilterPath *filter = sta->search()->filter(); - ExceptionStateSet::ConstIterator state_iter(states_); - while (state_iter.hasNext()) { - ExceptionState *state = state_iter.next(); + for (ExceptionState *state : *states_) { ExceptionPath *exception = state->exception(); if (exception->isLoop()) is_loop_ = true; @@ -110,7 +108,7 @@ Tag::asString(bool report_index, path_ap_index_); } - ClockEdge *clk_edge = clkEdge(); + const ClockEdge *clk_edge = clkEdge(); if (clk_edge) str += clk_edge->name(); else @@ -154,9 +152,7 @@ Tag::asString(bool report_index, str += " segment_start"; if (states_) { - ExceptionStateSet::ConstIterator state_iter(states_); - while (state_iter.hasNext()) { - ExceptionState *state = state_iter.next(); + for (ExceptionState *state : *states_) { ExceptionPath *exception = state->exception(); str += " "; str += exception->asString(network); @@ -196,13 +192,13 @@ Tag::setStates(ExceptionStateSet *states) states_ = states; } -ClockEdge * +const ClockEdge * Tag::clkEdge() const { return clk_info_->clkEdge(); } -Clock * +const Clock * Tag::clock() const { return clk_info_->clock(); @@ -220,15 +216,13 @@ Tag::isGenClkSrcPath() const return clk_info_->isGenClkSrcPath(); } -Clock * +const Clock * Tag::genClkSrcPathClk(const StaState *sta) const { if (clk_info_->isGenClkSrcPath() && states_) { FilterPath *filter = sta->search()->filter(); - ExceptionStateSet::ConstIterator state_iter(states_); - while (state_iter.hasNext()) { - ExceptionState *state = state_iter.next(); + for (ExceptionState *state : *states_) { ExceptionPath *except = state->exception(); if (except->isFilter() && except != filter) { @@ -237,7 +231,7 @@ Tag::genClkSrcPathClk(const StaState *sta) const ClockSet *clks = to->clks(); if (clks && clks->size() == 1) { ClockSet::Iterator clk_iter(clks); - Clock *clk = clk_iter.next(); + const Clock *clk = clk_iter.next(); return clk; } } @@ -257,11 +251,8 @@ Tag::findHash() hashIncr(hash_, is_clk_); hashIncr(hash_, is_segment_start_); if (states_) { - ExceptionStateSet::Iterator state_iter(states_); - while (state_iter.hasNext()) { - ExceptionState *state = state_iter.next(); + for (ExceptionState *state : *states_) hashIncr(hash_, state->hash()); - } } match_hash_ = hash_; @@ -271,7 +262,7 @@ Tag::findHash() hashIncr(hash_, input_delay_->index()); // Finish match_hash_. - ClockEdge *clk_edge = clk_info_->clkEdge(); + const ClockEdge *clk_edge = clk_info_->clkEdge(); if (clk_edge) hashIncr(match_hash_, clk_edge->index()); hashIncr(match_hash_, clk_info_->isGenClkSrcPath()); diff --git a/search/Tag.hh b/search/Tag.hh index 64bf8d28..532bce35 100644 --- a/search/Tag.hh +++ b/search/Tag.hh @@ -60,8 +60,8 @@ public: const StaState *sta) const; ClkInfo *clkInfo() const { return clk_info_; } bool isClock() const { return is_clk_; } - ClockEdge *clkEdge() const; - Clock *clock() const; + const ClockEdge *clkEdge() const; + const Clock *clock() const; const Pin *clkSrc() const; int trIndex() const { return tr_index_; } const RiseFall *transition() const; @@ -71,7 +71,7 @@ public: ExceptionStateSet *states() const { return states_; } void setStates(ExceptionStateSet *states); bool isGenClkSrcPath() const; - Clock *genClkSrcPathClk(const StaState *sta) const; + const Clock *genClkSrcPathClk(const StaState *sta) const; // Input delay at search startpoint (not propagated). InputDelay *inputDelay() const { return input_delay_; } bool isLoop() const { return is_loop_; } diff --git a/search/VertexVisitor.cc b/search/VertexVisitor.cc index 121d5ce1..99cf083b 100644 --- a/search/VertexVisitor.cc +++ b/search/VertexVisitor.cc @@ -21,7 +21,7 @@ namespace sta { -VertexPinCollector::VertexPinCollector(PinSet *pins) : +VertexPinCollector::VertexPinCollector(PinSet &pins) : pins_(pins) { } @@ -36,7 +36,7 @@ VertexPinCollector::copy() const void VertexPinCollector::visit(Vertex *vertex) { - pins_->insert(vertex->pin()); + pins_.insert(vertex->pin()); } } // namespace diff --git a/search/VisitPathEnds.cc b/search/VisitPathEnds.cc index 0e487f88..273f9cf8 100644 --- a/search/VisitPathEnds.cc +++ b/search/VisitPathEnds.cc @@ -133,8 +133,8 @@ VisitPathEnds::visitCheckEnd(const Pin *pin, PathEndVisitor *visitor, bool &is_constrained) { - ClockEdge *src_clk_edge = path->clkEdge(this); - Clock *src_clk = path->clock(this); + const ClockEdge *src_clk_edge = path->clkEdge(this); + const Clock *src_clk = path->clock(this); const MinMax *min_max = path_ap->pathMinMax(); const PathAnalysisPt *tgt_clk_path_ap = path_ap->tgtClkAnalysisPt(); bool check_clked = false; @@ -301,7 +301,7 @@ VisitPathEnds::visitOutputDelayEnd(const Pin *pin, output_delay->delays()->value(end_rf, min_max, margin, exists); if (exists) { const Pin *ref_pin = output_delay->refPin(); - ClockEdge *tgt_clk_edge = output_delay->clkEdge(); + const ClockEdge *tgt_clk_edge = output_delay->clkEdge(); if (!filtered || search_->matchesFilter(path, tgt_clk_edge)) { if (ref_pin) { @@ -344,7 +344,7 @@ VisitPathEnds::visitOutputDelayEnd1(OutputDelay *output_delay, // but the exception may be -to clk. ExceptionPath *exception = exceptionTo(path, pin, end_rf, tgt_clk_edge, min_max); - ClockEdge *src_clk_edge = path->clkEdge(this); + const ClockEdge *src_clk_edge = path->clkEdge(this); if (exception && exception->isPathDelay()) { PathDelay *path_delay = dynamic_cast(exception); @@ -383,7 +383,7 @@ VisitPathEnds::visitGatedClkEnd(const Pin *pin, PathEndVisitor *visitor, bool &is_constrained) { - ClockEdge *src_clk_edge = path->clkEdge(this); + const ClockEdge *src_clk_edge = path->clkEdge(this); if (src_clk_edge) { GatedClk *gated_clk = search_->gatedClk(); Clock *src_clk = src_clk_edge->clock(); @@ -492,7 +492,7 @@ VisitPathEnds::visitDataCheckEnd(const Pin *pin, PathEndVisitor *visitor, bool &is_constrained) { - ClockEdge *src_clk_edge = path->clkEdge(this); + const ClockEdge *src_clk_edge = path->clkEdge(this); if (src_clk_edge) { DataCheckSet *checks = sdc_->dataChecksTo(pin); if (checks) { diff --git a/search/WritePathSpice.cc b/search/WritePathSpice.cc index 7b5f0569..469ffd09 100644 --- a/search/WritePathSpice.cc +++ b/search/WritePathSpice.cc @@ -365,7 +365,7 @@ WritePathSpice::maxTime() TimingArc *next_arc = stageGateArc(input_stage + 1); float input_slew = findSlew(input_path, rf, next_arc); if (input_path->isClock(this)) { - Clock *clk = input_path->clock(this); + const Clock *clk = input_path->clock(this); float period = clk->period(); float first_edge_offset = period / 10; float max_time = period * clk_cycle_count_ + first_edge_offset; @@ -498,8 +498,8 @@ WritePathSpice::writeClkWaveform() Stage input_stage = stageFirst(); PathRef *input_path = stageDrvrPath(input_stage); TimingArc *next_arc = stageGateArc(input_stage + 1); - ClockEdge *clk_edge = input_path->clkEdge(this); - Clock *clk = clk_edge->clock(); + const ClockEdge *clk_edge = input_path->clkEdge(this); + const Clock *clk = clk_edge->clock(); float period = clk->period(); float time_offset = clkWaveformTImeOffset(clk); RiseFall *rf0, *rf1; @@ -790,7 +790,7 @@ WritePathSpice::writeGateStage(Stage stage) port_values.clear(); auto pin_iter = network_->connectedPinIterator(drvr_pin); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (pin != drvr_pin && pin != load_pin && network_->direction(pin)->isAnyInput() diff --git a/tcl/Cmds.tcl b/tcl/Cmds.tcl index 6528b553..d1a1b822 100644 --- a/tcl/Cmds.tcl +++ b/tcl/Cmds.tcl @@ -447,6 +447,7 @@ proc parse_corner_or_default { keys_var } { } } +# Return NULL for all. proc parse_corner_or_all { keys_var } { upvar 1 $keys_var keys diff --git a/tcl/Network.tcl b/tcl/Network.tcl index 8db521b5..b5f4e0cd 100644 --- a/tcl/Network.tcl +++ b/tcl/Network.tcl @@ -392,16 +392,17 @@ proc report_net_pin { pin verbose corner digits } { } elseif [$pin is_top_level_port] { set wire_cap "" set pin_cap "" + set corner [sta::cmd_corner] if { $verbose } { set port [$pin port] - set cap_min [port_ext_wire_cap $port "min"] - set cap_max [port_ext_wire_cap $port "max"] + set cap_min [port_ext_wire_cap $port $corner "min"] + set cap_max [port_ext_wire_cap $port $corner "max"] if { $cap_min > 0 || $cap_max > 0 } { set wire_cap " wire [capacitance_range_str $cap_min $cap_max $digits]" } - set cap_min [port_ext_pin_cap $port "min"] - set cap_max [port_ext_pin_cap $port "max"] + set cap_min [port_ext_pin_cap $port $corner "min"] + set cap_max [port_ext_pin_cap $port $corner "max"] if { $cap_min > 0 || $cap_max > 0} { set pin_cap " pin [capacitance_range_str $cap_min $cap_max $digits]" } diff --git a/tcl/Sdc.tcl b/tcl/Sdc.tcl index 2a67f711..af7a37d8 100644 --- a/tcl/Sdc.tcl +++ b/tcl/Sdc.tcl @@ -350,14 +350,7 @@ proc set_unit_values { unit key unit_name key_var } { define_cmd_args "all_clocks" {} proc all_clocks { } { - set clks {} - set clk_iter [clock_iterator] - while {[$clk_iter has_next]} { - set clk [$clk_iter next] - lappend clks $clk - } - $clk_iter finish - return $clks + return [get_clocks -quiet *] } ################################################################ @@ -2474,7 +2467,7 @@ proc set_input_transition { args } { ################################################################ define_cmd_args "set_load" \ - {[-rise] [-fall] [-max] [-min] [-subtract_pin_load]\ + {[-corner corner] [-rise] [-fall] [-max] [-min] [-subtract_pin_load]\ [-pin_load] [-wire_load] capacitance objects} proc set_load { args } { @@ -2499,11 +2492,11 @@ proc set_load { args } { # -pin_load is the default. if { $pin_load || (!$pin_load && !$wire_load) } { foreach port $ports { - set_port_pin_cap $port $tr $min_max $cap + set_port_ext_pin_cap $port $tr $corner $min_max $cap } } elseif { $wire_load } { foreach port $ports { - set_port_wire_cap $port $subtract_pin_load $tr $min_max $cap + set_port_ext_wire_cap $port $subtract_pin_load $tr $corner $min_max $cap } } } @@ -2668,10 +2661,10 @@ proc set_max_transition { args } { ################################################################ define_cmd_args "set_port_fanout_number" \ - {[-max] [-min] fanout ports} + {[-corner corner] [-max] [-min] fanout ports} proc set_port_fanout_number { args } { - parse_key_args "set_port_fanout_number" args keys {} flags {-max -min} + parse_key_args "set_port_fanout_number" args keys {-corner} flags {-max -min} set min_max [parse_min_max_all_check_flags flags] check_argc_eq2 "set_port_fanout_number" $args @@ -2679,8 +2672,9 @@ proc set_port_fanout_number { args } { set fanout [lindex $args 0] check_positive_integer "fanout" $fanout set ports [get_ports_error "ports" [lindex $args 1]] + set corner [parse_corner_or_all keys] foreach port $ports { - set_port_ext_fanout_cmd $port $fanout $min_max + set_port_ext_fanout_cmd $port $fanout $corner $min_max } } diff --git a/tcl/Search.tcl b/tcl/Search.tcl index 0ace5604..59fa0db8 100644 --- a/tcl/Search.tcl +++ b/tcl/Search.tcl @@ -231,13 +231,10 @@ proc report_delays_wrt_clks { pin_arg what } { if { $vertex != "NULL" } { report_delays_wrt_clk $vertex $what "NULL" "rise" report_delays_wrt_clk $vertex $what [default_arrival_clock] "rise" - set clk_iter [clock_iterator] - while {[$clk_iter has_next]} { - set clk [$clk_iter next] + foreach clk [all_clocks] { report_delays_wrt_clk $vertex $what $clk "rise" report_delays_wrt_clk $vertex $what $clk "fall" } - $clk_iter finish } } } @@ -266,13 +263,10 @@ proc report_wrt_clks { pin_arg what } { if { $vertex != "NULL" } { report_wrt_clk $vertex $what "NULL" "rise" report_wrt_clk $vertex $what [default_arrival_clock] "rise" - set clk_iter [clock_iterator] - while {[$clk_iter has_next]} { - set clk [$clk_iter next] + foreach clk [all_clocks] { report_wrt_clk $vertex $what $clk "rise" report_wrt_clk $vertex $what $clk "fall" } - $clk_iter finish } } } diff --git a/tcl/Sta.tcl b/tcl/Sta.tcl index 13f3b0ad..9a72b117 100644 --- a/tcl/Sta.tcl +++ b/tcl/Sta.tcl @@ -1375,12 +1375,9 @@ proc_redirect report_clock_properties { report_line "Clock Period Waveform" report_line "----------------------------------------------------" if { [llength $args] == 0 } { - set clk_iter [clock_iterator] - while {[$clk_iter has_next]} { - set clk [$clk_iter next] + foreach clk [all_clocks] { report_clock1 $clk } - $clk_iter finish } else { foreach clk [get_clocks_warn "clock_name" [lindex $args 0]] { report_clock1 $clk diff --git a/tcl/StaTcl.i b/tcl/StaTcl.i index 5ad09c97..b2a5c8fc 100644 --- a/tcl/StaTcl.i +++ b/tcl/StaTcl.i @@ -90,21 +90,10 @@ namespace sta { //////////////////////////////////////////////////////////////// typedef Vector LibrarySeq; -typedef CellSeq TmpCellSeq; -typedef LibertyCellSeq TmpLibertyCellSeq; -typedef PortSeq TmpPortSeq; -typedef LibertyPortSeq TmpLibertyPortSeq; -typedef PinSet TmpPinSet; -typedef PinSeq TmpPinSeq; -typedef InstanceSeq TmpInstanceSeq; -typedef InstanceSet TmpInstanceSet; typedef MinPulseWidthCheckSeq::Iterator MinPulseWidthCheckSeqIterator; -typedef FloatSeq TmpFloatSeq; typedef string TmpString; typedef Set StringSet; typedef MinMaxAll MinMaxAllNull; -typedef ClockSet TmpClockSet; -typedef StringSeq TmpStringSeq; using std::vector; @@ -177,30 +166,22 @@ tclListSeq(Tcl_Obj *const source, return nullptr; } -LibertyLibrarySeq * -tclListSeqLibertyLibrary(Tcl_Obj *const source, - Tcl_Interp *interp) -{ - return tclListSeq(source, SWIGTYPE_p_LibertyLibrary, interp); -} - -template -Set * +template +SET_TYPE * tclListSet(Tcl_Obj *const source, swig_type_info *swig_type, Tcl_Interp *interp) { int argc; Tcl_Obj **argv; - if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK && argc > 0) { - Set *set = new Set; + SET_TYPE *set = new SET_TYPE; for (int i = 0; i < argc; i++) { void *obj; // Ignore returned TCL_ERROR because can't get swig_type_info. SWIG_ConvertPtr(argv[i], &obj, swig_type, false); - set->insert(reinterpret_cast(obj)); + set->insert(reinterpret_cast(obj)); } return set; } @@ -208,11 +189,28 @@ tclListSet(Tcl_Obj *const source, return nullptr; } -PinSet * -tclListSetPin(Tcl_Obj *const source, - Tcl_Interp *interp) +template +SET_TYPE * +tclListNetworkSet(Tcl_Obj *const source, + swig_type_info *swig_type, + Tcl_Interp *interp, + const Network *network) { - return tclListSet(source, SWIGTYPE_p_Pin, interp); + int argc; + Tcl_Obj **argv; + if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK + && argc > 0) { + SET_TYPE *set = new SET_TYPE(network); + for (int i = 0; i < argc; i++) { + void *obj; + // Ignore returned TCL_ERROR because can't get swig_type_info. + SWIG_ConvertPtr(argv[i], &obj, swig_type, false); + set->insert(reinterpret_cast(obj)); + } + return set; + } + else + return nullptr; } StringSet * @@ -257,34 +255,89 @@ tclListSeqConstChar(Tcl_Obj *const source, //////////////////////////////////////////////////////////////// -TmpPinSet * +// Sequence out to tcl list. +template +void +seqPtrTclList(SEQ_TYPE *seq, + swig_type_info *swig_type, + Tcl_Interp *interp) +{ + Tcl_Obj *list = Tcl_NewListObj(0, nullptr); + for (const OBJECT_TYPE *obj : *seq) { + Tcl_Obj *tcl_obj = SWIG_NewInstanceObj(const_cast(obj), + swig_type, false); + Tcl_ListObjAppendElement(interp, list, tcl_obj); + } + Tcl_SetObjResult(interp, list); +} + +template +void +seqTclList(SEQ_TYPE &seq, + swig_type_info *swig_type, + Tcl_Interp *interp) +{ + Tcl_Obj *list = Tcl_NewListObj(0, nullptr); + for (const OBJECT_TYPE *obj : seq) { + Tcl_Obj *tcl_obj = SWIG_NewInstanceObj(const_cast(obj), + swig_type, false); + Tcl_ListObjAppendElement(interp, list, tcl_obj); + } + Tcl_SetObjResult(interp, list); +} + +template +void +setTclList(SET_TYPE set, + swig_type_info *swig_type, + Tcl_Interp *interp) +{ + Tcl_Obj *list = Tcl_NewListObj(0, nullptr); + for (const OBJECT_TYPE *obj : set) { + Tcl_Obj *tcl_obj = SWIG_NewInstanceObj(const_cast(obj), + swig_type, false); + Tcl_ListObjAppendElement(interp, list, tcl_obj); + } + Tcl_SetObjResult(interp, list); +} + +template +void +setPtrTclList(SET_TYPE *set, + swig_type_info *swig_type, + Tcl_Interp *interp) +{ + Tcl_Obj *list = Tcl_NewListObj(0, nullptr); + for (const OBJECT_TYPE *obj : *set) { + Tcl_Obj *tcl_obj = SWIG_NewInstanceObj(const_cast(obj), + swig_type, false); + Tcl_ListObjAppendElement(interp, list, tcl_obj); + } + Tcl_SetObjResult(interp, list); +} + +//////////////////////////////////////////////////////////////// + +PinSet findStartpoints() { - PinSet *pins = new PinSet; + Network *network = cmdNetwork(); + PinSet pins(network); VertexPinCollector visitor(pins); Sta::sta()->visitStartpoints(&visitor); return pins; } -TmpPinSet * +PinSet findEndpoints() { - PinSet *pins = new PinSet; + Network *network = cmdNetwork(); + PinSet pins(network); VertexPinCollector visitor(pins); Sta::sta()->visitEndpoints(&visitor); return pins; } -void -pushPowerResultFloats(PowerResult &power, - TmpFloatSeq *floats) -{ - floats->push_back(power.internal()); - floats->push_back(power.switching()); - floats->push_back(power.leakage()); - floats->push_back(power.total()); -} - //////////////////////////////////////////////////////////////// void @@ -367,26 +420,21 @@ using namespace sta; %typemap(out) StringSeq* { StringSeq *strs = $1; Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - StringSeq::Iterator str_iter(strs); - while (str_iter.hasNext()) { - const char *str = str_iter.next(); + for (const char *str : *strs) { Tcl_Obj *obj = Tcl_NewStringObj(str, strlen(str)); Tcl_ListObjAppendElement(interp, list, obj); } Tcl_SetObjResult(interp, list); } -%typemap(out) TmpStringSeq* { - StringSeq *strs = $1; +%typemap(out) StringSeq { + StringSeq &strs = $1; Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - StringSeq::Iterator str_iter(strs); - while (str_iter.hasNext()) { - const char *str = str_iter.next(); + for (const char *str : strs) { Tcl_Obj *obj = Tcl_NewStringObj(str, strlen(str)); Tcl_ListObjAppendElement(interp, list, obj); } Tcl_SetObjResult(interp, list); - delete strs; } %typemap(out) Library* { @@ -409,60 +457,24 @@ using namespace sta; Tcl_SetObjResult(interp, obj); } -%typemap(out) CellSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - CellSeq *cells = $1; - CellSeq::Iterator cell_iter(cells); - while (cell_iter.hasNext()) { - Cell *cell = cell_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(cell, SWIGTYPE_p_Cell, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - Tcl_SetObjResult(interp, list); -} - %typemap(in) CellSeq* { $1 = tclListSeq($input, SWIGTYPE_p_Cell, interp); } -%typemap(out) TmpCellSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - CellSeq *cells = $1; - CellSeq::Iterator cell_iter(cells); - while (cell_iter.hasNext()) { - Cell *cell = cell_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(cell, SWIGTYPE_p_Cell, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - Tcl_SetObjResult(interp, list); - delete cells; +%typemap(out) CellSeq { + seqTclList($1, SWIGTYPE_p_Cell, interp); } -%typemap(out) LibertyCellSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - LibertyCellSeq *cells = $1; - LibertyCellSeq::Iterator cell_iter(cells); - while (cell_iter.hasNext()) { - LibertyCell *cell = cell_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(cell, SWIGTYPE_p_LibertyCell, - false); - Tcl_ListObjAppendElement(interp, list, obj); - } - Tcl_SetObjResult(interp, list); +%typemap(out) LibertyCellSeq * { + seqPtrTclList($1, SWIGTYPE_p_LibertyCell, interp); } -%typemap(out) TmpLibertyCellSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - LibertyCellSeq *cells = $1; - LibertyCellSeq::Iterator cell_iter(cells); - while (cell_iter.hasNext()) { - LibertyCell *cell = cell_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(cell, SWIGTYPE_p_LibertyCell, - false); - Tcl_ListObjAppendElement(interp, list, obj); - } - Tcl_SetObjResult(interp, list); - delete cells; +%typemap(out) LibertyCellSeq { + seqTclList($1, SWIGTYPE_p_LibertyCell, interp); +} + +%typemap(out) LibertyPortSeq { + seqTclList($1, SWIGTYPE_p_LibertyPort, interp); } %typemap(out) CellPortIterator* { @@ -480,65 +492,12 @@ using namespace sta; Tcl_SetObjResult(interp, obj); } -%typemap(in) PortSet* { - $1 = tclListSet($input, SWIGTYPE_p_Port, interp); -} - %typemap(in) PortSeq* { - $1 = tclListSeq($input, SWIGTYPE_p_Port, interp); + $1 = tclListSeq($input, SWIGTYPE_p_Port, interp); } -%typemap(out) TmpPortSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - TmpPortSeq *ports = $1; - TmpPortSeq::Iterator port_iter(ports); - while (port_iter.hasNext()) { - Port *port = port_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(port, SWIGTYPE_p_Port, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete ports; - Tcl_SetObjResult(interp, list); -} - -%typemap(out) TmpLibertyPortSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - TmpLibertyPortSeq *ports = $1; - TmpLibertyPortSeq::Iterator port_iter(ports); - while (port_iter.hasNext()) { - LibertyPort *port = port_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(port, SWIGTYPE_p_LibertyPort, - false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete ports; - Tcl_SetObjResult(interp, list); -} - -%typemap(out) TmpPinSet* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - PinSet *pins = $1; - PinSet::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(pin, SWIGTYPE_p_Pin, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete pins; - Tcl_SetObjResult(interp, list); -} - -%typemap(out) TmpPinSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - PinSeq *pins = $1; - PinSeq::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(pin, SWIGTYPE_p_Pin, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete pins; - Tcl_SetObjResult(interp, list); +%typemap(out) PortSeq { + seqTclList($1, SWIGTYPE_p_Port, interp); } %typemap(out) PortMemberIterator* { @@ -557,9 +516,7 @@ using namespace sta; } %typemap(out) LibertyPortMemberIterator* { - Tcl_Obj *obj = SWIG_NewInstanceObj($1, - SWIGTYPE_p_LibertyPortMemberIterator, - false); + Tcl_Obj *obj = SWIG_NewInstanceObj($1, SWIGTYPE_p_LibertyPortMemberIterator, false); Tcl_SetObjResult(interp, obj); } @@ -568,24 +525,12 @@ using namespace sta; Tcl_SetObjResult(interp, obj); } -%typemap(out) const TimingArcSetSeq& { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - const TimingArcSetSeq *arc_sets = $1; - for (TimingArcSet *arc_set : *arc_sets) { - Tcl_Obj *obj = SWIG_NewInstanceObj(arc_set, SWIGTYPE_p_TimingArcSet, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - Tcl_SetObjResult(interp, list); +%typemap(out) TimingArcSetSeq& { + seqPtrTclList($1, SWIGTYPE_p_TimingArcSet, interp); } -%typemap(out) const TimingArcSeq& { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - const TimingArcSeq *arcs = $1; - for (TimingArc *arc : *arcs) { - Tcl_Obj *obj = SWIG_NewInstanceObj(arc, SWIGTYPE_p_TimingArc, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - Tcl_SetObjResult(interp, list); +%typemap(out) TimingArcSeq& { + seqPtrTclList($1, SWIGTYPE_p_TimingArc, interp); } %typemap(out) Wireload* { @@ -719,20 +664,11 @@ using namespace sta; } %typemap(in) InstanceSeq* { - $1 = tclListSeq($input, SWIGTYPE_p_Instance, interp); + $1 = tclListSeq($input, SWIGTYPE_p_Instance, interp); } -%typemap(out) TmpInstanceSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - TmpInstanceSeq *insts = $1; - TmpInstanceSeq::Iterator inst_iter(insts); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(inst, SWIGTYPE_p_Instance,false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete insts; - Tcl_SetObjResult(interp, list); +%typemap(out) InstanceSeq { + seqTclList($1, SWIGTYPE_p_Instance, interp); } %typemap(out) InstanceChildIterator* { @@ -761,16 +697,12 @@ using namespace sta; } %typemap(out) PinSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - PinSeq *pins = $1; - PinSeq::Iterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(pin, SWIGTYPE_p_Pin, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete pins; - Tcl_SetObjResult(interp, list); + seqPtrTclList($1, SWIGTYPE_p_Pin, interp); +} + + +%typemap(out) PinSeq { + seqTclList($1, SWIGTYPE_p_Pin, interp); } %typemap(out) Net* { @@ -779,16 +711,11 @@ using namespace sta; } %typemap(out) NetSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - NetSeq *nets = $1; - NetSeq::Iterator net_iter(nets); - while (net_iter.hasNext()) { - Net *net = net_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(net, SWIGTYPE_p_Net, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete nets; - Tcl_SetObjResult(interp, list); + seqPtrTclList($1, SWIGTYPE_p_Net, interp); +} + +%typemap(out) NetSeq { + seqTclList($1, SWIGTYPE_p_Net, interp); } %typemap(out) NetPinIterator* { @@ -817,21 +744,11 @@ using namespace sta; } %typemap(out) ClockSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - ClockSeq *clks = $1; - ClockSeq::Iterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(clk, SWIGTYPE_p_Clock, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete clks; - Tcl_SetObjResult(interp, list); + seqPtrTclList($1, SWIGTYPE_p_Clock, interp); } -%typemap(out) ClockIterator* { - Tcl_Obj *obj = SWIG_NewInstanceObj($1, $1_descriptor, false); - Tcl_SetObjResult(interp, obj); +%typemap(out) ClockSeq { + seqTclList($1, SWIGTYPE_p_Clock, interp); } %typemap(out) ClockEdge* { @@ -839,6 +756,57 @@ using namespace sta; Tcl_SetObjResult(interp, obj); } +%typemap(in) PinSeq* { + $1 = tclListSeq($input, SWIGTYPE_p_Pin, interp); +} + +%typemap(in) PinSet* { + Network *network = cmdNetwork(); + $1 = tclListNetworkSet($input, SWIGTYPE_p_Pin, interp, network); +} + +%typemap(out) PinSet* { + setPtrTclList($1, SWIGTYPE_p_Pin, interp); +} + +%typemap(out) PinSet { + setTclList($1, SWIGTYPE_p_Pin, interp); +} + +%typemap(out) const PinSet& { + Tcl_Obj *list = Tcl_NewListObj(0, nullptr); + // A swig bug sets the result to PinSet* rather than const PinSet&. + PinSet *pins = $1; + for (const Pin *pin : *pins) { + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(pin), SWIGTYPE_p_Pin, false); + Tcl_ListObjAppendElement(interp, list, obj); + } + Tcl_SetObjResult(interp, list); +} + +%typemap(in) ClockSet* { + $1 = tclListSet($input, SWIGTYPE_p_Clock, interp); +} + +%typemap(out) ClockSet* { + setPtrTclList($1, SWIGTYPE_p_Clock, interp); +} + +%typemap(in) InstanceSet* { + Network *network = cmdNetwork(); + $1 = tclListNetworkSet($input, SWIGTYPE_p_Instance, + interp, network); +} + +%typemap(out) InstanceSet { + setTclList($1, SWIGTYPE_p_Instance, interp); +} + +%typemap(in) NetSet* { + Network *network = cmdNetwork(); + $1 = tclListNetworkSet($input, SWIGTYPE_p_Net, interp, network); +} + %typemap(in) FloatSeq* { int argc; Tcl_Obj **argv; @@ -866,23 +834,20 @@ using namespace sta; FloatSeq *floats = $1; Tcl_Obj *list = Tcl_NewListObj(0, nullptr); if (floats) { - for (unsigned i = 0; i < floats->size(); i++) { - Tcl_Obj *obj = Tcl_NewDoubleObj((*floats)[i]); + for (float f : *floats) { + Tcl_Obj *obj = Tcl_NewDoubleObj(f); Tcl_ListObjAppendElement(interp, list, obj); } } Tcl_SetObjResult(interp, list); } -%typemap(out) TmpFloatSeq* { - FloatSeq *floats = $1; +%typemap(out) FloatSeq { + FloatSeq &floats = $1; Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - if (floats) { - for (unsigned i = 0; i < floats->size(); i++) { - Tcl_Obj *obj = Tcl_NewDoubleObj((*floats)[i]); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete floats; + for (float f : floats) { + Tcl_Obj *obj = Tcl_NewDoubleObj(f); + Tcl_ListObjAppendElement(interp, list, obj); } Tcl_SetObjResult(interp, list); } @@ -1102,96 +1067,6 @@ using namespace sta; } } -%typemap(in) PinSeq* { - $1 = tclListSeq($input, SWIGTYPE_p_Pin, interp); -} - -%typemap(in) PinSet* { - $1 = tclListSetPin($input, interp); -} - -%typemap(out) PinSet* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - const PinSet *pins = $1; - if (pins) { - PinSet::ConstIterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(pin, SWIGTYPE_p_Pin, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - } - Tcl_SetObjResult(interp, list); -} - -%typemap(out) PinSet& { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - const PinSet *pins = $1; - if (pins) { - PinSet::ConstIterator pin_iter(pins); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(pin, SWIGTYPE_p_Pin, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - } - Tcl_SetObjResult(interp, list); -} - -%typemap(in) ClockSet* { - $1 = tclListSet($input, SWIGTYPE_p_Clock, interp); -} - -%typemap(out) ClockSet* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - const ClockSet *clks = $1; - if (clks) { - ClockSet::ConstIterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(clk, SWIGTYPE_p_Clock, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - } - Tcl_SetObjResult(interp, list); -} - -%typemap(out) TmpClockSet* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - const ClockSet *clks = $1; - if (clks) { - ClockSet::ConstIterator clk_iter(clks); - while (clk_iter.hasNext()) { - Clock *clk = clk_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(clk, SWIGTYPE_p_Clock, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete clks; - } - Tcl_SetObjResult(interp, list); -} - -%typemap(in) InstanceSet* { - $1 = tclListSet($input, SWIGTYPE_p_Instance, interp); -} - -%typemap(out) TmpInstanceSet* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - InstanceSet *insts = $1; - InstanceSet::Iterator inst_iter(insts); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(inst, SWIGTYPE_p_Instance,false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete insts; - Tcl_SetObjResult(interp, list); -} - -%typemap(in) NetSet* { - $1 = tclListSet($input, SWIGTYPE_p_Net, interp); -} - %typemap(in) ExceptionThruSeq* { $1 = tclListSeq($input, SWIGTYPE_p_ExceptionThru, interp); } @@ -1213,26 +1088,17 @@ using namespace sta; Tcl_SetObjResult(interp, list); } -%typemap(in) EdgeSeq* { - $1 = tclListSeq($input, SWIGTYPE_p_Edge, interp); -} - %typemap(out) Edge* { Tcl_Obj *obj = SWIG_NewInstanceObj($1, $1_descriptor, false); Tcl_SetObjResult(interp, obj); } -%typemap(out) EdgeSeq* { - Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - EdgeSeq *edges = $1; - EdgeSeq::Iterator edge_iter(edges); - while (edge_iter.hasNext()) { - Edge *edge = edge_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(edge, SWIGTYPE_p_Edge, false); - Tcl_ListObjAppendElement(interp, list, obj); - } - delete edges; - Tcl_SetObjResult(interp, list); +%typemap(in) EdgeSeq* { + $1 = tclListSeq($input, SWIGTYPE_p_Edge, interp); +} + +%typemap(out) EdgeSeq { + seqTclList($1, SWIGTYPE_p_Edge, interp); } %typemap(out) VertexIterator* { @@ -1434,49 +1300,50 @@ using namespace sta; } break; case PropertyValue::Type::type_library: { - Tcl_Obj *obj = SWIG_NewInstanceObj(value.library(), + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(value.library()), SWIGTYPE_p_Library, false); Tcl_SetObjResult(interp, obj); } break; case PropertyValue::Type::type_cell: { - Tcl_Obj *obj = SWIG_NewInstanceObj(value.cell(), + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(value.cell()), SWIGTYPE_p_Cell, false); Tcl_SetObjResult(interp, obj); } break; case PropertyValue::Type::type_port: { - Tcl_Obj *obj = SWIG_NewInstanceObj(value.port(), + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(value.port()), SWIGTYPE_p_Port, false); Tcl_SetObjResult(interp, obj); } break; case PropertyValue::Type::type_liberty_library: { - Tcl_Obj *obj = SWIG_NewInstanceObj(value.libertyLibrary(), + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(value.libertyLibrary()), SWIGTYPE_p_LibertyLibrary, false); Tcl_SetObjResult(interp, obj); } break; case PropertyValue::Type::type_liberty_cell: { - Tcl_Obj *obj = SWIG_NewInstanceObj(value.libertyCell(), + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(value.libertyCell()), SWIGTYPE_p_LibertyCell, false); Tcl_SetObjResult(interp, obj); } break; case PropertyValue::Type::type_liberty_port: { - Tcl_Obj *obj = SWIG_NewInstanceObj(value.libertyPort(), + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(value.libertyPort()), SWIGTYPE_p_LibertyPort, false); Tcl_SetObjResult(interp, obj); } break; case PropertyValue::Type::type_instance: { - Tcl_Obj *obj = SWIG_NewInstanceObj(value.instance(), + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(value.instance()), SWIGTYPE_p_Instance, false); Tcl_SetObjResult(interp, obj); } break; case PropertyValue::Type::type_pin: { - Tcl_Obj *obj = SWIG_NewInstanceObj(value.pin(), SWIGTYPE_p_Pin, false); + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(value.pin()), + SWIGTYPE_p_Pin, false); Tcl_SetObjResult(interp, obj); } break; @@ -1485,21 +1352,21 @@ using namespace sta; PinSeq *pins = value.pins(); PinSeq::Iterator pin_iter(pins); while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); - Tcl_Obj *obj = SWIG_NewInstanceObj(pin, SWIGTYPE_p_Pin, false); + const Pin *pin = pin_iter.next(); + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(pin), SWIGTYPE_p_Pin, false); Tcl_ListObjAppendElement(interp, list, obj); } Tcl_SetObjResult(interp, list); } break; case PropertyValue::Type::type_net: { - Tcl_Obj *obj = SWIG_NewInstanceObj(value.net(), + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(value.net()), SWIGTYPE_p_Net, false); Tcl_SetObjResult(interp, obj); } break; case PropertyValue::Type::type_clk: { - Tcl_Obj *obj = SWIG_NewInstanceObj(value.clock(), + Tcl_Obj *obj = SWIG_NewInstanceObj(const_cast(value.clock()), SWIGTYPE_p_Clock, false); Tcl_SetObjResult(interp, obj); } @@ -1518,10 +1385,7 @@ using namespace sta; break; case PropertyValue::Type::type_path_refs: { Tcl_Obj *list = Tcl_NewListObj(0, nullptr); - PathRefSeq *paths = value.pathRefs(); - PathRefSeq::Iterator path_iter(paths); - while (path_iter.hasNext()) { - PathRef &path = path_iter.next(); + for (PathRef &path : *value.pathRefs()) { PathRef *copy = new PathRef(path); Tcl_Obj *obj = SWIG_NewInstanceObj(copy, SWIGTYPE_p_PathRef, false); Tcl_ListObjAppendElement(interp, list, obj); @@ -1770,13 +1634,6 @@ private: ~Clock(); }; -class ClockIterator -{ -private: - ClockIterator(); - ~ClockIterator(); -}; - class ClockEdge { private: @@ -2204,21 +2061,23 @@ find_liberty_cell(const char *name) return cmdNetwork()->findLibertyCell(name); } -TmpCellSeq * +CellSeq find_cells_matching(const char *pattern, bool regexp, bool nocase) { Network *network = cmdNetwork(); PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); - TmpCellSeq *cells = new TmpCellSeq; + CellSeq matches; LibraryIterator *lib_iter = network->libraryIterator(); while (lib_iter->hasNext()) { Library *lib = lib_iter->next(); - network->findCellsMatching(lib, &matcher, cells); + CellSeq lib_matches = network->findCellsMatching(lib, &matcher); + for (Cell *match : lib_matches) + matches.push_back(match); } delete lib_iter; - return cells; + return matches; } LibertyCellSeq * @@ -2315,7 +2174,7 @@ pin_direction(const Pin *pin) return cmdLinkedNetwork()->direction(pin)->name(); } -TmpPortSeq * +PortSeq find_ports_matching(const char *pattern, bool regexp, bool nocase) @@ -2323,43 +2182,37 @@ find_ports_matching(const char *pattern, Network *network = cmdLinkedNetwork(); PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); Cell *top_cell = network->cell(network->topInstance()); - PortSeq ports1; - network->findPortsMatching(top_cell, &matcher, &ports1); + PortSeq matches1 = network->findPortsMatching(top_cell, &matcher); // Expand bus/bundle ports. - TmpPortSeq *ports = new TmpPortSeq; - PortSeq::Iterator port_iter(ports1); - while (port_iter.hasNext()) { - Port *port = port_iter.next(); + PortSeq matches; + for (const Port *port : matches1) { if (network->isBus(port) || network->isBundle(port)) { PortMemberIterator *member_iter = network->memberIterator(port); while (member_iter->hasNext()) { Port *member = member_iter->next(); - ports->push_back(member); + matches.push_back(member); } delete member_iter; } else - ports->push_back(port); + matches.push_back(port); } - return ports; + return matches; } -TmpPinSeq * +PinSeq find_port_pins_matching(const char *pattern, bool regexp, bool nocase) { Network *network = cmdLinkedNetwork(); PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); - PortSeq ports; Instance *top_inst = network->topInstance(); Cell *top_cell = network->cell(top_inst); - network->findPortsMatching(top_cell, &matcher, &ports); - TmpPinSeq *pins = new TmpPinSeq; - PortSeq::Iterator port_iter(ports); - while (port_iter.hasNext()) { - Port *port = port_iter.next(); + PortSeq ports = network->findPortsMatching(top_cell, &matcher); + PinSeq pins; + for (const Port *port : ports) { if (network->isBus(port) || network->isBundle(port)) { PortMemberIterator *member_iter = network->memberIterator(port); @@ -2367,14 +2220,14 @@ find_port_pins_matching(const char *pattern, Port *member = member_iter->next(); Pin *pin = network->findPin(top_inst, member); if (pin) - pins->push_back(pin); + pins.push_back(pin); } delete member_iter; } else { Pin *pin = network->findPin(top_inst, port); if (pin) - pins->push_back(pin); + pins.push_back(pin); } } return pins; @@ -2393,7 +2246,7 @@ get_port_pin(const Port *port) return network->findPin(network->topInstance(), port); } -TmpPinSeq * +PinSeq find_pins_matching(const char *pattern, bool regexp, bool nocase) @@ -2402,12 +2255,11 @@ find_pins_matching(const char *pattern, Network *network = cmdLinkedNetwork(); PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); Instance *current_instance = sta->currentInstance(); - TmpPinSeq *pins = new TmpPinSeq; - network->findPinsMatching(current_instance, &matcher, pins); - return pins; + PinSeq matches = network->findPinsMatching(current_instance, &matcher); + return matches; } -TmpPinSeq * +PinSeq find_pins_hier_matching(const char *pattern, bool regexp, bool nocase) @@ -2416,9 +2268,8 @@ find_pins_hier_matching(const char *pattern, Network *network = cmdLinkedNetwork(); Instance *current_instance = sta->currentInstance(); PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); - TmpPinSeq *pins = new TmpPinSeq; - network->findPinsHierMatching(current_instance, &matcher, pins); - return pins; + PinSeq matches = network->findPinsHierMatching(current_instance, &matcher); + return matches; } Instance * @@ -2427,20 +2278,20 @@ find_instance(char *path_name) return cmdLinkedNetwork()->findInstance(path_name); } -TmpInstanceSeq * +InstanceSeq network_leaf_instances() { - InstanceSeq *insts = new InstanceSeq; + InstanceSeq insts; LeafInstanceIterator *iter = cmdLinkedNetwork()->leafInstanceIterator(); while (iter->hasNext()) { - Instance *inst = iter->next(); - insts->push_back(inst); + const Instance *inst = iter->next(); + insts.push_back(inst); } delete iter; return insts; } -TmpInstanceSeq * +InstanceSeq find_instances_matching(const char *pattern, bool regexp, bool nocase) @@ -2448,12 +2299,12 @@ find_instances_matching(const char *pattern, Sta *sta = Sta::sta(); Instance *current_instance = sta->currentInstance(); PatternMatch matcher(pattern, regexp, nocase, sta->tclInterp()); - TmpInstanceSeq *insts = new InstanceSeq; - cmdLinkedNetwork()->findInstancesMatching(current_instance, &matcher, insts); - return insts; + Network *network = cmdLinkedNetwork(); + InstanceSeq matches = network->findInstancesMatching(current_instance, &matcher); + return matches; } -TmpInstanceSeq * +InstanceSeq find_instances_hier_matching(const char *pattern, bool regexp, bool nocase) @@ -2462,73 +2313,72 @@ find_instances_hier_matching(const char *pattern, Network *network = cmdLinkedNetwork(); Instance *current_instance = sta->currentInstance(); PatternMatch matcher(pattern, regexp, nocase, sta->tclInterp()); - TmpInstanceSeq *insts = new InstanceSeq; - network->findInstancesHierMatching(current_instance, &matcher, insts); - return insts; + InstanceSeq matches = network->findInstancesHierMatching(current_instance, &matcher); + return matches; } -TmpInstanceSet * +InstanceSet find_register_instances(ClockSet *clks, const RiseFallBoth *clk_tr, bool edge_triggered, bool latches) { cmdLinkedNetwork(); - InstanceSet *insts = Sta::sta()->findRegisterInstances(clks, clk_tr, - edge_triggered, - latches); + InstanceSet insts = Sta::sta()->findRegisterInstances(clks, clk_tr, + edge_triggered, + latches); delete clks; return insts; } -TmpPinSet * +PinSet find_register_data_pins(ClockSet *clks, const RiseFallBoth *clk_tr, bool edge_triggered, bool latches) { cmdLinkedNetwork(); - PinSet *pins = Sta::sta()->findRegisterDataPins(clks, clk_tr, - edge_triggered, latches); + PinSet pins = Sta::sta()->findRegisterDataPins(clks, clk_tr, + edge_triggered, latches); delete clks; return pins; } -TmpPinSet * +PinSet find_register_clk_pins(ClockSet *clks, const RiseFallBoth *clk_tr, bool edge_triggered, bool latches) { cmdLinkedNetwork(); - PinSet *pins = Sta::sta()->findRegisterClkPins(clks, clk_tr, - edge_triggered, latches); + PinSet pins = Sta::sta()->findRegisterClkPins(clks, clk_tr, + edge_triggered, latches); delete clks; return pins; } -TmpPinSet * +PinSet find_register_async_pins(ClockSet *clks, const RiseFallBoth *clk_tr, bool edge_triggered, bool latches) { cmdLinkedNetwork(); - PinSet *pins = Sta::sta()->findRegisterAsyncPins(clks, clk_tr, - edge_triggered, latches); + PinSet pins = Sta::sta()->findRegisterAsyncPins(clks, clk_tr, + edge_triggered, latches); delete clks; return pins; } -TmpPinSet * +PinSet find_register_output_pins(ClockSet *clks, const RiseFallBoth *clk_tr, bool edge_triggered, bool latches) { cmdLinkedNetwork(); - PinSet *pins = Sta::sta()->findRegisterOutputPins(clks, clk_tr, - edge_triggered, latches); + PinSet pins = Sta::sta()->findRegisterOutputPins(clks, clk_tr, + edge_triggered, latches); delete clks; return pins; } @@ -2539,7 +2389,7 @@ find_net(char *path_name) return cmdLinkedNetwork()->findNet(path_name); } -NetSeq * +NetSeq find_nets_matching(const char *pattern, bool regexp, bool nocase) @@ -2547,12 +2397,11 @@ find_nets_matching(const char *pattern, Network *network = cmdLinkedNetwork(); Instance *current_instance = Sta::sta()->currentInstance(); PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); - NetSeq *nets = new NetSeq; - network->findNetsMatching(current_instance, &matcher, nets); - return nets; + NetSeq matches = network->findNetsMatching(current_instance, &matcher); + return matches; } -NetSeq * +NetSeq find_nets_hier_matching(const char *pattern, bool regexp, bool nocase) @@ -2560,35 +2409,32 @@ find_nets_hier_matching(const char *pattern, Network *network = cmdLinkedNetwork(); Instance *current_instance = Sta::sta()->currentInstance(); PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); - NetSeq *nets = new NetSeq; - network->findNetsHierMatching(current_instance, &matcher, nets); - return nets; + NetSeq matches = network->findNetsHierMatching(current_instance, &matcher); + return matches; } -TmpPortSeq * +PortSeq filter_ports(const char *property, const char *op, const char *pattern, PortSeq *ports) { Sta *sta = Sta::sta(); - TmpPortSeq *filtered_ports = new TmpPortSeq; - PortSeq::Iterator port_iter(ports); + PortSeq filtered_ports; bool exact_match = stringEq(op, "=="); - while (port_iter.hasNext()) { - Port *port = port_iter.next(); + for (const Port *port : *ports) { PropertyValue value(getProperty(port, property, sta)); const char *prop = value.stringValue(); if (prop && ((exact_match && stringEq(prop, pattern)) || (!exact_match && patternMatch(pattern, prop)))) - filtered_ports->push_back(port); + filtered_ports.push_back(port); } delete ports; return filtered_ports; } -TmpInstanceSeq * +InstanceSeq filter_insts(const char *property, const char *op, const char *pattern, @@ -2596,40 +2442,36 @@ filter_insts(const char *property, { Sta *sta = Sta::sta(); cmdLinkedNetwork(); - TmpInstanceSeq *filtered_insts = new TmpInstanceSeq; - TmpInstanceSeq::Iterator inst_iter(insts); bool exact_match = stringEq(op, "=="); - while (inst_iter.hasNext()) { - Instance *inst = inst_iter.next(); + InstanceSeq filtered_insts; + for (const Instance *inst : *insts) { PropertyValue value(getProperty(inst, property, sta)); const char *prop = value.stringValue(); if (prop && ((exact_match && stringEq(prop, pattern)) || (!exact_match && patternMatch(pattern, prop)))) - filtered_insts->push_back(inst); + filtered_insts.push_back(inst); } delete insts; return filtered_insts; } -PinSeq * +PinSeq filter_pins(const char *property, const char *op, const char *pattern, PinSeq *pins) { Sta *sta = Sta::sta(); - PinSeq *filtered_pins = new PinSeq; - PinSeq::Iterator pin_iter(pins); + PinSeq filtered_pins; bool exact_match = stringEq(op, "=="); - while (pin_iter.hasNext()) { - Pin *pin = pin_iter.next(); + for (const Pin *pin : *pins) { PropertyValue value(getProperty(pin, property, sta)); const char *prop = value.stringValue(); if (prop && ((exact_match && stringEq(prop, pattern)) || (!exact_match && patternMatch(pattern, prop)))) - filtered_pins->push_back(pin); + filtered_pins.push_back(pin); } delete pins; return filtered_pins; @@ -2820,24 +2662,22 @@ set_operating_conditions_cmd(OperatingConditions *op_cond, Sta::sta()->setOperatingConditions(op_cond, min_max); } -EdgeSeq * +EdgeSeq filter_timing_arcs(const char *property, const char *op, const char *pattern, EdgeSeq *edges) { Sta *sta = Sta::sta(); - EdgeSeq *filtered_edges = new EdgeSeq; - EdgeSeq::Iterator edge_iter(edges); + EdgeSeq filtered_edges; bool exact_match = stringEq(op, "=="); - while (edge_iter.hasNext()) { - Edge *edge = edge_iter.next(); + for (Edge *edge : *edges) { PropertyValue value(getProperty(edge, property, sta)); const char *prop = value.stringValue(); if (prop && ((exact_match && stringEq(prop, pattern)) || (!exact_match && patternMatch(pattern, prop)))) - filtered_edges->push_back(edge); + filtered_edges.push_back(edge); } delete edges; return filtered_edges; @@ -2866,74 +2706,80 @@ set_instance_pvt(Instance *inst, float temperature) { cmdLinkedNetwork(); - Pvt *pvt = new Pvt(process, voltage, temperature); + Pvt pvt(process, voltage, temperature); Sta::sta()->setPvt(inst, min_max, pvt); } float -port_ext_pin_cap(Port *port, +port_ext_pin_cap(const Port *port, + const Corner *corner, const MinMax *min_max) { cmdLinkedNetwork(); float pin_cap, wire_cap; int fanout; - Sta::sta()->portExtCaps(port, min_max, pin_cap, wire_cap, fanout); + Sta::sta()->portExtCaps(port, corner, min_max, pin_cap, wire_cap, fanout); return pin_cap; } void -set_port_pin_cap(Port *port, - const RiseFallBoth *rf, - const MinMaxAll *min_max, - float cap) +set_port_ext_pin_cap(const Port *port, + const RiseFallBoth *rf, + const Corner *corner, + const MinMaxAll *min_max, + float cap) { - Sta::sta()->setPortExtPinCap(port, rf, min_max, cap); + Sta::sta()->setPortExtPinCap(port, rf, corner, min_max, cap); } float -port_ext_wire_cap(Port *port, +port_ext_wire_cap(const Port *port, + const Corner *corner, const MinMax *min_max) { cmdLinkedNetwork(); float pin_cap, wire_cap; int fanout; - Sta::sta()->portExtCaps(port, min_max, pin_cap, wire_cap, fanout); + Sta::sta()->portExtCaps(port, corner, min_max, pin_cap, wire_cap, fanout); return wire_cap; } void -set_port_wire_cap(Port *port, - bool subtract_pin_cap, - const RiseFallBoth *rf, - const MinMaxAll *min_max, - float cap) +set_port_ext_wire_cap(const Port *port, + bool subtract_pin_cap, + const RiseFallBoth *rf, + const Corner *corner, + const MinMaxAll *min_max, + float cap) { - Sta::sta()->setPortExtWireCap(port, subtract_pin_cap, rf, min_max, cap); + Sta::sta()->setPortExtWireCap(port, subtract_pin_cap, rf, corner, min_max, cap); } void -set_port_ext_fanout_cmd(Port *port, +set_port_ext_fanout_cmd(const Port *port, int fanout, + const Corner *corner, const MinMaxAll *min_max) { - Sta::sta()->setPortExtFanout(port, fanout, min_max); + Sta::sta()->setPortExtFanout(port, fanout, corner, min_max); } float -port_ext_fanout(Port *port, +port_ext_fanout(const Port *port, + const Corner *corner, const MinMax *min_max) { cmdLinkedNetwork(); float pin_cap, wire_cap; int fanout; - Sta::sta()->portExtCaps(port, min_max, pin_cap, wire_cap, fanout); + Sta::sta()->portExtCaps(port, corner, min_max, pin_cap, wire_cap, fanout); return fanout; } void -set_net_wire_cap(Net *net, +set_net_wire_cap(const Net *net, bool subtract_pin_cap, - Corner *corner, + const Corner *corner, const MinMaxAll *min_max, float cap) { @@ -3779,12 +3625,6 @@ unset_timing_derate_cmd() Sta::sta()->unsetTimingDerate(); } -ClockIterator * -clock_iterator() -{ - return new ClockIterator(Sta::sta()->sdc()); -} - Clock * find_clock(const char *name) { @@ -3804,18 +3644,16 @@ default_arrival_clock() return Sta::sta()->sdc()->defaultArrivalClock(); } -ClockSeq * +ClockSeq find_clocks_matching(const char *pattern, bool regexp, bool nocase) { cmdLinkedNetwork(); - ClockSeq *clks = new ClockSeq; Sta *sta = Sta::sta(); Sdc *sdc = sta->sdc(); PatternMatch matcher(pattern, regexp, nocase, sta->tclInterp()); - sdc->findClocksMatching(&matcher, clks); - return clks; + return sdc->findClocksMatching(&matcher); } void @@ -4481,19 +4319,19 @@ worst_clk_skew_cmd(const SetupHold *setup_hold) return Sta::sta()->findWorstClkSkew(setup_hold); } -TmpPinSet * +PinSet startpoints() { return findStartpoints(); } -TmpPinSet * +PinSet endpoints() { return findEndpoints(); } -TmpPinSet * +PinSet group_path_pins(const char *group_path_name) { Sta *sta = Sta::sta(); @@ -4501,7 +4339,7 @@ group_path_pins(const char *group_path_name) if (sdc->isGroupPathName(group_path_name)) return sta->findGroupPathPins(group_path_name); else - return nullptr; + return PinSet(sta->network()); } //////////////////////////////////////////////////////////////// @@ -4745,7 +4583,7 @@ report_delay_calc_cmd(Edge *edge, //////////////////////////////////////////////////////////////// -PinSeq * +PinSeq check_slew_limits(Net *net, bool violators, const Corner *corner, @@ -4759,7 +4597,7 @@ size_t max_slew_violation_count() { cmdLinkedNetwork(); - return Sta::sta()->checkSlewLimits(nullptr, true, nullptr, MinMax::max())->size(); + return Sta::sta()->checkSlewLimits(nullptr, true, nullptr, MinMax::max()).size(); } float @@ -4767,7 +4605,7 @@ max_slew_check_slack() { cmdLinkedNetwork(); Sta *sta = Sta::sta(); - Pin *pin; + const Pin *pin; Slew slew; float slack; float limit; @@ -4780,7 +4618,7 @@ max_slew_check_limit() { cmdLinkedNetwork(); Sta *sta = Sta::sta(); - Pin *pin; + const Pin *pin; Slew slew; float slack; float limit; @@ -4812,7 +4650,7 @@ report_slew_limit_verbose(Pin *pin, //////////////////////////////////////////////////////////////// -PinSeq * +PinSeq check_fanout_limits(Net *net, bool violators, const MinMax *min_max) @@ -4825,7 +4663,7 @@ size_t max_fanout_violation_count() { cmdLinkedNetwork(); - return Sta::sta()->checkFanoutLimits(nullptr, true, MinMax::max())->size(); + return Sta::sta()->checkFanoutLimits(nullptr, true, MinMax::max()).size(); } float @@ -4833,7 +4671,7 @@ max_fanout_check_slack() { cmdLinkedNetwork(); Sta *sta = Sta::sta(); - Pin *pin; + const Pin *pin; float fanout; float slack; float limit; @@ -4846,7 +4684,7 @@ max_fanout_check_limit() { cmdLinkedNetwork(); Sta *sta = Sta::sta(); - Pin *pin; + const Pin *pin; float fanout; float slack; float limit; @@ -4876,7 +4714,7 @@ report_fanout_limit_verbose(Pin *pin, //////////////////////////////////////////////////////////////// -PinSeq * +PinSeq check_capacitance_limits(Net *net, bool violators, const Corner *corner, @@ -4890,7 +4728,7 @@ size_t max_capacitance_violation_count() { cmdLinkedNetwork(); - return Sta::sta()->checkCapacitanceLimits(nullptr, true,nullptr,MinMax::max())->size(); + return Sta::sta()->checkCapacitanceLimits(nullptr, true,nullptr,MinMax::max()).size(); } float @@ -4898,7 +4736,7 @@ max_capacitance_check_slack() { cmdLinkedNetwork(); Sta *sta = Sta::sta(); - Pin *pin; + const Pin *pin; float capacitance; float slack; float limit; @@ -4911,7 +4749,7 @@ max_capacitance_check_limit() { cmdLinkedNetwork(); Sta *sta = Sta::sta(); - Pin *pin; + const Pin *pin; float capacitance; float slack; float limit; @@ -4943,7 +4781,7 @@ report_capacitance_limit_verbose(Pin *pin, //////////////////////////////////////////////////////////////// -EdgeSeq * +EdgeSeq disabled_edges_sorted() { cmdLinkedNetwork(); @@ -5129,7 +4967,7 @@ timing_role_is_check(TimingRole *role) //////////////////////////////////////////////////////////////// -TmpPinSet * +PinSet find_fanin_pins(PinSeq *to, bool flat, bool startpoints_only, @@ -5140,14 +4978,14 @@ find_fanin_pins(PinSeq *to, { cmdLinkedNetwork(); Sta *sta = Sta::sta(); - PinSet *fanin = sta->findFaninPins(to, flat, startpoints_only, - inst_levels, pin_levels, - thru_disabled, thru_constants); + PinSet fanin = sta->findFaninPins(to, flat, startpoints_only, + inst_levels, pin_levels, + thru_disabled, thru_constants); delete to; return fanin; } -TmpInstanceSet * +InstanceSet find_fanin_insts(PinSeq *to, bool flat, bool startpoints_only, @@ -5158,14 +4996,14 @@ find_fanin_insts(PinSeq *to, { cmdLinkedNetwork(); Sta *sta = Sta::sta(); - InstanceSet *fanin = sta->findFaninInstances(to, flat, startpoints_only, - inst_levels, pin_levels, - thru_disabled, thru_constants); + InstanceSet fanin = sta->findFaninInstances(to, flat, startpoints_only, + inst_levels, pin_levels, + thru_disabled, thru_constants); delete to; return fanin; } -TmpPinSet * +PinSet find_fanout_pins(PinSeq *from, bool flat, bool endpoints_only, @@ -5176,14 +5014,14 @@ find_fanout_pins(PinSeq *from, { cmdLinkedNetwork(); Sta *sta = Sta::sta(); - PinSet *fanout = sta->findFanoutPins(from, flat, endpoints_only, - inst_levels, pin_levels, - thru_disabled, thru_constants); + PinSet fanout = sta->findFanoutPins(from, flat, endpoints_only, + inst_levels, pin_levels, + thru_disabled, thru_constants); delete from; return fanout; } -TmpInstanceSet * +InstanceSet find_fanout_insts(PinSeq *from, bool flat, bool endpoints_only, @@ -5194,38 +5032,38 @@ find_fanout_insts(PinSeq *from, { cmdLinkedNetwork(); Sta *sta = Sta::sta(); - InstanceSet *fanout = sta->findFanoutInstances(from, flat, endpoints_only, - inst_levels, pin_levels, - thru_disabled, thru_constants); + InstanceSet fanout = sta->findFanoutInstances(from, flat, endpoints_only, + inst_levels, pin_levels, + thru_disabled, thru_constants); delete from; return fanout; } -TmpPinSet * +PinSet net_load_pins(Net *net) { Network *network = cmdLinkedNetwork(); - PinSet *pins = new PinSet; + PinSet pins(network); NetConnectedPinIterator *pin_iter = network->connectedPinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (network->isLoad(pin)) - pins->insert(pin); + pins.insert(pin); } delete pin_iter; return pins; } -TmpPinSet * +PinSet net_driver_pins(Net *net) { Network *network = cmdLinkedNetwork(); - PinSet *pins = new PinSet; + PinSet pins(network); NetConnectedPinIterator *pin_iter = network->connectedPinIterator(net); while (pin_iter->hasNext()) { - Pin *pin = pin_iter->next(); + const Pin *pin = pin_iter->next(); if (network->isDriver(pin)) - pins->insert(pin); + pins.insert(pin); } delete pin_iter; return pins; @@ -5240,10 +5078,7 @@ report_loops() Network *network = cmdLinkedNetwork(); Graph *graph = cmdGraph(); Report *report = sta->report(); - GraphLoopSeq *loops = sta->graphLoops(); - GraphLoopSeq::Iterator loop_iter(loops); - while (loop_iter.hasNext()) { - GraphLoop *loop = loop_iter.next(); + for (GraphLoop *loop : *sta->graphLoops()) { loop->report(report, network, graph); report->reportLineString(""); } @@ -5530,15 +5365,14 @@ find_cell(const char *name) return cmdNetwork()->findCell(self, name); } -TmpCellSeq * +CellSeq find_cells_matching(const char *pattern, bool regexp, bool nocase) { PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); - TmpCellSeq *cells = new TmpCellSeq; - cmdNetwork()->findCellsMatching(self, &matcher, cells); - return cells; + CellSeq matches = cmdNetwork()->findCellsMatching(self, &matcher); + return matches; } } // Library methods @@ -5552,16 +5386,13 @@ find_liberty_cell(const char *name) return self->findLibertyCell(name); } -TmpLibertyCellSeq * +LibertyCellSeq find_liberty_cells_matching(const char *pattern, bool regexp, bool nocase) { PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); - // TmpLibertyCellSeq deletes temporary CellSeq after conversion to tcl list. - TmpLibertyCellSeq *cells = new TmpLibertyCellSeq; - self->findLibertyCellsMatching(&matcher, cells); - return cells; + return self->findLibertyCellsMatching(&matcher); } Wireload * @@ -5615,15 +5446,13 @@ find_port(const char *name) return cmdNetwork()->findPort(self, name); } -TmpPortSeq * +PortSeq find_ports_matching(const char *pattern, bool regexp, bool nocase) { PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); - TmpPortSeq *ports = new TmpPortSeq; - cmdNetwork()->findPortsMatching(self, &matcher, ports); - return ports; + return cmdNetwork()->findPortsMatching(self, &matcher); } } // Cell methods @@ -5641,15 +5470,13 @@ find_liberty_port(const char *name) return self->findLibertyPort(name); } -TmpLibertyPortSeq * +LibertyPortSeq find_liberty_ports_matching(const char *pattern, bool regexp, bool nocase) { PatternMatch matcher(pattern, regexp, nocase, Sta::sta()->tclInterp()); - TmpLibertyPortSeq *ports = new TmpLibertyPortSeq; - self->findLibertyPortsMatching(&matcher, ports); - return ports; + return self->findLibertyPortsMatching(&matcher); } LibertyCellPortIterator * @@ -5844,7 +5671,7 @@ vertices() %extend PinConnectedPinIterator { bool has_next() { return self->hasNext(); } -Pin *next() { return self->next(); } +const Pin *next() { return self->next(); } void finish() { delete self; } } // PinConnectedPinIterator methods @@ -5855,7 +5682,7 @@ Pin *pin() { return cmdLinkedNetwork()->pin(self); } %extend Net { Instance *instance() { return cmdLinkedNetwork()->instance(self); } -Net *highest_connected_net() +const Net *highest_connected_net() { return cmdLinkedNetwork()->highestConnectedNet(self); } NetPinIterator *pin_iterator() { return cmdLinkedNetwork()->pinIterator(self);} NetTermIterator *term_iterator() {return cmdLinkedNetwork()->termIterator(self);} @@ -5895,17 +5722,17 @@ wire_capacitance(Corner *corner, } // get_ports -of_objects net -TmpPortSeq * +PortSeq ports() { Network *network = cmdLinkedNetwork(); - PortSeq *ports = new PortSeq; + PortSeq ports; if (network->isTopInstance(network->instance(self))) { NetTermIterator *term_iter = network->termIterator(self); while (term_iter->hasNext()) { Term *term = term_iter->next(); Port *port = network->port(network->pin(term)); - ports->push_back(port); + ports.push_back(port); } delete term_iter; } @@ -5916,19 +5743,19 @@ ports() %extend NetPinIterator { bool has_next() { return self->hasNext(); } -Pin *next() { return self->next(); } +const Pin *next() { return self->next(); } void finish() { delete self; } } // NetPinIterator methods %extend NetTermIterator { bool has_next() { return self->hasNext(); } -Term *next() { return self->next(); } +const Term *next() { return self->next(); } void finish() { delete self; } } // NetTermIterator methods %extend NetConnectedPinIterator { bool has_next() { return self->hasNext(); } -Pin *next() { return self->next(); } +const Pin *next() { return self->next(); } void finish() { delete self; } } // NetConnectedPinIterator methods @@ -5940,7 +5767,7 @@ bool is_generated() { return self->isGenerated(); } bool waveform_valid() { return self->waveformValid(); } bool is_virtual() { return self->isVirtual(); } bool is_propagated() { return self->isPropagated(); } -PinSet &sources() { return self->pins(); } +const PinSet &sources() { return self->pins(); } float slew(const RiseFall *rf, @@ -5957,12 +5784,6 @@ RiseFall *transition() { return self->transition(); } float time() { return self->time(); } } -%extend ClockIterator { -bool has_next() { return self->hasNext(); } -Clock *next() { return self->next(); } -void finish() { delete self; } -} - %extend Vertex { Pin *pin() { return self->pin(); } bool is_bidirect_driver() { return self->isBidirectDriver(); } @@ -5998,74 +5819,74 @@ in_edge_iterator() return new VertexInEdgeIterator(self, Sta::sta()->graph()); } -TmpFloatSeq * +FloatSeq arrivals_clk(const RiseFall *rf, Clock *clk, const RiseFall *clk_rf) { Sta *sta = Sta::sta(); - TmpFloatSeq *floats = new FloatSeq; + FloatSeq arrivals; const ClockEdge *clk_edge = nullptr; if (clk) clk_edge = clk->edge(clk_rf); for (auto path_ap : sta->corners()->pathAnalysisPts()) { - floats->push_back(delayAsFloat(sta->vertexArrival(self, rf, clk_edge, - path_ap))); + arrivals.push_back(delayAsFloat(sta->vertexArrival(self, rf, clk_edge, + path_ap))); } - return floats; + return arrivals; } -TmpStringSeq * +StringSeq arrivals_clk_delays(const RiseFall *rf, Clock *clk, const RiseFall *clk_rf, int digits) { Sta *sta = Sta::sta(); - StringSeq *arrivals = new StringSeq; + StringSeq arrivals; const ClockEdge *clk_edge = nullptr; if (clk) clk_edge = clk->edge(clk_rf); for (auto path_ap : sta->corners()->pathAnalysisPts()) { - arrivals->push_back(delayAsString(sta->vertexArrival(self, rf, clk_edge, - path_ap), - sta, digits)); + arrivals.push_back(delayAsString(sta->vertexArrival(self, rf, clk_edge, + path_ap), + sta, digits)); } return arrivals; } -TmpFloatSeq * +FloatSeq requireds_clk(const RiseFall *rf, Clock *clk, const RiseFall *clk_rf) { Sta *sta = Sta::sta(); - TmpFloatSeq *floats = new FloatSeq; + FloatSeq requires; const ClockEdge *clk_edge = nullptr; if (clk) clk_edge = clk->edge(clk_rf); for (auto path_ap : sta->corners()->pathAnalysisPts()) { - floats->push_back(delayAsFloat(sta->vertexRequired(self, rf, clk_edge, - path_ap))); + requires.push_back(delayAsFloat(sta->vertexRequired(self, rf, clk_edge, + path_ap))); } - return floats; + return requires; } -TmpStringSeq * +StringSeq requireds_clk_delays(const RiseFall *rf, Clock *clk, const RiseFall *clk_rf, int digits) { Sta *sta = Sta::sta(); - StringSeq *requireds = new StringSeq; + StringSeq requireds; const ClockEdge *clk_edge = nullptr; if (clk) clk_edge = clk->edge(clk_rf); for (auto path_ap : sta->corners()->pathAnalysisPts()) { - requireds->push_back(delayAsString(sta->vertexRequired(self, rf, clk_edge, - path_ap), - sta, digits)); + requireds.push_back(delayAsString(sta->vertexRequired(self, rf, clk_edge, + path_ap), + sta, digits)); } return requireds; } @@ -6077,50 +5898,50 @@ slack(MinMax *min_max) return sta->vertexSlack(self, min_max); } -TmpFloatSeq * +FloatSeq slacks(RiseFall *rf) { Sta *sta = Sta::sta(); - TmpFloatSeq *floats = new FloatSeq; + FloatSeq slacks; for (auto path_ap : sta->corners()->pathAnalysisPts()) { - floats->push_back(delayAsFloat(sta->vertexSlack(self, rf, path_ap))); + slacks.push_back(delayAsFloat(sta->vertexSlack(self, rf, path_ap))); } - return floats; + return slacks; } // Slack with respect to a clock rise/fall edge. -TmpFloatSeq * +FloatSeq slacks_clk(const RiseFall *rf, Clock *clk, const RiseFall *clk_rf) { Sta *sta = Sta::sta(); - TmpFloatSeq *floats = new FloatSeq; + FloatSeq slacks; const ClockEdge *clk_edge = nullptr; if (clk) clk_edge = clk->edge(clk_rf); for (auto path_ap : sta->corners()->pathAnalysisPts()) { - floats->push_back(delayAsFloat(sta->vertexSlack(self, rf, clk_edge, - path_ap))); + slacks.push_back(delayAsFloat(sta->vertexSlack(self, rf, clk_edge, + path_ap))); } - return floats; + return slacks; } -TmpStringSeq * +StringSeq slacks_clk_delays(const RiseFall *rf, Clock *clk, const RiseFall *clk_rf, int digits) { Sta *sta = Sta::sta(); - StringSeq *slacks = new StringSeq; + StringSeq slacks; const ClockEdge *clk_edge = nullptr; if (clk) clk_edge = clk->edge(clk_rf); for (auto path_ap : sta->corners()->pathAnalysisPts()) { - slacks->push_back(delayAsString(sta->vertexSlack(self, rf, clk_edge, - path_ap), - sta, digits)); + slacks.push_back(delayAsString(sta->vertexSlack(self, rf, clk_edge, + path_ap), + sta, digits)); } return slacks; } @@ -6157,14 +5978,14 @@ Pin *from_pin() { return self->from(Sta::sta()->graph())->pin(); } Pin *to_pin() { return self->to(Sta::sta()->graph())->pin(); } TimingRole *role() { return self->role(); } const char *sense() { return timingSenseString(self->sense()); } -const TimingArcSeq & +TimingArcSeq & timing_arcs() { return self->timingArcSet()->arcs(); } bool is_disabled_loop() { return Sta::sta()->isDisabledLoop(self); } bool is_disabled_constraint() { return Sta::sta()->isDisabledConstraint(self);} bool is_disabled_constant() { return Sta::sta()->isDisabledConstant(self); } bool is_disabled_cond_default() { return Sta::sta()->isDisabledCondDefault(self); } -TmpPinSet * +PinSet disabled_constant_pins() { return Sta::sta()->disabledConstantPins(self); } bool is_disabled_bidirect_inst_path() { return Sta::sta()->isDisabledBidirectInstPath(self); } @@ -6175,25 +5996,25 @@ bool is_disabled_preset_clear() const char * sim_timing_sense(){return timingSenseString(Sta::sta()->simTimingSense(self));} -TmpFloatSeq * +FloatSeq arc_delays(TimingArc *arc) { Sta *sta = Sta::sta(); - TmpFloatSeq *floats = new FloatSeq; + FloatSeq delays; for (auto dcalc_ap : sta->corners()->dcalcAnalysisPts()) - floats->push_back(delayAsFloat(sta->arcDelay(self, arc, dcalc_ap))); - return floats; + delays.push_back(delayAsFloat(sta->arcDelay(self, arc, dcalc_ap))); + return delays; } -TmpStringSeq * +StringSeq arc_delay_strings(TimingArc *arc, int digits) { Sta *sta = Sta::sta(); - StringSeq *delays = new StringSeq; + StringSeq delays; for (auto dcalc_ap : sta->corners()->dcalcAnalysisPts()) - delays->push_back(delayAsString(sta->arcDelay(self, arc, dcalc_ap), - sta, digits)); + delays.push_back(delayAsString(sta->arcDelay(self, arc, dcalc_ap), + sta, digits)); return delays; } @@ -6301,8 +6122,8 @@ float source_clk_offset() { return self->sourceClkOffset(Sta::sta()); } Arrival source_clk_latency() { return self->sourceClkLatency(Sta::sta()); } Arrival source_clk_insertion_delay() { return self->sourceClkInsertionDelay(Sta::sta()); } -Clock *target_clk() { return self->targetClk(Sta::sta()); } -ClockEdge *target_clk_edge() { return self->targetClkEdge(Sta::sta()); } +const Clock *target_clk() { return self->targetClk(Sta::sta()); } +const ClockEdge *target_clk_edge() { return self->targetClkEdge(Sta::sta()); } Path *target_clk_path() { return self->targetClkPath(); } float target_clk_time() { return self->targetClkTime(Sta::sta()); } float target_clk_offset() { return self->targetClkOffset(Sta::sta()); } @@ -6352,7 +6173,7 @@ slack() return delayAsFloat(self->slack(sta)); } -Pin * +const Pin * pin() { Sta *sta = Sta::sta(); @@ -6367,14 +6188,14 @@ tag() } // mea_opt3 -TmpPinSeq * +PinSeq pins() { Sta *sta = Sta::sta(); - PinSeq *pins = new PinSeq; + PinSeq pins; PathRef path1(self); while (!path1.isNull()) { - pins->push_back(path1.vertex(sta)->pin()); + pins.push_back(path1.vertex(sta)->pin()); PathRef prev_path; path1.prevPath(sta, prev_path); path1.init(prev_path); @@ -6398,7 +6219,7 @@ void finish() { delete self; } %extend SlowDrvrIterator { bool has_next() { return self->hasNext(); } -Instance *next() { return self->next(); } +const Instance *next() { return self->next(); } void finish() { diff --git a/verilog/VerilogWriter.cc b/verilog/VerilogWriter.cc index 4b94f77d..27367cef 100644 --- a/verilog/VerilogWriter.cc +++ b/verilog/VerilogWriter.cc @@ -74,7 +74,7 @@ protected: FILE *stream_; Network *network_; - Set written_cells_; + CellSet written_cells_; Vector pending_children_; int unconnected_net_index_; }; @@ -108,8 +108,10 @@ VerilogWriter::VerilogWriter(const char *filename, filename_(filename), sort_(sort), include_pwr_gnd_(include_pwr_gnd_pins), + remove_cells_(network), stream_(stream), network_(network), + written_cells_(network), unconnected_net_index_(1) { if (remove_cells) { @@ -457,6 +459,7 @@ VerilogWriter::findChildNCcount(Instance *child) if (network_->hasMembers(port)) nc_count += findPortNCcount(child, port); } + delete port_iter; } return nc_count; }