dipin
Full Member level 4
- Joined
- Jul 16, 2014
- Messages
- 223
- Helped
- 14
- Reputation
- 28
- Reaction score
- 14
- Trophy points
- 18
- Activity points
- 1,731
hi,You didn't mention why you want to use cordic method?
,first i need to do is to reduce the number of clockcycle .What's the FMAX u want to achive
really sorry i didnt get this ??because 32bit is large enought.
32 bits is from 16 bit X*2+Y*2 ??[/
The question was, why do u need 32bit square root c ? Is it because data is from 32 bit ADC ?
You wrote that u tried cordic algorithm ( which required X,Y cordinates)
if rising_edge(CLK_i) then
if INPUT(31 downto 16) = x"0000" then OUTPUT <= SQRT_ROM(INPUT(15 downto 0));
elsif INPUT(31 downto 20) = x"000" then OUTPUT <= ROTATE_LEFT (SQRT_ROM(INPUT(19 downto 4),2);
elsif INPUT(31 downto 24) = x"00" then OUTPUT <= ROTATE_LEFT (SQRT_ROM(INPUT(23 downto 8),4);
elsif INPUT(31 downto 28) = x"0" then OUTPUT <= ROTATE_LEFT (SQRT_ROM(INPUT(27 downto 12)))),6);
else OUTPUT <= ROTATE_LEFT (SQRT_ROM(INPUT(31 downto 16),8);
end if;
end if;
So i fmax is not critical u can create 16bit ROM with SQRT of address line in it as output. Then as an input put 16 MSB of your input word that aren't zeros. Then rotate output word left to get real number.
pseudo code here:
Code:if rising_edge(CLK_i) then if INPUT(31 downto 16) = x"0000" then OUTPUT <= SQRT_ROM(INPUT(15 downto 0)); elsif INPUT(31 downto 20) = x"000" then OUTPUT <= ROTATE_LEFT (SQRT_ROM(INPUT(19 downto 4),2); elsif INPUT(31 downto 24) = x"00" then OUTPUT <= ROTATE_LEFT (SQRT_ROM(INPUT(23 downto 8),4); elsif INPUT(31 downto 28) = x"0" then OUTPUT <= ROTATE_LEFT (SQRT_ROM(INPUT(27 downto 12)))),6); else OUTPUT <= ROTATE_LEFT (SQRT_ROM(INPUT(31 downto 16),8); end if; end if;
the error of truncating in this method should be less then 1% (around 0.5%)
FUNCTION SQRT2 (Number_of_samples : integer) RETURN unsigned_array IS
variable result_v : unsigned_array(0 to Number_of_samples-1) := (others=>(others=>'0'));
begin
for i in result_v'range loop
result_v(i) := to_unsigned(integer(SQRT(real(i))),resize_to_number_of_bytes_u_want);
end loop;
RETURN result_v;
END FUNCTION SQRT2;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?