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

Subversion Repositories raytrac

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

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

powered by: WebSVN 2.1.0

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