Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unscheduled DFCIR & SystemVerilog output path options revamp #31

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,16 @@ The list of arguments for `hls`-mode is presented below:

* `-h,--help`: *optional* flag; used to print the help-message about other arguments.
* `--config <PATH>`: *required* filesystem-path option; used to specify the file for a JSON latency configuration file. Its format is presented in *JSON Configuration* section.
* `--out <NAME>`: *optional* filesystem-path option; used to specify the destination file for the output SystemVerilog to be generated in. If the name isn't provided or the provided name is an empty string, standard output stream is used.
* `--sv_out <PATH>`: *optional* filesystem-path option; used to specify the destination file for the output SystemVerilog to be generated in.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. "destination file for the output SystemVerilog to be generated in" -> "output SystemVerilog file"
  2. "--sv_out" -> "--out-sv"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

* `--dfcir_out <PATH>`: *optional* filesystem-path option; used to specify the destination file for the output DFCIR to be generated in.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. "destination file for the output DFCIR to be generated in" -> "output DFCIR file"
    1. "--dfcir_out" -> "--out-dfcir"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

* `-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**.

**At least one of the `*_out` options has to be specified.**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"_out" -> "--out-"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


Here is an example of an Utopia HLS CLI call:

```bash
umain hls --config ~/utopia-user/config.json --out ~/outFile -a
umain hls --config ~/utopia-user/config.json --sv_out ~/outFile.sv --dfcir_out ~/outFile2.mlir -a
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix options as are described above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

```

### JSON Configuration
Expand Down
1 change: 1 addition & 0 deletions src/model/dfcxx/include/dfcxx/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enum Scheduler {
// Used for accessing specified output format paths.
enum class OutputFormatID : uint8_t {
SystemVerilog = 0,
DFCIR,
// Utility value. Constains the number of elements in the enum.
COUNT
};
Expand Down
18 changes: 14 additions & 4 deletions src/model/dfcxx/lib/dfcxx/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ bool DFCIRConverter::convertAndPrint(mlir::ModuleOp module,
const Scheduler &sched) {
mlir::MLIRContext *context = module.getContext();
mlir::PassManager pm(context);

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

pm.addPass(mlir::dfcir::createDFCIRToFIRRTLPass(&config));
switch (sched) {
case Linear:
Expand All @@ -35,10 +41,14 @@ bool DFCIRConverter::convertAndPrint(mlir::ModuleOp module,
pm.addPass(mlir::dfcir::createDFCIRASAPSchedulerPass());
break;
}
pm.addPass(circt::createLowerFIRRTLToHWPass());
pm.addPass(circt::createLowerSeqToSVPass());
pm.addPass(circt::createExportVerilogPass(*(
outputStreams[OUT_FORMAT_ID_INT(SystemVerilog)])));

// Add FIRRTL->SystemVerilog passes if SystemVerilog output option is specified.
if (auto *stream = outputStreams[OUT_FORMAT_ID_INT(SystemVerilog)]) {
pm.addPass(circt::createLowerFIRRTLToHWPass());
pm.addPass(circt::createLowerSeqToSVPass());
pm.addPass(circt::createExportVerilogPass(*stream));
}

auto result = pm.run(module);
return result.succeeded();
}
Expand Down
6 changes: 6 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#define ASAP_SCHEDULER_JSON "asap_scheduler"
#define LP_SCHEDULER_JSON "lp_scheduler"
#define SV_OUT_JSON "sv_out"
#define DFCIR_OUT_JSON "dfcir_out"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


//===----------------------------------------------------------------------===//
// CLI args/flags definitions
Expand All @@ -47,6 +48,7 @@
#define LP_SCHEDULER_FLAG CLI_FLAG("l")
#define OUTPUT_GROUP "output"
#define SV_OUT_ARG CLI_ARG("sv_out")
#define DFCIR_OUT_ARG CLI_ARG("dfcir_out")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


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

Expand Down Expand Up @@ -180,6 +182,9 @@ struct HlsOptions final : public AppOptions {
outputGroup->add_option(SV_OUT_ARG,
outNames[OUT_FORMAT_ID_INT(SystemVerilog)],
"Path to output SystemVerilog module to");
outputGroup->add_option(DFCIR_OUT_ARG,
outNames[OUT_FORMAT_ID_INT(DFCIR)],
"Path to output unscheduled DFCIR to");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth to think about...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

outputGroup->require_option();
}

Expand All @@ -188,6 +193,7 @@ struct HlsOptions final : public AppOptions {
get(json, ASAP_SCHEDULER_JSON, asapScheduler);
get(json, LP_SCHEDULER_JSON, lpScheduler);
get(json, SV_OUT_JSON, outNames[OUT_FORMAT_ID_INT(SystemVerilog)]);
get(json, DFCIR_OUT_JSON, outNames[OUT_FORMAT_ID_INT(DFCIR)]);
}

std::string latConfigFile;
Expand Down