Skip to content

Commit

Permalink
wire_load fanout_length values in quotes ucsd20190808
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcherry56 committed Aug 8, 2019
1 parent 73fef11 commit e16696c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 86 deletions.
98 changes: 41 additions & 57 deletions liberty/LibertyReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1700,30 +1700,13 @@ void
LibertyReader::visitFanoutLength(LibertyAttr *attr)
{
if (wireload_) {
if (attr->isComplex()) {
LibertyAttrValueIterator value_iter(attr->values());
if (value_iter.hasNext()) {
LibertyAttrValue *value = value_iter.next();
if (value->isFloat()) {
float fanout = value->floatValue();
if (value_iter.hasNext()) {
value = value_iter.next();
if (value->isFloat())
wireload_->addFanoutLength(fanout, value->floatValue());
else
libWarn(attr, "fanout_length fanout not a float.\n");
}
else
libWarn(attr, "fanout_length is missing length.\n");
}
else
libWarn(attr, "fanout_length fanout not an integer.\n");
}
else
libWarn(attr, "fanout_length is missing fanout and length.\n");
}
float fanout, length;
bool exists;
getAttrFloat2(attr, fanout, length, exists);
if (exists)
wireload_->addFanoutLength(fanout, length);
else
libWarn(attr, "fanout_length is missing fanout and length.\n");
libWarn(attr, "fanout_length is missing length and fanout.\n");
}
}

Expand Down Expand Up @@ -4155,31 +4138,39 @@ LibertyReader::getAttrFloat(LibertyAttr *attr,
bool &valid)
{
valid = false;
if (attr->isSimple()) {
LibertyAttrValue *first = attr->firstValue();
if (first->isFloat()) {
if (attr->isSimple())
getAttrFloat(attr, attr->firstValue(), value, valid);
else
libWarn(attr, "%s is not a simple attribute.\n", attr->name());
}

void
LibertyReader::getAttrFloat(LibertyAttr *attr,
LibertyAttrValue *attr_value,
// Return values.
float &value,
bool &valid)
{
if (attr_value->isFloat()) {
valid = true;
value = attr_value->floatValue();
}
else if (attr_value->isString()) {
const char *string = attr_value->stringValue();
// See if attribute string is a variable.
variableValue(string, value, valid);
if (!valid) {
// For some reason area attributes for pads are quoted floats.
// Check that the string is a valid double.
char *end;
value = strtof(string, &end);
if (*end && !isspace(*end))
libWarn(attr, "%s value %s is not a float.\n",
attr->name(),
string);
valid = true;
value = first->floatValue();
}
else if (first->isString()) {
const char *string = first->stringValue();
// See if attribute string is a variable.
variableValue(string, value, valid);
if (!valid) {
// For some reason area attributes for pads are quoted floats.
// Check that the string is a valid double.
char *end;
value = strtof(string, &end);
if (*end && !isspace(*end))
libWarn(attr, "%s value %s is not a float.\n",
attr->name(),
string);
valid = true;
}
}
}
else
libWarn(attr, "%s is not a simple attribute.\n", attr->name());
}

// Get two floats in a complex attribute.
Expand All @@ -4196,25 +4187,18 @@ LibertyReader::getAttrFloat2(LibertyAttr *attr,
LibertyAttrValueIterator value_iter(attr->values());
if (value_iter.hasNext()) {
LibertyAttrValue *value = value_iter.next();
if (value->isFloat()) {
value1 = value->floatValue();
getAttrFloat(attr, value, value1, exists);
if (exists) {
if (value_iter.hasNext()) {
value = value_iter.next();
if (value->isFloat()) {
value2 = value->floatValue();
exists = true;
}
else
libWarn(attr, "%s value is not a float.\n", attr->name());
getAttrFloat(attr, value, value2, exists);
}
else
libWarn(attr, "%s range missing second value.\n", attr->name());
libWarn(attr, "%s missing values.\n", attr->name());
}
else
libWarn(attr, "%s value is not a float.\n", attr->name());
}
else
libWarn(attr, "%s range missing values.\n", attr->name());
libWarn(attr, "%s missing values.\n", attr->name());
}
else
libWarn(attr, "%s is not a complex attribute.\n", attr->name());
Expand Down
5 changes: 5 additions & 0 deletions liberty/LibertyReaderPvt.hh
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,11 @@ protected:
// Return values.
float &value,
bool &valid);
void getAttrFloat(LibertyAttr *attr,
LibertyAttrValue *attr_value,
// Return values.
float &value,
bool &valid);
void getAttrFloat2(LibertyAttr *attr,
// Return values.
float &value1,
Expand Down
63 changes: 34 additions & 29 deletions liberty/Wireload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,38 +106,43 @@ Wireload::findWireload(float fanout,
float &cap,
float &res) const
{
int max = static_cast<int>(fanout_lengths_.size()) - 1;
float fanout0 = fanout_lengths_[0]->first;
float fanout_max = fanout_lengths_[max]->first;
size_t size = fanout_lengths_.size();
float length;
if (fanout == fanout0)
length = fanout_lengths_[0]->second;
else if (fanout <= fanout0) {
// Extrapolate from lowest fanout entry.
length = fanout_lengths_[0]->second - (fanout0 - fanout) * slope_;
if (length < 0)
length = 0;
}
else if (fanout >= fanout_max)
// Extrapolate from max fanout entry.
length = fanout_lengths_[max]->second + (fanout - fanout_max) * slope_;
if (size == 0)
length = 0;
else {
// Bisection search.
int lower = -1;
int upper = max + 1;
while (upper - lower > 1) {
int mid = (upper + lower) >> 1;
if (fanout >= fanout_lengths_[mid]->first)
lower = mid;
else
upper = mid;
size_t max = size - 1;
float fanout0 = fanout_lengths_[0]->first;
float fanout_max = fanout_lengths_[max]->first;
if (fanout < fanout0) {
// Extrapolate from lowest fanout entry.
length = fanout_lengths_[0]->second - (fanout0 - fanout) * slope_;
if (length < 0)
length = 0;
}
else if (fanout == fanout0)
length = fanout_lengths_[0]->second;
else if (fanout >= fanout_max)
// Extrapolate from max fanout entry.
length = fanout_lengths_[max]->second + (fanout - fanout_max) * slope_;
else {
// Bisection search.
int lower = -1;
int upper = size;
while (upper - lower > 1) {
int mid = (upper + lower) >> 1;
if (fanout >= fanout_lengths_[mid]->first)
lower = mid;
else
upper = mid;
}
// Interpolate between lower and lower+1 entries.
float fanout1 = fanout_lengths_[lower]->first;
float fanout2 = fanout_lengths_[lower+1]->first;
float l1 = fanout_lengths_[lower]->second;
float l2 = fanout_lengths_[lower+1]->second;
length = l1 + (l2 - l1) * (fanout - fanout1) / (fanout2 - fanout1);
}
// Interpolate between lower and lower+1 entries.
float fanout1 = fanout_lengths_[lower]->first;
float fanout2 = fanout_lengths_[lower+1]->first;
float l1 = fanout_lengths_[lower]->second;
float l2 = fanout_lengths_[lower+1]->second;
length = l1 + (l2 - l1) * (fanout - fanout1) / (fanout2 - fanout1);
}
// Scale resistance and capacitance.
cap = length * capacitance_
Expand Down

0 comments on commit e16696c

Please sign in to comment.