Altera_Forum
Honored Contributor
15 years agoNeed help for VHDL recursive function
Hi!
I'm new to advance VHDL programming. Here below is my code for generating hermite plolynomial (hp). It can be defind recursively like below. hp(k, t) = 1 when k = 0, hp(k, t) = 2*t when k = 1, and hp(k, t) = 2*t*h(k-1, t) - 2*(k-1)*h(k-2,t) when K>1. Here, k is a positive integer, and t is continues time. Based on the expressions I wrote a VHDL I code as below. Library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; -- -------------------------------------- entity hermitePolynomial_2 is -- -------------------------------------- port ( clk_1 : in std_logic; -- System Clock (50MHz) ce_1 : in std_logic; Din : in std_logic_vector(3 downto 0); Tin : in std_logic_vector(15 downto 0); -- Result : out std_logic_vector(40 downto 0)); end hermitePolynomial_2; -- -------------------------------------- Architecture RTL of hermitePolynomial_2 is -- --------------------------------------- signal Tinr : std_logic_vector (Tin'range); function Her (d : natural; t : natural) return natural is variable res : natural; begin if d = 0 then -- note that, by convention, 0! = 1 res := (0=>'1',others=>'0'); -- 1 elsif d = 1 then res := 2 * t; else res := (2 * t * Her(d-1, t) - 2 * (d-1) * Her(d-2, t)); -- function call notation trick end if; return res; end function Her; Begin process(clk_1) begin if (rising_edge(clk_1)) then Dinr <= Din; -- input FFs Tinr <= Tin; -- input FFs Result <= std_logic_vector(Her(to_natural(Dinr), to_natural(Tinr))); end if; end process; End architecture RTL; I'm not able to synthezise it. Could anyone please hlep me to rectify my code? Please.. please..:confused: