Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/OpenRoad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,27 @@ void OpenRoad::readDb(const char* filename, bool hierarchy)
void OpenRoad::readDb(std::istream& stream)
{
if (db_->getChip() && db_->getChip()->getBlock()) {
logger_->error(
ORD, 47, "You can't load a new db file as the db is already populated");
// Notify observers (STA, GUI) to clean up before clearing
db_->triggerPreDbClear();

// Clear tool-specific cached state to ensure reproducibility
global_router_->clearForReload();
opendp_->clearForReload();
detailed_router_->clearForReload();
replace_->reset();
tritonCts_->clear();
macro_placer_->clear();
tapcell_->reset();
ioPlacer_->clear();
pdngen_->reset();
pdnsim_->clearSolvers();
antenna_checker_->clear();
resizer_->clear();
extractor_->clear();
estimate_parasitics_->clear();
verilog_network_->clear();

db_->clear();
}

stream.exceptions(std::ifstream::failbit | std::ifstream::badbit
Expand Down
1 change: 1 addition & 0 deletions src/ant/include/ant/AntennaChecker.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class AntennaChecker
odb::dbMTerm* diode_mterm,
float ratio_margin);
void setReportFileName(const char* file_name);
void clear();

// Used in repair
void initAntennaRules();
Expand Down
14 changes: 14 additions & 0 deletions src/ant/src/AntennaChecker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ void AntennaChecker::setReportFileName(const char* file_name)
impl_->setReportFileName(file_name);
}

void AntennaChecker::clear()
{
impl_->clear();
}

void AntennaChecker::makeNetWiresFromGuides(
const std::vector<odb::dbNet*>& nets)
{
Expand Down Expand Up @@ -1304,6 +1309,15 @@ void AntennaChecker::Impl::setReportFileName(const char* file_name)
report_file_name_ = file_name;
}

void AntennaChecker::Impl::clear()
{
block_ = nullptr;
layer_info_.clear();
net_violation_count_ = 0;
nets_.clear();
net_to_report_.clear();
}

void AntennaChecker::Impl::makeNetWiresFromGuides(
const std::vector<odb::dbNet*>& nets)
{
Expand Down
1 change: 1 addition & 0 deletions src/ant/src/AntennaCheckerImpl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class AntennaChecker::Impl
float ratio_margin);
void initAntennaRules();
void setReportFileName(const char* file_name);
void clear();
void makeNetWiresFromGuides(const std::vector<odb::dbNet*>& nets);

private:
Expand Down
3 changes: 3 additions & 0 deletions src/cts/include/cts/TritonCTS.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class TritonCTS
void resetRootBuffer() { rootBuffers_.clear(); }
void setSinkBuffer(const char* buffers);

void clear();

private:
std::string selectRootBuffer(std::vector<std::string>& buffers);
std::string selectSinkBuffer(std::vector<std::string>& buffers);
Expand Down Expand Up @@ -219,6 +221,7 @@ class TritonCTS
sta::dbSta* openSta_ = nullptr;
sta::dbNetwork* network_ = nullptr;
utl::Logger* logger_ = nullptr;
stt::SteinerTreeBuilder* st_builder_ = nullptr;
CtsOptions* options_ = nullptr;
std::unique_ptr<TechChar> techChar_;
rsz::Resizer* resizer_ = nullptr;
Expand Down
27 changes: 26 additions & 1 deletion src/cts/src/TritonCTS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,42 @@ TritonCTS::TritonCTS(utl::Logger* logger,
db_ = db;
network_ = network;
openSta_ = sta;
st_builder_ = st_builder;
resizer_ = resizer;
estimate_parasitics_ = estimate_parasitics;

options_ = new CtsOptions(logger_, st_builder);
options_ = new CtsOptions(logger_, st_builder_);
}

TritonCTS::~TritonCTS()
{
delete options_;
}

void TritonCTS::clear()
{
techChar_.reset();
builders_.clear();
staClockNets_.clear();
visitedClockNets_.clear();
inst2clkbuf_.clear();
driver2subnet_.clear();
net2builder_.clear();
rootBuffers_.clear();
sinkBuffers_.clear();
// Recreate options to reset all Tcl-settable CTS configuration
// (buffer list, cap/slew ranges, clustering, etc.)
delete options_;
options_ = new CtsOptions(logger_, st_builder_);
block_ = nullptr;
numberOfClocks_ = 0;
numClkNets_ = 0;
numFixedNets_ = 0;
dummyLoadIndex_ = 0;
regTreeRootBufIndex_ = 0;
delayBufIndex_ = 0;
}

