ice40: Adapt the relut process passes to the new $lut <=> SB_LUT4 port map
[yosys.git] / passes / cmds / logcmd.cc
1 /*
2 * yosys -- Yosys Open SYnthesis Suite
3 *
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
5 * Copyright (C) 2014 Johann Glaser <Johann.Glaser@gmx.at>
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 *
19 */
20
21 #include "kernel/register.h"
22 #include "kernel/rtlil.h"
23 #include "kernel/log.h"
24
25 USING_YOSYS_NAMESPACE
26 PRIVATE_NAMESPACE_BEGIN
27
28 struct LogPass : public Pass {
29 LogPass() : Pass("log", "print text and log files") { }
30 void help() YS_OVERRIDE
31 {
32 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
33 log("\n");
34 log(" log string\n");
35 log("\n");
36 log("Print the given string to the screen and/or the log file. This is useful for TCL\n");
37 log("scripts, because the TCL command \"puts\" only goes to stdout but not to\n");
38 log("logfiles.\n");
39 log("\n");
40 log(" -stdout\n");
41 log(" Print the output to stdout too. This is useful when all Yosys is executed\n");
42 log(" with a script and the -q (quiet operation) argument to notify the user.\n");
43 log("\n");
44 log(" -stderr\n");
45 log(" Print the output to stderr too.\n");
46 log("\n");
47 log(" -nolog\n");
48 log(" Don't use the internal log() command. Use either -stdout or -stderr,\n");
49 log(" otherwise no output will be generated at all.\n");
50 log("\n");
51 log(" -n\n");
52 log(" do not append a newline\n");
53 log("\n");
54 }
55 void execute(std::vector<std::string> args, RTLIL::Design*) YS_OVERRIDE
56 {
57 size_t argidx;
58 bool to_stdout = false;
59 bool to_stderr = false;
60 bool to_log = true;
61 bool newline = true;
62 std::string text;
63
64 for (argidx = 1; argidx < args.size(); argidx++)
65 {
66 if (args[argidx] == "-stdout") to_stdout = true;
67 else if (args[argidx] == "-stderr") to_stderr = true;
68 else if (args[argidx] == "-nolog") to_log = false;
69 else if (args[argidx] == "-n") newline = false;
70 else break;
71 }
72 for (; argidx < args.size(); argidx++)
73 text += args[argidx] + ' ';
74 if (!text.empty()) text.resize(text.size()-1);
75
76 if (to_stdout) fprintf(stdout, (newline ? "%s\n" : "%s"), text.c_str());
77 if (to_stderr) fprintf(stderr, (newline ? "%s\n" : "%s"), text.c_str());
78 if (to_log) log ( (newline ? "%s\n" : "%s"), text.c_str());
79 }
80 } LogPass;
81
82 PRIVATE_NAMESPACE_END