Skip to content

Commit

Permalink
Take the filename as argument
Browse files Browse the repository at this point in the history
  • Loading branch information
RCoeurjoly committed May 15, 2024
1 parent 24121d5 commit 480752b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions passes/cmds/example_dt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct ExampleDtPass : public Pass
log("\n");
}

void generate_json(const ComputeGraph<ExampleFn, int, IdString, IdString>& compute_graph) {
void generate_json(const ComputeGraph<ExampleFn, int, IdString, IdString>& compute_graph, const std::string& filename) {
Json::array json_nodes;

for (int i = 0; i < compute_graph.size(); ++i) {
Expand Down Expand Up @@ -83,15 +83,23 @@ struct ExampleDtPass : public Pass
{"nodes", json_nodes},
{"outputs", json_outputs}
};
std::ofstream outfile("compute_graph.json");
std::ofstream outfile(filename);
outfile << json.dump() << std::endl;

// return json.dump();
}

void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
size_t argidx = 1;
{
size_t argidx;
std::string filename;
for (argidx = 1; argidx < args.size(); argidx++)
{
if (args[argidx] == "-o" && argidx+1 < args.size()) {
filename = args[++argidx];
continue;
}
}
extra_args(args, argidx, design);

for (auto module : design->selected_modules()) {
Expand Down Expand Up @@ -289,7 +297,7 @@ struct ExampleDtPass : public Pass
log("return %d as %s \n", key.second, log_id(key.first));
}

generate_json(compute_graph);
generate_json(compute_graph, filename);
}
log("Plugin test passed!\n");
}
Expand Down

0 comments on commit 480752b

Please sign in to comment.