ice40: split out cells_map.v into ff_map.v
[yosys.git] / kernel / yosys.h
index 09e8139bb7b2a5e2586614d62ccc6eca51834bbd..c922faf26848075049401853579d55dfee534e60 100644 (file)
@@ -117,6 +117,10 @@ extern Tcl_Obj *Tcl_ObjSetVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr, Tcl_Obj *p
 #    define PATH_MAX MAX_PATH
 #    define isatty _isatty
 #    define fileno _fileno
+#  else
+//   mingw includes `wingdi.h` which defines a TRANSPARENT macro
+//   that conflicts with X(TRANSPARENT) entry in kernel/constids.inc
+#    undef TRANSPARENT
 #  endif
 #endif
 
@@ -151,6 +155,16 @@ extern Tcl_Obj *Tcl_ObjSetVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr, Tcl_Obj *p
 #  define YS_NORETURN
 #endif
 
+#if __cplusplus >= 201703L
+#  define YS_FALLTHROUGH [[fallthrough]];
+#elif defined(__clang__)
+#  define YS_FALLTHROUGH [[clang::fallthrough]];
+#elif defined(__GNUC__)
+#  define YS_FALLTHROUGH [[gnu::fallthrough]];
+#else
+#  define YS_FALLTHROUGH
+#endif
+
 YOSYS_NAMESPACE_BEGIN
 
 // Note: All headers included in hashlib.h must be included
@@ -207,9 +221,11 @@ namespace RTLIL {
        struct SigSpec;
        struct Wire;
        struct Cell;
+       struct Memory;
        struct Module;
        struct Design;
        struct Monitor;
+       enum State : unsigned char;
 }
 
 namespace AST {
@@ -228,6 +244,7 @@ using RTLIL::Design;
 namespace hashlib {
        template<> struct hash_ops<RTLIL::Wire*> : hash_obj_ops {};
        template<> struct hash_ops<RTLIL::Cell*> : hash_obj_ops {};
+       template<> struct hash_ops<RTLIL::Memory*> : hash_obj_ops {};
        template<> struct hash_ops<RTLIL::Module*> : hash_obj_ops {};
        template<> struct hash_ops<RTLIL::Design*> : hash_obj_ops {};
        template<> struct hash_ops<RTLIL::Monitor*> : hash_obj_ops {};
@@ -235,6 +252,7 @@ namespace hashlib {
 
        template<> struct hash_ops<const RTLIL::Wire*> : hash_obj_ops {};
        template<> struct hash_ops<const RTLIL::Cell*> : hash_obj_ops {};
+       template<> struct hash_ops<const RTLIL::Memory*> : hash_obj_ops {};
        template<> struct hash_ops<const RTLIL::Module*> : hash_obj_ops {};
        template<> struct hash_ops<const RTLIL::Design*> : hash_obj_ops {};
        template<> struct hash_ops<const RTLIL::Monitor*> : hash_obj_ops {};
@@ -256,7 +274,9 @@ int readsome(std::istream &f, char *s, int n);
 std::string next_token(std::string &text, const char *sep = " \t\r\n", bool long_strings = false);
 std::vector<std::string> split_tokens(const std::string &text, const char *sep = " \t\r\n");
 bool patmatch(const char *pattern, const char *string);
+#if !defined(YOSYS_DISABLE_SPAWN)
 int run_command(const std::string &command, std::function<void(const std::string&)> process_line = std::function<void(const std::string&)>());
+#endif
 std::string make_temp_file(std::string template_str = "/tmp/yosys_XXXXXX");
 std::string make_temp_dir(std::string template_str = "/tmp/yosys_XXXXXX");
 bool check_file_exists(std::string filename, bool is_exec = false);
@@ -305,12 +325,22 @@ RTLIL::IdString new_id(std::string file, int line, std::string func);
 #define NEW_ID \
        YOSYS_NAMESPACE_PREFIX new_id(__FILE__, __LINE__, __FUNCTION__)
 
-#define ID(_str) \
-       ([]() { static YOSYS_NAMESPACE_PREFIX RTLIL::IdString _id(_str); return _id; })()
+// Create a statically allocated IdString object, using for example ID::A or ID($add).
+//
+// Recipe for Converting old code that is using conversion of strings like ID::A and
+// "$add" for creating IdStrings: Run below SED command on the .cc file and then use for
+// example "meld foo.cc foo.cc.orig" to manually compile errors, if necessary.
+//
+//  sed -i.orig -r 's/"\\\\([a-zA-Z0-9_]+)"/ID(\1)/g; s/"(\$[a-zA-Z0-9_]+)"/ID(\1)/g;' <filename>
+//
+#define ID(_id) ([]() { const char *p = "\\" #_id, *q = p[1] == '$' ? p+1 : p; \
+        static const YOSYS_NAMESPACE_PREFIX RTLIL::IdString id(q); return id; })()
+namespace ID = RTLIL::ID;
 
 RTLIL::Design *yosys_get_design();
 std::string proc_self_dirname();
 std::string proc_share_dirname();
+std::string proc_program_prefix();
 const char *create_prompt(RTLIL::Design *design, int recursion_counter);
 std::vector<std::string> glob_filename(const std::string &filename_pattern);
 void rewrite_filename(std::string &filename);