library IEEE;
use ieee.std_logic_1164.all;
use ieee.fixed_pkg.all;
use ieee.numeric_std.all ;
entity fixed_test_tb is end;
architecture behave of fixed_test_tb is
component fixed_test
port(
dudx : in sfixed(2 downto -16);
dvdx : in sfixed(2 downto -16);
u0 : in sfixed(11 downto -16);
dudy : in sfixed(2 downto -16);
dvdy : in sfixed(2 downto -16);
v0 : in sfixed(11 downto -16);
data_in : in std_logic_vector (19 downto 0);
data_out : out std_logic_vector (57 downto 0);
clk : in std_logic
);
end component;
signal s_in_x,s_in_y : integer range 0 to 640;
signal s_dudx,s_dvdx,s_dudy,s_dvdy : sfixed(2 downto -16) ;
signal s_u0,s_v0 : sfixed(11 downto -16);
signal s_data_in : std_logic_vector (19 downto 0);
signal s_data_out : std_logic_vector (57 downto 0);
signal s_clk : std_logic;
constant clk_period : time := 10 ns;
begin
DUT:fixed_test
port map (
dudx =>s_dudx,
dvdx =>s_dvdx,
u0 =>s_u0,
dudy =>s_dudy,
dvdy =>s_dvdy,
v0 =>s_v0,
data_in =>s_data_in,
data_out =>s_data_out,
clk => s_clk);
s_dudx <=to_sfixed(0.7071,2,-16);
s_dvdx <=to_sfixed(0.7071,2,-16);
s_u0 <=to_sfixed(296.5685,11,-16);
s_dudy <=to_sfixed(-0.7071,2,-16);
s_dvdy <=to_sfixed(0.7071,2,-16);
s_v0 <=to_sfixed(-75.9798,11,-16);
s_data_in <= std_logic_vector( to_unsigned( s_in_y, 10 )) & std_logic_vector( to_unsigned( s_in_x, 10 ));
--s_data_in <= std_logic_vector( to_unsigned( 0 , 10 )) & std_logic_vector( to_unsigned( 5 , 10 ));
process
begin
s_clk <= '0';
wait for clk_period/2;
s_clk <= '1';
wait for clk_period/2;
end process;
process(s_clk)
begin
if s_clk'EVENT and s_clk='1' then
if s_in_x<480 then
s_in_x<=s_in_x+1;
elsif s_in_y<640 then
s_in_x<=0;
s_in_y<=s_in_y+1;
else
s_in_x<=0;
s_in_y<=0;
end if;
end if;
end process;
end behave;