Set::intersects
Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
parent
44159bbb53
commit
b0bede4c6d
|
|
@ -61,7 +61,8 @@ public:
|
|||
ExceptionThruSeq *thrus() const { return thrus_; }
|
||||
ExceptionTo *to() const { return to_; }
|
||||
ExceptionPt *firstPt();
|
||||
bool intersectsPts(ExceptionPath *exception) const;
|
||||
bool intersectsPts(ExceptionPath *exception,
|
||||
const Network *network) const;
|
||||
const MinMaxAll *minMax() const { return min_max_; }
|
||||
virtual bool matches(const MinMax *min_max,
|
||||
bool exact) const;
|
||||
|
|
@ -71,7 +72,8 @@ public:
|
|||
virtual bool resetMatch(ExceptionFrom *from,
|
||||
ExceptionThruSeq *thrus,
|
||||
ExceptionTo *to,
|
||||
const MinMaxAll *min_max);
|
||||
const MinMaxAll *min_max,
|
||||
const Network *network);
|
||||
// The priority remains the same even though pin/clock/net/inst objects
|
||||
// are added to the exceptions points during exception merging because
|
||||
// only exceptions with the same priority are merged.
|
||||
|
|
@ -262,7 +264,8 @@ public:
|
|||
virtual bool resetMatch(ExceptionFrom *from,
|
||||
ExceptionThruSeq *thrus,
|
||||
ExceptionTo *to,
|
||||
const MinMaxAll *min_max);
|
||||
const MinMaxAll *min_max,
|
||||
const Network *network);
|
||||
virtual int typePriority() const;
|
||||
virtual bool tighterThan(ExceptionPath *exception) const;
|
||||
};
|
||||
|
|
@ -424,7 +427,8 @@ public:
|
|||
const Network *network);
|
||||
ExceptionFrom *clone(const Network *network);
|
||||
virtual bool isFrom() const { return true; }
|
||||
bool intersectsPts(ExceptionFrom *from) const;
|
||||
bool intersectsPts(ExceptionFrom *from,
|
||||
const Network *network) const;
|
||||
virtual int typePriority() const { return 0; }
|
||||
|
||||
protected:
|
||||
|
|
@ -448,7 +452,8 @@ public:
|
|||
virtual bool isTo() const { return true; }
|
||||
const char *asString(const Network *network) const;
|
||||
const RiseFallBoth *endTransition() { return end_rf_; }
|
||||
bool intersectsPts(ExceptionTo *to) const;
|
||||
bool intersectsPts(ExceptionTo *to,
|
||||
const Network *network) const;
|
||||
virtual int typePriority() const { return 1; }
|
||||
bool matches(const Pin *pin,
|
||||
const ClockEdge *clk_edge,
|
||||
|
|
@ -511,7 +516,8 @@ public:
|
|||
const Network *network) const;
|
||||
virtual void mergeInto(ExceptionPt *pt,
|
||||
const Network *network);
|
||||
bool intersectsPts(ExceptionThru *thru) const;
|
||||
bool intersectsPts(ExceptionThru *thru,
|
||||
const Network *network) const;
|
||||
virtual int typePriority() const { return 2; }
|
||||
virtual size_t objectCount() const;
|
||||
virtual void connectPinAfter(PinSet *drvrs,
|
||||
|
|
|
|||
|
|
@ -146,6 +146,9 @@ public:
|
|||
static int compare(const InstanceSet *set1,
|
||||
const InstanceSet *set2,
|
||||
const Network *network);
|
||||
static bool intersects(const InstanceSet *set1,
|
||||
const InstanceSet *set2,
|
||||
const Network *network);
|
||||
};
|
||||
|
||||
class PinSet : public Set<const Pin*, PinIdLess>
|
||||
|
|
@ -156,6 +159,9 @@ public:
|
|||
static int compare(const PinSet *set1,
|
||||
const PinSet *set2,
|
||||
const Network *network);
|
||||
static bool intersects(const PinSet *set1,
|
||||
const PinSet *set2,
|
||||
const Network *network);
|
||||
};
|
||||
|
||||
class NetSet : public Set<const Net*, NetIdLess>
|
||||
|
|
@ -166,6 +172,9 @@ public:
|
|||
static int compare(const NetSet *set1,
|
||||
const NetSet *set2,
|
||||
const Network *network);
|
||||
static bool intersects(const NetSet *set1,
|
||||
const NetSet *set2,
|
||||
const Network *network);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ public:
|
|||
|
||||
static bool
|
||||
intersects(const std::set<KEY, CMP> *set1,
|
||||
const std::set<KEY, CMP> *set2);
|
||||
const std::set<KEY, CMP> *set2,
|
||||
CMP key_less);
|
||||
|
||||
// Java style container itererator
|
||||
// Set::Iterator<Key*> iter(set);
|
||||
|
|
@ -170,20 +171,21 @@ Set<KEY, CMP>::isSubset(const std::set<KEY, CMP> *set2)
|
|||
template <class KEY, class CMP>
|
||||
bool
|
||||
Set<KEY, CMP>::intersects(const std::set<KEY, CMP> *set1,
|
||||
const std::set<KEY, CMP> *set2)
|
||||
const std::set<KEY, CMP> *set2,
|
||||
CMP key_less)
|
||||
{
|
||||
if (set1 && !set1->empty()
|
||||
&& set2 && !set2->empty()) {
|
||||
if (set2->size() > set1->size())
|
||||
std::swap(set1, set2);
|
||||
if (set1 && set2) {
|
||||
auto iter1 = set1->begin();
|
||||
auto end1 = set1->end();
|
||||
auto iter2 = set2->begin();
|
||||
auto end2 = set2->end();
|
||||
while (iter2 != end2) {
|
||||
const KEY key2 = *iter2;
|
||||
if (set1->find(key2) != end1)
|
||||
while (iter1 != end1 && iter2 != end2) {
|
||||
if (key_less(*iter1, *iter2))
|
||||
iter1++;
|
||||
else if (key_less(*iter2, *iter1))
|
||||
iter2++;
|
||||
else
|
||||
return true;
|
||||
iter2++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -2093,6 +2093,16 @@ InstanceSet::compare(const InstanceSet *set1,
|
|||
return (size1 > size2) ? 1 : -1;
|
||||
}
|
||||
|
||||
bool
|
||||
InstanceSet::intersects(const InstanceSet *set1,
|
||||
const InstanceSet *set2,
|
||||
const Network *network)
|
||||
{
|
||||
return Set<const Instance*, InstanceIdLess>::intersects(set1, set2, InstanceIdLess(network));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
PinSet::PinSet() :
|
||||
Set<const Pin*, PinIdLess>(PinIdLess(nullptr))
|
||||
{
|
||||
|
|
@ -2130,6 +2140,16 @@ PinSet::compare(const PinSet *set1,
|
|||
return (size1 > size2) ? 1 : -1;
|
||||
}
|
||||
|
||||
bool
|
||||
PinSet::intersects(const PinSet *set1,
|
||||
const PinSet *set2,
|
||||
const Network *network)
|
||||
{
|
||||
return Set<const Pin*, PinIdLess>::intersects(set1, set2, PinIdLess(network));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
NetSet::NetSet() :
|
||||
Set<const Net*, NetIdLess>(NetIdLess(nullptr))
|
||||
{
|
||||
|
|
@ -2167,4 +2187,12 @@ NetSet::compare(const NetSet *set1,
|
|||
return (size1 > size2) ? 1 : -1;
|
||||
}
|
||||
|
||||
bool
|
||||
NetSet::intersects(const NetSet *set1,
|
||||
const NetSet *set2,
|
||||
const Network *network)
|
||||
{
|
||||
return Set<const Net*, NetIdLess>::intersects(set1, set2, NetIdLess(network));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ namespace sta {
|
|||
|
||||
static bool
|
||||
thrusIntersectPts(ExceptionThruSeq *thrus1,
|
||||
ExceptionThruSeq *thrus2);
|
||||
ExceptionThruSeq *thrus2,
|
||||
const Network *network);
|
||||
static void
|
||||
insertPinPairsThruHierPin(const Pin *hpin,
|
||||
const Network *network,
|
||||
|
|
@ -273,23 +274,24 @@ ExceptionPath::mergeablePts(ExceptionPath *exception2,
|
|||
}
|
||||
|
||||
bool
|
||||
ExceptionPath::intersectsPts(ExceptionPath *exception) const
|
||||
ExceptionPath::intersectsPts(ExceptionPath *exception,
|
||||
const Network *network) const
|
||||
{
|
||||
ExceptionFrom *from2 = exception->from();
|
||||
ExceptionThruSeq *thrus2 = exception->thrus();
|
||||
ExceptionTo *to2 = exception->to();
|
||||
if (((from_ == nullptr && from2 == nullptr)
|
||||
|| (from_ && from2 && from_->intersectsPts(from2)))
|
||||
|| (from_ && from2 && from_->intersectsPts(from2, network)))
|
||||
&& ((thrus_ == nullptr && thrus2 == nullptr)
|
||||
|| (thrus_ && thrus2 && thrus_->size() == thrus2->size()))
|
||||
&& ((to_ == nullptr && to2 == nullptr)
|
||||
|| (to_ && to2 && to_->intersectsPts(to2)))) {
|
||||
|| (to_ && to2 && to_->intersectsPts(to2, network)))) {
|
||||
ExceptionThruSeq::Iterator thrus_iter1(thrus_);
|
||||
ExceptionThruSeq::Iterator thrus_iter2(thrus2);
|
||||
while (thrus_iter1.hasNext() && thrus_iter2.hasNext()) {
|
||||
ExceptionThru *thru1 = thrus_iter1.next();
|
||||
ExceptionThru *thru2 = thrus_iter2.next();
|
||||
if (!thru1->intersectsPts(thru2))
|
||||
if (!thru1->intersectsPts(thru2, network))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -373,7 +375,8 @@ bool
|
|||
ExceptionPath::resetMatch(ExceptionFrom *from,
|
||||
ExceptionThruSeq *thrus,
|
||||
ExceptionTo *to,
|
||||
const MinMaxAll *min_max)
|
||||
const MinMaxAll *min_max,
|
||||
const Network *network)
|
||||
{
|
||||
// Only the reset expception points need to match.
|
||||
// For example, if the reset is -from, it matches any
|
||||
|
|
@ -382,56 +385,57 @@ ExceptionPath::resetMatch(ExceptionFrom *from,
|
|||
return ((from && from_
|
||||
&& thrus == nullptr
|
||||
&& to == nullptr
|
||||
&& from_->intersectsPts(from))
|
||||
&& from_->intersectsPts(from, network))
|
||||
// -thru
|
||||
|| (from == nullptr
|
||||
&& thrus && thrus_
|
||||
&& to == nullptr
|
||||
&& thrusIntersectPts(thrus_, thrus))
|
||||
&& thrusIntersectPts(thrus_, thrus, network))
|
||||
// -to
|
||||
|| (from == nullptr
|
||||
&& thrus == nullptr
|
||||
&& to && to_
|
||||
&& to_->intersectsPts(to))
|
||||
&& to_->intersectsPts(to, network))
|
||||
// -from -thru
|
||||
|| (from && from_
|
||||
&& thrus && thrus_
|
||||
&& to == nullptr
|
||||
&& from_->intersectsPts(from)
|
||||
&& thrusIntersectPts(thrus_, thrus))
|
||||
&& from_->intersectsPts(from, network)
|
||||
&& thrusIntersectPts(thrus_, thrus, network))
|
||||
// -from -to
|
||||
|| (from && from_
|
||||
&& thrus == nullptr
|
||||
&& to && to_
|
||||
&& from_->intersectsPts(from)
|
||||
&& to_->intersectsPts(to))
|
||||
&& from_->intersectsPts(from, network)
|
||||
&& to_->intersectsPts(to, network))
|
||||
// -thru -to
|
||||
|| (from == nullptr
|
||||
&& thrus && thrus_
|
||||
&& to && to_
|
||||
&& thrusIntersectPts(thrus_, thrus)
|
||||
&& to_->intersectsPts(to))
|
||||
&& thrusIntersectPts(thrus_, thrus, network)
|
||||
&& to_->intersectsPts(to, network))
|
||||
// -from -thru -to
|
||||
|| (from && from_
|
||||
&& thrus && thrus_
|
||||
&& to && to_
|
||||
&& from_->intersectsPts(from)
|
||||
&& thrusIntersectPts(thrus_, thrus)
|
||||
&& to_->intersectsPts(to)))
|
||||
&& from_->intersectsPts(from, network)
|
||||
&& thrusIntersectPts(thrus_, thrus, network)
|
||||
&& to_->intersectsPts(to, network)))
|
||||
&& (min_max == MinMaxAll::all()
|
||||
|| min_max_ == min_max);
|
||||
}
|
||||
|
||||
static bool
|
||||
thrusIntersectPts(ExceptionThruSeq *thrus1,
|
||||
ExceptionThruSeq *thrus2)
|
||||
ExceptionThruSeq *thrus2,
|
||||
const Network *network)
|
||||
{
|
||||
ExceptionThruSeq::Iterator thrus_iter1(thrus1);
|
||||
ExceptionThruSeq::Iterator thrus_iter2(thrus2);
|
||||
while (thrus_iter1.hasNext() && thrus_iter2.hasNext()) {
|
||||
ExceptionThru *thru1 = thrus_iter1.next();
|
||||
ExceptionThru *thru2 = thrus_iter2.next();
|
||||
if (!thru1->intersectsPts(thru2))
|
||||
if (!thru1->intersectsPts(thru2, network))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -774,7 +778,8 @@ bool
|
|||
FilterPath::resetMatch(ExceptionFrom *,
|
||||
ExceptionThruSeq *,
|
||||
ExceptionTo *,
|
||||
const MinMaxAll *)
|
||||
const MinMaxAll *,
|
||||
const Network *)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1220,12 +1225,13 @@ ExceptionFrom::clone(const Network *network)
|
|||
}
|
||||
|
||||
bool
|
||||
ExceptionFrom::intersectsPts(ExceptionFrom *from) const
|
||||
ExceptionFrom::intersectsPts(ExceptionFrom *from,
|
||||
const Network *network) const
|
||||
{
|
||||
return from->transition() == rf_
|
||||
&& ((pins_ && PinSet::intersects(pins_, from->pins()))
|
||||
|| (clks_ && ClockSet::intersects(clks_, from->clks()))
|
||||
|| (insts_ && InstanceSet::intersects(insts_, from->instances())));
|
||||
&& ((pins_ && PinSet::intersects(pins_, from->pins(), network))
|
||||
|| (clks_ && ClockSet::intersects(clks_, from->clks(), ClockIndexLess()))
|
||||
|| (insts_ && InstanceSet::intersects(insts_, from->instances(), network)));
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
@ -1284,13 +1290,14 @@ ExceptionTo::asString(const Network *network) const
|
|||
}
|
||||
|
||||
bool
|
||||
ExceptionTo::intersectsPts(ExceptionTo *to) const
|
||||
ExceptionTo::intersectsPts(ExceptionTo *to,
|
||||
const Network *network) const
|
||||
{
|
||||
return to->transition() == rf_
|
||||
&& to->endTransition() == end_rf_
|
||||
&& ((pins_ && PinSet::intersects(pins_, to->pins()))
|
||||
|| (clks_ && ClockSet::intersects(clks_, to->clks()))
|
||||
|| (insts_ && InstanceSet::intersects(insts_, to->instances())));
|
||||
&& ((pins_ && PinSet::intersects(pins_, to->pins(), network))
|
||||
|| (clks_ && ClockSet::intersects(clks_, to->clks(), ClockIndexLess()))
|
||||
|| (insts_ && InstanceSet::intersects(insts_, to->instances(), network)));
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -1926,12 +1933,13 @@ ExceptionThru::deleteObjects(ExceptionThru *pt,
|
|||
}
|
||||
|
||||
bool
|
||||
ExceptionThru::intersectsPts(ExceptionThru *thru) const
|
||||
ExceptionThru::intersectsPts(ExceptionThru *thru,
|
||||
const Network *network) const
|
||||
{
|
||||
return thru->transition() == rf_
|
||||
&& ((pins_ && PinSet::intersects(pins_, thru->pins()))
|
||||
|| (nets_ && NetSet::intersects(nets_, thru->nets()))
|
||||
|| (insts_ && InstanceSet::intersects(insts_, thru->instances())));
|
||||
&& ((pins_ && PinSet::intersects(pins_, thru->pins(), network))
|
||||
|| (nets_ && NetSet::intersects(nets_, thru->nets(), network))
|
||||
|| (insts_ && InstanceSet::intersects(insts_, thru->instances(), network)));
|
||||
}
|
||||
|
||||
size_t
|
||||
|
|
@ -1973,7 +1981,7 @@ ExceptionThru::connectPinAfter(PinSet *drvrs,
|
|||
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))
|
||||
if (PinSet::intersects(drvrs, thru_pin_drvrs, network))
|
||||
makePinEdges(thru_pin, network);
|
||||
}
|
||||
}
|
||||
|
|
@ -1985,7 +1993,7 @@ ExceptionThru::connectPinAfter(PinSet *drvrs,
|
|||
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))
|
||||
if (PinSet::intersects(drvrs, inst_pin_drvrs, network))
|
||||
makePinEdges(inst_pin, network);
|
||||
}
|
||||
delete inst_pin_iter;
|
||||
|
|
@ -1995,7 +2003,7 @@ ExceptionThru::connectPinAfter(PinSet *drvrs,
|
|||
if (nets_) {
|
||||
for (const Net *net : *nets_) {
|
||||
PinSet *net_drvrs = network->drivers(net);
|
||||
if (PinSet::intersects(drvrs, net_drvrs))
|
||||
if (PinSet::intersects(drvrs, net_drvrs, network))
|
||||
makeNetEdges(net, network);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4355,7 +4355,7 @@ Sdc::findMatchingExceptionsFirstThru(ExceptionPath *exception,
|
|||
ExceptionThru *match_thru = (*match->thrus())[0];
|
||||
if (match_thru->nets()->hasKey(net)
|
||||
&& match->overrides(exception)
|
||||
&& match->intersectsPts(exception))
|
||||
&& match->intersectsPts(exception, network_))
|
||||
matches.insert(match);
|
||||
}
|
||||
}
|
||||
|
|
@ -4427,7 +4427,7 @@ Sdc::findMatchingExceptions(ExceptionPath *exception,
|
|||
if (potential_matches) {
|
||||
for (ExceptionPath *match : *potential_matches) {
|
||||
if (match->overrides(exception)
|
||||
&& match->intersectsPts(exception))
|
||||
&& match->intersectsPts(exception, network_))
|
||||
matches.insert(match);
|
||||
}
|
||||
}
|
||||
|
|
@ -5072,7 +5072,7 @@ Sdc::resetPath(ExceptionFrom *from,
|
|||
ExceptionPathSet::Iterator except_iter(exceptions_);
|
||||
while (except_iter.hasNext()) {
|
||||
ExceptionPath *match = except_iter.next();
|
||||
if (match->resetMatch(from, thrus, to, min_max)) {
|
||||
if (match->resetMatch(from, thrus, to, min_max, network_)) {
|
||||
debugPrint(debug_, "exception_match", 3, "reset match %s",
|
||||
match->asString(network_));
|
||||
ExceptionPathSet expansions;
|
||||
|
|
@ -5081,7 +5081,7 @@ Sdc::resetPath(ExceptionFrom *from,
|
|||
ExceptionPathSet::Iterator expand_iter(expansions);
|
||||
while (expand_iter.hasNext()) {
|
||||
ExceptionPath *expand = expand_iter.next();
|
||||
if (expand->resetMatch(from, thrus, to, min_max)) {
|
||||
if (expand->resetMatch(from, thrus, to, min_max, network_)) {
|
||||
unrecordPathDelayInternalStartpoints(expand->from());
|
||||
unrecordPathDelayInternalEndpoints(expand);
|
||||
delete expand;
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ CheckCrpr::crprPossible(const Clock *clk1,
|
|||
|| clk1->isGenerated()
|
||||
|| clk2->isGenerated()
|
||||
// Different non-generated clocks with the same source pins (using -add).
|
||||
|| PinSet::intersects(&clk1->pins(), &clk2->pins()));
|
||||
|| PinSet::intersects(&clk1->pins(), &clk2->pins(), network_));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
|||
Loading…
Reference in New Issue