void TritonCTS::runTritonCts()
{
odb::dbChip* chip = db_->getChip();
Expand Down
1 change: 1 addition & 0 deletions src/dbSta/include/db_sta/dbSta.hh
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class dbSta : public Sta, public odb::dbDatabaseObserver
void postReadDef(odb::dbBlock* block) override;
void postReadDb(odb::dbDatabase* db) override;
void postRead3Dbx(odb::dbChip* chip) override;
void preDbClear(odb::dbDatabase* db) override;

// Find clock nets connected by combinational gates from the clock roots.
std::set<odb::dbNet*> findClkNets();
Expand Down
2 changes: 2 additions & 0 deletions src/dbSta/src/dbNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,8 @@ void dbNetwork::clear()
{
ConcreteNetwork::clear();
db_ = nullptr;
block_ = nullptr;
top_cell_ = nullptr;
}

Instance* dbNetwork::topInstance() const
Expand Down
21 changes: 21 additions & 0 deletions src/dbSta/src/dbSta.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,27 @@ void dbSta::postReadDb(odb::dbDatabase* db)
}
}

void dbSta::preDbClear(odb::dbDatabase* db)
{
db_cbk_->removeOwner();
// Clear staCell pointers on all masters before freeing the network.
// The GUI render thread may still be accessing these concurrently.
for (odb::dbLib* lib : db->getLibs()) {
for (odb::dbMaster* master : lib->getMasters()) {
master->staSetCell(nullptr);
}
}
// Delete scenes before clearing the network, since scenes hold
// LibertyLibrary pointers that ConcreteNetwork::clear() will free.
// Recreate the default scene so cmd_scene_ remains valid.
deleteScenes();
makeDefaultScene();
clear();
db_network_->clear();
// Restore db_ since dbNetwork::clear() nulls it, but we need it for reload
db_network_->init(db_, logger_);
Comment thread
eder-matheus marked this conversation as resolved.
}

float dbSta::slack(const odb::dbNet* db_net, const MinMax* min_max)
{
const Net* net = db_network_->dbToSta(db_net);
Expand Down
1 change: 1 addition & 0 deletions src/dpl/include/dpl/Opendp.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Opendp
public:
Opendp(odb::dbDatabase* db, utl::Logger* logger);
~Opendp();
void clearForReload();

Opendp(const Opendp&) = delete;
Opendp& operator=(const Opendp&) = delete;
Expand Down
10 changes: 10 additions & 0 deletions src/dpl/src/Opendp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ Opendp::Opendp(odb::dbDatabase* db, utl::Logger* logger)

Opendp::~Opendp() = default;

void Opendp::clearForReload()
{
importClear();
padding_ = std::make_shared<Padding>();
decap_masters_.clear();
disallow_one_site_gaps_ = false;
extra_dpl_enabled_ = false;
global_swap_params_ = GlobalSwapParams();
}

void Opendp::setPaddingGlobal(const int left, const int right)
{
padding_->setPaddingGlobal(GridX{left}, GridX{right});
Expand Down
1 change: 1 addition & 0 deletions src/drt/include/drt/TritonRoute.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class TritonRoute : public PinAccessService
void updateGlobals(const char* file_name);
void resetDb(const char* file_name);
void clearDesign();
void clearForReload();
void updateDesign(const std::vector<std::string>& updates, int num_threads);
void updateDesign(const std::string& path, int num_threads);
void addWorkerResults(
Expand Down
19 changes: 19 additions & 0 deletions src/drt/src/TritonRoute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,25 @@ void TritonRoute::clearDesign()
design_ = std::make_unique<frDesign>(logger_, router_cfg_.get());
}

void TritonRoute::clearForReload()
{
router_cfg_ = std::make_unique<RouterConfiguration>();
design_ = std::make_unique<frDesign>(logger_, router_cfg_.get());
dr_.reset();
pa_.reset();
// Block destructor will remove this callback; just detach so it can
// re-register on the new block via initDesign().
db_callback_->removeOwner();
num_drvs_ = -1;
distributed_ = false;
dist_ip_.clear();
dist_port_ = 0;
shared_volume_.clear();
workers_results_.clear();
results_sz_ = 0;
cloud_sz_ = 0;
}

static void deserializeUpdate(frDesign* design,
const std::string& updateStr,
std::vector<drUpdate>& updates)
Expand Down
1 change: 1 addition & 0 deletions src/est/include/est/EstimateParasitics.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class EstimateParasitics : public sta::dbStaState, public ParasiticsService
stt::SteinerTreeBuilder* stt_builder,
grt::GlobalRouter* global_router);
~EstimateParasitics() override;
void clear();

void estimateAllGlobalRouteParasitics() override;
void initSteinerRenderer(
Expand Down
17 changes: 17 additions & 0 deletions src/est/src/EstimateParasitics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ EstimateParasitics::~EstimateParasitics()
service_registry_->withdraw<ParasiticsService>(this);
}

void EstimateParasitics::clear()
{
block_ = nullptr;
signal_layers_.clear();
clk_layers_.clear();
layer_res_.clear();
layer_cap_.clear();
wire_signal_res_.clear();
wire_signal_cap_.clear();
wire_clk_res_.clear();
wire_clk_cap_.clear();
parasitics_src_ = ParasiticsSrc::kNone;
parasitics_invalid_.clear();
dbu_ = 0;
incremental_parasitics_enabled_ = false;
}

void EstimateParasitics::estimateAllGlobalRouteParasitics()
{
clearParasitics();
Expand Down
2 changes: 2 additions & 0 deletions src/gpl/src/replace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ void Replace::reset()

tb_.reset();
rb_.reset();

clusters_.clear();
}

void Replace::addPlacementCluster(const Cluster& cluster)
Expand Down
2 changes: 2 additions & 0 deletions src/grt/include/grt/GlobalRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class GlobalRouter
gui::HeatMapSourceHandle routing_congestion_data_source_rudy);

