aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sigtools.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sigtools.h')
-rw-r--r--kernel/sigtools.h30
1 files changed, 21 insertions, 9 deletions
diff --git a/kernel/sigtools.h b/kernel/sigtools.h
index 32ef444aa..f92a87dbb 100644
--- a/kernel/sigtools.h
+++ b/kernel/sigtools.h
@@ -29,9 +29,10 @@ struct SigPool
struct bitDef_t : public std::pair<RTLIL::Wire*, int> {
bitDef_t() : std::pair<RTLIL::Wire*, int>(NULL, 0) { }
bitDef_t(const RTLIL::SigBit &bit) : std::pair<RTLIL::Wire*, int>(bit.wire, bit.offset) { }
+ unsigned int hash() const { return first->name.hash() + second; }
};
- std::set<bitDef_t> bits;
+ pool<bitDef_t> bits;
void clear()
{
@@ -66,8 +67,8 @@ struct SigPool
void expand(RTLIL::SigSpec from, RTLIL::SigSpec to)
{
- log_assert(SIZE(from) == SIZE(to));
- for (int i = 0; i < SIZE(from); i++) {
+ log_assert(GetSize(from) == GetSize(to));
+ for (int i = 0; i < GetSize(from); i++) {
bitDef_t bit_from(from[i]), bit_to(to[i]);
if (bit_from.first != NULL && bit_to.first != NULL && bits.count(bit_from) > 0)
bits.insert(bit_to);
@@ -122,13 +123,13 @@ struct SigPool
RTLIL::SigSpec export_all()
{
- std::set<RTLIL::SigBit> sig;
+ pool<RTLIL::SigBit> sig;
for (auto &bit : bits)
sig.insert(RTLIL::SigBit(bit.first, bit.second));
return sig;
}
- size_t size()
+ size_t size() const
{
return bits.size();
}
@@ -140,9 +141,10 @@ struct SigSet
struct bitDef_t : public std::pair<RTLIL::Wire*, int> {
bitDef_t() : std::pair<RTLIL::Wire*, int>(NULL, 0) { }
bitDef_t(const RTLIL::SigBit &bit) : std::pair<RTLIL::Wire*, int>(bit.wire, bit.offset) { }
+ unsigned int hash() const { return first->name.hash() + second; }
};
- std::map<bitDef_t, std::set<T, Compare>> bits;
+ dict<bitDef_t, std::set<T, Compare>> bits;
void clear()
{
@@ -193,6 +195,15 @@ struct SigSet
}
}
+ void find(RTLIL::SigSpec sig, pool<T> &result)
+ {
+ for (auto &bit : sig)
+ if (bit.wire != NULL) {
+ auto &data = bits[bit];
+ result.insert(data.begin(), data.end());
+ }
+ }
+
std::set<T> find(RTLIL::SigSpec sig)
{
std::set<T> result;
@@ -214,6 +225,7 @@ struct SigMap
struct bitDef_t : public std::pair<RTLIL::Wire*, int> {
bitDef_t() : std::pair<RTLIL::Wire*, int>(NULL, 0) { }
bitDef_t(const RTLIL::SigBit &bit) : std::pair<RTLIL::Wire*, int>(bit.wire, bit.offset) { }
+ unsigned int hash() const { return first->name.hash() + second; }
};
struct shared_bit_data_t {
@@ -221,7 +233,7 @@ struct SigMap
std::set<bitDef_t> bits;
};
- std::map<bitDef_t, shared_bit_data_t*> bits;
+ dict<bitDef_t, shared_bit_data_t*> bits;
SigMap(RTLIL::Module *module = NULL)
{
@@ -346,9 +358,9 @@ struct SigMap
void add(RTLIL::SigSpec from, RTLIL::SigSpec to)
{
- log_assert(SIZE(from) == SIZE(to));
+ log_assert(GetSize(from) == GetSize(to));
- for (int i = 0; i < SIZE(from); i++)
+ for (int i = 0; i < GetSize(from); i++)
{
RTLIL::SigBit &bf = from[i];
RTLIL::SigBit &bt = to[i];