Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

signed number etiquette 1

Status
Not open for further replies.

doubledash

Technical User
Dec 17, 2003
1
US
Who can give me a short shpiel on the follwing: I have a 24bit input to a simple integrator (which is an accumulator that keeps adding the input to itself), then I multiply the accumulator with a constant gain (which right now is a 12 bit signed number). I have to make sure this final answer has a +-9.165 saturation limit.

my problem is keeping track of where the decimal point is (because i'm using a +-1 scheme where the decimal point is 1 bit in from the left). i have my acc 32 bits, my constant signed gain as 12 bits and i'm having trouble taking the correct bit slice from this to account for the integrator expanding to where the decimal point becomes 5 in from the left -- i know this because it saturates at +-25 right now).

does any of this make sense? any suggestions would be greatly appreciated. thanks in advance!!
 
I am not sure if you are using 2's complement or not. if so, and the input is all fractional (with one sign bit) in the accumulator the 9 msb bits will be integers. after the multipliaction, the result is 44 bits, and if again the coefficient has 1 sign bit, there will be 10 msbs as integers.
so for +-9.165, you'll need 5 integer bits (one is for sign). you'll need to check if the 5 leftmost bits are all equal (to 1 or 0). if not, you'll need saturation. of course this saturates to +-16. some more logic would be needed for saturation as you desire. (maybe a single comparator is better to see when too saturate.)
 
Sounds like you are tring to do some kind of floating point accumulator. I would just make it fixed, N bits bigger than the input there 2^N is the max number of samples you plan to integrate. If you need a floating point output, count the leading zeros to get the exponent, and left shift << zero_count the rest for the gain multiplier input.

For saturation, be sure you can't wrap before the limit compare test.

hope this helps,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top