mirror of https://github.com/YosysHQ/yosys.git
added hashlib::mkhash_init
This commit is contained in:
parent
ba43cf5807
commit
0675098733
|
@ -21,13 +21,15 @@ const int hashtable_size_trigger = 2;
|
||||||
const int hashtable_size_factor = 3;
|
const int hashtable_size_factor = 3;
|
||||||
|
|
||||||
// The XOR version of DJB2
|
// The XOR version of DJB2
|
||||||
// (traditionally 5381 is used as starting value for the djb2 hash)
|
|
||||||
inline unsigned int mkhash(unsigned int a, unsigned int b) {
|
inline unsigned int mkhash(unsigned int a, unsigned int b) {
|
||||||
return ((a << 5) + a) ^ b;
|
return ((a << 5) + a) ^ b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// traditionally 5381 is used as starting value for the djb2 hash
|
||||||
|
const unsigned int mkhash_init = 5381;
|
||||||
|
|
||||||
// The ADD version of DJB2
|
// The ADD version of DJB2
|
||||||
// (use this version for cache locality in b)
|
// (usunsigned int mkhashe this version for cache locality in b)
|
||||||
inline unsigned int mkhash_add(unsigned int a, unsigned int b) {
|
inline unsigned int mkhash_add(unsigned int a, unsigned int b) {
|
||||||
return ((a << 5) + a) + b;
|
return ((a << 5) + a) + b;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +98,7 @@ struct hash_cstr_ops {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
unsigned int hash(const char *a) const {
|
unsigned int hash(const char *a) const {
|
||||||
unsigned int hash = 5381;
|
unsigned int hash = mkhash_init;
|
||||||
while (*a)
|
while (*a)
|
||||||
hash = mkhash(hash, *(a++));
|
hash = mkhash(hash, *(a++));
|
||||||
return hash;
|
return hash;
|
||||||
|
|
|
@ -2325,7 +2325,7 @@ void RTLIL::SigSpec::updhash() const
|
||||||
cover("kernel.rtlil.sigspec.hash");
|
cover("kernel.rtlil.sigspec.hash");
|
||||||
that->pack();
|
that->pack();
|
||||||
|
|
||||||
that->hash_ = 5381;
|
that->hash_ = mkhash_init;
|
||||||
for (auto &c : that->chunks_)
|
for (auto &c : that->chunks_)
|
||||||
if (c.wire == NULL) {
|
if (c.wire == NULL) {
|
||||||
for (auto &v : c.data)
|
for (auto &v : c.data)
|
||||||
|
|
|
@ -463,7 +463,7 @@ struct RTLIL::Const
|
||||||
inline int size() const { return bits.size(); }
|
inline int size() const { return bits.size(); }
|
||||||
|
|
||||||
inline unsigned int hash() const {
|
inline unsigned int hash() const {
|
||||||
unsigned int h = 5381;
|
unsigned int h = mkhash_init;
|
||||||
for (auto b : bits)
|
for (auto b : bits)
|
||||||
mkhash(h, b);
|
mkhash(h, b);
|
||||||
return h;
|
return h;
|
||||||
|
|
|
@ -138,6 +138,7 @@ YOSYS_NAMESPACE_BEGIN
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::string;
|
using std::string;
|
||||||
using hashlib::mkhash;
|
using hashlib::mkhash;
|
||||||
|
using hashlib::mkhash_init;
|
||||||
using hashlib::mkhash_add;
|
using hashlib::mkhash_add;
|
||||||
using hashlib::mkhash_xorshift;
|
using hashlib::mkhash_xorshift;
|
||||||
using hashlib::hash_ops;
|
using hashlib::hash_ops;
|
||||||
|
|
Loading…
Reference in New Issue