2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
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
21 * representation (as generated by the 'ilang' backend).
25 #include "ilang_frontend.h"
26 #include "kernel/register.h"
27 #include "kernel/log.h"
29 void rtlil_frontend_ilang_yyerror(char const *s
)
31 YOSYS_NAMESPACE_PREFIX
log_error("Parser error in line %d: %s\n", rtlil_frontend_ilang_yyget_lineno(), s
);
36 struct IlangFrontend
: public Frontend
{
37 IlangFrontend() : Frontend("ilang", "read modules from ilang file") { }
38 void help() YS_OVERRIDE
40 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
42 log(" read_ilang [filename]\n");
44 log("Load modules from an ilang file to the current design. (ilang 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
) YS_OVERRIDE
61 ILANG_FRONTEND::flag_nooverwrite
= false;
62 ILANG_FRONTEND::flag_overwrite
= false;
63 ILANG_FRONTEND::flag_lib
= false;
65 log_header(design
, "Executing ILANG frontend.\n");
68 for (argidx
= 1; argidx
< args
.size(); argidx
++) {
69 std::string arg
= args
[argidx
];
70 if (arg
== "-nooverwrite") {
71 ILANG_FRONTEND::flag_nooverwrite
= true;
72 ILANG_FRONTEND::flag_overwrite
= false;
75 if (arg
== "-overwrite") {
76 ILANG_FRONTEND::flag_nooverwrite
= false;
77 ILANG_FRONTEND::flag_overwrite
= true;
81 ILANG_FRONTEND::flag_lib
= true;
86 extra_args(f
, filename
, args
, argidx
);
88 log("Input filename: %s\n", filename
.c_str());
90 ILANG_FRONTEND::lexin
= f
;
91 ILANG_FRONTEND::current_design
= design
;
92 rtlil_frontend_ilang_yydebug
= false;
93 rtlil_frontend_ilang_yyrestart(NULL
);
94 rtlil_frontend_ilang_yyparse();
95 rtlil_frontend_ilang_yylex_destroy();