From 169d1c471165f77612d049478ca25720071272c4 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Mon, 6 Apr 2015 17:06:15 +0200 Subject: Added support for initialized brams --- kernel/rtlil.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'kernel') 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; -- cgit v1.2.3