TableAxis::findAxisIndex axis values are always ascending
Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
parent
31cb8c2822
commit
fd53832b6e
|
|
@ -1370,15 +1370,14 @@ LibertyReader::makeAxis(int index,
|
|||
float scale = tableVariableUnit(axis_var, units)->scale();
|
||||
scaleFloats(axis_values, scale);
|
||||
}
|
||||
return std::make_shared<TableAxis>(axis_var, axis_values);
|
||||
return make_shared<TableAxis>(axis_var, axis_values);
|
||||
}
|
||||
else if (axis_values) {
|
||||
libWarn(62, group, "missing variable_%d attribute.", index + 1);
|
||||
delete axis_values;
|
||||
axis_values_[index] = nullptr;
|
||||
}
|
||||
// No warning for missing index_xx attributes because they are
|
||||
// not required by ic_shell.
|
||||
// No warning for missing index_xx attributes because they are not required.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -1448,8 +1447,20 @@ LibertyReader::visitIndex(int index,
|
|||
// Ignore index_xx in ecsm_waveform groups.
|
||||
&& !stringEq(libertyGroup()->type(), "ecsm_waveform")) {
|
||||
FloatSeq *axis_values = readFloatSeq(attr, 1.0F);
|
||||
if (axis_values)
|
||||
if (axis_values) {
|
||||
if (axis_values->empty())
|
||||
libWarn(172, attr, "missing table index values.");
|
||||
else {
|
||||
float prev = (*axis_values)[0];
|
||||
for (size_t i = 1; i < axis_values->size(); i++) {
|
||||
float value = (*axis_values)[i];
|
||||
if (value <= prev)
|
||||
libWarn(173, attr, "non-increasing table index values.");
|
||||
prev = value;
|
||||
}
|
||||
}
|
||||
axis_values_[index] = axis_values;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4366,7 +4377,7 @@ LibertyReader::makeTableAxis(int index)
|
|||
const Units *units = library_->units();
|
||||
float scale = tableVariableUnit(var, units)->scale();
|
||||
scaleFloats(values, scale);
|
||||
axis_[index] = std::make_shared<TableAxis>(var, values);
|
||||
axis_[index] = make_shared<TableAxis>(var, values);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5395,7 +5406,7 @@ RelatedPortGroup::setIsOneToOne(bool one)
|
|||
|
||||
TimingGroup::TimingGroup(int line) :
|
||||
RelatedPortGroup(line),
|
||||
attrs_(std::make_shared<TimingArcAttrs>()),
|
||||
attrs_(make_shared<TimingArcAttrs>()),
|
||||
related_output_port_name_(nullptr),
|
||||
receiver_model_(nullptr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1413,7 +1413,7 @@ Table3::report(const Units *units,
|
|||
line = unit2->asString(axis2_->axisValue(axis_index2),digits);
|
||||
line += " |";
|
||||
for (size_t axis_index3 = 0; axis_index3 < axis3_->size(); axis_index3++) {
|
||||
line += table_unit->asString(value(axis_index1, axis_index2, axis_index3), digits);
|
||||
line += table_unit->asString(value(axis_index1, axis_index2, axis_index3),digits);
|
||||
line += " ";
|
||||
}
|
||||
report->reportLineString(line);
|
||||
|
|
@ -1448,19 +1448,18 @@ TableAxis::inBounds(float value) const
|
|||
size_t
|
||||
TableAxis::findAxisIndex(float value) const
|
||||
{
|
||||
int max = static_cast<int>(values_->size()) - 1;
|
||||
if (value <= (*values_)[0] || max == 0)
|
||||
size_t size = values_->size();
|
||||
if (size <= 1 || value <= (*values_)[0])
|
||||
return 0;
|
||||
else if (value >= (*values_)[max])
|
||||
// Return max-1 for value too large so interpolation pts are index,index+1.
|
||||
return max - 1;
|
||||
else if (value >= (*values_)[size - 1])
|
||||
// Return max_index-1 for value too large so interpolation pts are index,index+1.
|
||||
return size - 2;
|
||||
else {
|
||||
int lower = -1;
|
||||
int upper = max + 1;
|
||||
bool ascend = ((*values_)[max] >= (*values_)[0]);
|
||||
int upper = size;
|
||||
while (upper - lower > 1) {
|
||||
int mid = (upper + lower) >> 1;
|
||||
if ((value >= (*values_)[mid]) == ascend)
|
||||
if (value >= (*values_)[mid])
|
||||
lower = mid;
|
||||
else
|
||||
upper = mid;
|
||||
|
|
@ -1475,13 +1474,12 @@ TableAxis::findAxisIndex(float value,
|
|||
size_t &index,
|
||||
bool &exists) const
|
||||
{
|
||||
int max = static_cast<int>(values_->size()) - 1;
|
||||
if (!values_->empty()
|
||||
size_t size = values_->size();
|
||||
if (size != 0
|
||||
&& value >= (*values_)[0]
|
||||
&& value <= (*values_)[max]) {
|
||||
&& value <= (*values_)[size - 1]) {
|
||||
int lower = -1;
|
||||
int upper = max + 1;
|
||||
bool ascend = ((*values_)[max] >= (*values_)[0]);
|
||||
int upper = size;
|
||||
while (upper - lower > 1) {
|
||||
int mid = (upper + lower) >> 1;
|
||||
if (value == (*values_)[mid]) {
|
||||
|
|
@ -1489,7 +1487,7 @@ TableAxis::findAxisIndex(float value,
|
|||
exists = true;
|
||||
return;
|
||||
}
|
||||
if ((value > (*values_)[mid]) == ascend)
|
||||
if (value > (*values_)[mid])
|
||||
lower = mid;
|
||||
else
|
||||
upper = mid;
|
||||
|
|
|
|||
|
|
@ -729,6 +729,6 @@ int
|
|||
SpefParse_error(const char *msg)
|
||||
{
|
||||
spefFlushBuffer();
|
||||
sta::spef_reader->warn(179, "%s.", msg);
|
||||
sta::spef_reader->warn(707, "%s.", msg);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue