Skip to content

Commit

Permalink
range iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcherry56 committed Jul 18, 2019
1 parent 73fb94a commit 9d93130
Show file tree
Hide file tree
Showing 36 changed files with 405 additions and 845 deletions.
4 changes: 1 addition & 3 deletions dcalc/GraphDelayCalc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ GraphDelayCalc::minPeriod(const Pin *pin,
{
exists = false;
const MinMax *min_max = MinMax::max();
DcalcAnalysisPtIterator dcalc_ap_iter(this);
while (dcalc_ap_iter.hasNext()) {
DcalcAnalysisPt *dcalc_ap = dcalc_ap_iter.next();
for (auto dcalc_ap : corners_->dcalcAnalysisPts()) {
// Sdf annotation.
float min_period1 = 0.0;
bool exists1 = false;
Expand Down
70 changes: 18 additions & 52 deletions dcalc/GraphDelayCalc1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,10 @@ MultiDrvrNet::findDelaysSlews(ArcDelayCalc *arc_delay_calc,
int count = TransRiseFall::index_count * corners->dcalcAnalysisPtCount();
parallel_delays_ = new ArcDelay[count];
parallel_slews_ = new Slew[count];
DcalcAnalysisPtIterator ap_iter(dcalc);
while (ap_iter.hasNext()) {
DcalcAnalysisPt *dcalc_ap = ap_iter.next();
for (auto dcalc_ap : corners->dcalcAnalysisPts()) {
DcalcAPIndex ap_index = dcalc_ap->index();
const Pvt *pvt = dcalc_ap->operatingConditions();
TransRiseFallIterator drvr_tr_iter;
while (drvr_tr_iter.hasNext()) {
TransRiseFall *drvr_tr = drvr_tr_iter.next();
for (auto drvr_tr : TransRiseFall::range()) {
int drvr_tr_index = drvr_tr->index();
int index = ap_index*TransRiseFall::index_count+drvr_tr_index;
dcalc->findMultiDrvrGateDelay(this, drvr_tr, pvt, dcalc_ap,
Expand Down Expand Up @@ -184,24 +180,20 @@ MultiDrvrNet::findCaps(const GraphDelayCalc1 *dcalc,
int count = TransRiseFall::index_count * corners->dcalcAnalysisPtCount();
net_caps_ = new NetCaps[count];
const Pin *drvr_pin = dcalc_drvr_->pin();
DcalcAnalysisPtIterator ap_iter(dcalc);
while (ap_iter.hasNext()) {
DcalcAnalysisPt *dcalc_ap = ap_iter.next();
for (auto dcalc_ap : corners->dcalcAnalysisPts()) {
DcalcAPIndex ap_index = dcalc_ap->index();
const Corner *corner = dcalc_ap->corner();
const OperatingConditions *op_cond = dcalc_ap->operatingConditions();
const MinMax *min_max = dcalc_ap->constraintMinMax();
TransRiseFallIterator drvr_tr_iter;
while (drvr_tr_iter.hasNext()) {
TransRiseFall *drvr_tr = drvr_tr_iter.next();
for (auto drvr_tr : TransRiseFall::range()) {
int drvr_tr_index = drvr_tr->index();
int index = ap_index * TransRiseFall::index_count + drvr_tr_index;
NetCaps &net_caps = net_caps_[index];
float pin_cap, wire_cap, fanout;
bool has_set_load;
// Find pin and external pin/wire capacitance.
sdc->connectedCap(drvr_pin, drvr_tr, op_cond, corner, min_max,
pin_cap, wire_cap, fanout, has_set_load);
pin_cap, wire_cap, fanout, has_set_load);
net_caps.init(pin_cap, wire_cap, fanout, has_set_load);
}
}
Expand Down Expand Up @@ -593,12 +585,8 @@ GraphDelayCalc1::seedDrvrSlew(Vertex *drvr_vertex,
Port *port = network_->port(drvr_pin);
drive = sdc_->findInputDrive(port);
}
TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
DcalcAnalysisPtIterator ap_iter(this);
while (ap_iter.hasNext()) {
DcalcAnalysisPt *dcalc_ap = ap_iter.next();
for (auto tr : TransRiseFall::range()) {
for (auto dcalc_ap : corners_->dcalcAnalysisPts()) {
if (drive) {
const MinMax *cnst_min_max = dcalc_ap->constraintMinMax();
LibertyCell *drvr_cell;
Expand Down Expand Up @@ -697,12 +685,8 @@ GraphDelayCalc1::seedLoadSlew(Vertex *vertex)
vertex->name(sdc_network_));
ClockSet *clks = sdc_->findVertexPinClocks(pin);
initSlew(vertex);
TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
const TransRiseFall *tr = tr_iter.next();
DcalcAnalysisPtIterator ap_iter(this);
while (ap_iter.hasNext()) {
DcalcAnalysisPt *dcalc_ap = ap_iter.next();
for (auto tr : TransRiseFall::range()) {
for (auto dcalc_ap : corners_->dcalcAnalysisPts()) {
const MinMax *slew_min_max = dcalc_ap->slewMinMax();
if (!vertex->slewAnnotated(tr, slew_min_max)) {
float slew = 0.0;
Expand Down Expand Up @@ -956,14 +940,10 @@ GraphDelayCalc1::findDriverDelays1(Vertex *drvr_vertex,
void
GraphDelayCalc1::initRootSlews(Vertex *vertex)
{
DcalcAnalysisPtIterator ap_iter(this);
while (ap_iter.hasNext()) {
DcalcAnalysisPt *dcalc_ap = ap_iter.next();
for (auto dcalc_ap : corners_->dcalcAnalysisPts()) {
const MinMax *slew_min_max = dcalc_ap->slewMinMax();
DcalcAPIndex ap_index = dcalc_ap->index();
TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
for (auto tr : TransRiseFall::range()) {
if (!vertex->slewAnnotated(tr, slew_min_max))
graph_->setSlew(vertex, tr, ap_index, default_slew);
}
Expand All @@ -986,9 +966,7 @@ GraphDelayCalc1::findDriverEdgeDelays(LibertyCell *drvr_cell,
bool delay_changed = false;
if (related_out_port)
related_out_pin = network_->findPin(drvr_inst, related_out_port);
DcalcAnalysisPtIterator ap_iter(this);
while (ap_iter.hasNext()) {
DcalcAnalysisPt *dcalc_ap = ap_iter.next();
for (auto dcalc_ap : corners_->dcalcAnalysisPts()) {
const Pvt *pvt = sdc_->pvt(drvr_inst, dcalc_ap->constraintMinMax());
if (pvt == nullptr)
pvt = dcalc_ap->operatingConditions();
Expand Down Expand Up @@ -1027,9 +1005,7 @@ GraphDelayCalc1::loadCap(const Pin *drvr_pin,
{
const MinMax *min_max = dcalc_ap->constraintMinMax();
float load_cap = 0.0;
TransRiseFallIterator drvr_tr_iter;
while (drvr_tr_iter.hasNext()) {
TransRiseFall *drvr_tr = drvr_tr_iter.next();
for (auto drvr_tr : TransRiseFall::range()) {
Parasitic *drvr_parasitic = arc_delay_calc_->findParasitic(drvr_pin, drvr_tr,
dcalc_ap);
float cap = loadCap(drvr_pin, nullptr, drvr_parasitic, drvr_tr, dcalc_ap);
Expand Down Expand Up @@ -1151,12 +1127,8 @@ GraphDelayCalc1::netCaps(const Pin *drvr_pin,
void
GraphDelayCalc1::initSlew(Vertex *vertex)
{
TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
DcalcAnalysisPtIterator ap_iter(this);
while (ap_iter.hasNext()) {
DcalcAnalysisPt *dcalc_ap = ap_iter.next();
for (auto tr : TransRiseFall::range()) {
for (auto dcalc_ap : corners_->dcalcAnalysisPts()) {
const MinMax *slew_min_max = dcalc_ap->slewMinMax();
if (!vertex->slewAnnotated(tr, slew_min_max)) {
DcalcAPIndex ap_index = dcalc_ap->index();
Expand All @@ -1176,17 +1148,13 @@ GraphDelayCalc1::initWireDelays(Vertex *drvr_vertex,
Edge *wire_edge = edge_iter.next();
if (wire_edge->isWire()) {
Vertex *load_vertex = wire_edge->to(graph_);
DcalcAnalysisPtIterator ap_iter(this);
while (ap_iter.hasNext()) {
DcalcAnalysisPt *dcalc_ap = ap_iter.next();
for (auto dcalc_ap : corners_->dcalcAnalysisPts()) {
const MinMax *delay_min_max = dcalc_ap->delayMinMax();
const MinMax *slew_min_max = dcalc_ap->slewMinMax();
Delay delay_init_value(delay_min_max->initValue());
Slew slew_init_value(slew_min_max->initValue());
DcalcAPIndex ap_index = dcalc_ap->index();
TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
for (auto tr : TransRiseFall::range()) {
if (!graph_->wireDelayAnnotated(wire_edge, tr, ap_index))
graph_->setWireArcDelay(wire_edge, tr, ap_index, delay_init_value);
// Init load vertex slew.
Expand Down Expand Up @@ -1541,9 +1509,7 @@ GraphDelayCalc1::findCheckEdgeDelays(Edge *edge,
const Pin *related_out_pin = 0;
if (related_out_port)
related_out_pin = network_->findPin(inst, related_out_port);
DcalcAnalysisPtIterator ap_iter(this);
while (ap_iter.hasNext()) {
DcalcAnalysisPt *dcalc_ap = ap_iter.next();
for (auto dcalc_ap : corners_->dcalcAnalysisPts()) {
DcalcAPIndex ap_index = dcalc_ap->index();
if (!graph_->arcDelayAnnotated(edge, arc, ap_index)) {
const Pvt *pvt = sdc_->pvt(inst,dcalc_ap->constraintMinMax());
Expand Down
9 changes: 2 additions & 7 deletions liberty/InternalPower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ InternalPowerAttrs::~InternalPowerAttrs()
void
InternalPowerAttrs::deleteContents()
{
TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
int tr_index = tr->index();
for (auto tr_index : TransRiseFall::rangeIndex()) {
InternalPowerModel *model = models_[tr_index];
if (model)
delete model;
Expand Down Expand Up @@ -80,9 +77,7 @@ InternalPower::InternalPower(LibertyCell *cell,
when_(attrs->when()),
related_pg_pin_(attrs->relatedPgPin())
{
TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
for (auto tr : TransRiseFall::range()) {
int tr_index = tr->index();
models_[tr_index] = attrs->model(tr);
}
Expand Down
36 changes: 7 additions & 29 deletions liberty/Liberty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ LibertyLibrary::LibertyLibrary(const char *name,
addTableTemplate(scalar_template, type);
}

TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
int tr_index = tr->index();
for (auto tr_index : TransRiseFall::rangeIndex()) {
wire_slew_degradation_tbls_[tr_index] = nullptr;
input_threshold_[tr_index] = input_threshold_default_;
output_threshold_[tr_index] = output_threshold_default_;
Expand All @@ -114,10 +111,7 @@ LibertyLibrary::~LibertyLibrary()
scale_factors_map_.deleteContents();
delete scale_factors_;

TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
int tr_index = tr->index();
for (auto tr_index : TransRiseFall::rangeIndex()) {
TableModel *model = wire_slew_degradation_tbls_[tr_index];
delete model;
}
Expand Down Expand Up @@ -2569,10 +2563,7 @@ ScaleFactors::ScaleFactors(const char *name) :
{
for (int type = 0; type < scale_factor_type_count; type++) {
for (int pvt = 0; pvt < int(ScaleFactorPvt::count); pvt++) {
TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
int tr_index = tr->index();
for (auto tr_index : TransRiseFall::rangeIndex()) {
scales_[type][pvt][tr_index] = 0.0;
}
}
Expand Down Expand Up @@ -2637,7 +2628,6 @@ ScaleFactors::print()
ScaleFactorType type = (ScaleFactorType) type_index;
printf("%10s ", scaleFactorTypeName(type));
for (int pvt_index = 0; pvt_index < int(ScaleFactorPvt::count); pvt_index++) {
TransRiseFallIterator tr_iter;
if (scaleFactorTypeRiseFallSuffix(type)
|| scaleFactorTypeRiseFallPrefix(type)
|| scaleFactorTypeLowHighSuffix(type)) {
Expand Down Expand Up @@ -2711,14 +2701,8 @@ TestCell::setScanOutInv(LibertyPort *port)
OcvDerate::OcvDerate(const char *name) :
name_(name)
{
EarlyLateIterator el_iter;
while (el_iter.hasNext()) {
EarlyLate *early_late = el_iter.next();
int el_index = early_late->index();
TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
int tr_index = tr->index();
for (auto el_index : EarlyLate::rangeIndex()) {
for (auto tr_index : TransRiseFall::rangeIndex()) {
derate_[tr_index][el_index][int(PathType::clk)] = nullptr;
derate_[tr_index][el_index][int(PathType::data)] = nullptr;
}
Expand All @@ -2731,14 +2715,8 @@ OcvDerate::~OcvDerate()
// Derating table models can be shared in multiple places in derate_;
// Collect them in a set to avoid duplicate deletes.
Set<Table*> models;
EarlyLateIterator el_iter;
while (el_iter.hasNext()) {
EarlyLate *early_late = el_iter.next();
int el_index = early_late->index();
TransRiseFallIterator tr_iter;
while (tr_iter.hasNext()) {
TransRiseFall *tr = tr_iter.next();
int tr_index = tr->index();
for (auto el_index : EarlyLate::rangeIndex()) {
for (auto tr_index : TransRiseFall::rangeIndex()) {
Table *derate;
derate = derate_[tr_index][el_index][int(PathType::clk)];
if (derate)
Expand Down
Loading

0 comments on commit 9d93130

Please sign in to comment.