Skip to content

Commit

Permalink
Allow write_lakeroad backend to write output to file instead of std…
Browse files Browse the repository at this point in the history
…out. (#9)

* Add code to write_lakeroad to file instead of stdout

* Fix a bug for writing to stdout as well

* Add suggested code
  • Loading branch information
thiskappaisgrey committed Dec 17, 2023
1 parent 4ccc4ba commit 2a18fe5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 5 additions & 1 deletion backends/lakeroad/example.ys
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ module test(input [1:0] a, input b, output o);
endmodule
EOF

write_lakeroad
# Write output to stdout
write_lakeroad
# Write output to file.egg
write_lakeroad file.egg
!rm file.egg
17 changes: 14 additions & 3 deletions backends/lakeroad/lakeroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "kernel/rtlil.h"
#include "kernel/sigtools.h"
#include "kernel/yw.h"
#include <string>
#include <assert.h>
#include <string>

USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN
Expand Down Expand Up @@ -1714,11 +1714,22 @@ struct BtorBackend : public Backend {
void execute(std::ostream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing Lakeroad egglog backend.\n");

RTLIL::Module *topmod = design->top_module();

// Copied from firrtl code.
size_t argidx = args.size();

if (filename == "") {
// The command itself is given as an arg
if (argidx > 1 && args[argidx - 1][0] != '-') {
// extra_args and friends need to see this argument.
argidx -= 1;
filename = args[argidx];
}
}

// Has to come after other arg parsing.
extra_args(f, filename, args, args.size());
extra_args(f, filename, args, argidx);

if (topmod == nullptr)
log_cmd_error("No top module found.\n");
Expand Down

0 comments on commit 2a18fe5

Please sign in to comment.