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

Subversion Repositories raytrac

[/] [raytrac/] [branches/] [fp_sgdma/] [raytrac.vhd] - Blame information for rev 221

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

Line No. Rev Author Line
1 219 jguarin200
--! @file raytrac.vhd
2
--! @brief Sistema de Procesamiento Vectorial. La interface es compatible con el bus Avalon de Altera.  
3
--! @author Julián Andrés Guarín Reyes
4
--------------------------------------------------------------
5
-- RAYTRAC
6
-- Author Julian Andres Guarin
7
-- raytrac.vhd
8
-- This file is part of raytrac.
9
-- 
10
--     raytrac is free software: you can redistribute it and/or modify
11
--     it under the terms of the GNU General Public License as published by
12
--     the Free Software Foundation, either version 3 of the License, or
13
--     (at your option) any later version.
14
-- 
15
--     raytrac is distributed in the hope that it will be useful,
16
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
17
--     MERCHANTABILITY or FITNESS FOR a PARTICULAR PURPOSE.  See the
18
--     GNU General Public License for more details.
19
-- 
20
--     You should have received a copy of the GNU General Public License
21
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>.
22
 
23 150 jguarin200
library ieee;
24
use ieee.std_logic_1164.all;
25 211 jguarin200
use ieee.std_logic_unsigned.all;
26 219 jguarin200
use work.arithpack.all;
27 150 jguarin200
 
28 211 jguarin200
library altera_mf;
29
use altera_mf.altera_mf_components.all;
30
 
31
library lpm;
32
use lpm.lpm_components.all;
33
 
34
 
35 217 jguarin200
entity raytrac is
36 211 jguarin200
        generic (
37
                wd      :       integer := 32;
38
                fd      :       integer := 8;   --! Result Fifo Depth = 2**fd =256
39 219 jguarin200
                mb      :       integer := 4    --! Max Burst Length = 2**mb            
40 211 jguarin200
        );
41 150 jguarin200
        port (
42 211 jguarin200
                clk:    in std_logic;
43
                rst:    in std_logic;
44 150 jguarin200
 
45 211 jguarin200
                --! Avalon MM Slave
46
                slave_address                   :       in      std_logic_vector(3 downto 0);
47
                slave_read                              :       in      std_logic;
48
                slave_write                             :       in      std_logic;
49
                slave_readdata                  :       out std_logic_vector(31 downto 0);
50
                slave_writedata                 :       in      std_logic_vector(31 downto 0);
51
 
52
                --! Avalon MM Master (Read & Write common signals)      
53
                master_address                  :       out std_logic_vector(31 downto 0);
54
                master_burstcount               :       out std_logic_vector(4 downto 0);
55
                master_waitrequest              :       in      std_logic;
56 150 jguarin200
 
57 211 jguarin200
                --! Avalon MM Master (Read Stage)
58
                master_read                             :       out     std_logic;
59
                master_readdata                 :       in      std_logic_vector(31 downto 0);
60
                master_readdatavalid    :       in      std_logic;
61 202 jguarin200
 
62 211 jguarin200
                --! Avalon MM Master (Write Stage)
63
                master_write                    :       out     std_logic;
64
                master_writedata                :       out std_logic_vector(31 downto 0);
65 150 jguarin200
 
66 211 jguarin200
                --! Avalon IRQ
67
                irq                                             :       out std_logic
68 150 jguarin200
 
69 211 jguarin200
 
70
 
71 150 jguarin200
        );
72
end entity;
73
 
74
 
75 217 jguarin200
architecture raytrac_arch of raytrac is
76 211 jguarin200
 
77
        --! Altera Compiler Directive, to avoid m9k autoinferring thanks to the guys at http://www.alteraforum.com/forum/archive/index.php/t-30784.html .... 
78
        attribute altera_attribute : string;
79 217 jguarin200
        attribute altera_attribute of raytrac_arch : architecture is "-name AUTO_SHIFT_REGISTER_RECOGNITION OFF";
80 161 jguarin200
 
81 211 jguarin200
 
82 219 jguarin200
        type    registerblock   is array (15 downto 0) of xfloat32;
83 211 jguarin200
        type    transferState   is (IDLE,SINK,SOURCE);
84 219 jguarin200
        type    upload_chain    is (UPVX,UPVY,UPVZ,SC,DMA);
85
        type    download_chain  is (DWAX,DWAY,DWAZ,DWBX,DWBY,DWBZ,DWAXBX,DWAYBY,DWAZBZ);
86 202 jguarin200
 
87 211 jguarin200
        constant reg_ctrl                               :       integer:=00;
88
        constant reg_vz                                 :       integer:=01;
89
        constant reg_vy                                 :       integer:=02;
90
        constant reg_vx                                 :       integer:=03;
91
        constant reg_scalar                             :       integer:=04;
92
        constant reg_scratch00                  :       integer:=05;
93
        constant reg_outputcounter              :       integer:=06;
94
        constant reg_inputcounter               :       integer:=07;
95
        constant reg_fetchstart                 :       integer:=08;
96
        constant reg_sinkstart                  :       integer:=09;
97
        constant reg_ax                                 :       integer:=10;
98
        constant reg_ay                                 :       integer:=11;
99
        constant reg_az                                 :       integer:=12;
100
        constant reg_bx                                 :       integer:=13;
101
        constant reg_by                                 :       integer:=14;
102
        constant reg_bz                                 :       integer:=15;
103
 
104
 
105 172 jguarin200
 
106 211 jguarin200
        constant reg_ctrl_cmb                   :       integer:=00;    --! CMB bit : Combinatorial Instruction.
107
        constant reg_ctrl_s                             :       integer:=01;    --! S bit of the DCS field.
108
        constant reg_ctrl_c                             :       integer:=02;    --! C bit of the DCS field.
109
        constant reg_ctrl_d                             :       integer:=03;    --! D bit of the DCS field.
110 202 jguarin200
 
111 211 jguarin200
        constant reg_ctrl_sc                    :       integer:=04;    --! SC bit of the VTSC field.
112
        constant reg_ctrl_vt                    :       integer:=05;    --! VT bit of the VTSC field.
113 217 jguarin200
        constant reg_ctrl_dma                   :       integer:=06;    --! DMA bit.
114 211 jguarin200
        constant reg_ctrl_flags_fc              :       integer:=07;    --! Flood Condition Flag.
115 202 jguarin200
 
116 211 jguarin200
        constant reg_ctrl_flags_dc              :       integer:=08;    --! Drain Condition Flag.       
117
        constant reg_ctrl_flags_wp              :       integer:=09;    --! Write on Memory Pending Flag.
118
        constant reg_ctrl_flags_pp              :       integer:=10;    --! Pipeline Pending Flag.
119
        constant reg_ctrl_flags_pl              :       integer:=11;    --! Load Parameter Pending Flag.
120 202 jguarin200
 
121 211 jguarin200
        constant reg_ctrl_flags_dp              :       integer:=12;    --! Data Pending flag.
122
        constant reg_ctrl_flags_ap              :       integer:=13;    --! Address Pending Flag.
123
        constant reg_ctrl_rlsc                  :       integer:=14;    --! RLSC bit : Reload Load Sync Chain.
