From 260c19ec5a3adb292158658dd69a352b9325ab64 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 23 Jul 2014 09:00:16 +0200 Subject: Refactoring {SigSpec|SigChunk}(RTLIL::Wire *wire, ..) constructor -- step 1/3 --- kernel/rtlil.cc | 32 ++++++++++++++++++++++++++++++++ kernel/rtlil.h | 10 ++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) (limited to 'kernel') diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 2ab4a8c6e..acfba057f 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1324,6 +1324,13 @@ RTLIL::SigChunk::SigChunk(const RTLIL::Const &value) offset = 0; } +RTLIL::SigChunk::SigChunk(RTLIL::Wire *wire) +{ + this->wire = wire; + this->width = wire->width; + this->offset = 0; +} + RTLIL::SigChunk::SigChunk(RTLIL::Wire *wire, int width, int offset) { this->wire = wire; @@ -1331,6 +1338,15 @@ RTLIL::SigChunk::SigChunk(RTLIL::Wire *wire, int width, int offset) this->offset = offset; } +RTLIL::SigChunk RTLIL::SigChunk::grml(RTLIL::Wire *wire, int offset, int width) +{ + RTLIL::SigChunk chunk; + chunk.wire = wire; + chunk.width = width; + chunk.offset = offset; + return chunk; +} + RTLIL::SigChunk::SigChunk(const std::string &str) { wire = NULL; @@ -1432,6 +1448,13 @@ RTLIL::SigSpec::SigSpec(const RTLIL::SigChunk &chunk) check(); } +RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire) +{ + chunks_.push_back(RTLIL::SigChunk(wire)); + width_ = chunks_.back().width; + check(); +} + RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire, int width, int offset) { chunks_.push_back(RTLIL::SigChunk(wire, width, offset)); @@ -1439,6 +1462,15 @@ RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire, int width, int offset) check(); } +RTLIL::SigSpec RTLIL::SigSpec::grml(RTLIL::Wire *wire, int offset, int width) +{ + RTLIL::SigSpec sig; + sig.chunks_.push_back(RTLIL::SigChunk::grml(wire, offset, width)); + sig.width_ = sig.chunks_.back().width; + sig.check(); + return sig; +} + RTLIL::SigSpec::SigSpec(const std::string &str) { chunks_.push_back(RTLIL::SigChunk(str)); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 0e74c958a..542e685de 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -462,7 +462,10 @@ 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 width); // <-- using this will cause a linker error + SigChunk(RTLIL::Wire *wire, int width, int offset) __attribute__((deprecated)); + static SigChunk grml(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 +525,10 @@ 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 width); // <-- using this will cause a linker error + SigSpec(RTLIL::Wire *wire, int width, int offset) __attribute__((deprecated)); + static SigSpec grml(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); -- cgit v1.2.3 From a8d3a68971ccc4e47c54a906aae374a9a54b1415 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 23 Jul 2014 08:40:31 +0200 Subject: Refactoring {SigSpec|SigChunk}(RTLIL::Wire *wire, ..) constructor -- step 2/3 --- kernel/rtlil.cc | 18 ++---------------- kernel/sigtools.h | 4 ++-- 2 files changed, 4 insertions(+), 18 deletions(-) (limited to 'kernel') diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index acfba057f..f5b84bc66 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1331,13 +1331,6 @@ RTLIL::SigChunk::SigChunk(RTLIL::Wire *wire) this->offset = 0; } -RTLIL::SigChunk::SigChunk(RTLIL::Wire *wire, int width, int offset) -{ - this->wire = wire; - this->width = width >= 0 ? width : wire->width; - this->offset = offset; -} - RTLIL::SigChunk RTLIL::SigChunk::grml(RTLIL::Wire *wire, int offset, int width) { RTLIL::SigChunk chunk; @@ -1455,13 +1448,6 @@ RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire) check(); } -RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire, int width, int offset) -{ - chunks_.push_back(RTLIL::SigChunk(wire, width, offset)); - width_ = chunks_.back().width; - check(); -} - RTLIL::SigSpec RTLIL::SigSpec::grml(RTLIL::Wire *wire, int offset, int width) { RTLIL::SigSpec sig; @@ -2166,7 +2152,7 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri std::vector 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::grml(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()); @@ -2174,7 +2160,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::grml(wire, a, b-a+1)); } } else sig.append(wire); diff --git a/kernel/sigtools.h b/kernel/sigtools.h index e93780b49..d011b0ef5 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::grml(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::grml(bit.first, bit.second)); sig.sort_and_unify(); return sig; } -- cgit v1.2.3 From ec923652e2eb721aa16657e54a67666f855c3d65 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 23 Jul 2014 09:48:26 +0200 Subject: Refactoring {SigSpec|SigChunk}(RTLIL::Wire *wire, ..) constructor -- step 3/3 --- kernel/rtlil.cc | 24 ++++++++++-------------- kernel/rtlil.h | 8 ++------ kernel/sigtools.h | 4 ++-- 3 files changed, 14 insertions(+), 22 deletions(-) (limited to 'kernel') diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index f5b84bc66..6bb3e6126 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1331,13 +1331,11 @@ RTLIL::SigChunk::SigChunk(RTLIL::Wire *wire) this->offset = 0; } -RTLIL::SigChunk RTLIL::SigChunk::grml(RTLIL::Wire *wire, int offset, int width) +RTLIL::SigChunk::SigChunk(RTLIL::Wire *wire, int offset, int width) { - RTLIL::SigChunk chunk; - chunk.wire = wire; - chunk.width = width; - chunk.offset = offset; - return chunk; + this->wire = wire; + this->width = width; + this->offset = offset; } RTLIL::SigChunk::SigChunk(const std::string &str) @@ -1448,13 +1446,11 @@ RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire) check(); } -RTLIL::SigSpec RTLIL::SigSpec::grml(RTLIL::Wire *wire, int offset, int width) +RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire, int offset, int width) { - RTLIL::SigSpec sig; - sig.chunks_.push_back(RTLIL::SigChunk::grml(wire, offset, width)); - sig.width_ = sig.chunks_.back().width; - sig.check(); - return sig; + chunks_.push_back(RTLIL::SigChunk(wire, offset, width)); + width_ = chunks_.back().width; + check(); } RTLIL::SigSpec::SigSpec(const std::string &str) @@ -2152,7 +2148,7 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri std::vector index_tokens; sigspec_parse_split(index_tokens, indices.substr(1, indices.size()-2), ':'); if (index_tokens.size() == 1) - sig.append(RTLIL::SigSpec::grml(wire, 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()); @@ -2160,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::grml(wire, a, b-a+1)); + sig.append(RTLIL::SigSpec(wire, a, b-a+1)); } } else sig.append(wire); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 542e685de..832146594 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -463,9 +463,7 @@ struct RTLIL::SigChunk { SigChunk(); SigChunk(const RTLIL::Const &value); SigChunk(RTLIL::Wire *wire); - SigChunk(RTLIL::Wire *wire, int width); // <-- using this will cause a linker error - SigChunk(RTLIL::Wire *wire, int width, int offset) __attribute__((deprecated)); - static SigChunk grml(RTLIL::Wire *wire, int offset, int width = 1); + 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); @@ -526,9 +524,7 @@ public: SigSpec(const RTLIL::Const &value); SigSpec(const RTLIL::SigChunk &chunk); SigSpec(RTLIL::Wire *wire); - SigSpec(RTLIL::Wire *wire, int width); // <-- using this will cause a linker error - SigSpec(RTLIL::Wire *wire, int width, int offset) __attribute__((deprecated)); - static SigSpec grml(RTLIL::Wire *wire, int offset, int width = 1); + 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 d011b0ef5..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::grml(bit.first, 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::grml(bit.first, bit.second)); + sig.append(RTLIL::SigSpec(bit.first, bit.second)); sig.sort_and_unify(); return sig; } -- cgit v1.2.3