Files
OpenROAD/include/ord/Design.h
Henner Zeller 5477201f3b Use absl::Mutex instead of std::mutex in most places.
absl::Mutex is generally optimized to reduce overhead and
minimized congestion, often it can avoid system calls.

In 'most places', as src/sta has to be dealt with
in the context of that repo.

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2026-02-19 09:07:52 -08:00

210 lines
3.8 KiB
C++

// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2022-2025, The OpenROAD Authors
#pragma once
#include <cstdint>
#include <memory>
#include <mutex>
#include <string>
#include <vector>
#include "absl/synchronization/mutex.h"
namespace odb {
class dbBlock;
class dbDatabase;
class dbMaster;
class dbMTerm;
class dbNet;
class dbInst;
class dbITerm;
} // namespace odb
namespace ifp {
class InitFloorplan;
}
namespace utl {
class Logger;
}
namespace ant {
class AntennaChecker;
}
namespace dft {
class Dft;
}
namespace grt {
class GlobalRouter;
}
namespace gpl {
class Replace;
}
namespace dpl {
class Opendp;
}
namespace exa {
class Example;
}
namespace mpl {
class MacroPlacer;
}
namespace ppl {
class IOPlacer;
}
namespace tap {
class Tapcell;
}
namespace cgt {
class ClockGating;
}
namespace cts {
class TritonCTS;
}
namespace drt {
class TritonRoute;
}
namespace fin {
class Finale;
}
namespace par {
class PartitionMgr;
}
namespace rcx {
class Ext;
}
namespace rmp {
class Restructure;
}
namespace rsz {
class Resizer;
}
namespace stt {
class SteinerTreeBuilder;
}
namespace psm {
class PDNSim;
}
namespace pdn {
class PdnGen;
}
namespace pad {
class ICeWall;
}
namespace sta {
class dbSta;
class LibertyCell;
} // namespace sta
namespace ord {
class OpenRoad;
class Tech;
class Design
{
public:
explicit Design(Tech* tech);
void readVerilog(const std::string& file_name);
void readDef(const std::string& file_name,
bool continue_on_errors = false,
bool floorplan_init = false,
bool incremental = false);
void link(const std::string& design_name);
void readDb(std::istream& stream);
void readDb(const std::string& file_name);
void writeDb(std::ostream& stream);
void writeDb(const std::string& file_name);
void writeDef(const std::string& file_name);
odb::dbBlock* getBlock();
utl::Logger* getLogger();
int micronToDBU(double coord);
// This is intended as a temporary back door to tcl from Python
std::string evalTclString(const std::string& cmd);
Tech* getTech();
bool isSequential(odb::dbMaster* master);
bool isBuffer(odb::dbMaster* master);
bool isInverter(odb::dbMaster* master);
bool isInSupply(odb::dbITerm* pin);
std::string getITermName(odb::dbITerm* pin);
bool isInClock(odb::dbInst* inst);
bool isInClock(odb::dbITerm* iterm);
std::uint64_t getNetRoutedLength(odb::dbNet* net);
// Services
ant::AntennaChecker* getAntennaChecker();
cgt::ClockGating* getClockGating();
cts::TritonCTS* getTritonCts();
dft::Dft* getDft();
dpl::Opendp* getOpendp();
exa::Example* getExample();
drt::TritonRoute* getTritonRoute();
fin::Finale* getFinale();
gpl::Replace* getReplace();
grt::GlobalRouter* getGlobalRouter();
ifp::InitFloorplan getFloorplan();
mpl::MacroPlacer* getMacroPlacer();
odb::dbDatabase* getDb();
pad::ICeWall* getICeWall();
par::PartitionMgr* getPartitionMgr();
pdn::PdnGen* getPdnGen();
ppl::IOPlacer* getIOPlacer();
psm::PDNSim* getPDNSim();
rcx::Ext* getOpenRCX();
rmp::Restructure* getRestructure();
rsz::Resizer* getResizer();
stt::SteinerTreeBuilder* getSteinerTreeBuilder();
tap::Tapcell* getTapcell();
// Needed by standalone startup, not for general use.
ord::OpenRoad* getOpenRoad();
// This returns a database that is not the one associated with
// the rest of the application. It is usable as a standalone
// db but should not passed to any other Design or Tech APIs.
//
// This is useful if you need a second database for specialized
// use cases and is not ordinarily required.
static odb::dbDatabase* createDetachedDb();
private:
sta::dbSta* getSta();
sta::LibertyCell* getLibertyCell(odb::dbMaster* master);
Tech* tech_;
// Single-thread access to the interpreter in evalTclString
static absl::Mutex interp_mutex;
};
} // namespace ord