Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

cosine look up table - how to store floating point numbers?

Status
Not open for further replies.

deepu_s_s

Full Member level 5
Joined
Mar 24, 2007
Messages
305
Helped
15
Reputation
30
Reaction score
5
Trophy points
1,298
Activity points
3,021
NEED HELP..........

Hi Friends,

I am designing cosine look up table.. I want to store the cosine values. How can i store the cos(11.25) = 0.98 in the binary format?

Thanks and Regards
Deepak
 

Re: NEED HELP..........

1) Store only 1/4 COS period (from 0 to 1)
2) two bits select quadrant
3) 10-bit value (for analog from 0 to 1 - binary from B"0000000000" to B"1111111111")

For example:
cos (11.25) = 0,98078528040323044912618223613424;

1023* 0,98078528040323044912618223613424 = 1003,3433418525047494560844275653 (B"1111101011")

But with quant. error and B"1111101011" you have:

cos(11.25) = 0,98044965786901270772238514173998

angle with 11,623644211467230326099045454004 dgr.

-- Regards
 

NEED HELP..........

I am sorry i didnt understand what u have said. Could u be more clear.....

Thanks and Regards
Deepak
 

NEED HELP..........

Is that ok if i represent in a IEEE 754 compliant ? or fixed point representation? which one would be accurate representation?
 

NEED HELP..........

You could multiply all the cosine values by a suitable constant, round them off to the nearest integer, and store the integers in the table. When you read out the data, don't forget that all the values have been scaled by a constant.

One approach is to select a constant that takes advantage of all the bits in the data word, but without overflowing. For 16-bit cosine data, I might use the constant 32767.4999.

If your project architecture requires traditional fixed-point representation, then use a power-of-two constant such as 16384 for 16-bit cosine data. Or maybe use 32768, and saturate the positive values at 32767 to avoid overflow.

Both IEEE 754 and fixed-point representations have roundoff error. You need to clarify your word "accurate".
 

NEED HELP..........

Can anybody tell how to represent 0.9802 in verilog code
 

NEED HELP..........

Verilog provides the 'real' data type. It is supported by most simulators, but not by most synthesis tools. For example:
real x = 0.9802;

If your tools doesn't support 'real', you can use the technique that I described previously. Multiply 0.9802 by some convenient scaling constant such as 32768, round it off to an integer, and use that integer in your Verilog code. Whenever you use the scaled value in a calculation, remember that it has been multiplied by a constant, and interpret the calculation results accordingly. The choice of scaling constant depends on the types of calculations you need to do, and the desired result format. Perhaps if you give an example of what you are trying to calculate, someone could give you a more detailed explanation.
 

NEED HELP..........

i am calculating the cosine values. like cos(11.25) =0.98082.

I want to represent both the 11.25 & 0.9808 in binary format
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top