mirror of https://github.com/YosysHQ/yosys.git
Use easyer-to-read unoptimized ceil_log2()
see here for details on the optimized version: http://svn.clifford.at/handicraft/2016/esbmc/ceilog2.c
This commit is contained in:
parent
7a9257e7b5
commit
45af4a4acf
|
@ -129,24 +129,11 @@ int ceil_log2(int x)
|
||||||
if (x <= 0)
|
if (x <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int y = (x & (x - 1));
|
for (int i = 0; i < 32; i++)
|
||||||
y = (y | -y) >> 31;
|
if (((x-1) >> i) == 0)
|
||||||
|
return i;
|
||||||
|
|
||||||
x |= (x >> 1);
|
log_abort();
|
||||||
x |= (x >> 2);
|
|
||||||
x |= (x >> 4);
|
|
||||||
x |= (x >> 8);
|
|
||||||
x |= (x >> 16);
|
|
||||||
|
|
||||||
x >>= 1;
|
|
||||||
x -= ((x >> 1) & 0x55555555);
|
|
||||||
x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
|
|
||||||
x = (((x >> 4) + x) & 0x0f0f0f0f);
|
|
||||||
x += (x >> 8);
|
|
||||||
x += (x >> 16);
|
|
||||||
x = x & 0x0000003f;
|
|
||||||
|
|
||||||
return x - y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string stringf(const char *fmt, ...)
|
std::string stringf(const char *fmt, ...)
|
||||||
|
|
Loading…
Reference in New Issue