diff options
Diffstat (limited to 'kernel/rtlil.cc')
-rw-r--r-- | kernel/rtlil.cc | 26 |
1 files changed, 20 insertions, 6 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); |