124
        constant reg_ctrl_rom                   :       integer:=15;    --! ROM bit : Read Only Mode bit.
125 202 jguarin200
 
126 211 jguarin200
        constant reg_ctrl_nfetch_low    :       integer:=16;    --! NFETCH_LOW : Lower bit to program the number of addresses to load in the interconnection.
127
        constant reg_ctrl_nfetch_high   :       integer:=30;    --! NFETCH_HIGH : Higher bit to program the number of addresses to load in the interconnection. 
128
        constant reg_ctrl_irq                   :       integer:=31;    --! IRQ bit : Interrupt Request Signal.
129
 
130
 
131
        --! Avalon MM Slave
132
        signal  sreg_block                      :       registerblock;
133
        signal  sslave_read                     :       std_logic;
134
        signal  sslave_write            :       std_logic;
135 219 jguarin200
        signal  sslave_writedata        :       std_logic_vector (wd-1 downto 0);
136
        signal  sslave_address          :       std_logic_vector (3 downto 0);
137 211 jguarin200
        signal  sslave_waitrequest      :       std_logic;
138 217 jguarin200
 
139 211 jguarin200
        --! Avalon MM Master
140
        signal  smaster_write           :       std_logic;
141
        signal  smaster_read            :       std_logic;
142 202 jguarin200
 
143 211 jguarin200
        --! State Machine and event signaling
144
        signal sm                                       :       transferState;
145
 
146
        signal sres_ack                         :       std_logic;
147
        signal soutb_ack                        :       std_logic;
148
 
149 219 jguarin200
        signal sres_q                           :       std_logic_vector (4*wd-1 downto 0);
150 211 jguarin200
 
151 219 jguarin200
        signal sres_d                           :       vectorblock04;
152 211 jguarin200
        signal soutb_d                          :       std_logic_vector(wd-1 downto 0);
153
 
154
 
155
        signal sres_w                           :       std_logic;
156
        signal soutb_w                          :       std_logic;
157
 
158
        signal sres_e                           :       std_logic;
159
        signal soutb_e                          :       std_logic;
160
        signal soutb_ae                         :       std_logic;
161
        signal soutb_af                         :       std_logic;
162
 
163 217 jguarin200
 
164 211 jguarin200
        signal soutb_usedw                      :       std_logic_vector(fd-1 downto 0);
165
 
166
        signal ssync_chain_1            :       std_logic;
167
        signal ssync_chain_pending      :       std_logic;
168
        signal sfetch_data_pending      :       std_logic;
169
        signal sload_add_pending        :       std_logic;
170
        signal spipeline_pending        :       std_logic;
171
        signal swrite_pending           :   std_logic;
172
        signal sparamload_pending       :       std_logic;
173
        signal sZeroTransit                     :       std_logic;
174
 
175
 
176
        --!Unload Control
177
        signal supload_chain    : upload_chain;
178
        signal supload_start    : upload_chain;
179 202 jguarin200
 
180 211 jguarin200
        --!Se&ntilde;ales de apoyo:
181
        signal zero : std_logic_vector(31 downto 0);
182
 
183
        --!High Register Bank Control Signals or AKA Load Sync Chain Control
184
        signal sdownload_chain  : download_chain;
185
        signal sdownload_start  : download_chain;
186
        signal srestart_chain   : std_logic;
187
        --!State Machine Hysteresis Control Signals
188
        signal sdrain_condition         : std_logic;
189
        signal sdrain_burstcount        : std_logic_vector(mb downto 0);
190
        signal sdata_fetch_counter      : std_logic_vector(reg_ctrl_nfetch_high downto reg_ctrl_nfetch_low);
191
        signal sburstcount_sink         : std_logic_vector(mb downto 0);
192
 
193
        signal sflood_condition         : std_logic;
194
        signal sflood_burstcount        : std_logic_vector(mb downto 0);
195 177 jguarin200
 
196 219 jguarin200
        --! Arithmetic Pipeline and Data Path Control
197
        component ap_n_dpc
198
        port (
199
                clk                                             : in    std_logic;
200
                rst                                             : in    std_logic;
201
 
202
                paraminput                              : in    vectorblock06;  --! Vectores A,B
203
 
204
                d,c,s                                   : in    std_logic;              --! Bit con el identificador del bloque AB vs CD e identificador del sub bloque (A/B) o (C/D). 
205
 
206
                sync_chain_1                    : in    std_logic;              --! Se&ntilde;al de dato valido que se va por toda la cadena de sincronizacion.
207
                sync_chain_pending              : out   std_logic;
208
 
209
                qresult_w                               : out   std_logic; --! Salidas de escritura y lectura en las colas de resultados.
210
                qresult_d                               : out   vectorblock04 --! 4 salidas de resultados, pues lo m&aacute;ximo que podr&aacute; calcularse por cada clock son 2 vectores. 
211 211 jguarin200
 
212 219 jguarin200
        );
213
        end component;
214
 
215
        signal sparaminput                      : vectorblock06;
216
 
217 211 jguarin200
begin
218
 
219 219 jguarin200
        --!Zero agreggate
220 211 jguarin200
        zero    <= (others => '0');
221
 
222 219 jguarin200
        sparaminput(ax) <= sreg_block(reg_ax);
223
        sparaminput(ay) <= sreg_block(reg_ay);
224
        sparaminput(az) <= sreg_block(reg_az);
225
        sparaminput(bx) <= sreg_block(reg_bx);
226
        sparaminput(by) <= sreg_block(reg_by);
227
        sparaminput(bz) <= sreg_block(reg_bz);
228 211 jguarin200
 
229 219 jguarin200
--! *************************************************************************************************************************************************************************************************************************************************************
230
--! ARITHMETIC PIPELINE AND DATA PATH INSTANTIATION  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  => 
231
--! *************************************************************************************************************************************************************************************************************************************************************
232 211 jguarin200
 
233 219 jguarin200
        --! Arithpipeline and Datapath Control Instance
234
        arithmetic_pipeline_and_datapath_controller : ap_n_dpc
235
        port map (
236
                clk                             => clk,
237
                rst                             => rst,
238
                paraminput                      => sparaminput,
239
                d                                       => sreg_block(reg_ctrl)(reg_ctrl_d),
240
                c                                       => sreg_block(reg_ctrl)(reg_ctrl_c),
241
                s                                       => sreg_block(reg_ctrl)(reg_ctrl_s),
242
                sync_chain_1            => ssync_chain_1,
243
                sync_chain_pending      => ssync_chain_pending,
244
                qresult_w                       => sres_w,
245
                qresult_d                       => sres_d
246
 
247
 
248
        );
249 211 jguarin200
 
250
 
251
--! ******************************************************************************************************************************************************                                              
252
--! TRANSFER CONTROL RTL CODE
253
--! ******************************************************************************************************************************************************                                              
254
        TRANSFER_CONTROL:
255 219 jguarin200
        process(clk,rst,master_waitrequest,sm,soutb_ae,soutb_usedw,spipeline_pending,soutb_e,zero,soutb_af,sfetch_data_pending,sreg_block,sslave_write,sslave_address,sslave_writedata,ssync_chain_pending,sres_e,smaster_read,smaster_write,sdata_fetch_counter,sload_add_pending,swrite_pending,sdownload_chain)
