aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/rtlil.cc7
-rw-r--r--kernel/rtlil.h12
2 files changed, 16 insertions, 3 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc
index a09f4a0d1..a5fbfeda4 100644
--- a/kernel/rtlil.cc
+++ b/kernel/rtlil.cc
@@ -1595,9 +1595,10 @@ void RTLIL::Module::remove(RTLIL::Cell *cell)
while (!cell->connections_.empty())
cell->unsetPort(cell->connections_.begin()->first);
- log_assert(cells_.count(cell->name) != 0);
+ auto it = cells_.find(cell->name);
+ log_assert(it != cells_.end());
log_assert(refcount_cells_ == 0);
- cells_.erase(cell->name);
+ cells_.erase(it);
delete cell;
}
@@ -3437,7 +3438,7 @@ void RTLIL::SigSpec::extend_u0(int width, bool is_signed)
if (width_ < width) {
RTLIL::SigBit padding = width_ > 0 ? (*this)[width_ - 1] : RTLIL::State::Sx;
- if (!is_signed)
+ if (padding != RTLIL::State::Sx && !is_signed)
padding = RTLIL::State::S0;
while (width_ < width)
append(padding);
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index 8509670ff..f4fcf5dcf 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -276,6 +276,18 @@ namespace RTLIL
return std::string(c_str() + pos, len);
}
+ bool begins_with(const char* prefix) const {
+ size_t len = strlen(prefix);
+ if (size() < len) return false;
+ return substr(0, len) == prefix;
+ }
+
+ bool ends_with(const char* suffix) const {
+ size_t len = strlen(suffix);
+ if (size() < len) return false;
+ return substr(size()-len) == suffix;
+ }
+
size_t size() const {
return str().size();
}