File size: 3,225 Bytes
f61bac1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | // SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2022-2025, The OpenROAD Authors
#include "ord/Tech.h"
#include <string>
#include "db_sta/dbNetwork.hh"
#include "db_sta/dbSta.hh"
#include "odb/db.h"
#include "ord/OpenRoad.hh"
#include "sta/Liberty.hh"
#include "sta/MinMax.hh"
#include "sta/Scene.hh"
#include "sta/Units.hh"
#include "tcl.h"
namespace ord {
Tech::Tech(Tcl_Interp* interp,
const char* log_filename,
const char* metrics_filename)
: app_(new OpenRoad())
{
OpenRoad::setOpenRoad(app_, /* reinit_ok */ true);
if (!interp) {
interp = Tcl_CreateInterp();
Tcl_Init(interp);
app_->init(interp, log_filename, metrics_filename, false);
}
}
Tech::~Tech()
{
if (OpenRoad::openRoad() == app_) {
OpenRoad::setOpenRoad(nullptr, /* reinit_ok */ true);
}
delete app_;
}
odb::dbDatabase* Tech::getDB()
{
return app_->getDb();
}
odb::dbTech* Tech::getTech()
{
return getDB()->getTech();
}
sta::dbSta* Tech::getSta()
{
return app_->getSta();
}
void Tech::readLef(const std::string& file_name)
{
const bool make_tech = getDB()->getTech() == nullptr;
const bool make_library = true;
std::string lib_name = file_name;
// Hacky but easier than dealing with stdc++fs linking
auto slash_pos = lib_name.find_last_of('/');
if (slash_pos != std::string::npos) {
lib_name.erase(0, slash_pos + 1);
}
auto dot_pos = lib_name.find_last_of('.');
if (dot_pos != std::string::npos) {
lib_name.erase(lib_name.begin() + dot_pos, lib_name.end());
}
const char* tech_name = make_tech ? lib_name.c_str() : "";
app_->readLef(
file_name.c_str(), lib_name.c_str(), tech_name, make_tech, make_library);
}
void Tech::readLiberty(const std::string& file_name)
{
// TODO: take corner & min/max args
getSta()->readLiberty(file_name.c_str(),
getSta()->cmdScene(),
sta::MinMaxAll::all(),
true /* infer_latches */);
}
float Tech::nominalProcess()
{
sta::dbSta* sta = getSta();
sta::dbNetwork* network = sta->getDbNetwork();
sta::LibertyLibrary* lib = network->defaultLibertyLibrary();
return lib->nominalProcess();
}
float Tech::nominalVoltage()
{
sta::dbSta* sta = getSta();
sta::dbNetwork* network = sta->getDbNetwork();
sta::LibertyLibrary* lib = network->defaultLibertyLibrary();
return lib->nominalVoltage();
}
float Tech::nominalTemperature()
{
sta::dbSta* sta = getSta();
sta::dbNetwork* network = sta->getDbNetwork();
sta::LibertyLibrary* lib = network->defaultLibertyLibrary();
return lib->nominalTemperature();
}
float Tech::timeScale()
{
return getSta()->units()->timeUnit()->scale();
}
float Tech::resistanceScale()
{
return getSta()->units()->resistanceUnit()->scale();
}
float Tech::capacitanceScale()
{
return getSta()->units()->capacitanceUnit()->scale();
}
float Tech::voltageScale()
{
return getSta()->units()->voltageUnit()->scale();
}
float Tech::currentScale()
{
return getSta()->units()->currentUnit()->scale();
}
float Tech::powerScale()
{
return getSta()->units()->powerUnit()->scale();
}
float Tech::distanceScale()
{
return getSta()->units()->distanceUnit()->scale();
}
} // namespace ord
|