256 211 jguarin200
        begin
257 202 jguarin200
 
258 211 jguarin200
                --! Conexi&oacuteln a se&ntilde;ales externas. 
259
                irq <= sreg_block(reg_ctrl)(reg_ctrl_irq);
260
                master_read <= smaster_read;
261
                master_write <= smaster_write;
262 202 jguarin200
 
263 217 jguarin200
                --! Direct Memory Access Selector.
264 150 jguarin200
 
265 217 jguarin200
 
266
 
267 211 jguarin200
                --! ZERO_TRANSIT: Cuando todos los elementos de sincronizaci&oacute;n est&aacute;n en cero menos la cola de sincronizaci&oacute;n de carga de parametros.
268
                sZeroTransit <= not(sload_add_pending or sfetch_data_pending or spipeline_pending or swrite_pending);
269 202 jguarin200
 
270 211 jguarin200
                --! ELEMENTO DE SINCRONIZACION OUT QUEUE: Datos pendientes por cargar a la memoria a trav&eacute;s de la interconexi&oacute;n
271
                swrite_pending <= not(soutb_e);
272 202 jguarin200
 
273 211 jguarin200
                --! ELEMENTO DE SINCRONIZACION ARITH PIPELINE: Hay datos transitando por el pipeline aritm&eacute;tico.
274
                if ssync_chain_pending='1' or sres_e='0' then
275
                        spipeline_pending <= '1';
276
                else
277
                        spipeline_pending <= '0';
278
                end if;
279 202 jguarin200
 
280 211 jguarin200
                --! ELEMENTO DE SINCRONIZACION DESCARGA DE DATOS: Hay datos pendientes por descargar desde la memoria a trav&eacute;s de la interconexi&oacute;n.
281
                if sdata_fetch_counter=zero(reg_ctrl_nfetch_high downto reg_ctrl_nfetch_low) then
282
                        sfetch_data_pending <= '0';
283
                else
284
                        sfetch_data_pending <= '1';
285
                end if;
286
 
287
                --! ELEMENTO DE SINCRONIZACION CARGA DE DIRECCIONES: Hay direcciones pendientes por cargar a la interconexi&oacute;n?
288
                if sreg_block(reg_ctrl)(reg_ctrl_nfetch_high downto reg_ctrl_nfetch_low)=zero(reg_ctrl_nfetch_high downto reg_ctrl_nfetch_low) then
289
                        sload_add_pending <= '0';
290
                else
291
                        sload_add_pending <= '1';
292
                end if;
293 202 jguarin200
 
294 211 jguarin200
                --! ELEMENTO DE SINCRONIZACION CARGA DE OPERANDOS: Se est&aacute;n cargando los operandos que ser&aacute;n operados en el pipeline aritm&eacute;tico.
295 219 jguarin200
                if sdownload_chain /= DWAX and sdownload_chain /= DWAXBX then
296 211 jguarin200
                        sparamload_pending <= '1';
297
                else
298
                        sparamload_pending <= '0';
299
                end if;
300
 
301
                --! Se debe iniciar una transacci&oacute;n de descarga de datos desde la memoria externa?
302
                if soutb_af='0' and sload_add_pending='1' then
303
                        --! Flow Control : La saturaci&oacute;n de la cola de resultados continuar&aacute; si no est&aacute; tan llena y adem&aacute;s hay pendientes datos por ser descargados.
304
                        sflood_condition <= '1';
305
                else
306
                        --! Flow Control : La saturaci&oacute;n de la cola de resultados debe parar porque est&aacute; cas&iacute; llena.       
307
                        sflood_condition <= '0';
308
                end if;
309
                if sreg_block(reg_ctrl)(reg_ctrl_nfetch_high downto reg_ctrl_nfetch_low+mb)/=zero(reg_ctrl_nfetch_high downto reg_ctrl_nfetch_low+mb) then
310
                        --! Flow Control: Si el n&uacute;mero de descargas pendientes es mayor o igual al max burst length, entonces cargar max burst en el contador.
311
                        sflood_burstcount <= '1'&zero(mb-1 downto 0);
312
                else
313
                        --! Flow Control: Si le n&uacute;mero de descargas pendientes es inferior a Max Burst Count entonces cargar los bits menos significativos del registro de descargas pendientes.
314
                        sflood_burstcount <= '0'&sreg_block(reg_ctrl)(reg_ctrl_nfetch_low+mb-1 downto reg_ctrl_nfetch_low);
315
                end if;
316 202 jguarin200
 
317 211 jguarin200
                --! Se debe iniciar una transacci&oacute;n de carga de datos hacia la memoria externa?
318
                if soutb_ae='1' then
319
                        --! Flow Control : Cuando se est&eacute; drenando la cola de resultados, si la cola est&aacute; cas&iacute; vac&iaute;a, la longitud del burst ser&aacute;n los bits menos significativos del contador de la cola.  
320
                        sdrain_burstcount <= soutb_usedw(mb downto 0);
321
                        --! Flow Control: El drenado de datos continuar&aacute; si el n&uacute;mero de datos en la cola bajo y no hay datos transitando por el pipeline, ni datos pendientes por cargar desde la memoria.   
322
                        sdrain_condition <= not(sload_add_pending) and not(sfetch_data_pending) and not(spipeline_pending) and swrite_pending;
323
                else
324
                        --! Flow Control: Cuando se est&eacute; drenando la cola de resultados, si la cola de tiene una cantidad de datos mayor al burst count entonces se har&aacute; una transacci&oacute;n de longitud equivalente al burst count.
325
                        sdrain_burstcount <= '1'&zero(mb-1 downto 0);
326
                        --! Flow Control: El drenado de datos continuar&aacute; si el n&uacute;mero de datos en la cola es mayor o igual a 2**mb O si hay muy pocos datos y no hay datos transitando por el pipeline.   
327
                        sdrain_condition <= '1';
328
                end if;
329 202 jguarin200
 
330 211 jguarin200
                --! Restart param load chain
331
                srestart_chain <= sreg_block(reg_ctrl)(reg_ctrl_irq) and sreg_block(reg_ctrl)(reg_ctrl_rlsc);
332 202 jguarin200
 
333 217 jguarin200
                --! Data dumpster: Descaratar dato de upload una vez la interconexi&oacute;n haya enganchado el dato.
334 211 jguarin200
                if sm=SINK and master_waitrequest='0' and smaster_write='1' then
335
                        soutb_ack <= '1';
336
                else
337
                        soutb_ack <= '0';
338
                end if;
339 202 jguarin200
 
340 217 jguarin200
 
341
 
342 211 jguarin200
                --! Flow Control State Machine.
343
                if rst=rstMasterValue then
344
 
345
                        --! State Machine 
346
                        sm <= IDLE;
347
 
348
 
349
                        --! Master Write & Read Common Signals Reset Value
350
                        master_burstcount       <= (others => '0');
351
                        master_address          <= (others => '0');
352
                        sdata_fetch_counter     <= (others => '0');
