Merge remote-tracking branch 'cherry/master'

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
This commit is contained in:
Matt Liberty 2023-12-20 16:20:27 -08:00
commit edfe0c8904
4 changed files with 38 additions and 40 deletions

View File

@ -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)
{

View File

@ -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,33 +1448,21 @@ TableAxis::inBounds(float value) const
size_t
TableAxis::findAxisIndex(float value) const
{
int max = static_cast<int>(values_->size()) - 1;
if (max <= 0 || value <= (*values_)[0])
// Return 0 if value is too small or the table is empty.
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]);
if (ascend) {
while (upper - lower > 1) {
int mid = (upper + lower) >> 1;
if (value >= (*values_)[mid])
lower = mid;
else
upper = mid;
}
} else {
while (upper - lower > 1) {
int mid = (upper + lower) >> 1;
if (value < (*values_)[mid])
lower = mid;
else
upper = mid;
}
int upper = size;
while (upper - lower > 1) {
int mid = (upper + lower) >> 1;
if (value >= (*values_)[mid])
lower = mid;
else
upper = mid;
}
return lower;
}
@ -1486,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]) {
@ -1500,7 +1487,7 @@ TableAxis::findAxisIndex(float value,
exists = true;
return;
}
if ((value > (*values_)[mid]) == ascend)
if (value > (*values_)[mid])
lower = mid;
else
upper = mid;

View File

@ -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;
}

View File

@ -153,7 +153,7 @@ Vcd::varAppendValue(string &id,
char value)
{
VcdValues &values = id_values_map_[id];
values.push_back(VcdValue(time, value, 0));
values.emplace_back(time, value, 0);
}
void
@ -162,7 +162,7 @@ Vcd::varAppendBusValue(string &id,
int64_t bus_value)
{
VcdValues &values = id_values_map_[id];
values.push_back(VcdValue(time, '\0', bus_value));
values.emplace_back(time, '\0', bus_value);
}
VcdValues &