Added support for changing Yosys namespace
authorBenedikt Tutzer <e1225461@student.tuwien.ac.at>
Wed, 3 Apr 2019 10:21:21 +0000 (12:21 +0200)
committerBenedikt Tutzer <e1225461@student.tuwien.ac.at>
Wed, 3 Apr 2019 10:21:21 +0000 (12:21 +0200)
kernel/yosys.h
py_wrap_generator.py

index a630798bb9053484204f4397d7d84c6c6088c1e5..2cf6188b4607990e3065a4e8b67a6105a7b7b77e 100644 (file)
@@ -119,6 +119,7 @@ extern const char *Tcl_GetStringResult(Tcl_Interp *interp);
 #  define PATH_MAX 4096
 #endif
 
+#define YOSYS_NAMESPACE          Yosys
 #define PRIVATE_NAMESPACE_BEGIN  namespace {
 #define PRIVATE_NAMESPACE_END    }
 #define YOSYS_NAMESPACE_BEGIN    namespace Yosys {
index aa2c46b2c4933eb9a2ead10031a39fc3230d25dd..09f934040d3e570deb2d69491884b73e61c98d42 100644 (file)
@@ -972,7 +972,7 @@ sources = [
        Source("kernel/cost",[])
        ]
 
-blacklist_methods = ["Yosys::Pass::run_register", "Yosys::Module::Pow", "Yosys::Module::Bu0", "Yosys::CaseRule::optimize"]
+blacklist_methods = ["YOSYS_NAMESPACE::Pass::run_register", "YOSYS_NAMESPACE::Module::Pow", "YOSYS_NAMESPACE::Module::Bu0", "YOSYS_NAMESPACE::CaseRule::optimize"]
 
 enum_names = ["State","SyncType","ConstFlags"]
 
@@ -1765,7 +1765,7 @@ def parse_header(source):
        private_segment = False
 
        while i < len(source_text):
-               line = source_text[i].replace("YOSYS_NAMESPACE_BEGIN", "                    namespace Yosys{").replace("YOSYS_NAMESPACE_END","                    }")
+               line = source_text[i].replace("YOSYS_NAMESPACE_BEGIN", "                    namespace YOSYS_NAMESPACE{").replace("YOSYS_NAMESPACE_END","                    }")
                ugly_line = unpretty_string(line)
 
                if str.startswith(ugly_line, "namespace "):# and ugly_line.find("std") == -1 and ugly_line.find("__") == -1:
@@ -1892,7 +1892,7 @@ def parse_header(source):
                if candidate != None:
                        while i < j:
                                i += 1
-                               line = source_text[i].replace("YOSYS_NAMESPACE_BEGIN", "                    namespace Yosys{").replace("YOSYS_NAMESPACE_END","                    }")
+                               line = source_text[i].replace("YOSYS_NAMESPACE_BEGIN", "                    namespace YOSYS_NAMESPACE{").replace("YOSYS_NAMESPACE_END","                    }")
                                ugly_line = unpretty_string(line)
                                if len(namespaces) != 0:
                                        namespaces[-1] = (namespaces[-1][0], namespaces[-1][1] + ugly_line.count("{") - ugly_line.count("}"))
@@ -2028,7 +2028,7 @@ def gen_wrappers(filename, debug_level_ = 0):
 #include <boost/python.hpp>
 #include <boost/log/exceptions.hpp>
 
-using namespace Yosys;
+USING_YOSYS_NAMESPACE
 
 namespace YOSYS_PYTHON {
 """)