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

> 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...

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 :).

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.

> 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 numberin your mindby 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

So it makes no difference in hardware if i implement the sin without floating points, btw. this way is much easier? 1024 would just be a shift, thats true

```
> if i implement the sin without floating points
I didn't get this... :-/
But you said, you already have a sine function (via LUT).
So why do you need floating points further on? For scaling the sine?
```

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?