void clear();
void clearForReload();

void setAdjustment(float adjustment);
void setMinRoutingLayer(int min_layer);
Expand Down Expand Up @@ -333,6 +334,7 @@ class GlobalRouter
odb::dbDatabase* db() const { return db_; }
FastRouteCore* fastroute() const { return fastroute_; }
Rudy* getRudy();
void clearRudy();

void writePinLocations(const char* file_name);

Expand Down
49 changes: 49 additions & 0 deletions src/grt/src/GlobalRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ void GlobalRouter::initGui(
void GlobalRouter::clear()
{
routes_.clear();
partial_routes_.clear();
for (auto [ignored, net] : db_net_map_) {
delete net;
}
Expand All @@ -131,7 +132,49 @@ void GlobalRouter::clear()
fastroute_->clear();
vertical_capacities_.clear();
horizontal_capacities_.clear();

pad_pins_connections_.clear();
h_nets_in_pos_.clear();
v_nets_in_pos_.clear();

block_ = nullptr;
delete repair_antennas_;
repair_antennas_ = nullptr;
delete grouter_cbk_;
grouter_cbk_ = nullptr;

initialized_ = false;
is_incremental_ = false;
total_diodes_count_ = 0;
}

void GlobalRouter::clearForReload()
{
clear();
clearRudy();
region_adjustments_.clear();
dirty_nets_.clear();
nets_to_route_.clear();

// Reset Tcl-settable configuration to constructor defaults
adjustment_ = 0.0;
congestion_iterations_ = 50;
congestion_report_iter_step_ = 0;
allow_congestion_ = false;
resistance_aware_ = false;
macro_extension_ = 0;
infinite_capacity_ = false;
grid_origin_ = odb::Point(0, 0);
verbose_ = false;
seed_ = 0;
caps_perturbation_percentage_ = 0;
perturbation_amount_ = 1;
use_cugr_ = false;
skip_large_fanout_ = std::numeric_limits<int>::max();
congestion_file_name_ = nullptr;
is_congested_ = false;
has_macros_or_pads_ = false;
check_pin_placement_ = true;
}

GlobalRouter::~GlobalRouter()
Expand Down Expand Up @@ -1139,6 +1182,12 @@ Rudy* GlobalRouter::getRudy()
return rudy_;
}

void GlobalRouter::clearRudy()
{
delete rudy_;
rudy_ = nullptr;
}

bool GlobalRouter::findPinAccessPointPositions(
const Pin& pin,
std::map<int, std::vector<PointPair>>& ap_positions,
Expand Down
9 changes: 9 additions & 0 deletions src/grt/src/GrouteRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ void GrouteRenderer::highlightRoute(odb::dbNet* net, bool show_pin_locations)

void GrouteRenderer::drawLayer(odb::dbTechLayer* layer, gui::Painter& painter)
{
// After a database reload, cached net pointers are stale.
// Detect the reload by checking if the tech changed.
if (layer->getTech() != tech_) {
tech_ = layer->getTech();
nets_.clear();
show_segments_.clear();
show_pin_locations_.clear();
}

painter.setPen(layer);
painter.setBrush(layer);

Expand Down
6 changes: 6 additions & 0 deletions src/grt/src/heatMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class RoutingCongestionDataSource : public gui::GlobalRoutingDataSource
public:
RoutingCongestionDataSource(utl::Logger* logger, odb::dbDatabase* db);

void setChip(odb::dbChip* chip) override
{
layer_ = nullptr;
HeatMapDataSource::setChip(chip);
}

protected:
bool populateMap() override;
void combineMapData(bool base_has_value,
Expand Down
Loading
Loading