Added "kernel/yosys.h" and "kernel/yosys.cc"
[yosys.git] / kernel / yosys.h
1 /*
2 * yosys -- Yosys Open SYnthesis Suite
3 *
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
5 *
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.
9 *
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.
17 *
18 */
19
20
21 // *** NOTE TO THE READER ***
22 //
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! ;)
25 //
26 // If you want to know how the design is represented by Yosys in the memory,
27 // you should read "kernel/rtlil.h".
28 //
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".
32
33
34 #ifndef YOSYS_H
35 #define YOSYS_H
36
37 #include <map>
38 #include <set>
39 #include <vector>
40 #include <string>
41 #include <initializer_list>
42
43 #if 0
44 # define YOSYS_NAMESPACE_BEGIN namespace Yosys {
45 # define YOSYS_NAMESPACE_END }
46 #else
47 # define YOSYS_NAMESPACE_BEGIN
48 # define YOSYS_NAMESPACE_END
49 #endif
50
51 YOSYS_NAMESPACE_BEGIN
52
53 std::string stringf(const char *fmt, ...);
54
55 #define SIZE(__obj) int(__obj.size())
56
57 YOSYS_NAMESPACE_END
58
59 #include "kernel/log.h"
60 #include "kernel/rtlil.h"
61 #include "kernel/register.h"
62 #include "kernel/compatibility.h"
63
64 YOSYS_NAMESPACE_BEGIN
65
66 #ifdef YOSYS_ENABLE_TCL
67 #include <tcl.h>
68 extern Tcl_Interp *yosys_get_tcl_interp();
69 #endif
70
71 // from kernel/version_*.o (cc source generated from Makefile)
72 extern const char *yosys_version_str;
73
74 // implemented in driver.cc
75 extern RTLIL::Design *yosys_get_design();
76 extern std::string proc_self_dirname();
77 extern std::string proc_share_dirname();
78 extern const char *create_prompt(RTLIL::Design *design, int recursion_counter);
79
80 // from passes/cmds/design.cc
81 extern std::map<std::string, RTLIL::Design*> saved_designs;
82 extern std::vector<RTLIL::Design*> pushed_designs;
83
84 YOSYS_NAMESPACE_END
85
86 #endif