prima thread safety

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2024-08-17 11:39:47 -07:00
parent b51885aa37
commit f54ab5b170
2 changed files with 22 additions and 14 deletions

View File

@ -16,6 +16,8 @@
#pragma once
#include <mutex>
#include "MinMax.hh"
#include "RiseFallMinMax.hh"
#include "ConcreteLibrary.hh"
@ -628,6 +630,7 @@ protected:
LibertyPgPortMap pg_port_map_;
bool has_internal_ports_;
bool have_voltage_waveforms_;
std::mutex waveform_lock_;
private:
friend class LibertyLibrary;

View File

@ -16,6 +16,7 @@
#include "Liberty.hh"
#include "Mutex.hh"
#include "EnumNameMap.hh"
#include "Report.hh"
#include "Debug.hh"
@ -1963,24 +1964,28 @@ void
LibertyCell::ensureVoltageWaveforms(const DcalcAnalysisPtSeq &dcalc_aps)
{
if (!have_voltage_waveforms_) {
float vdd = 0.0; // shutup gcc
bool vdd_exists;
liberty_library_->supplyVoltage("VDD", vdd, vdd_exists);
if (!vdd_exists || vdd == 0.0)
criticalError(1120, "library missing vdd");
for (TimingArcSet *arc_set : timingArcSets()) {
for (TimingArc *arc : arc_set->arcs()) {
for (const DcalcAnalysisPt *dcalc_ap : dcalc_aps) {
GateTableModel *model = arc->gateTableModel(dcalc_ap);
if (model) {
OutputWaveforms *output_waveforms = model->outputWaveforms();
if (output_waveforms)
output_waveforms->ensureVoltageWaveforms(vdd);
LockGuard lock(waveform_lock_);
// Recheck with lock.
if (!have_voltage_waveforms_) {
float vdd = 0.0; // shutup gcc
bool vdd_exists;
liberty_library_->supplyVoltage("VDD", vdd, vdd_exists);
if (!vdd_exists || vdd == 0.0)
criticalError(1120, "library missing vdd");
for (TimingArcSet *arc_set : timingArcSets()) {
for (TimingArc *arc : arc_set->arcs()) {
for (const DcalcAnalysisPt *dcalc_ap : dcalc_aps) {
GateTableModel *model = arc->gateTableModel(dcalc_ap);
if (model) {
OutputWaveforms *output_waveforms = model->outputWaveforms();
if (output_waveforms)
output_waveforms->ensureVoltageWaveforms(vdd);
}
}
}
}
have_voltage_waveforms_ = true;
}
have_voltage_waveforms_ = true;
}
}