I am still under confusion. I understand binary point. What I dont
understand is if I get an input whose bit width is different than the
bit width of ouptut, how will I know where the bianry point of the
inout is. I am trying to write a function for floor, ceiling and round
in VHDL. All these functions would have variable input and output bit
widths. How will I know where the binary point of the output is?
Thanks- Hide quoted text -
- Show quoted text -
It sounds like what you're actually trying to implement is a truncate/
sign extend function. Try looking at the resize() function in
numeric_std. If the input width is less than the output width, you
probably want to sign extend. If the input width is larger than the
output width, then you may want to chop off some of the LSB's, or
possibly chop off some MSB's (designer's choice). Be careful, because
I think the resize function actually may chop off MSB's - I can't
remember. The exact position of the binary point is something that the
caller of the function will have to keep track of, keeping in mind the
behavior of the function. You shouildn't have to worry about it while
writing the function. With fixed point, the binary point position
exists only in the designer's mind (or comments).
What you're describing has nothing to do with rounding. There is,
however, a truncation method called "round-to-even", which is much
like truncation (chopping off LSB's), but twiddles with the LSB of the
result to try to get rid of any DC bias resulting from the truncation,
which otherwise would always be rounding in the same direction. Google
for it in comp.dsp or the internet to get a better explanation of it -
it's been a while for me.
Hope this helps.
Dave