Continue to Site

# How to implement y=sinx in VHDL?

Status
Not open for further replies.

#### sachinmaheshwari

##### Member level 4
can any one tell me how to impliment
y=sinx in VHDL

please be sure whatever you r saying

#### shawndaking

##### Full Member level 3
Re: VHDL code

you can do it by :

1. preparing ROM for the calculation with all values defined.

2. in xilinx you can use CORDIC core for generating this function.

3. if your input is more limited to specific values, you can even use a decoder to
decode the values.

#### lordsathish

##### Full Member level 5
Re: VHDL code

if you want to design some core then you can try using the cordic algorithm...
there references available in the net about this algorithm which uses only shift and add operatios to compute sine as well as cos...

#### sachinmaheshwari

##### Member level 4
Re: VHDL code

what exactly is CORDIC algorithm?
is their some pdf regarding this?

#### shawndaking

##### Full Member level 3
Re: VHDL code

this is from xilinx coregen lib :

ypasha

### ypasha

Points: 2

#### apavan4u

##### Newbie level 1
Re: VHDL code

thanks

Yes u can use CORDIC or look up table...

but any one tried the results??

I mean, what input u r giving , and wat iutput u r getting?? Coz, i m trying with cordic, and look up table, both i m unable to analyze the results..

#### kalyansrinivas

VHDL code

hi
Is cordic Cordic algorithm is advantageous over the LUT based method ? Please let me know

#### sachinmaheshwari

##### Member level 4
Re: VHDL code

how to impliment
y=sinx

inputs as angles in degree represented by IEEE 32-bit floating-point no.
and produces output as IEEE 32-bit floating number

sign(1-bit) Exponent(8-bit) Mantissa(23 bit)
0/1 [(2^8 -1)- 127]=+128 to (0-127)=-127

floating point number = (+-)[1.mantissa]*2^exponent

#### suru

##### Full Member level 3
VHDL code

use vhdl_Ams for the same. it becomes very simple.

#### sachinmaheshwari

##### Member level 4
Re: VHDL code

what is vhdl_ams
can u be more specific
n do u have any example?
i just have to write the behavioral code of it.

##### Member level 2
Re: VHDL code

kalyansrinivas said:
hi
Is cordic Cordic algorithm is advantageous over the LUT based method ? Please let me know

LUT method is faster, you generate the address using the input data, and pick the value from the ROM; but the accuracy depends on the LUT size, or sampling density. Since sin/cos is periodic, you can combine LUT with some taylor interpolations to improve the accuracy.

CORDIC is relatively slow, the accuracy depends on the number of iterations, so higher accuracy means longer latency. But it only requires add/shift, very area efficient.

#### dmk

##### Full Member level 3
VHDL code

VHDL-AMS is VHDL for Analog & Mixed Signal Modeling. Use the following link to download "The Designer's Guide to AMS Modeling", author: R. Scott Cooper, Published by Synopsys, 2004, 356 pages:

#### FvM

##### Super Moderator
Staff member
Re: VHDL code

Please notice, that VHLD AMS or any other HDL that can calculate sine and other mathematical function, don't help somehow to get synthesizable code for a FPGA calculating sine function. They just support this function for simulation or can calculate a ROM table.

I understand, that you want the sine function for float numbers. Known Cordic cores are using fixed point only, e. g. from opencores.org or Xilinx. In contrast, usual FPGA floating point packages have 4 fundamentals and squareroot only.

I think, if full floating point resolution is needed, you should implement an usual numerical math iterative alrorithm. That's also done by processor FPU supporting higher math functions. A lot of literature can be found regarding implementation details.

#### echo47

VHDL code

Here's a nice web page describing CORDIC algorithms:

V
Points: 2