summaryrefslogtreecommitdiff
path: root/kernel/rtlil.h
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-07-22 21:33:52 +0200
committerClifford Wolf <clifford@clifford.at>2014-07-22 21:33:52 +0200
commit08e1e251698edfec7e0634a8ccdc321f42e8f27f (patch)
tree853c67c837a390716ff832989eb2aa4c40e5b226 /kernel/rtlil.h
parent28b3fd05fa9cf6d469fdec95e247a7ffe5bc001d (diff)
SigSpec refactoring: added RTLIL::SigSpec::bits() and pack/unpack api
Diffstat (limited to 'kernel/rtlil.h')
-rw-r--r--kernel/rtlil.h42
1 files changed, 32 insertions, 10 deletions
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index 9d5b3b30..1d84dd3b 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -498,14 +498,14 @@ struct RTLIL::SigBit {
struct RTLIL::SigSpec {
private:
std::vector<RTLIL::SigChunk> chunks_; // LSB at index 0
+ std::vector<RTLIL::SigBit> bits_; // LSB at index 0
int width_;
-public:
- std::vector<RTLIL::SigChunk> &chunks_rw() { return chunks_; }
- const std::vector<RTLIL::SigChunk> &chunks() const { return chunks_; }
-
- int size() const { return width_; }
+ void pack() const;
+ void unpack() const;
+ bool packed() const;
+public:
SigSpec();
SigSpec(const RTLIL::Const &data);
SigSpec(const RTLIL::SigChunk &chunk);
@@ -516,46 +516,68 @@ public:
SigSpec(RTLIL::SigBit bit, int width = 1);
SigSpec(std::vector<RTLIL::SigBit> bits);
SigSpec(std::set<RTLIL::SigBit> bits);
+
+ std::vector<RTLIL::SigChunk> &chunks_rw() { pack(); return chunks_; }
+ const std::vector<RTLIL::SigChunk> &chunks() const { pack(); return chunks_; }
+ const std::vector<RTLIL::SigBit> &bits() const { unpack(); return bits_; }
+
+ int size() const { return width_; }
+
void expand();
void optimize();
RTLIL::SigSpec optimized() const;
+
void sort();
void sort_and_unify();
+
void replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with);
void replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with, RTLIL::SigSpec *other) const;
+ void replace(int offset, const RTLIL::SigSpec &with);
+
void remove(const RTLIL::SigSpec &pattern);
void remove(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other) const;
void remove2(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other);
- RTLIL::SigSpec extract(RTLIL::SigSpec pattern, RTLIL::SigSpec *other = NULL) const;
- void replace(int offset, const RTLIL::SigSpec &with);
+ void remove(int offset, int length = 1);
void remove_const();
- void remove(int offset, int length);
+
+ RTLIL::SigSpec extract(RTLIL::SigSpec pattern, RTLIL::SigSpec *other = NULL) const;
RTLIL::SigSpec extract(int offset, int length) const;
+
void append(const RTLIL::SigSpec &signal);
void append_bit(const RTLIL::SigBit &bit);
- bool combine(RTLIL::SigSpec signal, RTLIL::State freeState = RTLIL::State::Sz, bool override = false);
+
+ bool combine(RTLIL::SigSpec signal, RTLIL::State freeState = RTLIL::State::Sz, bool do_override = false);
+
void extend(int width, bool is_signed = false);
void extend_u0(int width, bool is_signed = false);
- void check() const;
+
bool operator <(const RTLIL::SigSpec &other) const;
bool operator ==(const RTLIL::SigSpec &other) const;
bool operator !=(const RTLIL::SigSpec &other) const;
+
bool is_fully_const() const;
bool is_fully_def() const;
bool is_fully_undef() const;
bool has_marked_bits() const;
+
bool as_bool() const;
int as_int() const;
std::string as_string() const;
RTLIL::Const as_const() const;
+
bool match(std::string pattern) const;
+
std::set<RTLIL::SigBit> to_sigbit_set() const;
std::vector<RTLIL::SigBit> to_sigbit_vector() const;
RTLIL::SigBit to_single_sigbit() const;
+
static bool parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str);
static bool parse_sel(RTLIL::SigSpec &sig, RTLIL::Design *design, RTLIL::Module *module, std::string str);
static bool parse_rhs(const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str);
+
operator std::vector<RTLIL::SigBit>() const { return to_sigbit_vector(); }
+
+ void check() const;
};
inline RTLIL::SigBit::SigBit(const RTLIL::SigSpec &sig) {