353
                        sburstcount_sink        <= (others => '0');
354 150 jguarin200
 
355 211 jguarin200
                        --! Master Read Only Signals Reset Value
356
                        smaster_read            <= '0';
357
 
358
                        --! Master Write Only Signals
359
                        smaster_write           <= '0';
360
 
361
                        --! Reg Ctrl & Fetch address and writeaddress
362
                        --! Sinking address
363
                        sreg_block(reg_sinkstart) <= (others => '0');
364
                        --! Sourcing address
365
                        sreg_block(reg_fetchstart) <= (others => '0');
366
                        --! Control and Status Register
367
                        sreg_block(reg_ctrl) <= (others => '0');
368
                        --! Contador Overall
369
                        sreg_block(reg_inputcounter) <= (others => '0');
370
                        sreg_block(reg_outputcounter) <= (others => '0');
371
 
372
 
373
                elsif clk'event and clk='1' then
374 150 jguarin200
 
375 211 jguarin200
                        --! Nevermind the State, discount the incoming valid data counter.
376
                        sdata_fetch_counter <= sdata_fetch_counter-master_readdatavalid;
377
 
378
                        --! Debug Counter.
379
                        sreg_block(reg_inputcounter) <= sreg_block(reg_inputcounter) + master_readdatavalid;
380
                        sreg_block(reg_outputcounter) <= sreg_block(reg_outputcounter) + soutb_ack;
381 152 jguarin200
 
382 211 jguarin200
                        --! Flags
383
 
384
 
385
                        case sm is
386
                                when SOURCE =>
387
                                        --! ******************************************************************************************************************************************************                                              
388
                                        --! Flooding the pipeline ........
389
                                        --! ******************************************************************************************************************************************************                                              
390
                                        if smaster_read='0' then
391
                                                if sflood_condition = '1' then
392
                                                        --! Flow Control: Hay suficiente espacio en el buffer de salida y hay descargas pendientes por hacer
393
                                                        smaster_read <= '1';
394
                                                        master_address <= sreg_block(reg_fetchstart);
395
                                                        master_burstcount <= sflood_burstcount;
396
                                                        sdata_fetch_counter <= sdata_fetch_counter+sflood_burstcount-master_readdatavalid;
397
                                                        --! Context Saving:
398
                                                        sreg_block(reg_fetchstart) <= sreg_block(reg_fetchstart) + (sflood_burstcount&"00");
399
                                                        sreg_block(reg_ctrl)(reg_ctrl_nfetch_high downto reg_ctrl_nfetch_low) <= sreg_block(reg_ctrl)(reg_ctrl_nfetch_high downto reg_ctrl_nfetch_low) - sflood_burstcount;
400
                                                else
401
                                                        --! Flow Control : Cambiar al estado SINK, porque o est&aacute; muy llena la cola de salida o no hay descargas pendientes por realizar.
402
                                                        sm <= SINK;
403
                                                end if;
404
                                        else --master_read=1;
405
                                                if master_waitrequest='0' then
406
                                                        --! Las direcciones de lectura est&aacute;n cargadas. Terminar la transferencia.
407
                                                        smaster_read <= '0';
408
                                                end if;
409
                                        end if;
410
                                when SINK =>
411
 
412
                                        --! ******************************************************************************************************************************************************                                              
413
                                        --! Draining the pipeline ........
414
                                        --! ******************************************************************************************************************************************************                                              
415
                                        if smaster_write='0' then
416
 
417
                                                if sdrain_condition='1' then
418
                                                        --! Flow Control : Hay muchos datos aun en la cola de resultados &Oacute; la cola de resultados est&aacute; cas&iacute; vac&iacute;a y no hay datos transitando en el pipeline aritm&eetico.
419
                                                        smaster_write <= '1';
420
                                                        master_address <= sreg_block(reg_sinkstart);
421
                                                        master_burstcount <= sdrain_burstcount;
422 150 jguarin200
 
423 211 jguarin200
                                                        --!Context Saving
424
                                                        sreg_block(reg_sinkstart) <= sreg_block(reg_sinkstart) + (sdrain_burstcount&"00");
425
                                                        sburstcount_sink <= sdrain_burstcount-1;
426
                                                else
427
                                                        --! Flow Control: Son muy pocos los datos que hay en el buffer de salida y existen aun datos transitando en el resto del pipe ir al estado SOURCE.
428
                                                        if sZeroTransit='1' then
429
 
430
                                                                --! Flow Control: Finalizada la instrucci&oacute;n, generar una interrupci&oacute;n e ir al estado IDLE.
431
                                                                sm <= IDLE;
432
                                                                sreg_block(reg_ctrl)(reg_ctrl_irq) <= '1';
433
                                                                sreg_block(reg_ctrl)(reg_ctrl_rom) <= '0';
434 217 jguarin200
                                                                sreg_block(reg_ctrl)(reg_ctrl_flags_dc downto reg_ctrl_flags_fc) <= sdrain_condition & sflood_condition;
435 211 jguarin200
                                                                sreg_block(reg_ctrl)(reg_ctrl_flags_ap downto reg_ctrl_flags_wp) <= sload_add_pending & sfetch_data_pending & sparamload_pending & spipeline_pending & swrite_pending;
436
 
437
                                                        else
438
 
439
                                                                --! Flow Control: Cambiar a Source porque aun hay elementos transitando.
440
                                                                sm <= SOURCE;
441
                                                        end if;
442
 
443
                                                end if;
444
                                        else --!smaster_write=1 
445
                                                if master_waitrequest = '0' then
446
 
447
                                                        --! Descartar datos : revisar antes de este proceso secuencial la parte combinatoria (Data Dumpster).
448
 
449
 
450
                                                        if sburstcount_sink/=zero(mb downto 0) then
451
 
452
                                                                --! Datos pendientes por transmitir aun en el burst. Restar uno 
453
                                                                sburstcount_sink <= sburstcount_sink-1;
454
                                                        else
455
 
456
                                                                --! No escribir mas. Finalizar la transmisi&oacute;n
457
                                                                smaster_write <= '0';
458
 
459
                                                                --! Si no hay transito de dato se con terminada la instrucci&oacute;n siempre que el estado de control de flujo est&eacute; sidera  
460
                                                                if sZeroTransit='1' then
461
 
462
                                                                        --! Flow Control: Finalizada la instrucci&oacute;n, generar una interrupci&oacute;n e ir al estado IDLE.
463
                                                                        sm <= IDLE;
464
                                                                        sreg_block(reg_ctrl)(reg_ctrl_irq) <= '1';
465
                                                                        sreg_block(reg_ctrl)(reg_ctrl_rom) <= '0';
466 217 jguarin200
                                                                        sreg_block(reg_ctrl)(reg_ctrl_flags_dc downto reg_ctrl_flags_fc) <= sdrain_condition & sflood_condition;
467 211 jguarin200
                                                                        sreg_block(reg_ctrl)(reg_ctrl_flags_ap downto reg_ctrl_flags_wp) <= sload_add_pending & sfetch_data_pending & sparamload_pending & spipeline_pending & swrite_pending;
468
 
469
                                                                end if;
470
                                                        end if;
471
                                                end if;
