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

Subversion Repositories raytrac

[/] [raytrac/] [branches/] [fp/] [rt_tb.vhd] - Blame information for rev 155

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 155 jguarin200
library ieee;
2
use ieee.std_logic_1664.all;
3
use work.arithpack.all;
4 154 jguarin200
 
5 155 jguarin200
 
6
 
7
entity rt_tb is
8
end entity;
9
 
10
architecture rt_tb_arch of rt_tb is
11
 
12
        signal  clk,rst,rd,wr   : std_logic;
13
        signal  add                             : std_logic_vector(12 downto 0);
14
        signal  d,q                             : std_logic_vector(31 downto 0);
15
        signal  int                             : std_logic_vector(7 downto 0);
16
 
17
begin
18
 
19
        reset_p : process
20
        begin
21
                rst <= not(rstMasterValue);
22
                wait for 1 ns;
23
                rst <= rstMasterValue;
24
                wait for 52 ns;
25
                rst <= not(rstMasterValue);
26
        end process reset_p;
27
 
28
 
29
        clock_p : process
30
        begin
31
                clk <= '1';
32
                clock_loop:loop
33
                        wait for tclk_2;
34
                        clk <= '0';
35
                        wait for tclk_2;
36
                        clk <= '1';
37
                end loop clock_loop;
38
        end process clock_p;
39
 
40
 
41
 
42
        dude : raytrac
43
        port map (
44
 
45
                clk => clk,
46
                rst => rst,
47
                rd => rd,
48
                wr => wr,
49
                add => add,
50
                d => d,
51
                q => q,
52
                int => int
53
 
54
        );
55
 
56
 
57
        --! Este proceso c&aacute;lcula los rayos/vectores que desde un observador van a una pantalla de 16x16 pixeles.
58
        --! 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.
59
        --! Finalmente se escribe en la cola de instrucciones la instrucci&oacute;n "nrm". 
60
        --! 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.
61
 
62
        normalization_test_input : process (clk,rst)
63
                variable cam : apCamera;
64
                variable count : integer;
65
                variable v : v3f;
66
        begin
67
                if rst=rstMasterValue then
68
                        count := 0;
69
                        --! Camara observador.
70
                        --! Resoluci&oacute;n horizontal
71
                        cam.resx:=16;
72
                        --! Resoluci&oacute;n vertical
73
                        cam.resy:=16;
74
                        --! Dimensi&oacute;n horizontal
75
                        cam.width:=100;
76
                        --! Dimensi&oacute;n vertical
77
                        cam.height:=100;
78
                        --! Distancia del observador al plano de proyecci&oacute;n.
79
                        cam.dist:=100;
80
                        v(0):=(others => '0');
81
                        v(1):=(others => '0');
82
                        v(2):=(others => '0');
83
                        d <= (others => '0');
84
                        add <= (others => '0');
85
                        wr <= '0';
86
                elsif clk='1' and clk'event then
87
                        if count<256*3 then
88
                                if count mod 3 = 0 then
89
                                        --! Calcular el vector que va desde el obsevador hasta un pixel x,y en particular.
90
                                        --! C&aacute;lculo de la columna:       0 <= c % 16 <= 15, 0 <= c <= 255. 
91
                                        --! C&aacute;lculo de la fila:          0 <= c / 16 <= 15, 0 <= c <= 255.         
92
                                        v:=ap_slv_calc_xyvec((count/3) mod 16, (count/3)/16,cam);
93
                                end if;
94
                                --! Alistar componente vectorial para ser escrito.
95
                                d <= v(count mod 3);
96
                                --! Activar escritura
97
                                wr <= '1';
98
                                --! Direccionar en el bloque A comenzar 
99
                                add <= "00"&conv_std_logic_vector(count mod 3,2)&'0'&conv_std_logic_vector(count/3,8);
100
                                --! Avanzar
101
                                count:=count+1;
102
                        elsif count=256*3 then
103
                                --! Escribir la instrucci&oacute;n de normalizaci&oacute;n.
104
                                wr <= '1';
105
                                --! La direcci&oacute;n por defecto para escribir en la cola de instrucciones es 0x0600
106
                                -- add <= "0 0110 0000 0000";
107
                                add <= x"0600";
108
                                d <= ap_format_instruction("nrm",0,15,0,0,0);
109
                                count:=count+1;
110
                        else
111
                                --! Parar la escritura de datos. 
112
                                wr <= '0';
113
                        end if;
114
                end if;
115
        end process normalization_test;
116
 
117
        disp: process
118
                file f : text open write_mode is "default_output.csv";
119
        begin
120
                ap_print(f,string'("#RAYTRAC TESTBENCH OUTPUT FILE"));
121
                ap_print(f,string'("#This file is automatically generated by tb_compiler script, by Julian Andres Guarin Reyes"));
122
                ap_print(f,string'("#TB_COMPILER_GEN"));
123
        end process
124
 
125
 
126
end architecture;
127
 

powered by: WebSVN 2.1.0

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