diff options
author | whitequark <whitequark@whitequark.org> | 2020-05-28 09:59:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-28 09:59:17 +0000 |
commit | 736ccb2ad5e1aa7b8fff069e294d073195f6a1ac (patch) | |
tree | 39ec3a05e5e83912b6ea147676669eb454ec20a0 /backends/firrtl | |
parent | 2974183855018c1537955668dc35fce7107b91f8 (diff) | |
parent | 1688a625007b0ea7a1b9114ecf7a50d81fcfa38d (diff) | |
download | yosys-736ccb2ad5e1aa7b8fff069e294d073195f6a1ac.tar.gz yosys-736ccb2ad5e1aa7b8fff069e294d073195f6a1ac.tar.bz2 yosys-736ccb2ad5e1aa7b8fff069e294d073195f6a1ac.zip |
Merge pull request #2031 from epfl-vlsc/master
Add extmodule support to firrtl backend
Diffstat (limited to 'backends/firrtl')
-rw-r--r-- | backends/firrtl/firrtl.cc | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/backends/firrtl/firrtl.cc b/backends/firrtl/firrtl.cc index 89df0366f..a90b0b87a 100644 --- a/backends/firrtl/firrtl.cc +++ b/backends/firrtl/firrtl.cc @@ -392,7 +392,34 @@ struct FirrtlWorker return result; } - void run() + void emit_extmodule() + { + std::string moduleFileinfo = getFileinfo(module); + f << stringf(" extmodule %s: %s\n", make_id(module->name), moduleFileinfo.c_str()); + vector<std::string> port_decls; + + for (auto wire : module->wires()) + { + const auto wireName = make_id(wire->name); + std::string wireFileinfo = getFileinfo(wire); + + if (wire->port_input && wire->port_output) + { + log_error("Module port %s.%s is inout!\n", log_id(module), log_id(wire)); + } + port_decls.push_back(stringf(" %s %s: UInt<%d> %s\n", wire->port_input ? "input" : "output", + wireName, wire->width, wireFileinfo.c_str())); + } + + for (auto &str : port_decls) + { + f << str; + } + + f << stringf("\n"); + } + + void emit_module() { std::string moduleFileinfo = getFileinfo(module); f << stringf(" module %s: %s\n", make_id(module->name), moduleFileinfo.c_str()); @@ -1078,6 +1105,18 @@ struct FirrtlWorker for (auto str : wire_exprs) f << str; + + f << stringf("\n"); + } + + void run() + { + // Blackboxes should be emitted as `extmodule`s in firrtl. Only ports are + // emitted in such a case. + if (module->get_blackbox_attribute()) + emit_extmodule(); + else + emit_module(); } }; |