472
                                        end if;
473
 
474
                                when IDLE =>
475
                                        --! ******************************************************************************************************************************************************                                              
476
                                        --! Programming the pipeline
477
                                        --! ******************************************************************************************************************************************************                                              
478
                                        --! El registro de control en sus campos fetch e irq, es escribile solo cuando estamos en estado IDLE.           
479
                                        if sslave_write='1' then
480
                                                case sslave_address is
481
                                                        when x"0" =>
482
                                                                --! Solo se permitira escribir en el registro de control si no hay una interrupci&oacute;n activa o si la hay solamente si se esta intentando desactivar la interrupci&acute;n 
483
                                                                if sreg_block(reg_ctrl)(reg_ctrl_irq)='0' or sslave_writedata(reg_ctrl_irq)='0' then
484
                                                                        sreg_block(reg_ctrl)(reg_ctrl_irq downto reg_ctrl_nfetch_low) <= sslave_writedata(reg_ctrl_irq downto reg_ctrl_nfetch_low);
485
                                                                        sreg_block(reg_ctrl)(reg_ctrl_flags_wp-1 downto reg_ctrl_cmb) <= sslave_writedata(reg_ctrl_flags_wp-1 downto reg_ctrl_cmb);
486
                                                                end if;
487
                                                        when x"6" => sreg_block(reg_outputcounter) <= sslave_writedata;
488
                                                        when x"7" => sreg_block(reg_inputcounter) <= sslave_writedata;
489
                                                        when x"8" => sreg_block(reg_fetchstart) <= sslave_writedata;
490
                                                        when x"9" => sreg_block(reg_sinkstart) <= sslave_writedata;
491
                                                        when others => null;
492
                                                end case;
493
                                        else
494
 
495
                                                if sZeroTransit='0' then
496
 
497
 
498
                                                        --! Flow Control: Existe un n&uacute;mero de descargas programadas por el sistema, comenzar a realizarlas.
499
                                                        --! Ir al estado Source.
500
                                                        sm <= SOURCE;
501
                                                        sreg_block(reg_ctrl)(reg_ctrl_rom) <= '1';
502 219 jguarin200
 
503
                                                else
504
                                                        sreg_block(reg_ctrl)(reg_ctrl_rom) <= '0';
505
 
506 211 jguarin200
                                                end if;
507
                                        end if;
508
                        end case;
509
                end if;
510
        end process;
511
--! ******************************************************************************************************************************************************                                              
512
--! FLOW CONTROL RTL CODE
513
--! ******************************************************************************************************************************************************                                              
514
--! Colas de resultados y buffer de salida
515
--! ******************************************************************************************************************************************************                                              
516
        res:scfifo
517
        generic map     (lpm_numwords => 2**fd, lpm_showahead => "ON", lpm_width => 128, lpm_widthu     => fd, overflow_checking => "ON", underflow_checking => "ON", use_eab => "ON")
518 219 jguarin200
        port map        (rdreq => sres_ack, aclr => '0', empty => sres_e, clock => clk, q => sres_q,     wrreq => sres_w, data => sres_d(qsc)&sres_d(qx)&sres_d(qy)&sres_d(qz));
519 211 jguarin200
        output_buffer:scfifo
520
        generic map (almost_empty_value => 2**mb,almost_full_value => (2**fd)-52, lpm_widthu => fd, lpm_numwords => 2**fd, lpm_showahead => "ON", lpm_width => 32, overflow_checking => "ON", underflow_checking => "ON", use_eab => "ON")
521
        port map        (empty => soutb_e, aclr => '0', clock => clk, rdreq      => soutb_ack, wrreq     => soutb_w,     q => master_writedata, usedw    => soutb_usedw, almost_full => soutb_af, almost_empty => soutb_ae, data => soutb_d);
522
--! ******************************************************************************************************************************************************                                              
523
--! PROCESO DE CONTROL DE FLUJO ENTRE EL BUFFER DE RESULTADOS Y EL BUFFER DE SALIDA
524
--! ******************************************************************************************************************************************************                                              
525
 
526
        FLOW_CONTROL_OUTPUT_STAGE:
527 217 jguarin200
        process (clk,rst,master_readdata, master_readdatavalid,sres_e,sreg_block(reg_ctrl)(reg_ctrl_vt downto reg_ctrl_sc),sm,supload_chain,zero,ssync_chain_pending,sres_q,supload_start)
528 211 jguarin200
        begin
529
 
530
 
531
                --! Compute initial State.
532
 
533
                --! Escribir en el output buffer.
534 217 jguarin200
                if supload_chain=DMA then
535
                        --! Modo DMA escribir los datos de entrada directamente en el buffer.
536
                        soutb_w <= master_readdatavalid;
537
                else
538
                        --!Modo Arithmetic Pipeline 
539
                        soutb_w <= not(sres_e);
540
                end if;
541 211 jguarin200
 
542
                --! Control de lectura de la cola de resultados.
543
                if sres_e='0' then
544
                        --!Hay datos en la cola de resultados.
545 219 jguarin200
                        if (supload_chain=UPVZ and sreg_block(reg_ctrl)(reg_ctrl_sc)='0') or supload_chain=SC then
546 211 jguarin200
                                --!Se transfiere el ultimo componente vectorial y no se estan cargando resultados escalares.
547
                                sres_ack <= '1';
548 219 jguarin200
                        else
549
                                sres_ack <= '0';
550 211 jguarin200
                        end if;
551
                else
552
                        sres_ack <= '0';
553
                end if;
554
 
555 217 jguarin200
 
556 211 jguarin200
                --! Decodificar que salida de la cola de resultados se conecta a la entrada del otput buffer
557 217 jguarin200
                --! DMA Path Control: Si se encuentra habilitado el modo dma entonces conectar la entrada del buffer de salida a la interconexi&oacute;n
558 211 jguarin200
                case supload_chain is
559 219 jguarin200
                        when UPVX =>
560
                                soutb_d <= sres_q (32*qx+31 downto 32*qx);
561
                        when UPVY =>
562
                                soutb_d <= sres_q (32*qy+31 downto 32*qy);
563
                        when UPVZ =>
564
                                soutb_d <= sres_q (32*qz+31 downto 32*qz);
565 211 jguarin200
                        when SC =>
566 219 jguarin200
                                soutb_d <= sres_q (32*qsc+31 downto 32*qsc);
567 217 jguarin200
                        when DMA =>
568
                                soutb_d <= master_readdata;
569 211 jguarin200
                end case;
570
 
571
 
572
                case sreg_block(reg_ctrl)(reg_ctrl_vt downto reg_ctrl_sc) is
573
                        when "01" =>
574
                                supload_start <= SC;
575
                        when others =>
576 219 jguarin200
                                supload_start <= UPVX;
577 211 jguarin200
                end case;
578
 
579
 
580
                --! M&aacute;quina de estados para el width adaptation RES(128) -> OUTPUTBUFFER(32).    
581
                if rst=rstMasterValue then
582 219 jguarin200
                        supload_chain <= UPVX;
583 217 jguarin200
                elsif clk'event and clk='1' and sreg_block(reg_ctrl)(reg_ctrl_dma)='0' then
