Added "kernel/yosys.h" and "kernel/yosys.cc"
authorClifford Wolf <clifford@clifford.at>
Wed, 30 Jul 2014 12:10:15 +0000 (14:10 +0200)
committerClifford Wolf <clifford@clifford.at>
Wed, 30 Jul 2014 12:10:15 +0000 (14:10 +0200)
Makefile
kernel/driver.cc
kernel/log.cc
kernel/log.h
kernel/register.h
kernel/rtlil.h
kernel/yosys.cc [new file with mode: 0644]
kernel/yosys.h [new file with mode: 0644]

index 462861c8ae740df28965d6ee8ab4fff712e971c0..73d448337b720818a487713b9709a72173b66b5f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -121,7 +121,7 @@ S =
 endif
 
 OBJS += kernel/driver.o kernel/register.o kernel/rtlil.o kernel/log.o kernel/calc.o
-OBJS += kernel/compatibility.o
+OBJS += kernel/compatibility.o kernel/yosys.o
 
 OBJS += libs/bigint/BigIntegerAlgorithms.o libs/bigint/BigInteger.o libs/bigint/BigIntegerUtils.o
 OBJS += libs/bigint/BigUnsigned.o libs/bigint/BigUnsignedInABase.o
index 2e56f9a334d0aa2acb150be6eb8a704e4fe22eb5..c20be1dc1fc91542a0ae796c4c7eb0fc1187c523 100644 (file)
@@ -30,9 +30,7 @@
 #include <algorithm>
 #include <exception>
 
