Add RTLIL::Const::ext[su](), fix RTLIL::SigSpec::extend_u0 for 0-size signals
authorClifford Wolf <clifford@clifford.at>
Sat, 23 Mar 2019 13:38:48 +0000 (14:38 +0100)
committerClifford Wolf <clifford@clifford.at>
Sat, 23 Mar 2019 13:38:48 +0000 (14:38 +0100)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
kernel/rtlil.cc
kernel/rtlil.h

index d0fa88890921307aff48da5004e5be33587ad004..b3214579dbfff260f5b329ce0c8eaa56bde7d494 100644 (file)
@@ -3237,7 +3237,7 @@ void RTLIL::SigSpec::extend_u0(int width, bool is_signed)
                remove(width, width_ - width);
 
        if (width_ < width) {
-               RTLIL::SigBit padding = width_ > 0 ? (*this)[width_ - 1] : RTLIL::State::S0;
+               RTLIL::SigBit padding = width_ > 0 ? (*this)[width_ - 1] : RTLIL::State::Sx;
                if (!is_signed)
                        padding = RTLIL::State::S0;
                while (width_ < width)
index 01323d11280b150e409dd85503882b8557b6b8a6..52496e70214b5e6ecc942e59cbd1b2dc07f5da61 100644 (file)
@@ -546,6 +546,14 @@ struct RTLIL::Const
                return ret;
        }
 
+       void extu(int width) {
+               bits.resize(width, RTLIL::State::S0);
+       }
+
+       void exts(int width) {
+               bits.resize(width, bits.empty() ? RTLIL::State::Sx : bits.back());
+       }
+
        inline unsigned int hash() const {
                unsigned int h = mkhash_init;
                for (auto b : bits)