Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17241 討論

how to calculate sin inverse (ARCSIN) in VHDL?

Altera_Forum
榮譽貢獻者 II
5,950 檢視

I am using altera de0 nano soc fpga, and quartus 16.1 lite edition. I found that to calculate sin, cos and atan Altera's CORDIC IP core can be used.or lookup table (LUT) can be used for sin or cos .but how to get sin inverse (arcsin) in vhdl? is there a way to generate sin inverse

 

 

i want perform below calculation in vhdl, 

 

library ieee; 

library ieee_proposed; 

USE ieee.std_logic_1164.all; 

use ieee.math_real.all; 

use ieee_proposed.float_pkg.ALL;  

 

architecture, 

 

PROCESS(clk) 

variable ph ,r ,l ,rp : float (4downto-27); 

BEGIN 

IF rising_edge(clk)THEN 

ph := arcsin((r / l)* sin(rp); 

ENDIF; 

END PROCESS;
0 積分
10 回應
Altera_Forum
榮譽貢獻者 II
4,519 檢視

Why not just use a look up table like the rest?

Altera_Forum
榮譽貢獻者 II
4,519 檢視

Default Re: how to calculate sin inverse (ARCSIN) in VHDL? 

Why not just use a look up table like the rest? 

 

So there is no other way to calculate arcsin ? using CORDIC IP CORE?
Altera_Forum
榮譽貢獻者 II
4,519 檢視

 

--- Quote Start ---  

Why not just use a look up table like the rest? 

--- Quote End ---  

 

 

can you link a better lookup table here? I found one from this altera forum, it is 12 bits, 0-4095 sampled sine wave and cose wave.
Altera_Forum
榮譽貢獻者 II
4,519 檢視

You can create your own LUT, with values filled using your own values, to as many bits as you want. 

In VHDL - create a constant that contains all of the values - look into Altera's VHDL coding guidlines on how to infer rom, and populate it with your own values.
Altera_Forum
榮譽貢獻者 II
4,519 檢視

 

--- Quote Start ---  

You can create your own LUT, with values filled using your own values, to as many bits as you want. 

In VHDL - create a constant that contains all of the values - look into Altera's VHDL coding guidlines on how to infer rom, and populate it with your own values. 

--- Quote End ---  

 

 

Is there any easy way to create my own LUT?like using matlab?
Altera_Forum
榮譽貢獻者 II
4,519 檢視

You can calculate the table initialization in VHDL, using ieee.math_real.arcsin.

Altera_Forum
榮譽貢獻者 II
4,519 檢視

 

--- Quote Start ---  

You can calculate the table initialization in VHDL, using ieee.math_real.arcsin. 

--- Quote End ---  

 

 

I made a lookup table using excel and i put values in to switch case. and i get overlaps when accessing sin inverse. because when getting inverse of sine we point to a place at sin wave and get the phase of it. since sin wave is increasing and decreasing uniquely i get same amplitude levels twice when it increasing and decreasing. how to solve this. ?
Altera_Forum
榮譽貢獻者 II
4,519 檢視

I would recommend to use a integer based Version of the cordic.

Altera_Forum
榮譽貢獻者 II
4,519 檢視

 

--- Quote Start ---  

i get overlaps when accessing sin inverse 

--- Quote End ---  

 

Can only happen if you selected an unsuitable range for the table. Obviously you shouldn't exceed the +/- 90 degree principle value range, see https://en.wikipedia.org/wiki/inverse_trigonometric_functions#arcsin
Altera_Forum
榮譽貢獻者 II
4,519 檢視

andraka's cordic paper (http://www.andraka.com/files/crdcsrvy.pdf) discusses how to do this. You basically create a cordic (http://zipcpu.com/dsp/2017/08/30/cordic.html), input a vector of your input value, and rotate it until the input value reaches (1,0). 

 

Personally, I find the arctan form (http://zipcpu.com/dsp/2017/09/01/topolar.html) of the cordic (http://zipcpu.com/dsp/2017/08/30/cordic.html) more useful, as it doesn't struggle with scale issues and the output doesn't struggle with angular ambiguities. 

 

Dan
回覆