OpenCores
URL https://opencores.org/ocsvn/raytrac/raytrac/trunk

Subversion Repositories raytrac

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 154 to Rev 155
    Reverse comparison

Rev 154 → Rev 155

/raytrac/branches/fp/fadd32.vhd
25,8 → 25,9
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
library lpm;
use lpm.all;
 
use work.arithpack.all;
 
--! Esta entidad recibe dos n&uacutemeros en formato punto flotante IEEE 754, de precision simple y devuelve las mantissas signadas y corridas, y el exponente correspondiente al resultado antes de normalizarlo al formato float.
--!\nLas 2 mantissas y el exponente entran despues a la entidad add2 que suma las mantissas y entrega el resultado en formato IEEE 754.
entity fadd32 is
39,22 → 40,8
end entity;
architecture fadd32_arch of fadd32 is
component lpm_mult
generic (
lpm_hint : string;
lpm_representation : string;
lpm_type : string;
lpm_widtha : natural;
lpm_widthb : natural;
lpm_widthp : natural
);
port (
dataa : in std_logic_vector ( lpm_widtha-1 downto 0 );
datab : in std_logic_vector ( lpm_widthb-1 downto 0 );
result : out std_logic_vector( lpm_widthp-1 downto 0 )
);
end component;
signal s1zero,s7sign : std_logic;
--!TBXSTART:STAGE5
signal s5token : std_logic_vector(2 downto 0);
173,11 → 160,35
end case;
end process;
denormhighshiftermult:lpm_mult
generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9","UNSIGNED","LPM_MULT",9,18,27)
port map (s1shifter,s1zero&s1umantshift(22 downto 06),s1ph);
generic map (
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
lpm_pipeline => 0,
lpm_representation => "UNSIGNED",
lpm_type => "LPM_MULT",
lpm_widtha => 9,
lpm_widthb => 18,
lpm_widthp => 27
)
port map (
dataa => s1shifter,
datab => s1zero&s1umantshift(22 downto 06),
result => s1ph
);
denormlowshiftermult:lpm_mult
generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9","UNSIGNED","LPM_MULT",9,9,18)
port map (s1shifter,s1umantshift(5 downto 0)&"000",s1pl);
generic map (
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
lpm_pipeline => 0,
lpm_representation => "UNSIGNED",
lpm_type => "LPM_MULT",
lpm_widtha => 9,
lpm_widthb => 9,
lpm_widthp => 18
)
port map (
dataa => s1shifter,
datab => s1umantshift(5 downto 0)&"000",
result => s1pl
);
s1postshift(23 downto 7) <= s1ph(25 downto 9);
s1postshift(06 downto 0) <= s1ph(08 downto 2) or s1pl(17 downto 11);
243,11 → 254,35
--! Etapa 6: Ejecutar el corrimiento para normalizar la mantissa.
normhighshiftermult:lpm_mult
generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9","UNSIGNED","LPM_MULT",9,18,27)
port map (s6factorhot9,s6result(24 downto 7),s6ph);
generic map (
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
lpm_pipeline => 0,
lpm_representation => "UNSIGNED",
lpm_type => "LPM_MULT",
lpm_widtha => 9,
lpm_widthb => 18,
lpm_widthp => 27
)
port map (
dataa => s6factorhot9,
datab => s6result(24 downto 7),
result => s6ph
);
normlowshiftermult:lpm_mult
generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9","UNSIGNED","LPM_MULT",9,9,18)
port map (s6factorhot9,s6result(06 downto 0)&"00",s6pl);
generic map (
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
lpm_pipeline => 0,
lpm_representation => "UNSIGNED",
lpm_type => "LPM_MULT",
lpm_widtha => 9,
lpm_widthb => 9,
lpm_widthp => 18
)
port map (
dataa => s6factorhot9,
datab => s6result(06 downto 0)&"00",
result => s6pl
);
s6postshift(22 downto 15) <= s6ph(16 downto 09);
s6postshift(14 downto 06) <= s6ph(08 downto 00) + s6pl(17 downto 09);
s6postshift(05 downto 00) <= s6pl(08 downto 03);
/raytrac/branches/fp/arithpack.vhd
112,6 → 112,23
);
end component;
--! LPM_MULTIPLIER
component lpm_mult
generic (
lpm_hint : string;
lpm_pipeline : natural;
lpm_representation : string;
lpm_type : string;
lpm_widtha : natural;
lpm_widthb : natural;
lpm_widthp : natural
);
port (
dataa : in std_logic_vector ( lpm_widtha-1 downto 0 );
datab : in std_logic_vector ( lpm_widthb-1 downto 0 );
result : out std_logic_vector( lpm_widthp-1 downto 0 )
);
end component;
--! LPM Memory Compiler.
component scfifo
generic (
331,7 → 348,11
--! Funci&oacute;n que devuelve un vector en punto flotante IEEE754 a trav&eacute;s de un
function ap_slv_calc_xyvec (x,y:integer; cam:apCamera) return v3f;
--! Funci&oacute;n que devuelve una cadena con el n&uacute;mero flotante IEEE 754.
function ap_slvf2string(sl:std_logic_vector) return string;
--! Funci&oacute;n para escribir en una sola l&iacute;nea una cadena de caracteres.
procedure ap_print(f:in text;s:in string);
340,6 → 361,13
 
package body arithpack is
 
procedure ap_print(f:in text;s:in string) is
variable l:line;
begin
write(l,s);
writeline(f,l);
end procedure
 
function ap_slv2int (sl:std_logic_vector) return integer is
alias s : std_logic_vector (sl'high downto sl'low) is sl;
variable i : integer;
424,5 → 452,19
return v;
end function;
function ap_slvf2string(sl:std_logic_vector) return string is
alias f: std_logic_vector(31 downto 0) is sl;
variable r: real;
begin
r:=ap_slv2fp(f);
return real'image(r);
end function;
 
end package body;
/raytrac/branches/fp/fmul32.vhd
25,6 → 25,9
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use work.arithpack.all;
 
 
entity fmul32 is
port (
37,23 → 40,7
architecture fmul32_arch of fmul32 is
 
component lpm_mult
generic (
lpm_hint : string;
lpm_pipeline : natural;
lpm_representation : string;
lpm_type : string;
lpm_widtha : natural;
lpm_widthb : natural;
lpm_widthp : natural
);
port (
dataa : in std_logic_vector ( lpm_widtha-1 downto 0 );
datab : in std_logic_vector ( lpm_widthb-1 downto 0 );
result : out std_logic_vector ( lpm_widthp-1 downto 0 )
);
end component;
 
--Stage 0 signals
--!TBXSTART:MULT_STAGE0
signal s0sga,s0sgb,s0zrs : std_logic;
114,14 → 101,50
--! Multipliers
mult18x18ac:lpm_mult
generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,18,36)
port map (s0zrs&s0uma(22 downto 6),s0zrs&s0umb(22 downto 6),s0ac);
generic map (
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
lpm_pipeline => 0,
lpm_representation => "UNSIGNED",
lpm_type => "LPM_MULT",
lpm_widtha => 18,
lpm_widthb => 18,
lpm_widthp => 36
)
port map (
dataa => s0zrs&s0uma(22 downto 6),
datab => s0zrs&s0umb(22 downto 6),
result => s0ac
);
mult18x6ad:lpm_mult
generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,6,24)
port map (s0zrs&s0uma(22 downto 6),s0umb(5 downto 0),s0ad);
generic map (
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
lpm_pipeline => 0,
lpm_representation => "UNSIGNED",
lpm_type => "LPM_MULT",
lpm_widtha => 18,
lpm_widthb => 6,
lpm_widthp => 24
)
port map (
dataa => s0zrs&s0uma(22 downto 6),
datab => s0umb(5 downto 0),
result => s0ad
);
mult18x6bc:lpm_mult
generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,6,24)
port map (s0zrs&s0umb(22 downto 6),s0uma(5 downto 0),s0bc);
generic map (
lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
lpm_pipeline => 0,
lpm_representation => "UNSIGNED",
lpm_type => "LPM_MULT",
lpm_widtha => 18,
lpm_widthb => 6,
lpm_widthp => 24
)
port map (
dataa => s0zrs&s0umb(22 downto 6),
datab => s0uma(5 downto 0),
result => s0bc
);
--! Exponent Addition
process (s0sga,s0sgb,s0exa,s0exb)
/raytrac/branches/fp/rt_tb.vhd
1,14 → 127,50
library ieee;
use ieee.std_logic_1664.all;
use work.arithpack.all;
 
 
 
