From 038caab4e0de7e8c3b0dde8c77a716fbdb86cf1f Mon Sep 17 00:00:00 2001 From: Benedikt Tutzer Date: Tue, 21 Aug 2018 15:25:43 +0200 Subject: [PATCH] Wrapped functions that use unsigned int or type_t as types --- kernel/python_wrappers.cc | 134 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 127 insertions(+), 7 deletions(-) diff --git a/kernel/python_wrappers.cc b/kernel/python_wrappers.cc index 015a303f8..3d9094313 100644 --- a/kernel/python_wrappers.cc +++ b/kernel/python_wrappers.cc @@ -69,20 +69,29 @@ namespace YOSYS_PYTHON { } //WRAPPED static inline int get_reference(int idx) - static inline int get_reference(int idx); + static int get_reference(int idx); //WRAPPED static inline void put_reference(int idx) - static inline void put_reference(int idx); + static void put_reference(int idx); //WRAPPED std::string str() const { std::string str(); + //WRAPPED std::string substr(size_t pos = 0, size_t len = std::string::npos) const { + std::string substr(size_t pos = 0, size_t len = std::string::npos); + + //WRAPPED size_t size() const { + size_t size(); + //WRAPPED bool empty() const { bool empty(); //WRAPPED void clear() { void clear(); + //WRAPPED unsigned int hash() const { + unsigned int hash(); + //WRAPPED bool in(IdString rhs) const { return *this == rhs; } bool in_IdString(IdString *rhs); @@ -144,7 +153,7 @@ namespace YOSYS_PYTHON { std::string decode_string(); //WRAPPED inline int size() const { return bits.size(); } - inline int size(); + int size(); //WRAPPED bool is_fully_zero() const; bool is_fully_zero(); @@ -159,7 +168,10 @@ namespace YOSYS_PYTHON { bool is_fully_undef(); //WRAPPED inline RTLIL::Const extract(int offset, int len = 1, RTLIL::State padding = RTLIL::State::S0) const { - inline Const extract(int offset, int len = 1, State padding = RTLIL::State::S0); + Const extract(int offset, int len = 1, State padding = RTLIL::State::S0); + + //WRAPPED inline unsigned int hash() const { + unsigned int hash(); bool operator<(Const rhs) { return get_cpp_obj() get_cpp_obj()->str(); } + //WRAPPED std::string substr(size_t pos = 0, size_t len = std::string::npos) const { + std::string IdString::substr(size_t pos, size_t len) + { + return this->get_cpp_obj()->substr(pos, len); + } + + //WRAPPED size_t size() const { + size_t IdString::size() + { + return this->get_cpp_obj()->size(); + } + //WRAPPED bool empty() const { bool IdString::empty() { @@ -1737,6 +1785,12 @@ namespace YOSYS_PYTHON { this->get_cpp_obj()->clear(); } + //WRAPPED unsigned int hash() const { + unsigned int IdString::hash() + { + return this->get_cpp_obj()->hash(); + } + //WRAPPED bool in(IdString rhs) const { return *this == rhs; } bool IdString::in_IdString(IdString *rhs) { @@ -1825,6 +1879,12 @@ namespace YOSYS_PYTHON { return Const(this->get_cpp_obj()->extract(offset, len, padding)); } + //WRAPPED inline unsigned int hash() const { + inline unsigned int Const::hash() + { + return this->get_cpp_obj()->hash(); + } + //WRAPPED RTLIL::CaseRule *clone() const; CaseRule CaseRule::clone() { @@ -1855,6 +1915,18 @@ namespace YOSYS_PYTHON { return SigChunk(this->get_cpp_obj()->extract(offset, length)); } + //WRAPPED unsigned int hash() const; + unsigned int SigBit::hash() + { + return this->get_cpp_obj()->hash(); + } + + //WRAPPED size_t get_hash() const { + size_t SigSpec::get_hash() + { + return this->get_cpp_obj()->get_hash(); + } + //WRAPPED inline int size() const { return width_; } inline int SigSpec::size() { @@ -2111,12 +2183,24 @@ namespace YOSYS_PYTHON { return Yosys::RTLIL::SigSpec::parse_rhs(*lhs->get_cpp_obj(), *sig->get_cpp_obj(), module->get_cpp_obj(), str); } + //WRAPPED unsigned int hash() const { if(!hash_) updhash(); return hash_; }; + unsigned int SigSpec::hash() + { + return this->get_cpp_obj()->hash(); + } + //WRAPPED void check() const; void SigSpec::check() { this->get_cpp_obj()->check(); } + //WRAPPED unsigned int hash() const { return hashidx_; } + unsigned int Cell::hash() + { + return this->get_cpp_obj()->hash(); + } + //WRAPPED bool hasPort(RTLIL::IdString portname) const; bool Cell::hasPort(IdString *portname) { @@ -2183,6 +2267,24 @@ namespace YOSYS_PYTHON { return this->get_cpp_obj()->has_keep_attr(); } + //WRAPPED unsigned int hash() const { return hashidx_; } + unsigned int Wire::hash() + { + return this->get_cpp_obj()->hash(); + } + + //WRAPPED unsigned int hash() const { return hashidx_; } + unsigned int Memory::hash() + { + return this->get_cpp_obj()->hash(); + } + + //WRAPPED unsigned int hash() const { return hashidx_; } + unsigned int Module::hash() + { + return this->get_cpp_obj()->hash(); + } + //WRAPPED void connect(const RTLIL::SigSig &conn); void Module::connect_SigSig(PyObject* conn) { @@ -3096,6 +3198,12 @@ namespace YOSYS_PYTHON { return SigSpec(this->get_cpp_obj()->Initstate(*name->get_cpp_obj(), src)); } + //WRAPPED unsigned int hash() const { return hashidx_; } + unsigned int Design::hash() + { + return this->get_cpp_obj()->hash(); + } + //WRAPPED RTLIL::Module *module(RTLIL::IdString name); Module Design::module(IdString *name) { @@ -3284,8 +3392,11 @@ namespace YOSYS_PYTHON { .def("get_reference", &IdString::get_reference) .def("put_reference", &IdString::put_reference) .def("str", &IdString::str) + .def("substr", &IdString::substr) + .def("size", &IdString::size) .def("empty", &IdString::empty) .def("clear", &IdString::clear) + .def("hash", &IdString::hash) .def("in_IdString", &IdString::in_IdString) .def("in_std_string", &IdString::in_std_string) .def("in_pool_IdString", &IdString::in_pool_IdString) @@ -3308,6 +3419,7 @@ namespace YOSYS_PYTHON { .def("is_fully_def", &Const::is_fully_def) .def("is_fully_undef", &Const::is_fully_undef) .def("extract", &Const::extract) + .def("hash", &Const::hash) .def(self < self) .def(self == self) .def(self != self) @@ -3349,6 +3461,7 @@ namespace YOSYS_PYTHON { class_("SigBit") .def(boost::python::self_ns::str(boost::python::self_ns::self)) .def(boost::python::self_ns::repr(boost::python::self_ns::self)) + .def("hash", &SigBit::hash) .def(self < self) .def(self == self) .def(self != self) @@ -3357,6 +3470,7 @@ namespace YOSYS_PYTHON { class_("SigSpec") .def(boost::python::self_ns::str(boost::python::self_ns::self)) .def(boost::python::self_ns::repr(boost::python::self_ns::self)) + .def("get_hash", &SigSpec::get_hash) .def("size", &SigSpec::size) .def("empty", &SigSpec::empty) .def("replace_SigSpec_SigSpec", &SigSpec::replace_SigSpec_SigSpec) @@ -3397,6 +3511,7 @@ namespace YOSYS_PYTHON { .def("parse", &SigSpec::parse) .def("parse_sel", &SigSpec::parse_sel) .def("parse_rhs", &SigSpec::parse_rhs) + .def("hash", &SigSpec::hash) .def("check", &SigSpec::check) .def(self < self) .def(self == self) @@ -3406,6 +3521,7 @@ namespace YOSYS_PYTHON { class_("Cell", no_init) .def(boost::python::self_ns::str(boost::python::self_ns::self)) .def(boost::python::self_ns::repr(boost::python::self_ns::self)) + .def("hash", &Cell::hash) .def("hasPort", &Cell::hasPort) .def("unsetPort", &Cell::unsetPort) .def("setPort", &Cell::setPort) @@ -3422,11 +3538,13 @@ namespace YOSYS_PYTHON { class_("Wire", no_init) .def(boost::python::self_ns::str(boost::python::self_ns::self)) .def(boost::python::self_ns::repr(boost::python::self_ns::self)) + .def("hash", &Wire::hash) ; class_("Memory", no_init) .def(boost::python::self_ns::str(boost::python::self_ns::self)) .def(boost::python::self_ns::repr(boost::python::self_ns::self)) + .def("hash", &Memory::hash) ; class_("Module") @@ -3435,6 +3553,7 @@ namespace YOSYS_PYTHON { .def("get_cells", &Module::get_cells) .def("get_wires", &Module::get_wires) .def("register_monitor", &Module::register_monitor) + .def("hash", &Module::hash) .def("connect_SigSig", &Module::connect_SigSig) .def("connect_SigSpec_SigSpec", &Module::connect_SigSpec_SigSpec) .def("new_connections", &Module::new_connections) @@ -3593,6 +3712,7 @@ namespace YOSYS_PYTHON { .def("get_modules", &Design::get_modules) .def("run", &Design::run) .def("register_monitor", &Design::register_monitor) + .def("hash", &Design::hash) .def("module", &Design::module) .def("has", &Design::has) .def("add", &Design::add) -- 2.30.2