SigSpec::extract to take negative lengths
authorEddie Hung <eddie@fpgeh.com>
Fri, 19 Jul 2019 19:34:04 +0000 (12:34 -0700)
committerEddie Hung <eddie@fpgeh.com>
Fri, 19 Jul 2019 19:34:04 +0000 (12:34 -0700)
kernel/rtlil.cc

index a09f4a0d1cbfa81cb2edbf69a06f605684b95a63..85b013bdcf92f82172fc8b9cf578900cefc23ab1 100644 (file)
@@ -3353,7 +3353,7 @@ RTLIL::SigSpec RTLIL::SigSpec::extract(int offset, int length) const
 {
        unpack();
        cover("kernel.rtlil.sigspec.extract_pos");
-       return std::vector<RTLIL::SigBit>(bits_.begin() + offset, bits_.begin() + offset + length);
+       return std::vector<RTLIL::SigBit>(bits_.begin() + offset, length >= 0 ? bits_.begin() + offset + length : bits_.end() + length + 1);
 }
 
 void RTLIL::SigSpec::append(const RTLIL::SigSpec &signal)