write_timing_model escaped port resolves #222

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2025-03-26 10:01:16 -07:00
parent 206a581a1e
commit 950d5b3383
3 changed files with 41 additions and 16 deletions

View File

@ -59,8 +59,7 @@ LibertyPort *
LibertyBuilder::makePort(LibertyCell *cell, LibertyBuilder::makePort(LibertyCell *cell,
const char *port_name) const char *port_name)
{ {
string sta_name = portLibertyToSta(port_name); LibertyPort *port = new LibertyPort(cell, port_name, false, nullptr,
LibertyPort *port = new LibertyPort(cell, sta_name.c_str(), false, nullptr,
-1, -1, false, nullptr); -1, -1, false, nullptr);
cell->addPort(port); cell->addPort(port);
return port; return port;
@ -73,12 +72,11 @@ LibertyBuilder::makeBusPort(LibertyCell *cell,
int to_index, int to_index,
BusDcl *bus_dcl) BusDcl *bus_dcl)
{ {
string sta_name = portLibertyToSta(bus_name); LibertyPort *port = new LibertyPort(cell, bus_name, true, bus_dcl,
LibertyPort *port = new LibertyPort(cell, sta_name.c_str(), true, bus_dcl,
from_index, to_index, from_index, to_index,
false, new ConcretePortSeq); false, new ConcretePortSeq);
cell->addPort(port); cell->addPort(port);
makeBusPortBits(cell->library(), cell, port, sta_name.c_str(), from_index, to_index); makeBusPortBits(cell->library(), cell, port, bus_name, from_index, to_index);
return port; return port;
} }

View File

@ -2215,7 +2215,7 @@ LibertyReader::makeStatetable()
for (const string &internal : statetable_->internalPorts()) { for (const string &internal : statetable_->internalPorts()) {
LibertyPort *port = cell_->findLibertyPort(internal.c_str()); LibertyPort *port = cell_->findLibertyPort(internal.c_str());
if (port == nullptr) if (port == nullptr)
port = builder_.makePort(cell_, internal.c_str()); port = makePort(cell_, internal.c_str());
internal_ports.push_back(port); internal_ports.push_back(port);
} }
cell_->makeStatetable(input_ports, internal_ports, statetable_->table()); cell_->makeStatetable(input_ports, internal_ports, statetable_->table());
@ -3181,7 +3181,7 @@ LibertyReader::beginPin(LibertyGroup *group)
debugPrint(debug_, "liberty", 1, " port %s", name); debugPrint(debug_, "liberty", 1, " port %s", name);
LibertyPort *port = findPort(name); LibertyPort *port = findPort(name);
if (port == nullptr) if (port == nullptr)
port = builder_.makePort(cell_, name); port = makePort(cell_, name);
ports_->push_back(port); ports_->push_back(port);
} }
else else
@ -3195,7 +3195,7 @@ LibertyReader::beginPin(LibertyGroup *group)
if (param->isString()) { if (param->isString()) {
const char *name = param->stringValue(); const char *name = param->stringValue();
debugPrint(debug_, "liberty", 1, " port %s", name); debugPrint(debug_, "liberty", 1, " port %s", name);
LibertyPort *port = builder_.makePort(cell_, name); LibertyPort *port = makePort(cell_, name);
ports_->push_back(port); ports_->push_back(port);
} }
else else
@ -3207,6 +3207,25 @@ LibertyReader::beginPin(LibertyGroup *group)
} }
} }
LibertyPort *
LibertyReader::makePort(LibertyCell *cell,
const char *port_name)
{
string sta_name = portLibertyToSta(port_name);
return builder_.makePort(cell, sta_name.c_str());
}
LibertyPort *
LibertyReader::makeBusPort(LibertyCell *cell,
const char *bus_name,
int from_index,
int to_index,
BusDcl *bus_dcl)
{
string sta_name = portLibertyToSta(bus_name);
return builder_.makeBusPort(cell, bus_name, from_index, to_index, bus_dcl);
}
void void
LibertyReader::endPin(LibertyGroup *) LibertyReader::endPin(LibertyGroup *)
{ {
@ -3317,7 +3336,7 @@ LibertyReader::visitBusType(LibertyAttr *attr)
if (bus_dcl) { if (bus_dcl) {
for (const char *name : bus_names_) { for (const char *name : bus_names_) {
debugPrint(debug_, "liberty", 1, " bus %s", name); debugPrint(debug_, "liberty", 1, " bus %s", name);
LibertyPort *port = builder_.makeBusPort(cell_, name, bus_dcl->from(), LibertyPort *port = makeBusPort(cell_, name, bus_dcl->from(),
bus_dcl->to(), bus_dcl); bus_dcl->to(), bus_dcl);
ports_->push_back(port); ports_->push_back(port);
} }
@ -3363,7 +3382,7 @@ LibertyReader::visitMembers(LibertyAttr *attr)
const char *port_name = value->stringValue(); const char *port_name = value->stringValue();
LibertyPort *port = findPort(port_name); LibertyPort *port = findPort(port_name);
if (port == nullptr) if (port == nullptr)
port = builder_.makePort(cell_, port_name); port = makePort(cell_, port_name);
members->push_back(port); members->push_back(port);
} }
else else
@ -3964,16 +3983,16 @@ LibertyReader::beginSequential(LibertyGroup *group,
LibertyPort *out_port_inv = nullptr; LibertyPort *out_port_inv = nullptr;
if (out_name) { if (out_name) {
if (has_size) if (has_size)
out_port = builder_.makeBusPort(cell_, out_name, size - 1, 0, nullptr); out_port = makeBusPort(cell_, out_name, size - 1, 0, nullptr);
else else
out_port = builder_.makePort(cell_, out_name); out_port = makePort(cell_, out_name);
out_port->setDirection(PortDirection::internal()); out_port->setDirection(PortDirection::internal());
} }
if (out_inv_name) { if (out_inv_name) {
if (has_size) if (has_size)
out_port_inv = builder_.makeBusPort(cell_, out_inv_name, size - 1, 0, nullptr); out_port_inv = makeBusPort(cell_, out_inv_name, size - 1, 0, nullptr);
else else
out_port_inv = builder_.makePort(cell_, out_inv_name); out_port_inv = makePort(cell_, out_inv_name);
out_port_inv->setDirection(PortDirection::internal()); out_port_inv->setDirection(PortDirection::internal());
} }
sequential_ = new SequentialGroup(is_register, is_bank, sequential_ = new SequentialGroup(is_register, is_bank,
@ -4791,7 +4810,7 @@ LibertyReader::beginLut(LibertyGroup *group)
while (parser.hasNext()) { while (parser.hasNext()) {
char *name = parser.next(); char *name = parser.next();
if (name[0] != '\0') { if (name[0] != '\0') {
LibertyPort *port = builder_.makePort(cell_, name); LibertyPort *port = makePort(cell_, name);
port->setDirection(PortDirection::internal()); port->setDirection(PortDirection::internal());
} }
} }

View File

@ -500,6 +500,14 @@ public:
const char *port_name); const char *port_name);
protected: protected:
LibertyPort *makePort(LibertyCell *cell,
const char *port_name);
LibertyPort *makeBusPort(LibertyCell *cell,
const char *bus_name,
int from_index,
int to_index,
BusDcl *bus_dcl);
TimingModel *makeScalarCheckModel(float value, TimingModel *makeScalarCheckModel(float value,
ScaleFactorType scale_factor_type, ScaleFactorType scale_factor_type,
const RiseFall *rf); const RiseFall *rf);