From: Clifford Wolf Date: Fri, 19 Sep 2014 13:50:55 +0000 (+0200) Subject: Initialize RTLIL::Const from std::vector X-Git-Tag: yosys-0.4~111 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=00964f2f618d241a2e5cd32f4e7dbbcf55de4fb4;p=yosys.git Initialize RTLIL::Const from std::vector --- diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 6556b82ee..00be796f8 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -65,6 +65,13 @@ RTLIL::Const::Const(RTLIL::State bit, int width) bits.push_back(bit); } +RTLIL::Const::Const(const std::vector &bits) +{ + flags = RTLIL::CONST_FLAG_NONE; + for (auto b : bits) + this->bits.push_back(b ? RTLIL::S1 : RTLIL::S0); +} + bool RTLIL::Const::operator <(const RTLIL::Const &other) const { if (bits.size() != other.bits.size()) diff --git a/kernel/rtlil.h b/kernel/rtlil.h index c48837691..a0ae8f082 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -428,7 +428,8 @@ struct RTLIL::Const Const(std::string str); Const(int val, int width = 32); Const(RTLIL::State bit, int width = 1); - Const(std::vector bits) : bits(bits) { flags = CONST_FLAG_NONE; }; + Const(const std::vector &bits) : bits(bits) { flags = CONST_FLAG_NONE; }; + Const(const std::vector &bits); bool operator <(const RTLIL::Const &other) const; bool operator ==(const RTLIL::Const &other) const;