From 950d5b3383553d8a8db1679656a948b191a28f04 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Wed, 26 Mar 2025 10:01:16 -0700 Subject: [PATCH] write_timing_model escaped port resolves #222 Signed-off-by: James Cherry --- liberty/LibertyBuilder.cc | 8 +++----- liberty/LibertyReader.cc | 41 +++++++++++++++++++++++++++---------- liberty/LibertyReaderPvt.hh | 8 ++++++++ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/liberty/LibertyBuilder.cc b/liberty/LibertyBuilder.cc index 1bbca275..0756d101 100644 --- a/liberty/LibertyBuilder.cc +++ b/liberty/LibertyBuilder.cc @@ -59,8 +59,7 @@ LibertyPort * LibertyBuilder::makePort(LibertyCell *cell, const char *port_name) { - string sta_name = portLibertyToSta(port_name); - LibertyPort *port = new LibertyPort(cell, sta_name.c_str(), false, nullptr, + LibertyPort *port = new LibertyPort(cell, port_name, false, nullptr, -1, -1, false, nullptr); cell->addPort(port); return port; @@ -73,12 +72,11 @@ LibertyBuilder::makeBusPort(LibertyCell *cell, int to_index, BusDcl *bus_dcl) { - string sta_name = portLibertyToSta(bus_name); - LibertyPort *port = new LibertyPort(cell, sta_name.c_str(), true, bus_dcl, + LibertyPort *port = new LibertyPort(cell, bus_name, true, bus_dcl, from_index, to_index, false, new ConcretePortSeq); 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; } diff --git a/liberty/LibertyReader.cc b/liberty/LibertyReader.cc index cc75aa25..35d8b31f 100644 --- a/liberty/LibertyReader.cc +++ b/liberty/LibertyReader.cc @@ -2215,7 +2215,7 @@ LibertyReader::makeStatetable() for (const string &internal : statetable_->internalPorts()) { LibertyPort *port = cell_->findLibertyPort(internal.c_str()); if (port == nullptr) - port = builder_.makePort(cell_, internal.c_str()); + port = makePort(cell_, internal.c_str()); internal_ports.push_back(port); } cell_->makeStatetable(input_ports, internal_ports, statetable_->table()); @@ -3181,7 +3181,7 @@ LibertyReader::beginPin(LibertyGroup *group) debugPrint(debug_, "liberty", 1, " port %s", name); LibertyPort *port = findPort(name); if (port == nullptr) - port = builder_.makePort(cell_, name); + port = makePort(cell_, name); ports_->push_back(port); } else @@ -3195,7 +3195,7 @@ LibertyReader::beginPin(LibertyGroup *group) if (param->isString()) { const char *name = param->stringValue(); debugPrint(debug_, "liberty", 1, " port %s", name); - LibertyPort *port = builder_.makePort(cell_, name); + LibertyPort *port = makePort(cell_, name); ports_->push_back(port); } 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 LibertyReader::endPin(LibertyGroup *) { @@ -3317,8 +3336,8 @@ LibertyReader::visitBusType(LibertyAttr *attr) if (bus_dcl) { for (const char *name : bus_names_) { debugPrint(debug_, "liberty", 1, " bus %s", name); - LibertyPort *port = builder_.makeBusPort(cell_, name, bus_dcl->from(), - bus_dcl->to(), bus_dcl); + LibertyPort *port = makeBusPort(cell_, name, bus_dcl->from(), + bus_dcl->to(), bus_dcl); ports_->push_back(port); } } @@ -3363,7 +3382,7 @@ LibertyReader::visitMembers(LibertyAttr *attr) const char *port_name = value->stringValue(); LibertyPort *port = findPort(port_name); if (port == nullptr) - port = builder_.makePort(cell_, port_name); + port = makePort(cell_, port_name); members->push_back(port); } else @@ -3964,16 +3983,16 @@ LibertyReader::beginSequential(LibertyGroup *group, LibertyPort *out_port_inv = nullptr; if (out_name) { 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 - out_port = builder_.makePort(cell_, out_name); + out_port = makePort(cell_, out_name); out_port->setDirection(PortDirection::internal()); } if (out_inv_name) { 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 - out_port_inv = builder_.makePort(cell_, out_inv_name); + out_port_inv = makePort(cell_, out_inv_name); out_port_inv->setDirection(PortDirection::internal()); } sequential_ = new SequentialGroup(is_register, is_bank, @@ -4791,7 +4810,7 @@ LibertyReader::beginLut(LibertyGroup *group) while (parser.hasNext()) { char *name = parser.next(); if (name[0] != '\0') { - LibertyPort *port = builder_.makePort(cell_, name); + LibertyPort *port = makePort(cell_, name); port->setDirection(PortDirection::internal()); } } diff --git a/liberty/LibertyReaderPvt.hh b/liberty/LibertyReaderPvt.hh index c00083b0..a78e15d0 100644 --- a/liberty/LibertyReaderPvt.hh +++ b/liberty/LibertyReaderPvt.hh @@ -500,6 +500,14 @@ public: const char *port_name); 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, ScaleFactorType scale_factor_type, const RiseFall *rf);