[Backend][BLIF] Automatic generation of blif files #872
Conversation
|
I fill like it is quite redundant to store the path to abc and yosys inside the config class. I think it makes more sense to configure the bianry location at compile time and maybe fall back to PATH So we don’t need to use a variant differentiate the config between blif vs. verilog |
…unYosys and runAcb functions
| } | ||
|
|
||
| private: | ||
| std::string rtlConfigPath; /// Absolute path to the JSON RTL config file. |
There was a problem hiding this comment.
why does this still need RTL config?
| /// Parameters for Backend generation. | ||
| struct BackendParams { | ||
| std::string rtlConfigPath; /// Absolute path to the JSON RTL config. | ||
| std::string dynamaticRoot; /// Project root for $DYNAMATIC substitution. | ||
| std::string outputBaseDir; /// Base directory for per-module output. | ||
| }; |
There was a problem hiding this comment.
They could be just the private members of the generator class itself
|
|
||
| namespace dynamatic { | ||
|
|
||
| class BackendGenerator { |
|
|
||
| namespace dynamatic { | ||
|
|
||
| class BackendGenerator { |
| const std::string &getModuleName() const { return moduleName; } | ||
| /// Verilog backend: returns the generated .v files. | ||
| /// BLIF backend: returns a single-element vector with the .blif file path. | ||
| const std::vector<std::string> &getOutputFiles() const { return outputFiles; } |
There was a problem hiding this comment.
It is not clear to me here if we should use one generator instance for generating many units or one generator instance per one unit?
| std::filesystem::permissions(scriptPath, | ||
| std::filesystem::perms::owner_exec | | ||
| std::filesystem::perms::owner_read | | ||
| std::filesystem::perms::owner_write, | ||
| std::filesystem::perm_options::add); |
| // Check if ABC executable is configured. | ||
| #if !defined(DYNAMATIC_ABC_EXECUTABLE) | ||
| // If not configured, check that there is an "abc" executable in the system | ||
| // PATH. | ||
| if (system("which abc > /dev/null 2>&1") != 0) { | ||
| llvm::errs() << "ABC executable not found. Please install ABC or " | ||
| "re-build Dynamatic with ABC enabled.\n"; | ||
| return false; | ||
| } | ||
| abcExecutable = "abc"; | ||
| #else | ||
| abcExecutable = DYNAMATIC_ABC_EXECUTABLE; | ||
| if (!std::filesystem::exists(abcExecutable)) { | ||
| llvm::errs() << "ABC executable not found at configured path: " | ||
| << abcExecutable << "\n"; | ||
| return false; | ||
| } | ||
| #endif |
| std::string yosysExecutable; | ||
| // Check if Yosys executable is configured. | ||
| #if !defined(DYNAMATIC_YOSYS_EXECUTABLE) | ||
| // If not configured, check that there is a "yosys" executable in the system | ||
| // PATH. | ||
| if (system("which yosys > /dev/null 2>&1") != 0) { | ||
| llvm::errs() << "Yosys executable not found. Please install Yosys or " | ||
| "re-build Dynamatic with Yosys enabled.\n"; | ||
| return false; | ||
| } | ||
| yosysExecutable = "yosys"; | ||
| #else | ||
| yosysExecutable = DYNAMATIC_YOSYS_EXECUTABLE; | ||
| if (!std::filesystem::exists(yosysExecutable)) { | ||
| llvm::errs() << "Yosys executable not found at configured path: " | ||
| << yosysExecutable << "\n"; | ||
| return false; | ||
| } | ||
| #endif |
There was a problem hiding this comment.
separate function in the anonymous namespace
| if (Operation *defOp = outputVal.getDefiningOp()) { | ||
| defOp->setAttr("hw.module_name", modName); | ||
| defOp->setAttr("hw.port_name", portName); | ||
| } | ||
| ++outIdx; |
There was a problem hiding this comment.
I don't understand where are these attributes actually used
| std::ifstream configFile(rtlConfigPath); | ||
| if (!configFile.is_open()) { | ||
| llvm::errs() << "BackendGenerator: cannot open config: " << rtlConfigPath | ||
| << "\n"; | ||
| return false; | ||
| } |
There was a problem hiding this comment.
why don't you use this?
dynamatic/include/dynamatic/Support/RTL/RTL.h
Lines 509 to 550 in ffd7cbc
The following PR introduces a BLIF Generator, which automatically generates BLIF files of dataflow units.
The BLIF generator is automatically called by the BLIF file manager when a blif file is not found in the blif library.
Please refer to the doc for more information about it
This PR also fixes bugs present in the HandshakeToSynth conversion pass, it adds new attributes in the hw flattening pass, and adds yosys in the dynamatic flow.