2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 * A very simple and straightforward frontend for the RTLIL text
25 #include "rtlil_frontend.h"
26 #include "kernel/register.h"
27 #include "kernel/log.h"
29 void rtlil_frontend_yyerror(char const *s
)
31 YOSYS_NAMESPACE_PREFIX
log_error("Parser error in line %d: %s\n", rtlil_frontend_yyget_lineno(), s
);
36 struct RTLILFrontend
: public Frontend
{
37 RTLILFrontend() : Frontend("rtlil", "read modules from RTLIL file") { }
40 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
42 log(" read_rtlil [filename]\n");
44 log("Load modules from an RTLIL file to the current design. (RTLIL is a text\n");
45 log("representation of a design in yosys's internal format.)\n");
47 log(" -nooverwrite\n");
48 log(" ignore re-definitions of modules. (the default behavior is to\n");
49 log(" create an error message if the existing module is not a blackbox\n");
50 log(" module, and overwrite the existing module if it is a blackbox module.)\n");
53 log(" overwrite existing modules with the same name\n");
56 log(" only create empty blackbox modules\n");
59 void execute(std::istream
*&f
, std::string filename
, std::vector
<std::string
> args
, RTLIL::Design
*design
) override
61 RTLIL_FRONTEND::flag_nooverwrite
= false;
62 RTLIL_FRONTEND::flag_overwrite
= false;
63 RTLIL_FRONTEND::flag_lib
= false;
65 log_header(design
, "Executing RTLIL frontend.\n");
68 for (argidx
= 1; argidx
< args
.size(); argidx
++) {
69 std::string arg
= args
[argidx
];
70 if (arg
== "-nooverwrite") {
71 RTLIL_FRONTEND::flag_nooverwrite
= true;
72 RTLIL_FRONTEND::flag_overwrite
= false;
75 if (arg
== "-overwrite") {
76 RTLIL_FRONTEND::flag_nooverwrite
= false;
77 RTLIL_FRONTEND::flag_overwrite
= true;
81 RTLIL_FRONTEND::flag_lib
= true;
86 extra_args(f
, filename
, args
, argidx
);
88 log("Input filename: %s\n", filename
.c_str());
90 RTLIL_FRONTEND::lexin
= f
;
91 RTLIL_FRONTEND::current_design
= design
;
92 rtlil_frontend_yydebug
= false;
93 rtlil_frontend_yyrestart(NULL
);
94 rtlil_frontend_yyparse();
95 rtlil_frontend_yylex_destroy();
99 struct IlangFrontend
: public Frontend
{
100 IlangFrontend() : Frontend("ilang", "(deprecated) alias of read_rtlil") { }
103 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
105 log("See `help read_rtlil`.\n");
108 void execute(std::istream
*&f
, std::string filename
, std::vector
<std::string
> args
, RTLIL::Design
*design
) override
110 RTLILFrontend
.execute(f
, filename
, args
, design
);