Skip to content

Commit

Permalink
HLS mode: --out-scheduled-dfcir option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Litvinov Mikhail committed Jan 13, 2025
1 parent 8abcd43 commit 1830df1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ Unless neither of the three arguments is used, first argument is the mode which
* `--config <PATH>`: *required* filesystem-path option; used to specify the file for a JSON latency configuration file. Its format is presented in `docs/latency_config.md`.
* `--out-sv <PATH>`: *optional* filesystem-path option; used to specify the output SystemVerilog file.
* `--out-sv-lib <PATH>`: *optional* filesystem-path option; used to specify the output SystemVerilog file for generated operations library.
* `--out-dfcir <PATH>`: *optional* filesystem-path option; used to specify the output DFCIR file.
* `--out-dfcir <PATH>`: *optional* filesystem-path option; used to specify the output unscheduled DFCIR file.
* `--out-scheduled-dfcir <PATH>`: *optional* filesystem-path option; used to specify the output scheduled DFCIR file.
* `--out-firrtl <PATH>`: *optional* filesystem-path option; used to specify the output FIRRTL file.
* `--out-dot <PATH>`: *optional* filesystem-path option; used to specify the output DOT file.
* `-a` or `-l`: *required* flag; used to specify the chosen scheduling strategy - either as-soon-as-possible or linear programming. **Exactly one of these flags has to be specified**.
Expand Down
17 changes: 9 additions & 8 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"hls": {
"config" : "",
"asap_scheduler" : false,
"lp_scheduler" : false,
"out_sv" : "",
"out_sv_lib" : "",
"out_dfcir" : "",
"out_firrtl" : "",
"out_dot" : ""
"config" : "",
"asap_scheduler" : false,
"lp_scheduler" : false,
"out_sv" : "",
"out_sv_lib" : "",
"out_dfcir" : "",
"out_scheduled_dfcir": "",
"out_firrtl" : "",
"out_dot" : ""
},
"sim": {
"in" : "sim.txt",
Expand Down
3 changes: 2 additions & 1 deletion src/model/dfcxx/include/dfcxx/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ enum Scheduler {
enum class OutputFormatID : uint8_t {
SystemVerilog = 0,
SVLibrary,
DFCIR,
UnscheduledDFCIR,
ScheduledDFCIR,
FIRRTL,
DOT,
// Utility value. Constains the number of elements in the enum.
Expand Down
9 changes: 7 additions & 2 deletions src/model/dfcxx/lib/dfcxx/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ bool DFCIRConverter::convertAndPrint(mlir::ModuleOp module,
context->getOrLoadDialect<circt::sv::SVDialect>();
mlir::PassManager pm(context);

// Dump DFCIR if the corresponding option is specified.
if (auto *stream = outputStreams[OUT_FORMAT_ID_INT(DFCIR)]) {
// Dump unscheduled DFCIR if the corresponding option is specified.
if (auto *stream = outputStreams[OUT_FORMAT_ID_INT(UnscheduledDFCIR)]) {
module.print(*stream);
}

Expand All @@ -72,6 +72,11 @@ bool DFCIRConverter::convertAndPrint(mlir::ModuleOp module,
break;
}

// Dump scheduled DFCIR if the corresponding option is specified.
if (auto *stream = outputStreams[OUT_FORMAT_ID_INT(ScheduledDFCIR)]) {
pm.addPass(createDFCIRDumperPass(stream));
}

pm.addPass(mlir::dfcir::createDFCIRToFIRRTLPass());

// Dump FIRRTL if the corresponding option is specified.
Expand Down
30 changes: 18 additions & 12 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
#define LP_SCHEDULER_JSON "lp_scheduler"
#define OUT_SV_JSON "out_sv"
#define OUT_SV_LIB_JSON "out_sv_lib"
#define OUT_DFCIR_JSON "out_dfcir"
#define OUT_UNSCHEDULED_DFCIR_JSON "out_dfcir"
#define OUT_SCHEDULED_DFCIR_JSON "out_scheduled_dfcir"
#define OUT_FIRRTL_JSON "out_firrtl"
#define OUT_DOT_JSON "out_dot"

Expand All @@ -60,7 +61,8 @@
#define OUTPUT_GROUP "output"
#define OUT_SV_ARG CLI_ARG("out-sv")
#define OUT_SV_LIB_ARG CLI_ARG("out-sv-lib")
#define OUT_DFCIR_ARG CLI_ARG("out-dfcir")
#define OUT_UNSCHEDULED_DFCIR_ARG CLI_ARG("out-dfcir")
#define OUT_SCHEDULED_DFCIR_ARG CLI_ARG("out-scheduled-dfcir")
#define OUT_FIRRTL_ARG CLI_ARG("out-firrtl")
#define OUT_DOT_ARG CLI_ARG("out-dot")

Expand Down Expand Up @@ -206,9 +208,12 @@ struct HlsOptions final : public AppOptions {
outputGroup->add_option(OUT_SV_LIB_ARG,
outNames[OUT_FORMAT_ID_INT(SVLibrary)],
"Path to output SystemVerilog modules for generated operations");
outputGroup->add_option(OUT_DFCIR_ARG,
outNames[OUT_FORMAT_ID_INT(DFCIR)],
outputGroup->add_option(OUT_UNSCHEDULED_DFCIR_ARG,
outNames[OUT_FORMAT_ID_INT(UnscheduledDFCIR)],
"Path to output unscheduled DFCIR");
outputGroup->add_option(OUT_SCHEDULED_DFCIR_ARG,
outNames[OUT_FORMAT_ID_INT(ScheduledDFCIR)],
"Path to output scheduled DFCIR");
outputGroup->add_option(OUT_FIRRTL_ARG,
outNames[OUT_FORMAT_ID_INT(FIRRTL)],
"Path to output scheduled FIRRTL");
Expand All @@ -219,14 +224,15 @@ struct HlsOptions final : public AppOptions {
}

void fromJson(Json json) override {
get(json, CONFIG_JSON, latencyCfgFile);
get(json, ASAP_SCHEDULER_JSON, asapScheduler);
get(json, LP_SCHEDULER_JSON, lpScheduler);
get(json, OUT_SV_JSON, outNames[OUT_FORMAT_ID_INT(SystemVerilog)]);
get(json, OUT_SV_LIB_JSON, outNames[OUT_FORMAT_ID_INT(SVLibrary)]);
get(json, OUT_DFCIR_JSON, outNames[OUT_FORMAT_ID_INT(DFCIR)]);
get(json, OUT_FIRRTL_JSON, outNames[OUT_FORMAT_ID_INT(FIRRTL)]);
get(json, OUT_DOT_JSON, outNames[OUT_FORMAT_ID_INT(DOT)]);
get(json, CONFIG_JSON, latencyCfgFile);
get(json, ASAP_SCHEDULER_JSON, asapScheduler);
get(json, LP_SCHEDULER_JSON, lpScheduler);
get(json, OUT_SV_JSON, outNames[OUT_FORMAT_ID_INT(SystemVerilog)]);
get(json, OUT_SV_LIB_JSON, outNames[OUT_FORMAT_ID_INT(SVLibrary)]);
get(json, OUT_UNSCHEDULED_DFCIR_JSON, outNames[OUT_FORMAT_ID_INT(UnscheduledDFCIR)]);
get(json, OUT_SCHEDULED_DFCIR_JSON, outNames[OUT_FORMAT_ID_INT(ScheduledDFCIR)]);
get(json, OUT_FIRRTL_JSON, outNames[OUT_FORMAT_ID_INT(FIRRTL)]);
get(json, OUT_DOT_JSON, outNames[OUT_FORMAT_ID_INT(DOT)]);
}

dfcxx::Ops convertFieldToEnum(const std::string field) {
Expand Down

0 comments on commit 1830df1

Please sign in to comment.