Skip to content

Commit

Permalink
report_path -format json
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcherry56 committed Jul 6, 2020
1 parent 17b48a6 commit 27cc8f1
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 2 deletions.
7 changes: 7 additions & 0 deletions include/sta/Network.hh
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ public:
virtual VertexId vertexId(const Pin *pin) const = 0;
virtual void setVertexId(Pin *pin,
VertexId id) = 0;
// Return the physical X/Y coordinates of the pin.
virtual void location(const Pin *pin,
// Return values.
double x,
double y,
bool exists) const;

int pinCount();
int pinCount(Instance *inst);
int leafPinCount();
Expand Down
3 changes: 2 additions & 1 deletion include/sta/SearchClass.hh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ enum class ReportPathFormat { full,
shorter,
endpoint,
summary,
slack_only
slack_only,
json
};

static const int tag_index_bits = 24;
Expand Down
11 changes: 11 additions & 0 deletions network/Network.cc
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,17 @@ Network::findInstPinsMatching(const Instance *instance,
}
}

void
Network::location(const Pin *pin,
// Return values.
double x,
double y,
bool exists) const
{
x = y = 0.0;
exists = false;
}

int
Network::instanceCount(Instance *inst)
{
Expand Down
62 changes: 62 additions & 0 deletions search/ReportPath.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2503,13 +2503,75 @@ ReportPath::reportPath(const PathEnd *end,
void
ReportPath::reportPath(const Path *path,
string &result)
{
switch (format_) {
case ReportPathFormat::full:
case ReportPathFormat::full_clock:
case ReportPathFormat::full_clock_expanded:
reportPathFull(path, result);
break;
case ReportPathFormat::json:
reportPathJson(path, result);
break;
case ReportPathFormat::summary:
case ReportPathFormat::slack_only:
default:
internalError("unsupported path type");
break;
}
}

void
ReportPath::reportPathFull(const Path *path,
string &result)
{
reportPathHeader(result);
PathExpanded expanded(path, this);
reportSrcClkAndPath(path, expanded, 0.0, delay_zero, delay_zero,
false, result);
}

void
ReportPath::reportPathJson(const Path *path,
string &result)
{
result += "{ \"path\": [\n";
PathExpanded expanded(path, this);
for (auto i = expanded.startIndex(); i < expanded.size(); i++) {
PathRef *path = expanded.path(i);
const Pin *pin = path->vertex(this)->pin();
result += " {\n";
result += " \"pin\": \"";
result += network_->pathName(pin);
result += "\",\n";

double x, y;
bool exists;
string tmp;
network_->location(pin, x, y, exists);
if (exists) {
result += " \"x\": ";
stringPrint(tmp, "%.3f", x);
result += tmp + ",\n";
result += " \"y\": ";
stringPrint(tmp, "%.3f", y);
result += tmp + "\n";
}

result += " \"arrival\": ";
stringPrint(tmp, "%.3e", path->arrival(this));
result += tmp + ",\n";

result += " \"slew\": ";
stringPrint(tmp, "%.3e", path->slew(this));
result += tmp + ",\n";

result += " }\n";
}
result += " ]\n";
result += "}\n";
}

void
ReportPath::reportPath1(const Path *path,
PathExpanded &expanded,
Expand Down
5 changes: 5 additions & 0 deletions search/ReportPath.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public:
void reportPathEnd(PathEnd *end,
PathEnd *prev_end);
void reportPathEnds(PathEndSeq *ends);
// for debugging
void reportPath(const Path *path);

void reportShort(const PathEndUnconstrained *end,
Expand Down Expand Up @@ -341,6 +342,10 @@ protected:
string &result);
void reportPath(const Path *path,
string &result);
void reportPathFull(const Path *path,
string &result);
void reportPathJson(const Path *path,
string &result);
void reportPathHeader(string &result);
void reportPath1(const Path *path,
PathExpanded &expanded,
Expand Down
2 changes: 1 addition & 1 deletion tcl/Search.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ proc parse_report_path_options { cmd args_var default_format
if [info exists path_options(-format)] {
set format $path_options(-format)
set formats {full full_clock full_clock_expanded short \
end slack_only summary}
end slack_only summary json}
if { [lsearch $formats $format] == -1 } {
sta_error "-format $format not recognized."
}
Expand Down
2 changes: 2 additions & 0 deletions tcl/StaTcl.i
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,8 @@ using namespace sta;
$1 = ReportPathFormat::summary;
else if (stringEq(arg, "slack_only"))
$1 = ReportPathFormat::slack_only;
else if (stringEq(arg, "json"))
$1 = ReportPathFormat::json;
else {
tclError(interp, "Error: unknown path type %s.", arg);
return TCL_ERROR;
Expand Down

0 comments on commit 27cc8f1

Please sign in to comment.