SdfReader::makeCondPortSpec use std::string

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2022-01-13 11:49:01 -07:00
parent 6342c96e90
commit 2befa8023a
2 changed files with 19 additions and 24 deletions

View File

@ -96,7 +96,9 @@ readSdf(const char *filename,
unescaped_dividers, incremental_only, unescaped_dividers, incremental_only,
cond_use, sta); cond_use, sta);
sdf_reader = &reader; sdf_reader = &reader;
return reader.read(); bool success = reader.read();
sdf_reader = nullptr;
return success;
} }
SdfReader::SdfReader(const char *filename, SdfReader::SdfReader(const char *filename,
@ -827,25 +829,23 @@ SdfReader::makePortSpec(Transition *tr,
SdfPortSpec * SdfPortSpec *
SdfReader::makeCondPortSpec(char *cond_port) SdfReader::makeCondPortSpec(char *cond_port)
{ {
char *cond = cond_port;
// Search from end to find port name because condition may contain spaces. // Search from end to find port name because condition may contain spaces.
char *p = &cond_port[strlen(cond_port) - 1]; string cond_port1(cond_port);
// Trim trailing port spaces. trimRight(cond_port1);
while (*p != '\0' && isspace(*p)) auto port_idx = cond_port1.find_last_of(" ");
p--; if (port_idx != cond_port1.npos) {
p[1] = '\0'; string port1 = cond_port1.substr(port_idx + 1);
while (*p != '\0' && !isspace(*p)) auto cond_end = cond_port1.find_last_not_of(" ", port_idx);
p--; if (cond_end != cond_port1.npos) {
char *port = &p[1]; string cond1 = cond_port1.substr(0, cond_end + 1);
// Trim trailing cond spaces. SdfPortSpec *port_spec = makePortSpec(Transition::riseFall(),
while (*p != '\0' && isspace(*p)) stringCopy(port1.c_str()),
p--; stringCopy(cond1.c_str()));
p[1] = '\0'; stringDelete(cond_port);
SdfPortSpec *port_spec = makePortSpec(Transition::riseFall(), return port_spec;
stringCopy(port), }
stringCopy(cond)); }
stringDelete(cond_port); return nullptr;
return port_spec;
} }
void void

View File

@ -27,11 +27,6 @@ class Graph;
class Corner; class Corner;
class StaState; class StaState;
// Sdf index is:
// sdf_min = 0
// sdf_typ = 1
// sdf_max = 2
//
// If unescaped_dividers is true, path names in the SDF do not have to // If unescaped_dividers is true, path names in the SDF do not have to
// escape hierarchy dividers when the path name is escaped. For // escape hierarchy dividers when the path name is escaped. For
// example, the escaped Verilog instance name "\inst1/inst2 " can be // example, the escaped Verilog instance name "\inst1/inst2 " can be