584
                        --! Modo de operaci&oacute;n normal.
585 211 jguarin200
                        case supload_chain is
586 219 jguarin200
                                when UPVX =>
587 211 jguarin200
                                        if sres_e='1' then
588
                                                supload_chain <= supload_start;
589
                                        else
590 219 jguarin200
                                                supload_chain <= UPVY;
591 211 jguarin200
                                        end if;
592 219 jguarin200
                                when UPVY =>
593
                                        supload_chain <= UPVZ;
594
                                when UPVZ =>
595 211 jguarin200
                                        if sreg_block(reg_ctrl)(reg_ctrl_sc)='0' then
596 219 jguarin200
                                                supload_chain <= UPVX;
597 211 jguarin200
                                        else
598
                                                supload_chain <= SC;
599
                                        end if;
600 217 jguarin200
                                when SC|DMA =>
601 211 jguarin200
                                        supload_chain <= supload_start;
602 217 jguarin200
 
603 211 jguarin200
                        end case;
604 217 jguarin200
 
605
                elsif clk'event and clk='1' then
606
                        --! Modo DMA
607
                        supload_chain <= DMA;
608 211 jguarin200
                end if;
609
 
610
 
611
        end process;
612
--! ******************************************************************************************************************************************************                                              
613
--! PROCESO DE CONTROL DE FLUJO ENTRE LA ENTRADA DESDE LA INTERCONEXI&OACUTE;N Y LOS PARAMETROS DE ENTRADA EN EL PIPELINE ARITMETICO
614
--! ******************************************************************************************************************************************************                                              
615
        FLOW_CONTROL_INPUT_STAGE:
616 217 jguarin200
        process(clk,rst,master_readdatavalid,master_readdata,sreg_block(reg_ctrl)(reg_ctrl_dma downto reg_ctrl_s),sslave_write,sslave_address,supload_chain)
617 211 jguarin200
        begin
618
                --! Est&aacute; ocurriendo un evento de transici&oacute;n del estado TX al estado FETCH: Programar el enganche de par&aacute;metros que vienen de la interconexi&oacute;n.
619 219 jguarin200
                --! Mirar como es la carga inicial. Si es Normalizacion o Magnitud (dcs=110) entonces cargar DWAXBX de lo contrario solo DWAX.
620 211 jguarin200
                case sreg_block(reg_ctrl)(reg_ctrl_d downto reg_ctrl_s) is
621 221 jguarin200
                        when "110"      =>      sdownload_start <= DWAXBX;
622
                        when others     =>      sdownload_start <= DWAX;
623 211 jguarin200
                end case;
624
                if rst=rstMasterValue then
625
                        ssync_chain_1 <= '0';
626 219 jguarin200
                        sdownload_chain <= DWAX;
627 211 jguarin200
                        for i in reg_bz downto reg_ax loop
628
                                sreg_block(i) <= (others => '0');
629
                        end loop;
630
                elsif clk'event and clk='1' then
631
                        ssync_chain_1   <= '0';
632 217 jguarin200
                        if master_readdatavalid='1' and sreg_block(reg_ctrl)(reg_ctrl_dma)='0' then
633 211 jguarin200
                                --! El dato en la interconexi&oacute;n es valido, se debe enganchar. 
634
                                case sdownload_chain is
635 219 jguarin200
                                        when DWAX | DWAXBX  =>
636 211 jguarin200
                                                --! Cargar el operando correspondiente al componente "X" del vector "A" 
637
                                                ssync_chain_1 <= '0';
638
                                                sreg_block(reg_ax) <= master_readdata;
639 219 jguarin200
                                                if sdownload_start = DWAXBX then
640 211 jguarin200
                                                        --! Operaci&oacute;n Unaria por ejemplo magnitud de un vector
641
                                                        --! Escribir en el registro bx adicionalmente. 
642
                                                        sreg_block(reg_bx) <= master_readdata;
643
                                                        --! El siguiente estado es cargar el componente "Y" de del operando a ejecutar. 
644 219 jguarin200
                                                        sdownload_chain <= DWAYBY;
645 211 jguarin200
                                                else
646
                                                        --! Operaci&oacute;n de dos operandos. Por ejemplo Producto Cruz.
647
                                                        --! El siguiente estado es cargar el vector "Y" del operando "A".
648 219 jguarin200
                                                        sdownload_chain <= DWAY;
649 211 jguarin200
                                                end if;
650 219 jguarin200
                                        when DWAY | DWAYBY =>
651 211 jguarin200
                                                sreg_block(reg_ay) <= master_readdata;
652
                                                ssync_chain_1 <= '0';
653 219 jguarin200
                                                if sdownload_chain = DWAYBY then
654 211 jguarin200
                                                        sreg_block(reg_by) <= master_readdata;
655 219 jguarin200
                                                        sdownload_chain <= DWAZBZ;
656 211 jguarin200
                                                else
657 219 jguarin200
                                                        sdownload_chain <= DWAZ;
658 211 jguarin200
                                                end if;
659 219 jguarin200
                                        when DWAZ  | DWAZBZ =>
660 211 jguarin200
                                                sreg_block(reg_az) <= master_readdata;
661 219 jguarin200
                                                if sdownload_chain=DWAZBZ then
662 211 jguarin200
                                                        ssync_chain_1 <= '1';
663
                                                        sreg_block(reg_bz) <= master_readdata;
664 219 jguarin200
                                                        sdownload_chain <= DWAXBX;
665 211 jguarin200
                                                else
666
                                                        ssync_chain_1 <= '0';
667 219 jguarin200
                                                        sdownload_chain <= DWBX;
668 211 jguarin200
                                                end if;
669 219 jguarin200
                                        when DWBX  =>
670 211 jguarin200
                                                ssync_chain_1 <= '0';
671
                                                sreg_block(reg_bx) <= master_readdata;
672 219 jguarin200
                                                sdownload_chain <= DWBY;
673
                                        when DWBY =>
674 211 jguarin200
                                                ssync_chain_1 <= '0';
675
                                                sreg_block(reg_by) <= master_readdata;
676 219 jguarin200
                                                sdownload_chain <= DWBZ;
677
                                        when DWBZ =>
678 211 jguarin200
                                                sreg_block(reg_bz) <= master_readdata;
679
                                                ssync_chain_1 <= '1';
680
                                                if sreg_block(reg_ctrl)(reg_ctrl_cmb)='1' then
681 219 jguarin200
                                                        sdownload_chain <= DWBX;
682 211 jguarin200
                                                else
683 219 jguarin200
                                                        sdownload_chain <= DWAX;
684 211 jguarin200
                                                end if;
685
                                        when others =>
686
                                                null;
687
                                end case;
688
 
689
                                if srestart_chain='1' then
690
                                        sdownload_chain <= sdownload_start;
691
                                end if;
692
 
693
                        end if;
694
                end if;
695
        end process;
696
--! *************************************************************************************************************************************************************************************************************************************************************
697
--! AVALON MEMORY MAPPED MASTER FINISHED
698
--! *************************************************************************************************************************************************************************************************************************************************************
699
--! *************************************************************************************************************************************************************************************************************************************************************
700
--! AVALON MEMORY MAPPED SLAVE BEGINS =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>  =>
701
--! *************************************************************************************************************************************************************************************************************************************************************
702
        --! Master Slave Process: Proceso para la escritura y lectura de registros desde el NIOS II.