entity rt_tb is
end entity;
 
architecture rt_tb_arch of rt_tb is
 
signal clk,rst,rd,wr : std_logic;
signal add : std_logic_vector(12 downto 0);
signal d,q : std_logic_vector(31 downto 0);
signal int : std_logic_vector(7 downto 0);
 
begin
 
reset_p : process
begin
rst <= not(rstMasterValue);
wait for 1 ns;
rst <= rstMasterValue;
wait for 52 ns;
rst <= not(rstMasterValue);
end process reset_p;
 
clock_p : process
begin
clk <= '1';
clock_loop:loop
wait for tclk_2;
clk <= '0';
wait for tclk_2;
clk <= '1';
end loop clock_loop;
end process clock_p;
 
dude : raytrac
port map (
clk => clk,
rst => rst,
rd => rd,
wr => wr,
add => add,
d => d,
q => q,
int => int
);
--! Este proceso c&aacute;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.
--! Finalmente se escribe en la cola de instrucciones la instrucci&oacute;n "nrm".
--! Para obtener m&aacute;s informaci&oacute;n sobre la interfase de programaci&oacute;n del Raytrac, refierase al libro en el cap&iacute;tulo M&aacute;quina de Estados e Interfase de Programaci&oacute;n.
normalization_test_input : process (clk,rst)
variable cam : apCamera;
variable count : integer;
variable v : v3f;
begin
if rst=rstMasterValue then
count := 0;
--! Camara observador.
--! Resoluci&oacute;n horizontal
cam.resx:=16;
--! Resoluci&oacute;n vertical
cam.resy:=16;
--! Dimensi&oacute;n horizontal
cam.width:=100;
--! Dimensi&oacute;n vertical
cam.height:=100;
--! Distancia del observador al plano de proyecci&oacute;n.
cam.dist:=100;
v(0):=(others => '0');
v(1):=(others => '0');
v(2):=(others => '0');
d <= (others => '0');
add <= (others => '0');
wr <= '0';
elsif clk='1' and clk'event then
if count<256*3 then
if count mod 3 = 0 then
--! Calcular el vector que va desde el obsevador hasta un pixel x,y en particular.
--! C&aacute;lculo de la columna: 0 <= c % 16 <= 15, 0 <= c <= 255.
--! C&aacute;lculo de la fila: 0 <= c / 16 <= 15, 0 <= c <= 255.
v:=ap_slv_calc_xyvec((count/3) mod 16, (count/3)/16,cam);
end if;
--! Alistar componente vectorial para ser escrito.
d <= v(count mod 3);
--! Activar escritura
wr <= '1';
--! Direccionar en el bloque A comenzar
add <= "00"&conv_std_logic_vector(count mod 3,2)&'0'&conv_std_logic_vector(count/3,8);
--! Avanzar
count:=count+1;
elsif count=256*3 then
--! Escribir la instrucci&oacute;n de normalizaci&oacute;n.
wr <= '1';
--! La direcci&oacute;n por defecto para escribir en la cola de instrucciones es 0x0600
-- add <= "0 0110 0000 0000";
add <= x"0600";
d <= ap_format_instruction("nrm",0,15,0,0,0);
count:=count+1;
else
--! Parar la escritura de datos.
wr <= '0';
end if;
end if;
end process normalization_test;
 
disp: process
file f : text open write_mode is "default_output.csv";
begin
ap_print(f,string'("#RAYTRAC TESTBENCH OUTPUT FILE"));
ap_print(f,string'("#This file is automatically generated by tb_compiler script, by Julian Andres Guarin Reyes"));
ap_print(f,string'("#TB_COMPILER_GEN"));
end process
 
 
end architecture;
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.