rm redundant StaState args

This commit is contained in:
James Cherry 2019-06-17 08:32:28 -07:00
parent 3f7e207491
commit 49b2c3cea7
15 changed files with 47 additions and 77 deletions

View File

@ -24,7 +24,7 @@
using sta::stringEq; using sta::stringEq;
using sta::Sta; using sta::Sta;
using sta::staMain; using sta::staMain;
using sta::showUseage; using sta::showUsage;
// Swig uses C linkage for init functions. // Swig uses C linkage for init functions.
extern "C" { extern "C" {
@ -40,7 +40,7 @@ main(int argc,
char *argv[]) char *argv[])
{ {
if (argc == 2 && stringEq(argv[1], "-help")) { if (argc == 2 && stringEq(argv[1], "-help")) {
showUseage(argv[0]); showUsage(argv[0]);
return 0; return 0;
} }
else if (argc == 2 && stringEq(argv[1], "-version")) { else if (argc == 2 && stringEq(argv[1], "-version")) {

View File

@ -125,7 +125,7 @@ staTclAppInit(Tcl_Interp *interp)
if (argc > 2 || if (argc > 2 ||
(argc > 1 && argv[1][0] == '-')) (argc > 1 && argv[1][0] == '-'))
showUseage(argv[0]); showUsage(argv[0]);
else { else {
if (argc == 2) { if (argc == 2) {
char *cmd_file = argv[1]; char *cmd_file = argv[1];
@ -230,7 +230,7 @@ evalTclInit(Tcl_Interp *interp,
} }
void void
showUseage(char *prog) showUsage(const char * prog)
{ {
printf("Usage: %s [-help] [-version] [-no_init] [-exit] cmd_file\n", prog); printf("Usage: %s [-help] [-version] [-no_init] [-exit] cmd_file\n", prog);
printf(" -help show help and exit\n"); printf(" -help show help and exit\n");

View File

@ -62,7 +62,7 @@ findCmdLineKey(int &argc,
const char *key); const char *key);
void void
showUseage(char *prog); showUsage(const char *prog);
void void
parseThreadsArg(int argc, parseThreadsArg(int argc,
char **argv, char **argv,

View File

@ -48,14 +48,11 @@ scaleFloats(FloatSeq *floats,
LibertyLibrary * LibertyLibrary *
readLibertyFile(const char *filename, readLibertyFile(const char *filename,
bool infer_latches, bool infer_latches,
Report *report,
Debug *debug,
Network *network) Network *network)
{ {
LibertyBuilder builder; LibertyBuilder builder;
LibertyReader reader(&builder); LibertyReader reader(&builder);
return reader.readLibertyFile(filename, infer_latches, return reader.readLibertyFile(filename, infer_latches, network);
report, debug, network);
} }
LibertyReader::LibertyReader(LibertyBuilder *builder) : LibertyReader::LibertyReader(LibertyBuilder *builder) :
@ -91,14 +88,12 @@ LibertyReader::~LibertyReader()
LibertyLibrary * LibertyLibrary *
LibertyReader::readLibertyFile(const char *filename, LibertyReader::readLibertyFile(const char *filename,
bool infer_latches, bool infer_latches,
Report *report,
Debug *debug,
Network *network) Network *network)
{ {
filename_ = filename; filename_ = filename;
infer_latches_ = infer_latches; infer_latches_ = infer_latches;
report_ = report; report_ = network->report();
debug_ = debug; debug_ = network->debug();
network_ = network; network_ = network;
var_map_ = nullptr; var_map_ = nullptr;
library_ = nullptr; library_ = nullptr;
@ -143,7 +138,7 @@ LibertyReader::readLibertyFile(const char *filename,
have_slew_upper_threshold_[tr_index] = false; have_slew_upper_threshold_[tr_index] = false;
} }
parseLibertyFile(filename, this, report); parseLibertyFile(filename, this, report_);
return library_; return library_;
} }

View File

@ -19,16 +19,12 @@
namespace sta { namespace sta {
class Report;
class Debug;
class Network; class Network;
class LibertyLibrary; class LibertyLibrary;
LibertyLibrary * LibertyLibrary *
readLibertyFile(const char *filename, readLibertyFile(const char *filename,
bool infer_latches, bool infer_latches,
Report *report,
Debug *debug,
Network *network); Network *network);
} // namespace } // namespace

View File

@ -64,8 +64,6 @@ public:
virtual ~LibertyReader(); virtual ~LibertyReader();
virtual LibertyLibrary *readLibertyFile(const char *filename, virtual LibertyLibrary *readLibertyFile(const char *filename,
bool infer_latches, bool infer_latches,
Report *report,
Debug *debug,
Network *network); Network *network);
LibertyLibrary *library() const { return library_; } LibertyLibrary *library() const { return library_; }
virtual bool save(LibertyGroup *) { return false; } virtual bool save(LibertyGroup *) { return false; }

View File

@ -601,8 +601,7 @@ Sta::readLiberty(const char *filename,
{ {
Stats stats(debug_); Stats stats(debug_);
LibertyLibrary *library = readLibertyFile(filename, corner, min_max, LibertyLibrary *library = readLibertyFile(filename, corner, min_max,
infer_latches, infer_latches, network_);
report_, debug_, network_);
if (library if (library
// The default library is the first library read. // The default library is the first library read.
// This corresponds to a link_path of '*'. // This corresponds to a link_path of '*'.
@ -620,12 +619,10 @@ Sta::readLibertyFile(const char *filename,
Corner *corner, Corner *corner,
const MinMaxAll *min_max, const MinMaxAll *min_max,
bool infer_latches, bool infer_latches,
Report *report,
Debug *debug,
Network *network) Network *network)
{ {
LibertyLibrary *liberty = sta::readLibertyFile(filename, infer_latches, LibertyLibrary *liberty = sta::readLibertyFile(filename, infer_latches,
report, debug, network); network);
if (liberty) { if (liberty) {
// Don't map liberty cells if they are redefined by reading another // Don't map liberty cells if they are redefined by reading another
// library with the same cell names. // library with the same cell names.
@ -643,12 +640,9 @@ Sta::readLibertyFile(const char *filename,
LibertyLibrary * LibertyLibrary *
Sta::readLibertyFile(const char *filename, Sta::readLibertyFile(const char *filename,
bool infer_latches, bool infer_latches,
Report *report,
Debug *debug,
Network *network) Network *network)
{ {
return sta::readLibertyFile(filename, infer_latches, return sta::readLibertyFile(filename, infer_latches, network);
report, debug, network);
} }
void void
@ -669,7 +663,7 @@ Sta::setMinLibrary(const char *min_filename,
if (max_lib) { if (max_lib) {
LibertyLibrary *min_lib = readLibertyFile(min_filename, cmd_corner_, LibertyLibrary *min_lib = readLibertyFile(min_filename, cmd_corner_,
MinMaxAll::min(), false, MinMaxAll::min(), false,
report_, debug_, network_); network_);
return min_lib != nullptr; return min_lib != nullptr;
} }
else else

View File

@ -1215,14 +1215,10 @@ protected:
Corner *corner, Corner *corner,
const MinMaxAll *min_max, const MinMaxAll *min_max,
bool infer_latches, bool infer_latches,
Report *report,
Debug *debug,
Network *network); Network *network);
// Allow external Liberty reader to parse forms not used by Sta. // Allow external Liberty reader to parse forms not used by Sta.
virtual LibertyLibrary *readLibertyFile(const char *filename, virtual LibertyLibrary *readLibertyFile(const char *filename,
bool infer_latches, bool infer_latches,
Report *report,
Debug *debug,
Network *network); Network *network);
void ensureLevelized(); void ensureLevelized();
void ensureClkArrivals(); void ensureClkArrivals();

View File

@ -48,18 +48,11 @@ using std::string;
using std::ofstream; using std::ofstream;
using std::ifstream; using std::ifstream;
typedef Vector<string> StringVector;
typedef Map<string, StringVector*> CellSpicePortNames; typedef Map<string, StringVector*> CellSpicePortNames;
typedef int Stage; typedef int Stage;
typedef Map<ParasiticNode*, int> ParasiticNodeMap; typedef Map<ParasiticNode*, int> ParasiticNodeMap;
typedef Map<LibertyPort*, LogicValue> LibertyPortLogicValues; typedef Map<LibertyPort*, LogicValue> LibertyPortLogicValues;
void
split(const string &text,
const string &delims,
// Return values.
StringVector &tokens);
void void
streamPrint(ofstream &stream, streamPrint(ofstream &stream,
const char *fmt, const char *fmt,
@ -1630,22 +1623,4 @@ streamPrint(ofstream &stream,
va_end(args); va_end(args);
} }
void
split(const string &text,
const string &delims,
// Return values.
StringVector &tokens)
{
auto start = text.find_first_not_of(delims);
auto end = text.find_first_of(delims, start);
while (end != string::npos) {
tokens.push_back(text.substr(start, end - start));
start = text.find_first_not_of(delims, end);
end = text.find_first_of(delims, start);
}
if (start != string::npos)
tokens.push_back(text.substr(start));
}
} // namespace } // namespace

View File

@ -231,4 +231,21 @@ trimRight(string &str)
str.erase(str.find_last_not_of(" ") + 1); str.erase(str.find_last_not_of(" ") + 1);
} }
void
split(const string &text,
const string &delims,
// Return values.
StringVector &tokens)
{
auto start = text.find_first_not_of(delims);
auto end = text.find_first_of(delims, start);
while (end != string::npos) {
tokens.push_back(text.substr(start, end - start));
start = text.find_first_not_of(delims, end);
end = text.find_first_of(delims, start);
}
if (start != string::npos)
tokens.push_back(text.substr(start));
}
} // namespace } // namespace

View File

@ -20,6 +20,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <string> #include <string>
#include "Vector.hh"
namespace sta { namespace sta {
@ -168,5 +169,13 @@ deleteTmpStrings();
void void
trimRight(string &str); trimRight(string &str);
typedef Vector<string> StringVector;
void
split(const string &text,
const string &delims,
// Return values.
StringVector &tokens);
} // namespace } // namespace
#endif #endif

View File

@ -74,9 +74,7 @@ extern VerilogReader *verilog_reader;
class VerilogReader class VerilogReader
{ {
public: public:
explicit VerilogReader(Report *report, explicit VerilogReader(NetworkReader *network);
Debug *debug,
NetworkReader *network);
~VerilogReader(); ~VerilogReader();
bool read(const char *filename); bool read(const char *filename);
// flex YY_INPUT yy_n_chars arg changed definition from int to size_t, // flex YY_INPUT yy_n_chars arg changed definition from int to size_t,

View File

@ -37,7 +37,7 @@ read_verilog(const char *filename)
NetworkReader *network = sta->networkReader(); NetworkReader *network = sta->networkReader();
if (network) { if (network) {
sta->readNetlistBefore(); sta->readNetlistBefore();
return readVerilogFile(filename, sta->report(), sta->debug(), network); return readVerilogFile(filename, network);
} }
else else
return false; return false;

View File

@ -54,12 +54,10 @@ linkVerilogNetwork(Cell *top_cell,
bool bool
readVerilogFile(const char *filename, readVerilogFile(const char *filename,
Report *report,
Debug *debug,
NetworkReader *network) NetworkReader *network)
{ {
if (verilog_reader == nullptr) if (verilog_reader == nullptr)
verilog_reader = new VerilogReader(report, debug, network); verilog_reader = new VerilogReader(network);
return verilog_reader->read(filename); return verilog_reader->read(filename);
} }
@ -140,11 +138,9 @@ public:
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
VerilogReader::VerilogReader(Report *report, VerilogReader::VerilogReader(NetworkReader *network) :
Debug *debug, report_(network->report()),
NetworkReader *network) : debug_(network->debug()),
report_(report),
debug_(debug),
network_(network), network_(network),
library_(nullptr), library_(nullptr),
black_box_index_(0), black_box_index_(0),

View File

@ -19,15 +19,11 @@
namespace sta { namespace sta {
class Report; class NetworkReader;
class Debug;
class Cell;
class NetworkEdit;
class Instance;
// Return true if successful. // Return true if successful.
bool bool
readVerilogFile(const char *filename, Report *report, Debug *debug, readVerilogFile(const char *filename,
NetworkReader *network); NetworkReader *network);
void void