703
        low_register_bank:
704
        process (clk,rst,sreg_block)
705
        begin
706
                if rst=rstMasterValue then
707
                        for i in reg_scratch00 downto reg_vz loop
708
                                sreg_block(i) <= (others => '0');
709
                        end loop;
710
 
711
                        slave_readdata <= (others => '0');
712
                        sslave_address <= (others => '0');
713
                        sslave_writedata <= (others => '0');
714
                        sslave_write <= '0';
715
                        sslave_read <= '0';
716
                elsif clk'event and clk='1' then
717
 
718
 
719
                        sslave_address          <= slave_address;
720
                        sslave_write            <= slave_write;
721
                        sslave_read                     <= slave_read;
722
                        sslave_writedata        <= slave_writedata;
723
                        for i in reg_scratch00 downto reg_vz loop
724
                                if sslave_address=i then
725
                                        if sslave_write='1' then
726
                                                sreg_block(i) <= sslave_writedata;
727
                                        end if;
728
                                end if;
729
                        end loop;
730
                        for i in 15 downto 0 loop
731
                                if sslave_address=i then
732
                                        if sslave_read='1' then
733
                                                slave_readdata <= sreg_block(i);
734
                                        end if;
735
                                end if;
736
                        end loop;
737
                end if;
738
        end process;
739
--! *************************************************************************************************************************************************************************************************************************************************************
740
--! AVALON MEMORY MAPPED SLAVE FINISHED
741
--! *************************************************************************************************************************************************************************************************************************************************************
742
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------
743 217 jguarin200
        --! Control Register (reg_ctrl) BASE_ADDRESS + 0x0                                                                                                                                                                                              |
744 211 jguarin200
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------
745
        --! Bit No.     | Nombre        | Descripci&oacute;n                                                                                                                                                                                            |
746
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------
747 217 jguarin200
        --! 0           | cmb (rw)      | 1:    La operaci&oacute;n es combinatoria, por lo tanto cargan los primeros 3 valores en el Operando A y el           |
748
        --!                     |                       |               de vectores en el operando B.                                                                                                                                                           |
749 211 jguarin200
        --!                     |                       | 0:    La operaci&oacute;n no es combinatoria, se cargan vectores en los operandos A y B.                                                      |
750
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
751
        --!                     |                       |               Configuraci&oacute;n del Datapath, Interconexi&oacute;n del Pipeline Aritm&eacute;tico y Cadena de Carga        |
752
        --!                     |                       |               Dependiendo del valor de estos 3 bits se configura la operaci&oacute;n a ejecutar.                                                      |
753
        --!                     |                       |                                                                                                                                                                                                                                       |
754
        --! [3:1]       | dcs (rw)      | 011:  Producto Cruz                                                                                                                                                                                           |
755
        --!                     |                       | 000:  Suma Vectorial                                                                                                                                                                                          |
756
        --!                     |                       | 001:  Resta Vectorial                                                                                                                                                                                         |
757
        --!                     |                       | 110:  Normalizaci&oacute;n Vectorial y c&aacute;lculo de Magnitud Vectorial                                                                           |
758
        --!                     |                       | 100:  Producto Punto                                                                                                                                                                                          |
759
        --!                     |                       | 111:  Producto Simple                                                                                                                                                                                         |
760
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
761
        --! [5:4]       | vtsc (rw)     | 00:   Solo leer los resultados vectoriales.                                                                                                                                           |
762
        --!                     |                       | 01:   Solo leer los resultados escalares.                                                                                                                                                     |
763
        --!                     |                       | 10:   Solo leer los resultados vectoriales.                                                                                                                                           |
764
        --!                     |                       | 11:   Leer los resultados escalares y vectoriales.                                                                                                                            |
765
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
766 217 jguarin200
        --! 6           | dma (rw)      |  1:   Modo DMA: Los datos que ingresan se leen desde la direcci&oacute;n FETCHSTART (BASE+0x08) y se escriben en  |
767
        --!                     |                       |               la direcci&oacute;n SINKSTART (BASE+0x09).                                                                                                                                      |
768
        --!                     |                       |  0:   Modo Arithmetic Pipeline: Los datos ingresan en grupos de a 6 valores para 2 vectores de 3 valores cada uno,|
769
        --!                     |                       |               cuando se usa en modo uno a uno (cmb=1), &oacute; en grupos de 3 valores para 1 vector de 3 valores,            |
770
        --!                     |                       |               pero con el operando A fijado con el valor de la primera carga de valores en modo combinatorio (cmb=1).         |
771
        --!                     |                       |               De la misma manera que en modo DMA se cargan los operandos en la direcci&oacute;n FETCHSTART y se escriben      |
772
        --!                     |                       |               los resultados en la direcci&oacute;n SINKSTART.                                                                                                                        |
773
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
774
        --! 7           | flag_fc(r)|  1:       Al momento de generar una interrupci&oacute;n este bit se coloca en 1 si se cumplen las condiciones de          |
775
        --!                     |                       |               descarga de datos de la memoria (revisar el net signal sflood_condition). Si se encuentra en uno se                     |
776
        --!                     |                       |               tratar&iacute;a de una inconsistencia puesto que la interrupci&oacute;n se dispara una vez se ha terminado      |
777
        --!             |                       |               de ejecutar una instrucci&oacute;n y el que la bandera este en uno significa que hay transacciones de           |       
778
        --!                     |                       |               descarga de datos desde la memoria pendientes.                                                                                                                          |
779
        --!                     |                       |                                                                                                                                                                                                                                       |
780
        --!                     |                       |               En general que cualquiera de estas banderas se coloque en uno es una se&ntilde;alizacion de error, puesto       |
781
        --!                     |                       |               que una vez se ha terminado de ejecutar una instrucci&oacute;n no deben haber transacciones pendientes.         |
782
        --!                     |                       |               La raz&oacute;n de ser de estas banderas es hacer depuraci&oacute;n del hardware mas que del software.          |
783
        --!                     |                       |                                                                                                                                                                                                                                       |
784
        --!                     |                       |  0:   Flood Condition off.                                                                                                                                                                            |
785
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
786
        --! 8           | flag_dc(r)|  1:       Error, la instrucci&oacute;n ya se ejecut&oacute; y hay datos transitando en el buffer de salida aun.           |
787
        --!                     |                       |  0:   Drain Condition off.                                                                                                                                                                            |
788
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
789
        --! 9           | wp(r)         |  1:   Error, la instrucci&oacute;n ya se ejecut&oacute; y hay datos transitando en el buffer de salida aun.           |                                                                                                                                                                                       
790
        --!                     |                       |  0:   Write on Memory not pending.                                                                                                                                                            |
791
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
792
        --! 10          | pp(r)         |  1:   Error, la instrucci&oacute;n ya se ejecut&oacute;n y hay datos transitando el pipeline aritm&eacute;tico.       |
793
        --!                     |                       |  0:   Pipeline not pending.                                                                                                                                                                           |
