Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/Silisizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <fstream>
#include <iostream>
#include <list>
#include <memory>

#include "sta/Liberty.hh"
#include "sta/Network.hh"
Expand Down Expand Up @@ -284,4 +285,49 @@ int Silisizer::silisize(const char *workdir) {
return 0;
}

// Remove escape characters from JSON output
static std::string jsonName(const char *s) {
std::string out;
for (; *s; ++s) if (*s != '\\') out.push_back(*s);
return out;
}

// JSON dumper for clock gating related instances
void dumpIcgJson(const char *path) {
sta::Sta *sta = sta::Sta::sta();
sta::Network *network = sta->network();

std::ofstream f(path);
if (!f.good()) {
std::cerr << "dump_icg_json: cannot open " << path << " for write" << std::endl;
return;
}

// Dump gated registers.
f << "{\n \"gated_flops\": [";
bool first = true;
for (const sta::Instance *reg : sta->clockGatedRegisters()) {
if (!first) f << ",";
f << "\n \"" << jsonName(network->pathName(reg)) << "\"";
first = false;
}
f << (first ? "" : "\n ") << "],\n \"icgs\": {";

// Dump clock-gating instances mapped to their liberty cell names.
first = true;
std::unique_ptr<sta::LeafInstanceIterator> it(network->leafInstanceIterator());
while (it->hasNext()) {
sta::Instance *inst = it->next();
sta::Cell *cell = network->cell(inst);
if (!cell) continue;
sta::LibertyCell *lc = network->libertyCell(cell);
if (!lc || !lc->isClockGate()) continue;
if (!first) f << ",";
f << "\n \"" << jsonName(network->pathName(inst))
<< "\": \"" << jsonName(lc->name()) << "\"";
first = false;
}
f << (first ? "" : "\n ") << "}\n}\n";
}

} // namespace silisizer
2 changes: 2 additions & 0 deletions src/Silisizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ class Silisizer : public sta::Sta {
int silisize(const char *workdir);
};

void dumpIcgJson(const char *path);

} // namespace silisizer
1 change: 1 addition & 0 deletions src/Silisizer.i
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
%inline %{

extern int silisize(const char *workdir);
extern void dump_icg_json(const char *path);

extern void test_abrt();
extern void test_segv();
Expand Down
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ int silisize(const char *workdir) {
return sizer->silisize(workdir);
}

void dump_icg_json(const char *path) {
silisizer::dumpIcgJson(path);
}

void segv_call_fn() {
int a;
a = 6;
Expand Down
2 changes: 1 addition & 1 deletion third_party/OpenSTA
Loading