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.
21 // *** NOTE TO THE READER ***
23 // Maybe you have just opened this file in the hope to learn more about the
24 // Yosys API. Let me congratulate you on this great decision! ;)
26 // If you want to know how the design is represented by Yosys in the memory,
27 // you should read "kernel/rtlil.h".
29 // If you want to know how to register a command with Yosys, you could read
30 // "kernel/register.h", but it would be easier to just look at a simple
31 // example instead. A simple one would be "passes/cmds/log.cc".
33 // This header is very boring. It just defines some general things that
34 // belong nowhere else and includes the interesting headers.
36 // Find more information in the "CodingReadme" file.
48 #include <initializer_list>
62 # error It looks like you are trying to build Yosys with the config defines set. \
63 When building Yosys with a custom make system, make sure you set all the \
64 defines the Yosys Makefile would set for your build configuration.
67 #ifdef YOSYS_ENABLE_TCL
71 #define PRIVATE_NAMESPACE_BEGIN namespace {
72 #define PRIVATE_NAMESPACE_END }
73 #define YOSYS_NAMESPACE_BEGIN namespace Yosys {
74 #define YOSYS_NAMESPACE_END }
75 #define YOSYS_NAMESPACE_PREFIX Yosys::
76 #define USING_YOSYS_NAMESPACE using namespace Yosys;
78 #if __cplusplus >= 201103L
79 # define OVERRIDE override
86 #if !defined(__GNUC__) && !defined(__clang__)
87 # define __attribute__(...)
99 std::string
stringf(const char *fmt
, ...) __attribute__ ((format (printf
, 1, 2)));
100 std::string
vstringf(const char *fmt
, va_list ap
);
101 std::string
next_token(std::string
&text
, const char *sep
);
102 bool patmatch(const char *pattern
, const char *string
);
103 int run_command(const std::string
&command
, std::function
<void(const std::string
&)> process_line
= std::function
<void(const std::string
&)>());
104 std::string
make_temp_file(std::string template_str
= "/tmp/yosys_XXXXXX");
105 std::string
make_temp_dir(std::string template_str
= "/tmp/yosys_XXXXXX");
106 void remove_directory(std::string dirname
);
108 template<typename T
> int GetSize(const T
&obj
) { return obj
.size(); }
109 int GetSize(RTLIL::Wire
*wire
);
113 #include "kernel/log.h"
114 #include "kernel/rtlil.h"
115 #include "kernel/register.h"
117 YOSYS_NAMESPACE_BEGIN
120 void yosys_shutdown();
122 #ifdef YOSYS_ENABLE_TCL
123 Tcl_Interp
*yosys_get_tcl_interp();
127 extern RTLIL::Design
*yosys_design
;
129 RTLIL::IdString
new_id(std::string file
, int line
, std::string func
);
132 YOSYS_NAMESPACE_PREFIX new_id(__FILE__, __LINE__, __FUNCTION__)
135 ([]() { static YOSYS_NAMESPACE_PREFIX RTLIL::IdString _id(_str); return _id; })()
137 RTLIL::Design
*yosys_get_design();
138 std::string
proc_self_dirname();
139 std::string
proc_share_dirname();
140 const char *create_prompt(RTLIL::Design
*design
, int recursion_counter
);
142 void run_frontend(std::string filename
, std::string command
, RTLIL::Design
*design
, std::string
*backend_command
, std::string
*from_to_label
);
143 void run_pass(std::string command
, RTLIL::Design
*design
);
144 void run_backend(std::string filename
, std::string command
, RTLIL::Design
*design
);
145 void shell(RTLIL::Design
*design
);
147 // from kernel/version_*.o (cc source generated from Makefile)
148 extern const char *yosys_version_str
;
150 // from passes/cmds/design.cc
151 extern std::map
<std::string
, RTLIL::Design
*> saved_designs
;
152 extern std::vector
<RTLIL::Design
*> pushed_designs
;
154 // from passes/cmds/pluginc.cc
155 extern std::map
<std::string
, void*> loaded_plugins
;
156 extern std::map
<std::string
, std::string
> loaded_plugin_aliases
;
157 void load_plugin(std::string filename
, std::vector
<std::string
> aliases
);