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

Subversion Repositories raytrac

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

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

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

powered by: WebSVN 2.1.0

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