K-J
Advanced Member level 2
- Joined
- Jan 26, 2012
- Messages
- 657
- Helped
- 308
- Reputation
- 620
- Reaction score
- 301
- Trophy points
- 1,343
- Activity points
- 7,053
Really appreciate your patience. I'm doing that with every new message.
Let me ask a series of Yes/No questions - this will help me understand.
Do you agree that your implementation of what you call ceil_log2:
And this combination:
Code:ceil ( log2 ( real ( x ) ) ) -- uses the math.real log2 function
Will give different results?
We do not agree. The testbench that verifies that the 'synthesizable' version of log2 (i.e. the one from comp.lang.vhdl FAQ) along with my ceil_log2 function matches exactly with the ieee.math_real version of ceil(log2(x)) at least in the range of x from 1 to 4096. No mismatches.
As an aside, for those values of x that are integer powers of 2, ieee.math_real.log2(x) mostly matches the synthesizable log2(x) as noted below. This is somewhat of a tangent from the path that this thread has taken, but it goes back to what started the whole thread because the particular case of x=8 happens to be one of the cases where the ieee.math_real.log2 function does not return exactly the same value as the synthesizable version of log2 and x=8 was the value you happened to be using.
But again, this is about the performance of the log2 function, not the ceil_log2 function which is what is needed to define bit widths.
x Match?
1 Match
2 Match
4 Match
8 No Match
16 Match
32 Match
64 No Match
128 No Match
256 Match
512 Match
1024 Match
2048 Match
4096 No Match
Kevin Jennings