Skip to content

Commit

Permalink
Simulation output path option was added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Muxianesty committed Aug 16, 2024
1 parent 5aabc77 commit 4ebe450
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ int hlsMain(const HlsContext &context) {

int simMain(const SimContext &context) {
auto kernel = start();
return !kernel->simulate(context.options.dataFiles(), std::cout);
return !kernel->simulate(context.options.dataFiles(),
context.options.outFilePath);
}

int main(int argc, char **argv) {
Expand Down
2 changes: 1 addition & 1 deletion src/model/dfcxx/include/dfcxx/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Kernel {
const Scheduler &sched);

bool simulate(const std::vector<std::string> &dataPaths,
std::ostream &stream);
const std::string &outFilePath);

};

Expand Down
2 changes: 1 addition & 1 deletion src/model/dfcxx/includeDev/dfcxx/simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace dfcxx {

class DFCXXSimulator {
public:
bool simulate(std::ifstream &in, std::ostream &out, std::vector<Node> nodes);
bool simulate(std::ifstream &in, std::ofstream &out, std::vector<Node> nodes);
};

} // namespace dfcxx
Expand Down
5 changes: 3 additions & 2 deletions src/model/dfcxx/lib/dfcxx/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ bool Kernel::compile(const DFLatencyConfig &config,


bool Kernel::simulate(const std::vector<std::string> &dataPaths,
std::ostream &stream) {
const std::string &outFilePath) {
bool result = true;
std::vector<Node> sorted = topSort(graph.startNodes,
graph.outputs,
graph.nodes.size());
DFCXXSimulator sim;
std::ofstream out(outFilePath, std::ios::out);
for (const std::string &path : dataPaths) {
std::ifstream input(path, std::ios::in);
sim.simulate(input, stream, sorted);
sim.simulate(input, out, sorted);
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion src/model/dfcxx/lib/dfcxx/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace dfcxx {


bool DFCXXSimulator::simulate(std::ifstream &in,
std::ostream &out,
std::ofstream &out,
std::vector<Node> nodes) {
return true;
}
Expand Down
13 changes: 13 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#define OUT_FIRRTL_JSON "out_firrtl"

#define SIM_ID_JSON "sim"
#define SIM_OUT_JSON "out"

//===----------------------------------------------------------------------===//
// CLI args/flags definitions
Expand All @@ -59,6 +60,7 @@
#define OUT_FIRRTL_ARG CLI_ARG("out-firrtl")

#define SIM_USAGE_FILES_ARG "files"
#define SIM_OUT_ARG CLI_ARG("out")

//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -319,6 +321,11 @@ struct SimOptions final : public AppOptions {
SimOptions(AppOptions &parent):
AppOptions(parent, SIM_CMD, "DFCxx simulation") {
//options->formatter(std::make_shared<UsageFormatter>());

// Named options.
options->add_option(SIM_OUT_ARG,
outFilePath,
"Simulation output path")->expected(1);
// For processing data files' paths.
options->allow_extras();
auto *var = options; // Used for lambda variable passing.
Expand All @@ -332,6 +339,12 @@ struct SimOptions final : public AppOptions {
std::vector<std::string> dataFiles() const {
return options->remaining();
}

void fromJson(Json json) override {
get(json, SIM_OUT_JSON, outFilePath);
}

std::string outFilePath;
};

struct Options final : public AppOptions {
Expand Down

0 comments on commit 4ebe450

Please sign in to comment.