summaryrefslogtreecommitdiff
path: root/kernel/rtlil.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/rtlil.h')
-rw-r--r--kernel/rtlil.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index 702addd7..9b9afcee 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -474,7 +474,16 @@ struct RTLIL::Const
std::string decode_string() const;
inline int size() const { return bits.size(); }
- inline RTLIL::State operator[](int index) { return bits.at(index); }
+ inline RTLIL::State &operator[](int index) { return bits.at(index); }
+ inline const RTLIL::State &operator[](int index) const { return bits.at(index); };
+
+ inline RTLIL::Const extract(int offset, int len = 1, RTLIL::State padding = RTLIL::State::S0) const {
+ RTLIL::Const ret;
+ ret.bits.reserve(len);
+ for (int i = offset; i < offset + len; i++)
+ ret.bits.push_back(i < GetSize(bits) ? bits[i] : padding);
+ return ret;
+ }
inline unsigned int hash() const {
unsigned int h = mkhash_init;