spef unescaped names resolves #208
commit ce315777630daa66702dc08f60992dd50ad822c1
Author: James Cherry <cherry@parallaxsw.com>
Date: Mon Feb 10 17:30:34 2025 -0700
spef missing escapes
Signed-off-by: James Cherry <cherry@parallaxsw.com>
Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
parent
0dfea7dfad
commit
b8b67ba4df
|
|
@ -210,8 +210,8 @@ public:
|
||||||
virtual bool isTopInstance(const Instance *inst) const;
|
virtual bool isTopInstance(const Instance *inst) const;
|
||||||
virtual Instance *findInstance(const char *path_name) const;
|
virtual Instance *findInstance(const char *path_name) const;
|
||||||
// Find instance relative to hierarchical instance.
|
// Find instance relative to hierarchical instance.
|
||||||
Instance *findInstanceRelative(const Instance *inst,
|
virtual Instance *findInstanceRelative(const Instance *inst,
|
||||||
const char *path_name) const;
|
const char *path_name) const;
|
||||||
// Default implementation uses linear search.
|
// Default implementation uses linear search.
|
||||||
virtual InstanceSeq findInstancesMatching(const Instance *context,
|
virtual InstanceSeq findInstancesMatching(const Instance *context,
|
||||||
const PatternMatch *pattern) const;
|
const PatternMatch *pattern) const;
|
||||||
|
|
@ -363,8 +363,8 @@ public:
|
||||||
virtual ObjectId id(const Net *net) const = 0;
|
virtual ObjectId id(const Net *net) const = 0;
|
||||||
virtual Net *findNet(const char *path_name) const;
|
virtual Net *findNet(const char *path_name) const;
|
||||||
// Find net relative to hierarchical instance.
|
// Find net relative to hierarchical instance.
|
||||||
Net *findNetRelative(const Instance *inst,
|
virtual Net *findNetRelative(const Instance *inst,
|
||||||
const char *path_name) const;
|
const char *path_name) const;
|
||||||
// Default implementation uses linear search.
|
// Default implementation uses linear search.
|
||||||
virtual NetSeq findNetsMatching(const Instance *context,
|
virtual NetSeq findNetsMatching(const Instance *context,
|
||||||
const PatternMatch *pattern) const;
|
const PatternMatch *pattern) const;
|
||||||
|
|
|
||||||
|
|
@ -208,9 +208,13 @@ public:
|
||||||
const char *pathName(const Net *net) const override;
|
const char *pathName(const Net *net) const override;
|
||||||
|
|
||||||
Instance *findInstance(const char *path_name) const override;
|
Instance *findInstance(const char *path_name) const override;
|
||||||
|
Instance *findInstanceRelative(const Instance *inst,
|
||||||
|
const char *path_name) const override;
|
||||||
InstanceSeq findInstancesMatching(const Instance *context,
|
InstanceSeq findInstancesMatching(const Instance *context,
|
||||||
const PatternMatch *pattern) const override;
|
const PatternMatch *pattern) const override;
|
||||||
Net *findNet(const char *path_name) const override;
|
Net *findNet(const char *path_name) const override;
|
||||||
|
Net *findNetRelative(const Instance *instance,
|
||||||
|
const char *net_name) const override;
|
||||||
Net *findNet(const Instance *instance,
|
Net *findNet(const Instance *instance,
|
||||||
const char *net_name) const override;
|
const char *net_name) const override;
|
||||||
NetSeq findNetsMatching(const Instance *parent,
|
NetSeq findNetsMatching(const Instance *parent,
|
||||||
|
|
|
||||||
|
|
@ -789,6 +789,22 @@ SdcNetwork::findInstance(const char *path_name) const
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Instance *
|
||||||
|
SdcNetwork::findInstanceRelative(const Instance *inst,
|
||||||
|
const char *path_name) const
|
||||||
|
{
|
||||||
|
Instance *inst1 = network_->findInstanceRelative(inst, path_name);
|
||||||
|
if (inst1 == nullptr) {
|
||||||
|
string path_name1 = escapeBrackets(path_name, this);
|
||||||
|
inst1 = network_->findInstanceRelative(inst, path_name1.c_str());
|
||||||
|
if (inst1 == nullptr) {
|
||||||
|
string path_name2 = escapeDividers(path_name1.c_str(), network_);
|
||||||
|
inst1 = network_->findInstanceRelative(inst, path_name2.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return inst1;
|
||||||
|
}
|
||||||
|
|
||||||
InstanceSeq
|
InstanceSeq
|
||||||
SdcNetwork::findInstancesMatching(const Instance *context,
|
SdcNetwork::findInstancesMatching(const Instance *context,
|
||||||
const PatternMatch *pattern) const
|
const PatternMatch *pattern) const
|
||||||
|
|
@ -835,17 +851,34 @@ SdcNetwork::findNet(const char *path_name) const
|
||||||
parsePath(path_name, inst, net_name);
|
parsePath(path_name, inst, net_name);
|
||||||
if (inst == nullptr)
|
if (inst == nullptr)
|
||||||
inst = network_->topInstance();
|
inst = network_->topInstance();
|
||||||
return findNet(inst, net_name);
|
return findNetRelative(inst, net_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Net *
|
Net *
|
||||||
SdcNetwork::findNet(const Instance *instance,
|
SdcNetwork::findNet(const Instance *instance,
|
||||||
const char *net_name) const
|
const char *net_name) const
|
||||||
{
|
{
|
||||||
Net *net = network_->findNet(instance, net_name);
|
Net *net = network_->findNet(instance, net_name);
|
||||||
if (net == nullptr) {
|
if (net == nullptr) {
|
||||||
string net_name1 = escapeBrackets(net_name, this);
|
string net_name1 = escapeBrackets(net_name, this);
|
||||||
net = network_->findNet(instance, net_name1.c_str());
|
string net_name2 = escapeDividers(net_name1.c_str(), network_);
|
||||||
|
net = network_->findNet(instance, net_name2.c_str());
|
||||||
|
}
|
||||||
|
return net;
|
||||||
|
}
|
||||||
|
|
||||||
|
Net *
|
||||||
|
SdcNetwork::findNetRelative(const Instance *inst,
|
||||||
|
const char *path_name) const
|
||||||
|
{
|
||||||
|
Net *net = network_->findNetRelative(inst, path_name);
|
||||||
|
if (net == nullptr) {
|
||||||
|
string path_name1 = escapeBrackets(path_name, this);
|
||||||
|
net = network_->findNetRelative(inst, path_name1.c_str());
|
||||||
|
if (net == nullptr) {
|
||||||
|
string path_name2 = escapeDividers(path_name1.c_str(), network_);
|
||||||
|
net = network_->findNetRelative(inst, path_name2.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return net;
|
return net;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ typedef sta::SpefParse::token token;
|
||||||
%option never-interactive
|
%option never-interactive
|
||||||
%option stack
|
%option stack
|
||||||
%option yylineno
|
%option yylineno
|
||||||
/* %option debug */
|
%option debug
|
||||||
|
|
||||||
%x COMMENT
|
%x COMMENT
|
||||||
%x QUOTE
|
%x QUOTE
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,6 @@ SpefReader::~SpefReader()
|
||||||
delete design_flow_;
|
delete design_flow_;
|
||||||
design_flow_ = nullptr;
|
design_flow_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto [index, name] : name_map_)
|
|
||||||
stringDelete(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -121,6 +118,7 @@ SpefReader::read()
|
||||||
SpefScanner scanner(&stream, filename_, this, report_);
|
SpefScanner scanner(&stream, filename_, this, report_);
|
||||||
scanner_ = &scanner;
|
scanner_ = &scanner;
|
||||||
SpefParse parser(&scanner, this);
|
SpefParse parser(&scanner, this);
|
||||||
|
//parser.set_debug_level(1);
|
||||||
// yyparse returns 0 on success.
|
// yyparse returns 0 on success.
|
||||||
success = (parser.parse() == 0);
|
success = (parser.parse() == 0);
|
||||||
stats.report("Read spef");
|
stats.report("Read spef");
|
||||||
|
|
@ -160,7 +158,7 @@ SpefReader::setBusBrackets(char left,
|
||||||
Instance *
|
Instance *
|
||||||
SpefReader::findInstanceRelative(const char *name)
|
SpefReader::findInstanceRelative(const char *name)
|
||||||
{
|
{
|
||||||
return network_->findInstanceRelative(instance_, name);
|
return sdc_network_->findInstanceRelative(instance_, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Net *
|
Net *
|
||||||
|
|
@ -257,21 +255,21 @@ SpefReader::setInductScale(float scale,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SpefReader::makeNameMapEntry(char *index,
|
SpefReader::makeNameMapEntry(const char *index,
|
||||||
char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
int i = atoi(index + 1);
|
int i = atoi(index + 1);
|
||||||
name_map_[i] = name;
|
name_map_[i] = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
SpefReader::nameMapLookup(char *name)
|
SpefReader::nameMapLookup(const char *name)
|
||||||
{
|
{
|
||||||
if (name && name[0] == '*') {
|
if (name && name[0] == '*') {
|
||||||
int index = atoi(name + 1);
|
int index = atoi(name + 1);
|
||||||
auto itr = name_map_.find(index);
|
const auto &itr = name_map_.find(index);
|
||||||
if (itr != name_map_.end())
|
if (itr != name_map_.end())
|
||||||
return itr->second;
|
return itr->second.c_str();
|
||||||
else {
|
else {
|
||||||
warn(1645, "no name map entry for %d.", index);
|
warn(1645, "no name map entry for %d.", index);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -310,19 +308,19 @@ SpefReader::findPin(char *name)
|
||||||
char *delim = strrchr(name, delimiter_);
|
char *delim = strrchr(name, delimiter_);
|
||||||
if (delim) {
|
if (delim) {
|
||||||
*delim = '\0';
|
*delim = '\0';
|
||||||
name = nameMapLookup(name);
|
const char *name1 = nameMapLookup(name);
|
||||||
if (name) {
|
if (name1) {
|
||||||
Instance *inst = findInstanceRelative(name);
|
Instance *inst = findInstanceRelative(name1);
|
||||||
// Replace delimiter for error messages.
|
// Replace delimiter for error messages.
|
||||||
*delim = delimiter_;
|
*delim = delimiter_;
|
||||||
const char *port_name = delim + 1;
|
const char *port_name = delim + 1;
|
||||||
if (inst) {
|
if (inst) {
|
||||||
pin = network_->findPin(inst, port_name);
|
pin = network_->findPin(inst, port_name);
|
||||||
if (pin == nullptr)
|
if (pin == nullptr)
|
||||||
warn(1647, "pin %s not found.", name);
|
warn(1647, "pin %s not found.", name1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
warn(1648, "instance %s not found.", name);
|
warn(1648, "instance %s not found.", name1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -335,14 +333,14 @@ SpefReader::findPin(char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
Net *
|
Net *
|
||||||
SpefReader::findNet(char *name)
|
SpefReader::findNet(const char *name)
|
||||||
{
|
{
|
||||||
Net *net = nullptr;
|
Net *net = nullptr;
|
||||||
name = nameMapLookup(name);
|
const char *name1 = nameMapLookup(name);
|
||||||
if (name) {
|
if (name1) {
|
||||||
net = findNetRelative(name);
|
net = findNetRelative(name1);
|
||||||
if (net == nullptr)
|
if (net == nullptr)
|
||||||
warn(1650, "net %s not found.", name);
|
warn(1650, "net %s not found.", name1);
|
||||||
}
|
}
|
||||||
return net;
|
return net;
|
||||||
}
|
}
|
||||||
|
|
@ -447,26 +445,26 @@ SpefReader::findParasiticNode(char *name,
|
||||||
if (delim) {
|
if (delim) {
|
||||||
*delim = '\0';
|
*delim = '\0';
|
||||||
char *name2 = delim + 1;
|
char *name2 = delim + 1;
|
||||||
name = nameMapLookup(name);
|
const char *name1 = nameMapLookup(name);
|
||||||
if (name) {
|
if (name1) {
|
||||||
Instance *inst = findInstanceRelative(name);
|
Instance *inst = findInstanceRelative(name1);
|
||||||
if (inst) {
|
if (inst) {
|
||||||
// <instance>:<port>
|
// <instance>:<port>
|
||||||
Pin *pin = network_->findPin(inst, name2);
|
Pin *pin = network_->findPin(inst, name2);
|
||||||
if (pin) {
|
if (pin) {
|
||||||
if (local_only
|
if (local_only
|
||||||
&& !network_->isConnected(net_, pin))
|
&& !network_->isConnected(net_, pin))
|
||||||
warn(1651, "%s not connected to net %s.", name, network_->pathName(net_));
|
warn(1651, "%s not connected to net %s.", name1, network_->pathName(net_));
|
||||||
return parasitics_->ensureParasiticNode(parasitic_, pin, network_);
|
return parasitics_->ensureParasiticNode(parasitic_, pin, network_);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Replace delimiter for error message.
|
// Replace delimiter for error message.
|
||||||
*delim = delimiter_;
|
*delim = delimiter_;
|
||||||
warn(1652, "pin %s not found.", name);
|
warn(1652, "pin %s not found.", name1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Net *net = findNet(name);
|
Net *net = findNet(name1);
|
||||||
// Replace delimiter for error messages.
|
// Replace delimiter for error messages.
|
||||||
*delim = delimiter_;
|
*delim = delimiter_;
|
||||||
if (net) {
|
if (net) {
|
||||||
|
|
@ -477,25 +475,29 @@ SpefReader::findParasiticNode(char *name,
|
||||||
if (local_only
|
if (local_only
|
||||||
&& !network_->isConnected(net, net_))
|
&& !network_->isConnected(net, net_))
|
||||||
warn(1653, "%s not connected to net %s.",
|
warn(1653, "%s not connected to net %s.",
|
||||||
name,
|
name1,
|
||||||
network_->pathName(net_));
|
network_->pathName(net_));
|
||||||
return parasitics_->ensureParasiticNode(parasitic_, net, id, network_);
|
return parasitics_->ensureParasiticNode(parasitic_, net, id, network_);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
warn(1654, "node %s not a pin or net:number", name);
|
warn(1654, "node %s not a pin or net:number", name1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// <top_level_port>
|
// <top_level_port>
|
||||||
name = nameMapLookup(name);
|
const char *name1 = nameMapLookup(name);
|
||||||
Pin *pin = findPortPinRelative(name);
|
if (name1) {
|
||||||
if (pin) {
|
Pin *pin = findPortPinRelative(name1);
|
||||||
if (local_only
|
if (pin) {
|
||||||
&& !network_->isConnected(net_, pin))
|
if (local_only
|
||||||
warn(1655, "%s not connected to net %s.", name, network_->pathName(net_));
|
&& !network_->isConnected(net_, pin))
|
||||||
return parasitics_->ensureParasiticNode(parasitic_, pin, network_);
|
warn(1655, "%s not connected to net %s.", name1, network_->pathName(net_));
|
||||||
|
return parasitics_->ensureParasiticNode(parasitic_, pin, network_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
warn(1656, "pin %s not found.", name1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
warn(1656, "pin %s not found.", name);
|
warn(1656, "pin %s not found.", name);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,9 @@ class SpefTriple;
|
||||||
class Corner;
|
class Corner;
|
||||||
class SpefScanner;
|
class SpefScanner;
|
||||||
|
|
||||||
typedef std::map<int, char*, std::less<int>> SpefNameMap;
|
using std::string;
|
||||||
|
|
||||||
|
typedef std::map<int, string> SpefNameMap;
|
||||||
|
|
||||||
class SpefReader : public StaState
|
class SpefReader : public StaState
|
||||||
{
|
{
|
||||||
|
|
@ -79,12 +81,12 @@ public:
|
||||||
const char *units);
|
const char *units);
|
||||||
void setInductScale(float scale,
|
void setInductScale(float scale,
|
||||||
const char *units);
|
const char *units);
|
||||||
void makeNameMapEntry(char *index,
|
void makeNameMapEntry(const char *index,
|
||||||
char *name);
|
const char *name);
|
||||||
char *nameMapLookup(char *index);
|
const char *nameMapLookup(const char *index);
|
||||||
void setDesignFlow(StringSeq *flow_keys);
|
void setDesignFlow(StringSeq *flow_keys);
|
||||||
Pin *findPin(char *name);
|
Pin *findPin(char *name);
|
||||||
Net *findNet(char *name);
|
Net *findNet(const char *name);
|
||||||
void rspfBegin(Net *net,
|
void rspfBegin(Net *net,
|
||||||
SpefTriple *total_cap);
|
SpefTriple *total_cap);
|
||||||
void rspfFinish();
|
void rspfFinish();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue