Verilog - FloatingPoint

Guest #2432049
Rate this post
useful
not useful
Hi,

i want to create a sinus generator in verilog. My problem is that i dont 
know how i can connect the output of my module with a floating point 
number.

Perhaps someone can give me an small example how to work with floating 
point and the output. I tried to use "real" but i dont work as output.

Greetings
Moderator (Company: Titel) #2432108
Rate this post
useful
not useful
> i want to create a sinus generator in verilog.
What is your actual problem?
Do you want to do DDFS?
Then the usual way is to read values out of a sins table.
The other way would be a cordic calculation.

> I tried to use "real" but i dont work as output.
Real numbers are not for snthesis. You can use them for testbenches, but 
you will encounter problem with them on real hardware...
Guest #2432205
Rate this post
useful
not useful
I'd suggest you get the datasheet of, for instance, the AD9835. There is 
explained how digital synthesis works (in case you do not know). With 
that and a very few lines of Verilog (you will need two registers, one 
for the phase accumulator and another one for the period of the signal 
and a fully populated RAM block, i.e. with a sinus) you get a sinus 
generator :).
Guest #2447192
Rate this post
useful
not useful
I got a sinus already using a LUT. But my Problem is that I multiplied 
the floating point values with 1000, so that i dont need a point.

Ok, i got an sinus and an amplitude of 1000. But i want an amplitude of 
1. And the problem is if i use floating point values my reg dont save 
the values.
Moderator (Company: Titel) #2447205
Rate this post
useful
not useful
> And the problem is if i use floating point values my reg dont save
> the values.
No. The problem is, that you don't understand how numbers are 
represented in hardware. Or: do you know what a floating point number 
looks like and how difficult it is to handle simple operations like 
addition or multiplication on it in hardware?

To keep it short: I don't think you need a floating point number. But 
you must rearrange your mind for a different presentation of the 
numbers. Lets say: take a 8 bit number in a range from 
1000000...00000000...01111111 then you get a decimal value of 
-128...0...+127. And then divide this number in your mind by 128 and 
you get -1...0...+0.992 for the SAME bit pattern. Think thoroughly about 
that!

> an amplitude of 1000
Never ever take decimal numbers in hardware. A multiplication with 1000 
takes a lot of effort. A multiplication with 1024 instead is just a 
different wiring and brings zero overhead...  :-o
Moderator (Company: Titel) #2447447
Rate this post
useful
not useful
As I said: -1...+1 isn't possible:
With a 16 bit word you can get  0x1000 ... 0x0000 ... 0x7fff
That is decimal                 -32768 ...      0 ... 32767
If you divide it mentally by     32768
then you get virtually              -1 ...      0 ... +0.999969

So, what do you get out of your sine LUT/algorithm?

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now