794
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
795
        --! 11          | pl(r)         |  1:   La carga de parametros no se complet&oacute;. Esto por lo general pasa cuando uno va a realizar una                     |
796
        --!             |                       |               operaci&acute;n combinatoria y solo cargo el primer operando, el A, esto puede ocurrir porque por ejemplo       |
797
        --!                     |                       |               se puede desear sumar un conjunto de vectores a un vector de referencia. Este vector de referencia puede        |
798
        --!                     |                       |               estar en un area de memoria distinta, que el resto de los vectores. Por lo tanto el pseudo codigo para          |
799
        --!                     |                       |               ejecutar una operaci&oacute;n de este tipo seria:                                                                                                                       |
800
        --!                     |                       |                                                                                                                                                                                                                                       |       
801
        --!                     |                       |               ld vect,add,cmb;        //Resultados solo vectoriales, ejecutar operaci&oacute;n suma en modo combinatorio              |
802
        --!                     |                       |               ld &A;                          //Cargar la direccion del Vector A.                                                                                                             |
803
        --!                     |                       |               ld 3;                           //Cargar 3 valores, o sea el Vector A.                                                                                                  | 
804
        --!                     |                       |               wait int;                       //Esperar a que se ejecute la interrupcion. Una vez se termine de ejecutar si la bandera|
805
        --!                     |                       |                                                       //pl est&aacute; en uno se vuelve a comenzar y se deshecha el dato que hay como                 |
806
        --!                     |                       |                                                       //par&aacute;metro.     Para este ejemplo se asume que est&aacute en uno                                        |
807
        --!                     |                       |               ld &B;                          //Cargar la direcci&oacute;n donde se encuentran los vectores B                                                 |
808
        --!                     |                       |               ld &C;                          //Cargar la direcci&oacute;n donde se exribiran los resultados.                                                 |
809
        --!                     |                       |               ld 24;                          //Cargar los siguientes 24 valores a partir de &B correspondiente a 8 vectores                  |
810
        --!                     |                       |                                                       //ejecutando 8 sumas vectoriales que se escribir&iacute;n a apartir de &C                               |
811
        --!                     |                       |               wait int;                       //Esperar a que termine la ejecuci&oacute;n de las sumas.                                                               |
812
        --!                     |                       |                                                                                                                                                                                                                                       |
813
        --!                     |                       |  0:   Los operandos se cargaron integros se cargo del todo y no hubo que desechar parametros.                                         |
814
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
815
        --! 12          | dp (r)        |  1:   Error, la instrucci&oacute;n se termino y aun hay datos pendientes por ser descargados                                          |
816
        --!                     |                       |  0:   No hay datos pendientes por ser descargados.                                                                                                                            |
817
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
818
        --! 13          | ap (r)        |  1:   Carga de direcciones en la interconexi&oacute;n a&uacute;n est&aacute; pendiente y la instrucci&oacute; ya      |
819
        --!                     |                       |               se ejecut&oacute;                                                                                                                                                                                       |
820
        --!                     |                       |  0:   No hay direcciones pendientes por cargar.                                                                                                                                       |
821
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
822 211 jguarin200
        --! 14          | rlsc (rw)     | 1:    El sistema est&aacute; configurado para resetear la recarga sincronizada de par&aacute;metros una vez           |
823
        --!                     |                       |               concluya la instrucci&oacute;n                                                                                                                                                          |
824
        --!                     |                       |                                                                                                                                                                                                                                       |
825 217 jguarin200
        --!                     |                       | 0:    El sistema est&aacute; configurado para no resetear la cadena de sincronizaci&oacute;n de carga.                        |
826 211 jguarin200
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
827 217 jguarin200
        --! 15          | rom (r)       | 1: Los registros solo se pueden leer no se pueden escribir. Etsado SINK y SOURCE                                                                      |
828 211 jguarin200
        --!                     |                       | 0: Los registros se pueden leer y escribir.                                                                                                                                           |
829
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
830
        --! [30:16]     | nfetch(rw)| Cantidad de direcciones a cargar en la interconex&oacute;n para realizar la posterior descarga de datos de la     |
831
        --!                     |                       | memoria al RayTrac.
832
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
833
        --!     31              | irq           | 1:    Evento de interrupci&oacute;n. El usuario debe hacer clear de este bit para dar la interrupci&o;n por           |
834
        --!                     |                       |               por atendida. Este bit se pone en uno cuando el sistema pasa de estado TX a FETCH o FETCH a TX.                         |
835
        --!                     |                       |                                                                                                                                                                                                                                       |
836
        --!                     |                       | 0:    El RayTrac se encuentra en operaci&oacute;n Normal.                                                                                                                     |
837
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------
838 217 jguarin200
        --! Result Vector Z component (reg_vz)  BASE_ADDRESS + 0x4                                                                                                                                                                      |
839 211 jguarin200
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
840 217 jguarin200
        --! Result Vector Y component (reg_vy) BASE_ADDRESS + 0x8                                                                                                                                                                       |
841 211 jguarin200
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
842 217 jguarin200
        --! Result Vector X component (reg_vx) BASE_ADDRESS + 0xC                                                                                                                                                                       |
843 211 jguarin200
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
844 217 jguarin200
        --! Result Vector Scalar component (reg_scalar) BASE_ADDRESS + 0x10                                                                                                                                                     |
845 211 jguarin200
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
846 217 jguarin200
        --! Scratch Vector 00   (reg_scratch00) BASE_ADDRESS +  0x14                                                                                                                                                            |
847 211 jguarin200
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
848 217 jguarin200
        --! output Data Counter (reg_outputcounter) BASE_ADDRESS + 0x18                                                                                                                                                         |
849 211 jguarin200
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
850 217 jguarin200
        --! Input Data Counter  (reg_inputcounter) BASE_ADDRESS + 0x1C                                                                                                                                                          |
851
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
852
        --! Data Fetch Start Address (reg_fetchstart) BASE_ADDRESS + 0x20                                                                                                                                                       |
853
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
854
        --! Data Write Start Address (reg_sinkstart) BASE_ADDRESS + 0x24                                                                                                                                                        |
855
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
856 219 jguarin200
        --! Parameter AX component (reg_ax) BASE_ADDRESS + 0x28                                                                                                                                                                         |
857 217 jguarin200
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
858
        --! Parameter Ay component (reg_ay) BASE_ADDRESS + 0x2C                                                                                                                                                                         |
859
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
860
        --! Parameter Az component (reg_az) BASE_ADDRESS + 0x30                                                                                                                                                                         |
861
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
862
        --! Parameter Bx component (reg_bx) BASE_ADDRESS + 0x34                                                                                                                                                                         |
863
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
864
        --! Parameter By component (reg_by) BASE_ADDRESS + 0x38                                                                                                                                                                         |
865
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|
866
        --! Parameter Bz component (reg_bz) BASE_ADDRESS + 0x3C                                                                                                                                                                         |
867
        --!---------|-----------|-------------------------------------------------------------------------------------------------------------------|   
868
 
869
 
870
 
871
 
872
 
873
 
874
end architecture;
875
 

powered by: WebSVN 2.1.0

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