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 #include "kernel/yosys.h"
21 #include "kernel/satgen.h"
28 #ifdef YOSYS_ENABLE_ZLIB
31 PRIVATE_NAMESPACE_BEGIN
32 #define GZ_BUFFER_SIZE 8192
33 void decompress_gzip(const std::string
&filename
, std::stringstream
&out
)
35 char buffer
[GZ_BUFFER_SIZE
];
37 gzFile gzf
= gzopen(filename
.c_str(), "rb");
39 bytes_read
= gzread(gzf
, reinterpret_cast<void *>(buffer
), GZ_BUFFER_SIZE
);
40 out
.write(buffer
, bytes_read
);
46 An output stream that uses a stringbuf to buffer data internally,
47 using zlib to write gzip-compressed data every time the stream is flushed.
49 class gzip_ostream
: public std::ostream
{
55 bool open(const std::string
&filename
)
57 return outbuf
.open(filename
);
60 class gzip_streambuf
: public std::stringbuf
{
63 bool open(const std::string
&filename
)
65 gzf
= gzopen(filename
.c_str(), "wb");
66 return gzf
!= nullptr;
68 virtual int sync() override
70 gzwrite(gzf
, reinterpret_cast<const void *>(str().c_str()), unsigned(str().size()));
89 #define MAX_REG_COUNT 1000
91 bool echo_mode
= false;
92 Pass
*first_queued_pass
;
95 std::map
<std::string
, Frontend
*> frontend_register
;
96 std::map
<std::string
, Pass
*> pass_register
;
97 std::map
<std::string
, Backend
*> backend_register
;
99 std::vector
<std::string
> Frontend::next_args
;
101 Pass::Pass(std::string name
, std::string short_help
) : pass_name(name
), short_help(short_help
)
103 next_queued_pass
= first_queued_pass
;
104 first_queued_pass
= this;
109 void Pass::run_register()
111 log_assert(pass_register
.count(pass_name
) == 0);
112 pass_register
[pass_name
] = this;
115 void Pass::init_register()
117 while (first_queued_pass
) {
118 first_queued_pass
->run_register();
119 first_queued_pass
= first_queued_pass
->next_queued_pass
;
123 void Pass::done_register()
125 frontend_register
.clear();
126 pass_register
.clear();
127 backend_register
.clear();
128 log_assert(first_queued_pass
== NULL
);
135 Pass::pre_post_exec_state_t
Pass::pre_execute()
137 pre_post_exec_state_t state
;
139 state
.begin_ns
= PerformanceTimer::query();
140 state
.parent_pass
= current_pass
;
146 void Pass::post_execute(Pass::pre_post_exec_state_t state
)
148 IdString::checkpoint();
151 int64_t time_ns
= PerformanceTimer::query() - state
.begin_ns
;
152 runtime_ns
+= time_ns
;
153 current_pass
= state
.parent_pass
;
155 current_pass
->runtime_ns
-= time_ns
;
161 log("No help message for command `%s'.\n", pass_name
.c_str());
165 void Pass::clear_flags()
169 void Pass::cmd_log_args(const std::vector
<std::string
> &args
)
171 if (args
.size() <= 1)
173 log("Full command line:");
174 for (size_t i
= 0; i
< args
.size(); i
++)
175 log(" %s", args
[i
].c_str());
179 void Pass::cmd_error(const std::vector
<std::string
> &args
, size_t argidx
, std::string msg
)
181 std::string command_text
;
184 for (size_t i
= 0; i
< args
.size(); i
++) {
186 error_pos
+= args
[i
].size() + 1;
187 command_text
= command_text
+ (command_text
.empty() ? "" : " ") + args
[i
];
190 log("\nSyntax error in command `%s':\n", command_text
.c_str());
193 log_cmd_error("Command syntax error: %s\n> %s\n> %*s^\n",
194 msg
.c_str(), command_text
.c_str(), error_pos
, "");
197 void Pass::extra_args(std::vector
<std::string
> args
, size_t argidx
, RTLIL::Design
*design
, bool select
)
199 for (; argidx
< args
.size(); argidx
++)
201 std::string arg
= args
[argidx
];
203 if (arg
.compare(0, 1, "-") == 0)
204 cmd_error(args
, argidx
, "Unknown option or option in arguments.");
207 cmd_error(args
, argidx
, "Extra argument.");
209 handle_extra_select_args(this, args
, argidx
, args
.size(), design
);
212 // cmd_log_args(args);
215 void Pass::call(RTLIL::Design
*design
, std::string command
)
217 std::vector
<std::string
> args
;
219 std::string cmd_buf
= command
;
220 std::string tok
= next_token(cmd_buf
, " \t\r\n", true);
226 cmd_buf
= command
.substr(command
.find('!') + 1);
227 while (!cmd_buf
.empty() && (cmd_buf
.back() == ' ' || cmd_buf
.back() == '\t' ||
228 cmd_buf
.back() == '\r' || cmd_buf
.back() == '\n'))
229 cmd_buf
.resize(cmd_buf
.size()-1);
230 log_header(design
, "Shell command: %s\n", cmd_buf
.c_str());
231 int retCode
= run_command(cmd_buf
);
233 log_cmd_error("Shell command returned error code %d.\n", retCode
);
237 while (!tok
.empty()) {
240 for (stop
= 0; stop
< GetSize(cmd_buf
); stop
++)
241 if (cmd_buf
[stop
] == '\r' || cmd_buf
[stop
] == '\n')
243 cmd_buf
= cmd_buf
.substr(stop
);
245 if (tok
.back() == ';') {
246 int num_semikolon
= 0;
247 while (!tok
.empty() && tok
.back() == ';')
248 tok
.resize(tok
.size()-1), num_semikolon
++;
253 if (num_semikolon
== 2)
254 call(design
, "clean");
255 if (num_semikolon
== 3)
256 call(design
, "clean -purge");
259 bool found_nl
= false;
260 for (auto c
: cmd_buf
) {
261 if (c
== ' ' || c
== '\t')
263 if (c
== '\r' || c
== '\n')
271 tok
= next_token(cmd_buf
, " \t\r\n", true);
277 void Pass::call(RTLIL::Design
*design
, std::vector
<std::string
> args
)
279 if (args
.size() == 0 || args
[0][0] == '#' || args
[0][0] == ':')
283 log("%s", create_prompt(design
, 0));
284 for (size_t i
= 0; i
< args
.size(); i
++)
285 log("%s%s", i
? " " : "", args
[i
].c_str());
289 if (pass_register
.count(args
[0]) == 0)
290 log_cmd_error("No such command: %s (type 'help' for a command overview)\n", args
[0].c_str());
292 size_t orig_sel_stack_pos
= design
->selection_stack
.size();
293 auto state
= pass_register
[args
[0]]->pre_execute();
294 pass_register
[args
[0]]->execute(args
, design
);
295 pass_register
[args
[0]]->post_execute(state
);
296 while (design
->selection_stack
.size() > orig_sel_stack_pos
)
297 design
->selection_stack
.pop_back();
300 void Pass::call_on_selection(RTLIL::Design
*design
, const RTLIL::Selection
&selection
, std::string command
)
302 std::string backup_selected_active_module
= design
->selected_active_module
;
303 design
->selected_active_module
.clear();
304 design
->selection_stack
.push_back(selection
);
306 Pass::call(design
, command
);
308 design
->selection_stack
.pop_back();
309 design
->selected_active_module
= backup_selected_active_module
;
312 void Pass::call_on_selection(RTLIL::Design
*design
, const RTLIL::Selection
&selection
, std::vector
<std::string
> args
)
314 std::string backup_selected_active_module
= design
->selected_active_module
;
315 design
->selected_active_module
.clear();
316 design
->selection_stack
.push_back(selection
);
318 Pass::call(design
, args
);
320 design
->selection_stack
.pop_back();
321 design
->selected_active_module
= backup_selected_active_module
;
324 void Pass::call_on_module(RTLIL::Design
*design
, RTLIL::Module
*module
, std::string command
)
326 std::string backup_selected_active_module
= design
->selected_active_module
;
327 design
->selected_active_module
= module
->name
.str();
328 design
->selection_stack
.push_back(RTLIL::Selection(false));
329 design
->selection_stack
.back().select(module
);
331 Pass::call(design
, command
);
333 design
->selection_stack
.pop_back();
334 design
->selected_active_module
= backup_selected_active_module
;
337 void Pass::call_on_module(RTLIL::Design
*design
, RTLIL::Module
*module
, std::vector
<std::string
> args
)
339 std::string backup_selected_active_module
= design
->selected_active_module
;
340 design
->selected_active_module
= module
->name
.str();
341 design
->selection_stack
.push_back(RTLIL::Selection(false));
342 design
->selection_stack
.back().select(module
);
344 Pass::call(design
, args
);
346 design
->selection_stack
.pop_back();
347 design
->selected_active_module
= backup_selected_active_module
;
350 bool ScriptPass::check_label(std::string label
, std::string info
)
352 if (active_design
== nullptr) {
355 log(" %s:\n", label
.c_str());
357 log(" %s: %s\n", label
.c_str(), info
.c_str());
360 if (!active_run_from
.empty() && active_run_from
== active_run_to
) {
361 block_active
= (label
== active_run_from
);
363 if (label
== active_run_from
)
365 if (label
== active_run_to
)
366 block_active
= false;
372 void ScriptPass::run(std::string command
, std::string info
)
374 if (active_design
== nullptr) {
376 log(" %s\n", command
.c_str());
378 log(" %s %s\n", command
.c_str(), info
.c_str());
380 Pass::call(active_design
, command
);
381 active_design
->check();
385 void ScriptPass::run_script(RTLIL::Design
*design
, std::string run_from
, std::string run_to
)
388 active_design
= design
;
389 block_active
= run_from
.empty();
390 active_run_from
= run_from
;
391 active_run_to
= run_to
;
395 void ScriptPass::help_script()
399 active_design
= nullptr;
401 active_run_from
.clear();
402 active_run_to
.clear();
406 Frontend::Frontend(std::string name
, std::string short_help
) :
407 Pass(name
.rfind("=", 0) == 0 ? name
.substr(1) : "read_" + name
, short_help
),
408 frontend_name(name
.rfind("=", 0) == 0 ? name
.substr(1) : name
)
412 void Frontend::run_register()
414 log_assert(pass_register
.count(pass_name
) == 0);
415 pass_register
[pass_name
] = this;
417 log_assert(frontend_register
.count(frontend_name
) == 0);
418 frontend_register
[frontend_name
] = this;
421 Frontend::~Frontend()
425 void Frontend::execute(std::vector
<std::string
> args
, RTLIL::Design
*design
)
427 log_assert(next_args
.empty());
429 std::istream
*f
= NULL
;
431 auto state
= pre_execute();
432 execute(f
, std::string(), args
, design
);
436 } while (!args
.empty());
439 FILE *Frontend::current_script_file
= NULL
;
440 std::string
Frontend::last_here_document
;
442 void Frontend::extra_args(std::istream
*&f
, std::string
&filename
, std::vector
<std::string
> args
, size_t argidx
)
444 bool called_with_fp
= f
!= NULL
;
448 if (argidx
< args
.size())
450 std::string arg
= args
[argidx
];
452 if (arg
.compare(0, 1, "-") == 0)
453 cmd_error(args
, argidx
, "Unknown option or option in arguments.");
455 cmd_error(args
, argidx
, "Extra filename argument in direct file mode.");
458 if (filename
== "<<" && argidx
+1 < args
.size())
459 filename
+= args
[++argidx
];
460 if (filename
.compare(0, 2, "<<") == 0) {
461 if (Frontend::current_script_file
== NULL
)
462 log_error("Unexpected here document '%s' outside of script!\n", filename
.c_str());
463 if (filename
.size() <= 2)
464 log_error("Missing EOT marker in here document!\n");
465 std::string eot_marker
= filename
.substr(2);
466 last_here_document
.clear();
471 if (fgets(block
, 4096, Frontend::current_script_file
) == NULL
)
472 log_error("Unexpected end of file in here document '%s'!\n", filename
.c_str());
474 if (buffer
.size() > 0 && (buffer
[buffer
.size() - 1] == '\n' || buffer
[buffer
.size() - 1] == '\r'))
477 size_t indent
= buffer
.find_first_not_of(" \t\r\n");
478 if (indent
!= std::string::npos
&& buffer
.compare(indent
, eot_marker
.size(), eot_marker
) == 0)
480 last_here_document
+= buffer
;
482 f
= new std::istringstream(last_here_document
);
484 rewrite_filename(filename
);
485 vector
<string
> filenames
= glob_filename(filename
);
486 filename
= filenames
.front();
487 if (GetSize(filenames
) > 1) {
488 next_args
.insert(next_args
.end(), args
.begin(), args
.begin()+argidx
);
489 next_args
.insert(next_args
.end(), filenames
.begin()+1, filenames
.end());
491 std::ifstream
*ff
= new std::ifstream
;
492 ff
->open(filename
.c_str());
493 yosys_input_files
.insert(filename
);
499 // Check for gzip magic
500 unsigned char magic
[3];
501 int n
= readsome(*ff
, reinterpret_cast<char*>(magic
), 3);
502 if (n
== 3 && magic
[0] == 0x1f && magic
[1] == 0x8b) {
503 #ifdef YOSYS_ENABLE_ZLIB
504 log("Found gzip magic in file `%s', decompressing using zlib.\n", filename
.c_str());
506 log_cmd_error("gzip file `%s' uses unsupported compression type %02x\n",
507 filename
.c_str(), unsigned(magic
[2]));
509 std::stringstream
*df
= new std::stringstream();
510 decompress_gzip(filename
, *df
);
513 log_cmd_error("File `%s' is a gzip file, but Yosys is compiled without zlib.\n", filename
.c_str());
517 ff
->seekg(0, std::ios::beg
);
522 log_cmd_error("Can't open input file `%s' for reading: %s\n", filename
.c_str(), strerror(errno
));
524 for (size_t i
= argidx
+1; i
< args
.size(); i
++)
525 if (args
[i
].compare(0, 1, "-") == 0)
526 cmd_error(args
, i
, "Found option, expected arguments.");
528 if (argidx
+1 < args
.size()) {
529 if (next_args
.empty())
530 next_args
.insert(next_args
.end(), args
.begin(), args
.begin()+argidx
);
531 next_args
.insert(next_args
.end(), args
.begin()+argidx
+1, args
.end());
532 args
.erase(args
.begin()+argidx
+1, args
.end());
537 cmd_error(args
, argidx
, "No filename given.");
540 args
.push_back(filename
);
542 // cmd_log_args(args);
545 void Frontend::frontend_call(RTLIL::Design
*design
, std::istream
*f
, std::string filename
, std::string command
)
547 std::vector
<std::string
> args
;
548 char *s
= strdup(command
.c_str());
549 for (char *p
= strtok(s
, " \t\r\n"); p
; p
= strtok(NULL
, " \t\r\n"))
552 frontend_call(design
, f
, filename
, args
);
555 void Frontend::frontend_call(RTLIL::Design
*design
, std::istream
*f
, std::string filename
, std::vector
<std::string
> args
)
557 if (args
.size() == 0)
559 if (frontend_register
.count(args
[0]) == 0)
560 log_cmd_error("No such frontend: %s\n", args
[0].c_str());
563 auto state
= frontend_register
[args
[0]]->pre_execute();
564 frontend_register
[args
[0]]->execute(f
, filename
, args
, design
);
565 frontend_register
[args
[0]]->post_execute(state
);
566 } else if (filename
== "-") {
567 std::istream
*f_cin
= &std::cin
;
568 auto state
= frontend_register
[args
[0]]->pre_execute();
569 frontend_register
[args
[0]]->execute(f_cin
, "<stdin>", args
, design
);
570 frontend_register
[args
[0]]->post_execute(state
);
572 if (!filename
.empty())
573 args
.push_back(filename
);
574 frontend_register
[args
[0]]->execute(args
, design
);
578 Backend::Backend(std::string name
, std::string short_help
) :
579 Pass(name
.rfind("=", 0) == 0 ? name
.substr(1) : "write_" + name
, short_help
),
580 backend_name(name
.rfind("=", 0) == 0 ? name
.substr(1) : name
)
584 void Backend::run_register()
586 log_assert(pass_register
.count(pass_name
) == 0);
587 pass_register
[pass_name
] = this;
589 log_assert(backend_register
.count(backend_name
) == 0);
590 backend_register
[backend_name
] = this;
597 void Backend::execute(std::vector
<std::string
> args
, RTLIL::Design
*design
)
599 std::ostream
*f
= NULL
;
600 auto state
= pre_execute();
601 execute(f
, std::string(), args
, design
);
607 void Backend::extra_args(std::ostream
*&f
, std::string
&filename
, std::vector
<std::string
> args
, size_t argidx
)
609 bool called_with_fp
= f
!= NULL
;
611 for (; argidx
< args
.size(); argidx
++)
613 std::string arg
= args
[argidx
];
615 if (arg
.compare(0, 1, "-") == 0 && arg
!= "-")
616 cmd_error(args
, argidx
, "Unknown option or option in arguments.");
618 cmd_error(args
, argidx
, "Extra filename argument in direct file mode.");
621 filename
= "<stdout>";
627 rewrite_filename(filename
);
628 if (filename
.size() > 3 && filename
.compare(filename
.size()-3, std::string::npos
, ".gz") == 0) {
629 #ifdef YOSYS_ENABLE_ZLIB
630 gzip_ostream
*gf
= new gzip_ostream
;
631 if (!gf
->open(filename
)) {
633 log_cmd_error("Can't open output file `%s' for writing: %s\n", filename
.c_str(), strerror(errno
));
635 yosys_output_files
.insert(filename
);
638 log_cmd_error("Yosys is compiled without zlib support, unable to write gzip output.\n");
641 std::ofstream
*ff
= new std::ofstream
;
642 ff
->open(filename
.c_str(), std::ofstream::trunc
);
643 yosys_output_files
.insert(filename
);
646 log_cmd_error("Can't open output file `%s' for writing: %s\n", filename
.c_str(), strerror(errno
));
653 args
.push_back(filename
);
655 // cmd_log_args(args);
658 filename
= "<stdout>";
663 void Backend::backend_call(RTLIL::Design
*design
, std::ostream
*f
, std::string filename
, std::string command
)
665 std::vector
<std::string
> args
;
666 char *s
= strdup(command
.c_str());
667 for (char *p
= strtok(s
, " \t\r\n"); p
; p
= strtok(NULL
, " \t\r\n"))
670 backend_call(design
, f
, filename
, args
);
673 void Backend::backend_call(RTLIL::Design
*design
, std::ostream
*f
, std::string filename
, std::vector
<std::string
> args
)
675 if (args
.size() == 0)
677 if (backend_register
.count(args
[0]) == 0)
678 log_cmd_error("No such backend: %s\n", args
[0].c_str());
680 size_t orig_sel_stack_pos
= design
->selection_stack
.size();
683 auto state
= backend_register
[args
[0]]->pre_execute();
684 backend_register
[args
[0]]->execute(f
, filename
, args
, design
);
685 backend_register
[args
[0]]->post_execute(state
);
686 } else if (filename
== "-") {
687 std::ostream
*f_cout
= &std::cout
;
688 auto state
= backend_register
[args
[0]]->pre_execute();
689 backend_register
[args
[0]]->execute(f_cout
, "<stdout>", args
, design
);
690 backend_register
[args
[0]]->post_execute(state
);
692 if (!filename
.empty())
693 args
.push_back(filename
);
694 backend_register
[args
[0]]->execute(args
, design
);
697 while (design
->selection_stack
.size() > orig_sel_stack_pos
)
698 design
->selection_stack
.pop_back();
701 static struct CellHelpMessages
{
702 dict
<string
, string
> cell_help
, cell_code
;
704 #include "techlibs/common/simlib_help.inc"
705 #include "techlibs/common/simcells_help.inc"
709 } cell_help_messages
;
711 struct HelpPass
: public Pass
{
712 HelpPass() : Pass("help", "display help messages") { }
713 void help() YS_OVERRIDE
716 log(" help ................ list all commands\n");
717 log(" help <command> ...... print help message for given command\n");
718 log(" help -all ........... print complete command reference\n");
720 log(" help -cells .......... list all cell types\n");
721 log(" help <celltype> ..... print help message for given cell type\n");
722 log(" help <celltype>+ .... print verilog code for given cell type\n");
725 void escape_tex(std::string
&tex
)
727 for (size_t pos
= 0; (pos
= tex
.find('_', pos
)) != std::string::npos
; pos
+= 2)
728 tex
.replace(pos
, 1, "\\_");
729 for (size_t pos
= 0; (pos
= tex
.find('$', pos
)) != std::string::npos
; pos
+= 2)
730 tex
.replace(pos
, 1, "\\$");
732 void write_tex(FILE *f
, std::string cmd
, std::string title
, std::string text
)
734 size_t begin
= text
.find_first_not_of("\n"), end
= text
.find_last_not_of("\n");
735 if (begin
!= std::string::npos
&& end
!= std::string::npos
&& begin
< end
)
736 text
= text
.substr(begin
, end
-begin
+1);
737 std::string cmd_unescaped
= cmd
;
740 fprintf(f
, "\\section{%s -- %s}\n", cmd
.c_str(), title
.c_str());
741 fprintf(f
, "\\label{cmd:%s}\n", cmd_unescaped
.c_str());
742 fprintf(f
, "\\begin{lstlisting}[numbers=left,frame=single]\n");
743 fprintf(f
, "%s\n\\end{lstlisting}\n\n", text
.c_str());
745 void escape_html(std::string
&html
)
748 while ((pos
= html
.find_first_of("<>&", pos
)) != std::string::npos
)
751 html
.replace(pos
, 1, "<");
755 html
.replace(pos
, 1, ">");
759 html
.replace(pos
, 1, "&");
764 void write_html(FILE *idxf
, std::string cmd
, std::string title
, std::string text
)
766 FILE *f
= fopen(stringf("cmd_%s.in", cmd
.c_str()).c_str(), "wt");
767 fprintf(idxf
, "<li><a href=\"cmd_%s.html\"> ", cmd
.c_str());
773 fprintf(idxf
, "%s</a> <span>%s</span></a>\n", cmd
.c_str(), title
.c_str());
775 fprintf(f
, "@cmd_header %s@\n", cmd
.c_str());
776 fprintf(f
, "<h1>%s - %s</h1>\n", cmd
.c_str(), title
.c_str());
777 fprintf(f
, "<pre>%s</pre>\n", text
.c_str());
778 fprintf(f
, "@footer@\n");
782 void execute(std::vector
<std::string
> args
, RTLIL::Design
*) YS_OVERRIDE
784 if (args
.size() == 1) {
786 for (auto &it
: pass_register
)
787 log(" %-20s %s\n", it
.first
.c_str(), it
.second
->short_help
.c_str());
789 log("Type 'help <command>' for more information on a command.\n");
790 log("Type 'help -cells' for a list of all cell types.\n");
795 if (args
.size() == 2) {
796 if (args
[1] == "-all") {
797 for (auto &it
: pass_register
) {
799 log("%s -- %s\n", it
.first
.c_str(), it
.second
->short_help
.c_str());
800 for (size_t i
= 0; i
< it
.first
.size() + it
.second
->short_help
.size() + 6; i
++)
806 else if (args
[1] == "-cells") {
808 for (auto &it
: cell_help_messages
.cell_help
) {
809 string line
= split_tokens(it
.second
, "\n").at(0);
810 string cell_name
= next_token(line
);
811 log(" %-15s %s\n", cell_name
.c_str(), line
.c_str());
814 log("Type 'help <cell_type>' for more information on a cell type.\n");
818 // this option is undocumented as it is for internal use only
819 else if (args
[1] == "-write-tex-command-reference-manual") {
820 FILE *f
= fopen("command-reference-manual.tex", "wt");
821 fprintf(f
, "%% Generated using the yosys 'help -write-tex-command-reference-manual' command.\n\n");
822 for (auto &it
: pass_register
) {
823 std::ostringstream buf
;
824 log_streams
.push_back(&buf
);
826 log_streams
.pop_back();
827 write_tex(f
, it
.first
, it
.second
->short_help
, buf
.str());
831 // this option is undocumented as it is for internal use only
832 else if (args
[1] == "-write-web-command-reference-manual") {
833 FILE *f
= fopen("templates/cmd_index.in", "wt");
834 for (auto &it
: pass_register
) {
835 std::ostringstream buf
;
836 log_streams
.push_back(&buf
);
838 log_streams
.pop_back();
839 write_html(f
, it
.first
, it
.second
->short_help
, buf
.str());
843 else if (pass_register
.count(args
[1])) {
844 pass_register
.at(args
[1])->help();
846 else if (cell_help_messages
.cell_help
.count(args
[1])) {
847 log("%s", cell_help_messages
.cell_help
.at(args
[1]).c_str());
848 log("Run 'help %s+' to display the Verilog model for this cell type.\n", args
[1].c_str());
851 else if (cell_help_messages
.cell_code
.count(args
[1])) {
853 log("%s", cell_help_messages
.cell_code
.at(args
[1]).c_str());
856 log("No such command or cell type: %s\n", args
[1].c_str());
864 struct EchoPass
: public Pass
{
865 EchoPass() : Pass("echo", "turning echoing back of commands on and off") { }
866 void help() YS_OVERRIDE
871 log("Print all commands to log before executing them.\n");
876 log("Do not print all commands to log before executing them. (default)\n");
879 void execute(std::vector
<std::string
> args
, RTLIL::Design
*) YS_OVERRIDE
882 cmd_error(args
, 2, "Unexpected argument.");
884 if (args
.size() == 2) {
887 else if (args
[1] == "off")
890 cmd_error(args
, 1, "Unexpected argument.");
893 log("echo %s\n", echo_mode
? "on" : "off");
897 SatSolver
*yosys_satsolver_list
;
898 SatSolver
*yosys_satsolver
;
900 struct MinisatSatSolver
: public SatSolver
{
901 MinisatSatSolver() : SatSolver("minisat") {
902 yosys_satsolver
= this;
904 ezSAT
*create() YS_OVERRIDE
{
905 return new ezMiniSAT();