diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-07-23 10:05:42 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-07-23 10:05:42 +0200 |
commit | 5b51b67297a5e5e20cbe2b015b584aee4c30489f (patch) | |
tree | 934ce8ee55c3c58a1e2c11f19eec194665413906 /kernel | |
parent | c61467a32c4bd3ec4b9e0cb6d36d602f0e4dea81 (diff) | |
parent | ec923652e2eb721aa16657e54a67666f855c3d65 (diff) | |
download | yosys-5b51b67297a5e5e20cbe2b015b584aee4c30489f.tar.gz yosys-5b51b67297a5e5e20cbe2b015b584aee4c30489f.tar.bz2 yosys-5b51b67297a5e5e20cbe2b015b584aee4c30489f.zip |
Merge branch: Refactoring {SigSpec|SigChunk}(RTLIL::Wire *wire, ..) constructor
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/rtlil.cc | 26 | ||||
-rw-r--r-- | kernel/rtlil.h | 6 | ||||
-rw-r--r-- | kernel/sigtools.h | 4 |
3 files changed, 26 insertions, 10 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 2ab4a8c6e..6bb3e6126 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1324,10 +1324,17 @@ RTLIL::SigChunk::SigChunk(const RTLIL::Const &value) offset = 0; } -RTLIL::SigChunk::SigChunk(RTLIL::Wire *wire, int width, int offset) +RTLIL::SigChunk::SigChunk(RTLIL::Wire *wire) { this->wire = wire; - this->width = width >= 0 ? width : wire->width; + this->width = wire->width; + this->offset = 0; +} + +RTLIL::SigChunk::SigChunk(RTLIL::Wire *wire, int offset, int width) +{ + this->wire = wire; + this->width = width; this->offset = offset; } @@ -1432,9 +1439,16 @@ RTLIL::SigSpec::SigSpec(const RTLIL::SigChunk &chunk) check(); } -RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire, int width, int offset) +RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire) +{ + chunks_.push_back(RTLIL::SigChunk(wire)); + width_ = chunks_.back().width; + check(); +} + +RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire, int offset, int width) { - chunks_.push_back(RTLIL::SigChunk(wire, width, offset)); + chunks_.push_back(RTLIL::SigChunk(wire, offset, width)); width_ = chunks_.back().width; check(); } @@ -2134,7 +2148,7 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri std::vector<std::string> index_tokens; sigspec_parse_split(index_tokens, indices.substr(1, indices.size()-2), ':'); if (index_tokens.size() == 1) - sig.append(RTLIL::SigSpec(wire, 1, atoi(index_tokens.at(0).c_str()))); + sig.append(RTLIL::SigSpec(wire, atoi(index_tokens.at(0).c_str()))); else { int a = atoi(index_tokens.at(0).c_str()); int b = atoi(index_tokens.at(1).c_str()); @@ -2142,7 +2156,7 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri int tmp = a; a = b, b = tmp; } - sig.append(RTLIL::SigSpec(wire, b-a+1, a)); + sig.append(RTLIL::SigSpec(wire, a, b-a+1)); } } else sig.append(wire); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 0e74c958a..832146594 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -462,7 +462,8 @@ struct RTLIL::SigChunk { int width, offset; SigChunk(); SigChunk(const RTLIL::Const &value); - SigChunk(RTLIL::Wire *wire, int width, int offset); + SigChunk(RTLIL::Wire *wire); + SigChunk(RTLIL::Wire *wire, int offset, int width = 1); SigChunk(const std::string &str); SigChunk(int val, int width = 32); SigChunk(RTLIL::State bit, int width = 1); @@ -522,7 +523,8 @@ public: SigSpec(); SigSpec(const RTLIL::Const &value); SigSpec(const RTLIL::SigChunk &chunk); - SigSpec(RTLIL::Wire *wire, int width = -1, int offset = 0); + SigSpec(RTLIL::Wire *wire); + SigSpec(RTLIL::Wire *wire, int offset, int width = 1); SigSpec(const std::string &str); SigSpec(int val, int width = 32); SigSpec(RTLIL::State bit, int width = 1); diff --git a/kernel/sigtools.h b/kernel/sigtools.h index e93780b49..cd179ebf0 100644 --- a/kernel/sigtools.h +++ b/kernel/sigtools.h @@ -144,7 +144,7 @@ struct SigPool { RTLIL::SigSpec sig; for (auto &bit : bits) { - sig.append(RTLIL::SigSpec(bit.first, 1, bit.second)); + sig.append(RTLIL::SigSpec(bit.first, bit.second)); break; } return sig; @@ -154,7 +154,7 @@ struct SigPool { RTLIL::SigSpec sig; for (auto &bit : bits) - sig.append(RTLIL::SigSpec(bit.first, 1, bit.second)); + sig.append(RTLIL::SigSpec(bit.first, bit.second)); sig.sort_and_unify(); return sig; } |