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

Subversion Repositories raytrac

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

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 156 jguarin200
        --!TBXSTART:CTRL
13
        signal  sclk,srst,srd,swr       : std_logic;
14
        --!TBXEND
15
        --!TBXSTART:ADD_BUS
16
        signal  sadd                            : std_logic_vector(12 downto 0);
17
        --!TBXEND
18
        --!TBXSTART:DATA_BUS
19
        signal  sd,sq                           : std_logic_vector(31 downto 0);
20
        --!TBXEND
21
        --!TBXSTART:INT_BUS
22
        signal  sint                            : std_logic_vector(7 downto 0);
23
        --!TBXEND
24
 
25 155 jguarin200
begin
26
 
27
        reset_p : process
28
        begin
29
                rst <= not(rstMasterValue);
30
                wait for 1 ns;
31
                rst <= rstMasterValue;
32
                wait for 52 ns;
33
                rst <= not(rstMasterValue);
34
        end process reset_p;
35
 
36
 
37
        clock_p : process
38
        begin
39
                clk <= '1';
40
                clock_loop:loop
41
                        wait for tclk_2;
42
                        clk <= '0';
43
                        wait for tclk_2;
44
                        clk <= '1';
45
                end loop clock_loop;
46
        end process clock_p;
47
 
48
 
49 156 jguarin200
        --!TBXINSTANCESTART
50 155 jguarin200
        dude : raytrac
51
        port map (
52
 
53 156 jguarin200
                clk => sclk,
54
                rst => srst,
55
                rd => srd,
56
                wr => swr,
57
                add => sadd,
58
                d => sd,
59
                q => sq,
60
                int => sint
61 155 jguarin200
 
62
        );
63 156 jguarin200
        --!TBXINSTANCEEND
64 155 jguarin200
 
65
 
66
        --! Este proceso c&aacute;lcula los rayos/vectores que desde un observador van a una pantalla de 16x16 pixeles.
67
        --! 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.
68
        --! Finalmente se escribe en la cola de instrucciones la instrucci&oacute;n "nrm". 
69
        --! 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.
70
 
71
        normalization_test_input : process (clk,rst)
72
                variable cam : apCamera;
73
                variable count : integer;
74
                variable v : v3f;
75
        begin
76
                if rst=rstMasterValue then
77
                        count := 0;
78
                        --! Camara observador.
79
                        --! Resoluci&oacute;n horizontal
80
                        cam.resx:=16;
81
                        --! Resoluci&oacute;n vertical
82
                        cam.resy:=16;
83
                        --! Dimensi&oacute;n horizontal
84
                        cam.width:=100;
85
                        --! Dimensi&oacute;n vertical
86
                        cam.height:=100;
87
                        --! Distancia del observador al plano de proyecci&oacute;n.
88
                        cam.dist:=100;
89
                        v(0):=(others => '0');
90
                        v(1):=(others => '0');
91
                        v(2):=(others => '0');
92
                        d <= (others => '0');
93
                        add <= (others => '0');
94
                        wr <= '0';
95
                elsif clk='1' and clk'event then
96
                        if count<256*3 then
97
                                if count mod 3 = 0 then
98
                                        --! Calcular el vector que va desde el obsevador hasta un pixel x,y en particular.
99
                                        --! C&aacute;lculo de la columna:       0 <= c % 16 <= 15, 0 <= c <= 255. 
100
                                        --! C&aacute;lculo de la fila:          0 <= c / 16 <= 15, 0 <= c <= 255.         
101
                                        v:=ap_slv_calc_xyvec((count/3) mod 16, (count/3)/16,cam);
102
                                end if;
103
                                --! Alistar componente vectorial para ser escrito.
104
                                d <= v(count mod 3);
105
                                --! Activar escritura
106
                                wr <= '1';
107
                                --! Direccionar en el bloque A comenzar 
108
                                add <= "00"&conv_std_logic_vector(count mod 3,2)&'0'&conv_std_logic_vector(count/3,8);
109
                                --! Avanzar
110
                                count:=count+1;
111
                        elsif count=256*3 then
112
                                --! Escribir la instrucci&oacute;n de normalizaci&oacute;n.
113
                                wr <= '1';
114
                                --! La direcci&oacute;n por defecto para escribir en la cola de instrucciones es 0x0600
115
                                -- add <= "0 0110 0000 0000";
116
                                add <= x"0600";
117
                                d <= ap_format_instruction("nrm",0,15,0,0,0);
118
                                count:=count+1;
119
                        else
120
                                --! Parar la escritura de datos. 
121
                                wr <= '0';
122
                        end if;
123
                end if;
124
        end process normalization_test;
125
 
126 156 jguarin200
 
127
        --! tb_compiler: The following line (disp:process) is MANDATORY to be so tb_compiler knows here is where the display process takes place. 
128 155 jguarin200
        disp: process
129 156 jguarin200
                --! 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. 
130 155 jguarin200
                file f : text open write_mode is "default_output.csv";
131 156 jguarin200
                variable l : line;
132 155 jguarin200
        begin
133 156 jguarin200
                --! tb_compiler: You can write lines as many as you want. tb_compiler will set lines after the lines you wrote.........
134 155 jguarin200
                ap_print(f,string'("#RAYTRAC TESTBENCH OUTPUT FILE"));
135
                ap_print(f,string'("#This file is automatically generated by tb_compiler script, by Julian Andres Guarin Reyes"));
136 156 jguarin200
 
137
                wait for 5 ns;
138
                wait until rst=not(rstMasterValue);
139
                wait until clock='1';
140
                wait for tclk_2+tclk_4;
141
 
142
 
143
                --! from here on, tb_compiler writes the data to be displayed
144
                --! tb_compiler: the following line MUST go here
145
                disp_loop:loop
146
                        --!TBXDISPLAYOPERATION
147
                        wait for tclk;
148
 
149
                end loop;
150
 
151
 
152
        end process;
153 155 jguarin200
 
154
 
155
end architecture;
156
 

powered by: WebSVN 2.1.0

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