library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_arith.all;
|
use ieee.std_logic_arith.all;
|
use std.textio.all;
|
use std.textio.all;
|
use work.arithpack.all;
|
use work.arithpack.all;
|
|
|
|
|
|
|
entity rt_tb is
|
entity rt_tb is
|
end entity;
|
end entity;
|
|
|
architecture rt_tb_arch of rt_tb is
|
architecture rt_tb_arch of rt_tb is
|
|
|
--!TBXSTART:CTRL
|
--!TBXSTART:CTRL
|
signal sclk,srst,srd,swr : std_logic;
|
signal sclk,srst,srd,swr : std_logic;
|
--!TBXEND
|
--!TBXEND
|
--!TBXSTART:ADD_BUS
|
--!TBXSTART:ADD_BUS
|
signal sadd : std_logic_vector(12 downto 0);
|
signal sadd : std_logic_vector(12 downto 0);
|
--!TBXEND
|
--!TBXEND
|
--!TBXSTART:DATA_BUS
|
--!TBXSTART:DATA_BUS
|
signal sd,sq : xfloat32;
|
signal sd,sq : xfloat32;
|
--!TBXEND
|
--!TBXEND
|
--!TXBXSTART:INT_BUS
|
--!TXBXSTART:INT_BUS
|
signal sint : std_logic_vector(7 downto 0);
|
signal sint : std_logic;
|
--!TBXEND
|
--!TBXEND
|
|
|
begin
|
begin
|
|
|
reset_p : process
|
reset_p : process
|
begin
|
begin
|
srst <= not(rstMasterValue);
|
srst <= not(rstMasterValue);
|
wait for 1 ns;
|
wait for 1 ns;
|
srst <= rstMasterValue;
|
srst <= rstMasterValue;
|
wait for 52 ns;
|
wait for 52 ns;
|
srst <= not(rstMasterValue);
|
srst <= not(rstMasterValue);
|
wait;
|
wait;
|
end process reset_p;
|
end process reset_p;
|
|
|
|
|
clock_p : process
|
clock_p : process
|
begin
|
begin
|
sclk <= '1';
|
sclk <= '1';
|
clock_loop:loop
|
clock_loop:loop
|
wait for tclk_2;
|
wait for tclk_2;
|
sclk <= '0';
|
sclk <= '0';
|
wait for tclk_2;
|
wait for tclk_2;
|
sclk <= '1';
|
sclk <= '1';
|
end loop clock_loop;
|
end loop clock_loop;
|
end process clock_p;
|
end process clock_p;
|
|
|
|
|
--!TBXINSTANCESTART
|
--!TBXINSTANCESTART
|
dude : raytrac
|
dude : raytrac
|
port map (
|
port map (
|
|
|
clk => sclk,
|
clk => sclk,
|
rst => srst,
|
rst => srst,
|
rd => srd,
|
rd => srd,
|
wr => swr,
|
wr => swr,
|
add => sadd,
|
add => sadd,
|
d => sd,
|
d => sd,
|
q => sq,
|
q => sq,
|
int => sint
|
int => sint
|
|
|
);
|
);
|
--!TBXINSTANCEEND
|
--!TBXINSTANCEEND
|
|
|
|
|
--! Este proceso cálcula los rayos/vectores que desde un observador van a una pantalla de 16x16 pixeles.
|
--! Este proceso cálcula los rayos/vectores que desde un observador van a una pantalla de 16x16 pixeles.
|
--! Posteriormente cada uno de estos rayos vectores es ingresado a la memoria del Raytrac. Son 256 rayos/vectores, que se escriben en los primeros 16 bloques vectoriales de los 32 que posee el bloque vectorial A.
|
--! Posteriormente cada uno de estos rayos vectores es ingresado a la memoria del Raytrac. Son 256 rayos/vectores, que se escriben en los primeros 16 bloques vectoriales de los 32 que posee el bloque vectorial A.
|
--! Finalmente se escribe en la cola de instrucciones la instrucción "nrm".
|
--! Finalmente se escribe en la cola de instrucciones la instrucción "nrm".
|
--! Para obtener más información sobre la interfase de programación del Raytrac, refierase al libro en el capítulo Máquina de Estados e Interfase de Programación.
|
--! Para obtener más información sobre la interfase de programación del Raytrac, refierase al libro en el capítulo Máquina de Estados e Interfase de Programación.
|
|
|
normalization_test_input : process (sclk,srst)
|
normalization_test_input : process (sclk,srst)
|
variable cam : apCamera;
|
variable cam : apCamera;
|
variable count : integer;
|
variable count : integer;
|
variable v : v3f;
|
variable v : v3f;
|
|
|
begin
|
begin
|
if srst=rstMasterValue then
|
if srst=rstMasterValue then
|
count := 0;
|
count := 0;
|
--! Camara observador.
|
--! Camara observador.
|
--! Resolución horizontal
|
--! Resolución horizontal
|
cam.resx:=16;
|
cam.resx:=16;
|
--! Resolución vertical
|
--! Resolución vertical
|
cam.resy:=16;
|
cam.resy:=16;
|
--! Dimensión horizontal
|
--! Dimensión horizontal
|
cam.width:=100.0;
|
cam.width:=100.0;
|
--! Dimensión vertical
|
--! Dimensión vertical
|
cam.height:=100.0;
|
cam.height:=100.0;
|
--! Distancia del observador al plano de proyección.
|
--! Distancia del observador al plano de proyección.
|
cam.dist:=100.0;
|
cam.dist:=100.0;
|
v(0):=(others => '0');
|
v(0):=(others => '0');
|
v(1):=(others => '0');
|
v(1):=(others => '0');
|
v(2):=(others => '0');
|
v(2):=(others => '0');
|
sd <= (others => '0');
|
sd <= (others => '0');
|
sadd <= (others => '0');
|
sadd <= (others => '0');
|
swr <= '0';
|
swr <= '0';
|
elsif sclk='1' and sclk'event then
|
elsif sclk='1' and sclk'event then
|
if count<256*3 then
|
if count<256*3 then
|
if count mod 3 = 0 then
|
if count mod 3 = 0 then
|
--! Calcular el vector que va desde el obsevador hasta un pixel x,y en particular.
|
--! Calcular el vector que va desde el obsevador hasta un pixel x,y en particular.
|
--! Cálculo de la columna: 0 <= c % 16 <= 15, 0 <= c <= 255.
|
--! Cálculo de la columna: 0 <= c % 16 <= 15, 0 <= c <= 255.
|
--! Cálculo de la fila: 0 <= c / 16 <= 15, 0 <= c <= 255.
|
--! Cálculo de la fila: 0 <= c / 16 <= 15, 0 <= c <= 255.
|
v:=ap_slv_calc_xyvec((count/3) mod 16, (count/3)/16,cam);
|
v:=ap_slv_calc_xyvec((count/3) mod 16, (count/3)/16,cam);
|
end if;
|
end if;
|
--! Alistar componente vectorial para ser escrito.
|
--! Alistar componente vectorial para ser escrito.
|
sd <= v(count mod 3);
|
sd <= v(count mod 3);
|
--! Activar escritura
|
--! Activar escritura
|
swr <= '1';
|
swr <= '1';
|
--! Direccionar en el bloque A comenzar
|
--! Direccionar en el bloque A comenzar
|
sadd <= "00"&conv_std_logic_vector(count mod 3,2)&'0'&conv_std_logic_vector(count/3,8);
|
sadd <= "00"&conv_std_logic_vector(count mod 3,2)&'0'&conv_std_logic_vector(count/3,8);
|
--! Avanzar
|
--! Avanzar
|
count:=count+1;
|
count:=count+1;
|
elsif count=256*3 then
|
elsif count=256*3 then
|
--! Escribir la instrucción de normalización.
|
--! Escribir la instrucción de normalización.
|
swr <= '1';
|
swr <= '1';
|
--! La dirección por defecto para escribir en la cola de instrucciones es 0x0600
|
--! La dirección por defecto para escribir en la cola de instrucciones es 0x0600
|
-- add <= "0 0110 0000 0000";
|
-- add <= "0 0110 0000 0000";
|
sadd <= '0'&x"600";
|
sadd <= '0'&x"600";
|
sd <= ap_format_instruction(string'("nrm"),"00000","01111","00000","00000",'0');
|
sd <= ap_format_instruction(string'("nrm"),"00000","01111","00000","00000",'0');
|
count:=count+1;
|
count:=count+1;
|
else
|
else
|
--! Parar la escritura de datos.
|
--! Parar la escritura de datos.
|
swr <= '0';
|
swr <= '0';
|
end if;
|
end if;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
|
|
--! tb_compiler: The following line (disp:process) is MANDATORY to be so tb_compiler knows here is where the display process takes place.
|
--! tb_compiler: The following line (disp:process) is MANDATORY to be so tb_compiler knows here is where the display process takes place.
|
disp: process
|
disp: process
|
--! if a csv output file is NOT specefied then defaultoutput.csv is the name took as the default output file name, otherwise tb_compiler will change the following line to the proper user selected name.
|
--! if a csv output file is NOT specefied then defaultoutput.csv is the name took as the default output file name, otherwise tb_compiler will change the following line to the proper user selected name.
|
file f : text open write_mode is "default_output.csv";
|
file f : text open write_mode is "default_output.csv";
|
variable l : line;
|
variable l : line;
|
begin
|
begin
|
wait for 5 ns;
|
wait for 5 ns;
|
--wait until srst=not(rstMasterValue);
|
--wait until srst=not(rstMasterValue);
|
wait until sclk='1';
|
wait until sclk='1';
|
wait for tclk_2+tclk_4;
|
wait for tclk_2+tclk_4;
|
|
|
|
|
--! from here on, tb_compiler writes the data to be displayed
|
--! from here on, tb_compiler writes the data to be displayed
|
--! tb_compiler: the following line MUST go here
|
--! tb_compiler: the following line MUST go here
|
--!TBXDISPTOPLINE
|
--!TBXDISPTOPLINE
|
disp_loop:loop
|
disp_loop:loop
|
--! tb_compiler: the following line MUST go here
|
--! tb_compiler: the following line MUST go here
|
--!TBXDISPLAYOPERATION
|
--!TBXDISPLAYOPERATION
|
wait for tclk;
|
wait for tclk;
|
|
|
end loop;
|
end loop;
|
|
|
|
|
end process;
|
end process;
|
|
|
|
|
end architecture;
|
end architecture;
|
|
|
|
|