-#include "kernel/rtlil.h"
-#include "kernel/register.h"
-#include "kernel/log.h"
+#include "kernel/yosys.h"
 
 bool fgetline(FILE *f, std::string &buffer)
 {
index 8036b23603d6f5e979e0dc4a5c73cbc9aa7377cd..5fe0d0863b80016a9f68553851f0842f0066fe0a 100644 (file)
  *
  */
 
-#include "kernel/log.h"
-#include "kernel/rtlil.h"
-#include "kernel/register.h"
-#include "kernel/compatibility.h"
+#include "kernel/yosys.h"
 #include "backends/ilang/ilang_backend.h"
 
 #include <sys/time.h>
@@ -43,25 +40,6 @@ std::list<std::string> string_buf;
 static struct timeval initial_tv = { 0, 0 };
 static bool next_print_log = false;
 
-std::string stringf(const char *fmt, ...)
-{
-       std::string string;
-       char *str = NULL;
-       va_list ap;
-
-       va_start(ap, fmt);
-       if (vasprintf(&str, fmt, ap) < 0)
-               str = NULL;
-       va_end(ap);
-
-       if (str != NULL) {
-               string = str;
-               free(str);
-       }
-
-       return string;
-}
-
 void logv(const char *format, va_list ap)
 {
        if (log_time) {
index 3152fc5af515cd6534e001714f6108507264a39b..803365b39f2a1d171e5d773ee2fb1e7cb3bc0e19 100644 (file)
@@ -17,6 +17,8 @@
  *
  */
 
+#include "kernel/yosys.h"
+
 #ifndef LOG_H
 #define LOG_H
 
 #include <sys/time.h>
 #include <sys/resource.h>
 
-#include <map>
-#include <vector>
-#include <string>
-
 #define S__LINE__sub2(x) #x
 #define S__LINE__sub1(x) S__LINE__sub2(x)
 #define S__LINE__ S__LINE__sub1(__LINE__)
index 73875e96810a2c3881253942704ea1130300f670..68f09c822059340f109b25f87fbb4c1eb9e0a540 100644 (file)
 #include <vector>
 #include <map>
 
-#ifdef YOSYS_ENABLE_TCL
-#include <tcl.h>
-extern Tcl_Interp *yosys_get_tcl_interp();
-#endif
-
-// from kernel/version_*.o (cc source generated from Makefile)
-extern const char *yosys_version_str;
-
-// implemented in driver.cc
-extern RTLIL::Design *yosys_get_design();
-extern std::string proc_self_dirname();
-extern std::string proc_share_dirname();
-extern const char *create_prompt(RTLIL::Design *design, int recursion_counter);
-
-// from passes/cmds/design.cc
-extern std::map<std::string, RTLIL::Design*> saved_designs;
-extern std::vector<RTLIL::Design*> pushed_designs;
-
 struct Pass
 {
        std::string pass_name, short_help;
index 1f25542f3fc0bf15021b28e78239dcb6936f21fa..d6acb5bcc01f5a6403cf573cc69cf7b5df3394aa 100644 (file)
  *
  */
 
+#include "kernel/yosys.h"
+
 #ifndef RTLIL_H
 #define RTLIL_H
 
-#include <map>
-#include <set>
-#include <vector>
-#include <string>
-
-#include "kernel/log.h"
-#include <initializer_list>
-
-// various helpers (unrelated to RTLIL)
-std::string stringf(const char *fmt, ...);
-#define SIZE(__obj) int(__obj.size())
-
 namespace RTLIL
 {
        enum State : unsigned char {
diff --git a/kernel/yosys.cc b/kernel/yosys.cc
new file mode 100644 (file)
index 0000000..d254438
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *  yosys -- Yosys Open SYnthesis Suite
+ *
+ *  Copyright (C) 2012  Clifford Wolf <clifford@clifford.at>
+ *  
+ *  Permission to use, copy, modify, and/or distribute this software for any
+ *  purpose with or without fee is hereby granted, provided that the above
+ *  copyright notice and this permission notice appear in all copies.
+ *  
+ *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ *  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ *  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ *  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ *  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#include "kernel/yosys.h"
+
+std::string stringf(const char *fmt, ...)
+{
+       std::string string;
+       char *str = NULL;
+       va_list ap;
+
+       va_start(ap, fmt);
+       if (vasprintf(&str, fmt, ap) < 0)
+               str = NULL;
+       va_end(ap);
+
+       if (str != NULL) {
+               string = str;
+               free(str);
+       }
+
+       return string;
+}
+
diff --git a/kernel/yosys.h b/kernel/yosys.h
new file mode 100644 (file)
index 0000000..67629d9
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ *  yosys -- Yosys Open SYnthesis Suite
+ *
+ *  Copyright (C) 2012  Clifford Wolf <clifford@clifford.at>
+ *  
+ *  Permission to use, copy, modify, and/or distribute this software for any
+ *  purpose with or without fee is hereby granted, provided that the above
+ *  copyright notice and this permission notice appear in all copies.
+ *  
+ *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ *  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ *  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ *  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ *  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+
+// *** NOTE TO THE READER ***
+//
+// Maybe you have just opened this file in the hope to learn more about the
+// Yosys API. Let me congratulate you on this great decision!  ;)
+//
+// If you want to know how the design is represented by Yosys in the memory,
+// you should read "kernel/rtlil.h".
+//
+// If you want to know how to register a command with Yosys, you could read
+// "kernel/register.h", but it would be easier to just look at a simple
+// example instead. A simple one would be "passes/cmds/log.cc".
+
+
+#ifndef YOSYS_H
+#define YOSYS_H
+
+#include <map>
+#include <set>
+#include <vector>
+#include <string>
+#include <initializer_list>
+
+#if 0
+#  define YOSYS_NAMESPACE_BEGIN  namespace Yosys {
+#  define YOSYS_NAMESPACE_END    }
+#else
+#  define YOSYS_NAMESPACE_BEGIN
+#  define YOSYS_NAMESPACE_END
+#endif
+
+YOSYS_NAMESPACE_BEGIN
+
+std::string stringf(const char *fmt, ...);
+
+#define SIZE(__obj) int(__obj.size())
+
+YOSYS_NAMESPACE_END
+
+#include "kernel/log.h"
+#include "kernel/rtlil.h"
+#include "kernel/register.h"
+#include "kernel/compatibility.h"
+
+YOSYS_NAMESPACE_BEGIN
+
+#ifdef YOSYS_ENABLE_TCL
+#include <tcl.h>
+extern Tcl_Interp *yosys_get_tcl_interp();
+#endif
+
+// from kernel/version_*.o (cc source generated from Makefile)
+extern const char *yosys_version_str;
+
+// implemented in driver.cc
+extern RTLIL::Design *yosys_get_design();
+extern std::string proc_self_dirname();
+extern std::string proc_share_dirname();
+extern const char *create_prompt(RTLIL::Design *design, int recursion_counter);
+
+// from passes/cmds/design.cc
+extern std::map<std::string, RTLIL::Design*> saved_designs;
+extern std::vector<RTLIL::Design*> pushed_designs;
+
+YOSYS_NAMESPACE_END
+
+#endif