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

Subversion Repositories pcie_sg_dma

[/] [pcie_sg_dma/] [trunk/] [rtl/] [rx_MRd_Channel.vhd] - Blame information for rev 12

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

Line No. Rev Author Line
1 2 weng_ziti
----------------------------------------------------------------------------------
2
-- Company:  ziti, Uni. HD
3
-- Engineer:  wgao
4
-- 
5
-- Design Name: 
6
-- Module Name:    rx_MRd_Transact - Behavioral 
7
-- Project Name: 
8
-- Target Devices: 
9
-- Tool versions: 
10
-- Description: 
11
--
12
-- Dependencies: 
13
--
14
-- Revision 1.00 - first release.  14.12.2006
15
-- 
16
-- Additional Comments: 
17
--
18
----------------------------------------------------------------------------------
19
 
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_ARITH.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
 
25
library work;
26
use work.abb64Package.all;
27
 
28
-- Uncomment the following library declaration if instantiating
29
-- any Xilinx primitives in this code.
30
--library UNISIM;
31
--use UNISIM.VComponents.all;
32
 
33
entity rx_MRd_Transact is
34
    port (
35
      -- Transaction receive interface
36
      trn_rsof_n         : IN  std_logic;
37
      trn_reof_n         : IN  std_logic;
38
      trn_rd             : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
39
      trn_rrem_n         : IN  std_logic_vector(C_DBUS_WIDTH/8-1 downto 0);
40
      trn_rerrfwd_n      : IN  std_logic;
41
      trn_rsrc_rdy_n     : IN  std_logic;
42
--      trn_rdst_rdy_n     : OUT std_logic;
43
      trn_rnp_ok_n       : OUT std_logic;
44
      trn_rsrc_dsc_n     : IN std_logic;
45
      trn_rbar_hit_n     : IN  std_logic_vector(C_BAR_NUMBER-1 downto 0);
46
--      trn_rfc_ph_av      : IN  std_logic_vector(7 downto 0);
47
--      trn_rfc_pd_av      : IN  std_logic_vector(11 downto 0);
48
--      trn_rfc_nph_av     : IN  std_logic_vector(7 downto 0);
49
--      trn_rfc_npd_av     : IN  std_logic_vector(11 downto 0);
50
--      trn_rfc_cplh_av    : IN  std_logic_vector(7 downto 0);
51
--      trn_rfc_cpld_av    : IN  std_logic_vector(11 downto 0);
52
 
53
      IORd_Type          : IN  std_logic;
54
      MRd_Type           : IN  std_logic_vector(3 downto 0);
55
      Tlp_straddles_4KB  : IN  std_logic;
56
 
57
      -- MRd Channel
58
      pioCplD_Req        : OUT std_logic;
59
      pioCplD_RE         : IN  std_logic;
60
      pioCplD_Qout       : OUT std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
61
--      FIFO_Data_Count    : IN  std_logic_vector(C_FIFO_DC_WIDTH-1 downto 0);
62
      FIFO_Empty         : IN  std_logic;
63
      FIFO_Reading       : IN  std_logic;
64
      pio_FC_stop        : IN  std_logic;
65
      pio_reading_status : OUT std_logic;
66
 
67
      -- Channel reset (from MWr channel)
68
      Channel_Rst        : IN  std_logic;
69
 
70
      -- Common ports
71
      trn_clk            : IN  std_logic;
72
      trn_reset_n        : IN  std_logic;
73
      trn_lnk_up_n       : IN  std_logic
74
    );
75
 
76
end entity rx_MRd_Transact;
77
 
78
 
79
architecture Behavioral of rx_MRd_Transact is
80
 
81
  type RxMRdTrnStates is         ( ST_MRd_RESET
82
                                 , ST_MRd_IDLE
83
                                 , ST_MRd_HEAD2
84
                                 , ST_MRd_Tail
85
                                 );
86
 
87
  -- State variables
88
  signal RxMRdTrn_NextState      : RxMRdTrnStates;
89
  signal RxMRdTrn_State          : RxMRdTrnStates;
90
 
91
  -- trn_rx stubs            
92
  signal  trn_rsof_n_i           : std_logic;
93
  signal  trn_reof_n_i           : std_logic;
94
  signal  trn_rd_i               : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
95
  signal  trn_rrem_n_i           : std_logic_vector(C_DBUS_WIDTH/8-1 downto 0);
96
  signal  trn_rbar_hit_n_i       : std_logic_vector(C_BAR_NUMBER-1 downto 0);
97
  signal  trn_rerrfwd_n_i        : std_logic;
98
 
99
  -- delays
100
  signal  trn_rd_r1              : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
101
  signal  trn_rbar_hit_n_r1      : std_logic_vector(C_BAR_NUMBER-1 downto 0);
102
 
103
  -- BAR encoded
104
  signal  Encoded_BAR_Index      : std_logic_vector(C_ENCODE_BAR_NUMBER-1 downto 0);
105
 
106
  -- Reset
107
  signal  local_Reset            : std_logic;
108
 
109
  -- Output signals
110
--  signal  trn_rdst_rdy_n_i       : std_logic;
111
  signal  trn_rnp_ok_n_i         : std_logic;
112
  signal  trn_rsrc_dsc_n_i       : std_logic;
113
 
114
  -- Throttle
115
  signal  trn_rx_throttle        : std_logic;
116
 
117
  signal  pio_reading_status_i   : std_logic;
118
  signal  pio_read_fading_cnt    : std_logic_vector(8-1 downto 0);
119
  signal  MRd_Has_3DW_Header     : std_logic;
120
  signal  MRd_Has_4DW_Header     : std_logic;
121
  signal  Tlp_is_Zero_Length     : std_logic;
122
  signal  Illegal_Leng_on_FIFO   : std_logic;
123
 
124
  -- Built-in single-port fifo as MRd channel buffer
125
  component v5sfifo_15x128
126
    port (
127
          clk                  : IN  std_logic;
128
          rst                  : IN  std_logic;
129
          prog_full            : OUT std_logic;
130
--          wr_clk               : IN  std_logic;
131
          wr_en                : IN  std_logic;
132
          din                  : IN  std_logic_VECTOR(C_CHANNEL_BUF_WIDTH-1 downto 0);
133
          full                 : OUT std_logic;
134
--          rd_clk               : IN  std_logic;
135
          rd_en                : IN  std_logic;
136
          dout                 : OUT std_logic_VECTOR(C_CHANNEL_BUF_WIDTH-1 downto 0);
137
          prog_empty           : OUT std_logic;
138
          empty                : OUT std_logic
139
    );
140
  end component;
141
 
142
 
143
  -- Signal with MRd channel FIFO
144
  signal  pioCplD_din            : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
145
  signal  pioCplD_Qout_wire      : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
146
  signal  pioCplD_RE_i           : std_logic;
147
  signal  pioCplD_we             : std_logic;
148
  signal  pioCplD_empty_i        : std_logic;
149
  signal  pioCplD_full           : std_logic;
150
  signal  pioCplD_prog_Full      : std_logic;
151
  signal  pioCplD_empty_r1       : std_logic;
152
  signal  pioCplD_prog_full_r1   : std_logic;
153
 
154
  signal  pioCplD_Qout_i         : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
155
  signal  pioCplD_Qout_reg       : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
156
 
157
  -- Request for output arbitration
158
  signal  pioCplD_Req_i        : std_logic;
159
  signal  pioCplD_Leng         : std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0);
160
 
161
  -- Busy/Done state bits generation
162
  type FSM_Request is         (
163
                                 REQST_Idle
164
                               , REQST_1Read
165
                               , REQST_Decision
166
                               , REQST_nFIFO_Req
167
--                               , REQST_Quantity
168
--                               , REQST_FIFO_Req
169
                               );
170
 
171
  signal FSM_REQ_pio          : FSM_Request;
172
 
173
begin
174
 
175
   -- positive reset and local
176
   local_Reset       <= not trn_reset_n or Channel_Rst;
177
 
178
 
179
   -- MRd channel buffer control
180
--   pioCplD_RE_i      <= pioCplD_RE;
181
 
182
   pioCplD_Qout      <= pioCplD_Qout_i;
183
   pioCplD_Req       <= pioCplD_Req_i;  -- and not FIFO_Reading;
184
 
185
   pio_reading_status  <= pio_reading_status_i;
186
 
187
 
188
   -- Output to the core as handshaking
189
   trn_rsof_n_i      <= trn_rsof_n;
190
   trn_reof_n_i      <= trn_reof_n;
191
   trn_rd_i          <= trn_rd;
192
   trn_rrem_n_i      <= trn_rrem_n;
193
   trn_rerrfwd_n_i   <= trn_rerrfwd_n;
194
   trn_rsrc_dsc_n_i  <= trn_rsrc_dsc_n;
195
   trn_rbar_hit_n_i  <= trn_rbar_hit_n;
196
 
197
   -- Output to the core as handshaking
198
   trn_rnp_ok_n      <= trn_rnp_ok_n_i;
199
   trn_rnp_ok_n_i    <= pioCplD_prog_full_r1;
200
 
201
   -- ( trn_rsrc_rdy_n seems never deasserted during packet)
202
   trn_rx_throttle   <= trn_rsrc_rdy_n;    --  or trn_rdst_rdy_n_i;
203
 
204
 
205
-- ------------------------------------------------
206
-- Synchronous Delay: trn_rd + trn_rbar_hit_n
207
-- 
208
   Synch_Delay_trn_rd:
209
   process ( trn_clk )
210
   begin
211
      if trn_clk'event and trn_clk = '1' then
212
         trn_rd_r1          <= trn_rd_i;
213
         trn_rbar_hit_n_r1  <= trn_rbar_hit_n_i;
214
      end if;
215
 
216
   end process;
217
 
218
 
219
-- ------------------------------------------------
220
-- States synchronous
221
--
222
   Syn_RxTrn_States:
223
   process ( trn_clk, local_Reset)
224
   begin
225
      if local_Reset = '1' then
226
         RxMRdTrn_State   <= ST_MRd_RESET;
227
      elsif trn_clk'event and trn_clk = '1' then
228
         RxMRdTrn_State   <= RxMRdTrn_NextState;
229
      end if;
230
 
231
   end process;
232
 
233
 
234
-- Next States
235
   Comb_RxTrn_NextStates:
236
   process (
237
             RxMRdTrn_State
238
           , MRd_Type
239
--           , IORd_Type
240
           , trn_rx_throttle
241
           , trn_rnp_ok_n_i
242
           , trn_rsrc_dsc_n_i
243
           , trn_rerrfwd_n_i
244
           )
245
   begin
246
     case RxMRdTrn_State  is
247
 
248
        when ST_MRd_RESET =>
249
              RxMRdTrn_NextState <= ST_MRd_IDLE;
250
 
251
        when ST_MRd_IDLE =>
252
 
253
           if trn_rnp_ok_n_i='0' then
254
 
255
            case MRd_Type is
256
 
257
             when C_TLP_TYPE_IS_MRD_H3 =>
258
               RxMRdTrn_NextState <= ST_MRd_HEAD2;
259
             when C_TLP_TYPE_IS_MRD_H4 =>
260
               RxMRdTrn_NextState <= ST_MRd_HEAD2;
261
             when C_TLP_TYPE_IS_MRDLK_H3 =>
262
               RxMRdTrn_NextState <= ST_MRd_HEAD2;
263
             when C_TLP_TYPE_IS_MRDLK_H4 =>
264
               RxMRdTrn_NextState <= ST_MRd_HEAD2;
265
             when OTHERS =>
266
--               if IORd_Type='1' then   -- Temp taking IORd as MRd3
267
--                 RxMRdTrn_NextState <= ST_MRd3_HEAD1;
268
--               else
269
                 RxMRdTrn_NextState <= ST_MRd_IDLE;
270
--               end if;
271
 
272
            end case;  -- MRd_Type
273
 
274
           else
275
             RxMRdTrn_NextState <= ST_MRd_IDLE;
276
           end if;
277
 
278
 
279
        when ST_MRd_HEAD2 =>
280
           if trn_rx_throttle = '1' then
281
              RxMRdTrn_NextState <= ST_MRd_HEAD2;
282
           else
283
              RxMRdTrn_NextState <= ST_MRd_Tail;
284
           end if;
285
 
286
 
287
        when ST_MRd_Tail =>      -- support back-to-back transactions
288
 
289
           if trn_rnp_ok_n_i='0' then
290
 
291
            case MRd_Type is
292
 
293
             when C_TLP_TYPE_IS_MRD_H3 =>
294
               RxMRdTrn_NextState <= ST_MRd_HEAD2;
295
             when C_TLP_TYPE_IS_MRD_H4 =>
296
               RxMRdTrn_NextState <= ST_MRd_HEAD2;
297
             when C_TLP_TYPE_IS_MRDLK_H3 =>
298
               RxMRdTrn_NextState <= ST_MRd_HEAD2;
299
             when C_TLP_TYPE_IS_MRDLK_H4 =>
300
               RxMRdTrn_NextState <= ST_MRd_HEAD2;
301
             when OTHERS =>
302
--               if IORd_Type='1' then   -- Temp taking IORd as MRd3
303
--                 RxMRdTrn_NextState <= ST_MRd3_HEAD1;
304
--               else
305
                 RxMRdTrn_NextState <= ST_MRd_IDLE;
306
--               end if;
307
 
308
            end case;  -- MRd_Type
309
 
310
           else
311
             RxMRdTrn_NextState <= ST_MRd_IDLE;
312
           end if;
313
 
314
        when OTHERS =>
315
           RxMRdTrn_NextState <= ST_MRd_RESET;
316
 
317
     end case;
318
 
319
   end process;
320
 
321
 
322
 
323
-- ------------------------------------------------
324
-- Synchronous calculation: Encoded_BAR_Index
325
-- 
326
   Syn_Calc_Encoded_BAR_Index:
327
   process ( trn_clk, local_Reset)
328
   begin
329
      if local_Reset = '1' then
330
         Encoded_BAR_Index <= (OTHERS=>'1');
331
 
332
      elsif trn_clk'event and trn_clk = '1' then
333
 
334
         if    trn_rbar_hit_n(0)='0' then
335
            Encoded_BAR_Index <= CONV_STD_LOGIC_VECTOR(0, C_ENCODE_BAR_NUMBER);
336
         elsif trn_rbar_hit_n(1)='0' then
337
            Encoded_BAR_Index <= CONV_STD_LOGIC_VECTOR(1, C_ENCODE_BAR_NUMBER);
338
         elsif trn_rbar_hit_n(2)='0' then
339
            Encoded_BAR_Index <= CONV_STD_LOGIC_VECTOR(2, C_ENCODE_BAR_NUMBER);
340
         elsif trn_rbar_hit_n(3)='0' then
341
            Encoded_BAR_Index <= CONV_STD_LOGIC_VECTOR(3, C_ENCODE_BAR_NUMBER);
342
         elsif trn_rbar_hit_n(4)='0' then
343
            Encoded_BAR_Index <= CONV_STD_LOGIC_VECTOR(4, C_ENCODE_BAR_NUMBER);
344
         elsif trn_rbar_hit_n(5)='0' then
345
            Encoded_BAR_Index <= CONV_STD_LOGIC_VECTOR(5, C_ENCODE_BAR_NUMBER);
346
         elsif trn_rbar_hit_n(6)='0' then
347
            Encoded_BAR_Index <= CONV_STD_LOGIC_VECTOR(6, C_ENCODE_BAR_NUMBER);
348
         else
349
            Encoded_BAR_Index <= CONV_STD_LOGIC_VECTOR(7, C_ENCODE_BAR_NUMBER);
350
         end if;
351
 
352
      end if;
353
   end process;
354
 
355
 
356
-- ----------------------------------------------------------------------------------
357
-- 
358
-- Synchronous output: MRd FIFO write port
359
-- 
360
-- PIO Channel Buffer (128-bit) definition:
361
--     Note: Type not shows in this buffer
362
--
363
--  127 ~ xxx : Peripheral address
364
--  xxy ~  97 : reserved
365
--         96 : Zero-length
366
--         95 : reserved
367
--         94 : Valid
368
--   93 ~  68 : reserved
369
--   67 ~  65 : BAR number
370
--   64 ~  49 : Requester ID
371
--   48 ~  41 : Tag
372
--   40 ~  34 : Lower Address
373
--   33 ~  31 : Completion Status
374
--   30 ~  19 : Byte count
375
--
376
--   18 ~  17 : Format
377
--   16 ~  14 : TC
378
--         13 : TD
379
--         12 : EP
380
--   11 ~  10 : Attribute
381
--    9 ~   0 : Length
382
-- 
383
   RxFSM_Output_pioCplD_WR:
384
   process ( trn_clk, local_Reset)
385
   begin
386
      if local_Reset = '1' then
387
         pioCplD_we  <= '0';
388
         pioCplD_din <= (OTHERS=>'0');
389
 
390
      elsif trn_clk'event and trn_clk = '1' then
391
 
392
         case RxMRdTrn_State is
393
 
394
 
395
            when ST_MRd_HEAD2 =>
396
               pioCplD_we  <= '0';
397
 
398
               if Illegal_Leng_on_FIFO='1' then          -- Cpl : unsupported request
399
                 pioCplD_din(C_CHBUF_FMT_BIT_TOP downto C_CHBUF_FMT_BIT_BOT)
400
                             <= C_FMT3_NO_DATA;
401
                 pioCplD_din(C_CHBUF_CPLD_CS_BIT_TOP downto C_CHBUF_CPLD_CS_BIT_BOT)
402
                             <= "001";      --------------- ############
403
               else
404
                 pioCplD_din(C_CHBUF_FMT_BIT_TOP downto C_CHBUF_FMT_BIT_BOT)
405
                             <= C_FMT3_WITH_DATA;
406
                 pioCplD_din(C_CHBUF_CPLD_CS_BIT_TOP downto C_CHBUF_CPLD_CS_BIT_BOT)
407
                             <= "000";      --------------- ############
408
               end if;
409
 
410
 
411
               pioCplD_din(C_CHBUF_TC_BIT_TOP downto C_CHBUF_TC_BIT_BOT)
412
                           <= trn_rd_r1(C_TLP_TC_BIT_TOP downto C_TLP_TC_BIT_BOT);
413
 
414
               pioCplD_din(C_CHBUF_TD_BIT)  <= '0';
415
 
416
               pioCplD_din(C_CHBUF_EP_BIT)  <= '0';
417
 
418
               pioCplD_din(C_CHBUF_ATTR_BIT_TOP downto C_CHBUF_ATTR_BIT_BOT)
419
--                           <= trn_rd_r1(C_TLP_ATTR_BIT_TOP) & C_NO_SNOOP;  -- downto C_TLP_ATTR_BIT_BOT);
420
                           <= trn_rd_r1(C_TLP_ATTR_BIT_TOP downto C_TLP_ATTR_BIT_BOT);
421
 
422
               pioCplD_din(C_CHBUF_LENG_BIT_TOP downto C_CHBUF_LENG_BIT_BOT)
423
                             <= trn_rd_r1(C_TLP_LENG_BIT_TOP downto C_TLP_LENG_BIT_BOT);
424
 
425
               pioCplD_din(C_CHBUF_QVALID_BIT)  <= '1';
426
 
427
               pioCplD_din(C_CHBUF_CPLD_REQID_BIT_TOP downto C_CHBUF_CPLD_REQID_BIT_BOT)
428
                           <= trn_rd_r1(C_TLP_REQID_BIT_TOP downto C_TLP_REQID_BIT_BOT);
429
 
430
               pioCplD_din(C_CHBUF_CPLD_TAG_BIT_TOP downto C_CHBUF_CPLD_TAG_BIT_BOT)
431
                           <= trn_rd_r1(C_TLP_TAG_BIT_TOP downto C_TLP_TAG_BIT_BOT);
432
 
433
               pioCplD_din(C_CHBUF_0LENG_BIT) <= Tlp_is_Zero_Length;
434
 
435
               if Tlp_is_Zero_Length='1' then
436
                 pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
437
                           <= CONV_STD_LOGIC_VECTOR(0, C_ENCODE_BAR_NUMBER);
438
---- ** begin: avoid PIO read blocking
439
--               elsif trn_rbar_hit_n_r1(CINT_FIFO_SPACE_BAR)='0' and FIFO_Empty='1' then
440
--                 pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
441
--                           <= CONV_STD_LOGIC_VECTOR(0, C_ENCODE_BAR_NUMBER);
442
---- ** end
443
               else
444
                 pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
445
                           <= Encoded_BAR_Index;
446
               end if;
447
 
448
 
449
            when ST_MRd_Tail =>
450
 
451
              if MRd_Has_4DW_Header='1' then
452
                pioCplD_din(C_CHBUF_CPLD_LA_BIT_TOP downto C_CHBUF_CPLD_LA_BIT_BOT)
453
                             <= trn_rd_r1(C_CHBUF_CPLD_LA_BIT_TOP-C_CHBUF_CPLD_LA_BIT_BOT downto 0);
454
 
455
                if trn_rbar_hit_n_r1(CINT_REGS_SPACE_BAR)='0' then
456
                   pioCplD_din(C_CHBUF_PA_BIT_TOP downto C_CHBUF_PA_BIT_BOT)
457
                               <= trn_rd_r1(C_CHBUF_PA_BIT_TOP-C_CHBUF_PA_BIT_BOT downto 0);
458
--                   pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
459
--                               <= CONV_STD_LOGIC_VECTOR(CINT_REGS_SPACE_BAR, C_ENCODE_BAR_NUMBER);   --- "000";
460
                elsif trn_rbar_hit_n_r1(CINT_BRAM_SPACE_BAR)='0' then
461
                   pioCplD_din(C_CHBUF_MA_BIT_TOP downto C_CHBUF_MA_BIT_BOT)
462
                               <= trn_rd_r1(C_CHBUF_MA_BIT_TOP-C_CHBUF_MA_BIT_BOT downto 0);
463
--                   pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
464
--                               <= CONV_STD_LOGIC_VECTOR(CINT_BRAM_SPACE_BAR, C_ENCODE_BAR_NUMBER);   --- "001";
465
                elsif trn_rbar_hit_n_r1(CINT_DDR_SPACE_BAR)='0' then
466
                   pioCplD_din(C_CHBUF_DDA_BIT_TOP downto C_CHBUF_DDA_BIT_BOT)
467
                               <= trn_rd_r1(C_CHBUF_DDA_BIT_TOP-C_CHBUF_DDA_BIT_BOT downto 0);
468
--                   pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
469
--                               <= CONV_STD_LOGIC_VECTOR(CINT_DDR_SPACE_BAR, C_ENCODE_BAR_NUMBER);   --- "001";
470
                else
471
                   pioCplD_din(C_CHBUF_PA_BIT_TOP downto C_CHBUF_PA_BIT_BOT)
472
                               <= C_ALL_ZEROS(C_CHBUF_PA_BIT_TOP downto C_CHBUF_PA_BIT_BOT);
473
--                   pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
474
--                               <= C_ALL_ONES(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT);    --- "111" !!!
475
                end if;
476
 
477
              else
478
                pioCplD_din(C_CHBUF_CPLD_LA_BIT_TOP downto C_CHBUF_CPLD_LA_BIT_BOT)
479
                             <= trn_rd_r1(C_CHBUF_CPLD_LA_BIT_TOP-C_CHBUF_CPLD_LA_BIT_BOT+32 downto 32);
480
 
481
                if trn_rbar_hit_n_r1(CINT_REGS_SPACE_BAR)='0' then
482
                   pioCplD_din(C_CHBUF_PA_BIT_TOP downto C_CHBUF_PA_BIT_BOT)
483
                               <= trn_rd_r1(C_CHBUF_PA_BIT_TOP-C_CHBUF_PA_BIT_BOT+32 downto 32);
484
--                   pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
485
--                               <= CONV_STD_LOGIC_VECTOR(CINT_REGS_SPACE_BAR, C_ENCODE_BAR_NUMBER);   --- "000";
486
                elsif trn_rbar_hit_n_r1(CINT_BRAM_SPACE_BAR)='0' then
487
                   pioCplD_din(C_CHBUF_MA_BIT_TOP downto C_CHBUF_MA_BIT_BOT)
488
                               <= trn_rd_r1(C_CHBUF_MA_BIT_TOP-C_CHBUF_MA_BIT_BOT+32 downto 32);
489
--                   pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
490
--                               <= CONV_STD_LOGIC_VECTOR(CINT_BRAM_SPACE_BAR, C_ENCODE_BAR_NUMBER);   --- "001";
491
                elsif trn_rbar_hit_n_r1(CINT_DDR_SPACE_BAR)='0' then
492
                   pioCplD_din(C_CHBUF_DDA_BIT_TOP downto C_CHBUF_DDA_BIT_BOT)
493
                               <= trn_rd_r1(C_CHBUF_DDA_BIT_TOP-C_CHBUF_DDA_BIT_BOT+32 downto 32);
494
--                   pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
495
--                               <= CONV_STD_LOGIC_VECTOR(CINT_DDR_SPACE_BAR, C_ENCODE_BAR_NUMBER);   --- "001";
496
                else
497
                   pioCplD_din(C_CHBUF_PA_BIT_TOP downto C_CHBUF_PA_BIT_BOT)
498
                               <= C_ALL_ZEROS(C_CHBUF_PA_BIT_TOP downto C_CHBUF_PA_BIT_BOT);
499
--                   pioCplD_din(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
500
--                               <= C_ALL_ONES(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT);    --- "111" !!!
501
                end if;
502
              end if;
503
 
504
 
505
              if pioCplD_din(C_CHBUF_0LENG_BIT) ='1' then   --  Zero-length
506
                 pioCplD_din(C_CHBUF_CPLD_BC_BIT_TOP downto C_CHBUF_CPLD_BC_BIT_BOT)
507
                          <= CONV_STD_LOGIC_VECTOR(1, C_CHBUF_CPLD_BC_BIT_TOP-C_CHBUF_CPLD_BC_BIT_BOT+1);
508
              else
509
                 pioCplD_din(C_CHBUF_CPLD_BC_BIT_TOP downto C_CHBUF_CPLD_BC_BIT_BOT)
510
                          <= pioCplD_din(C_CHBUF_LENG_BIT_TOP downto C_CHBUF_LENG_BIT_BOT) &"00";
511
              end if;
512
 
513
--              if trn_rbar_hit_n_r1(CINT_REGS_SPACE_BAR)='0'
514
--                 or trn_rbar_hit_n_r1(CINT_BRAM_SPACE_BAR)='0' 
515
--                 then
516
              if trn_rbar_hit_n_r1(CINT_BAR_SPACES-1 downto 0) /= C_ALL_ONES(CINT_BAR_SPACES-1 downto 0) then
517
                 pioCplD_we  <= not Tlp_straddles_4KB;                    --'1';
518
              else
519
                 pioCplD_we  <= '0';
520
              end if;
521
 
522
 
523
            when OTHERS =>
524
               pioCplD_we  <= '0';
525
               pioCplD_din <= pioCplD_din;
526
 
527
         end case;
528
 
529
      end if;
530
   end process;
531
 
532
 
533
-- -----------------------------------------------------------------------
534
-- Capture: MRd_Has_4DW_Header
535
--        : Tlp_is_Zero_Length
536
-- 
537
   Syn_Capture_MRd_Has_4DW_Header:
538
   process ( trn_clk, trn_reset_n)
539
   begin
540
      if trn_reset_n = '0' then
541
         MRd_Has_3DW_Header   <= '0';
542
         MRd_Has_4DW_Header   <= '0';
543
         Tlp_is_Zero_Length   <= '0';
544
         Illegal_Leng_on_FIFO <= '0';
545
      elsif trn_clk'event and trn_clk = '1' then
546
         if trn_rsof_n_i='0' then
547
            MRd_Has_3DW_Header   <= not trn_rd_i(C_TLP_FMT_BIT_BOT) and not trn_rd_i(C_TLP_FMT_BIT_BOT+1);
548
            MRd_Has_4DW_Header   <= trn_rd_i(C_TLP_FMT_BIT_BOT) and not trn_rd_i(C_TLP_FMT_BIT_BOT+1);
549
            Tlp_is_Zero_Length   <= not (trn_rd_i(3) or trn_rd_i(2) or trn_rd_i(1) or trn_rd_i(0));
550
            if     trn_rd_i(C_TLP_LENG_BIT_TOP downto C_TLP_LENG_BIT_BOT)/=CONV_STD_LOGIC_VECTOR(1, C_TLP_FLD_WIDTH_OF_LENG)
551
               and trn_rd_i(C_TLP_LENG_BIT_TOP downto C_TLP_LENG_BIT_BOT)/=CONV_STD_LOGIC_VECTOR(2, C_TLP_FLD_WIDTH_OF_LENG)
552
               and trn_rbar_hit_n(CINT_FIFO_SPACE_BAR)='0'
553
               then
554
              Illegal_Leng_on_FIFO  <= '1';
555
            else
556
              Illegal_Leng_on_FIFO  <= '0';
557
            end if;
558
         else
559
            MRd_Has_3DW_Header    <= MRd_Has_3DW_Header;
560
            MRd_Has_4DW_Header    <= MRd_Has_4DW_Header;
561
            Tlp_is_Zero_Length    <= Tlp_is_Zero_Length;
562
            Illegal_Leng_on_FIFO  <= Illegal_Leng_on_FIFO;
563
         end if;
564
      end if;
565
   end process;
566
 
567
 
568
-- -----------------------------------------------------------------------
569
-- syn
570
--        : pio_reading_status
571
-- 
572
   Syn_PIO_Reading_EB_Status:
573
   process ( trn_clk, trn_reset_n)
574
   begin
575
      if trn_reset_n = '0' then
576
         pio_reading_status_i <= '0';
577
         pio_read_fading_cnt  <= (OTHERS=>'0');
578
      elsif trn_clk'event and trn_clk = '1' then
579
         if trn_reof_n_i='0' then
580
            if  MRd_Has_4DW_Header='1'
581
            and trn_rbar_hit_n(CINT_REGS_SPACE_BAR)='0'
582
            and trn_rd_i(8-1 downto 0)=X"90" then
583
                pio_reading_status_i <= '1';
584
                pio_read_fading_cnt  <= X"E0";
585
            elsif MRd_Has_3DW_Header='1'
586
            and trn_rbar_hit_n(CINT_REGS_SPACE_BAR)='0'
587
            and trn_rd_i(32+8-1 downto 32)=X"90" then
588
                pio_reading_status_i <= '1';
589
                pio_read_fading_cnt  <= X"E0";
590
            elsif pio_read_fading_cnt(7)='1' then
591
                pio_reading_status_i <= '1';
592
                pio_read_fading_cnt  <= pio_read_fading_cnt + '1';
593
            else
594
                pio_reading_status_i <= '0';
595
                pio_read_fading_cnt  <= (OTHERS=>'0');
596
            end if;
597
         elsif pio_read_fading_cnt=X"00" then
598
                pio_reading_status_i <= '0';
599
                pio_read_fading_cnt  <= (OTHERS=>'0');
600
         else
601
                pio_reading_status_i <= pio_reading_status_i;
602
                pio_read_fading_cnt  <= pio_read_fading_cnt + '1';
603
         end if;
604
 
605
      end if;
606
   end process;
607
 
608
 
609
   -- -------------------------------------------------
610
   -- MRd TLP Buffer
611
   -- -------------------------------------------------
612
   pioCplD_Buffer:
613
   v5sfifo_15x128
614
      port map (
615
         clk           => trn_clk,
616
         rst           => local_Reset,
617
         prog_full     => pioCplD_prog_Full,
618
--         wr_clk        => trn_clk,
619
         wr_en         => pioCplD_we,
620
         din           => pioCplD_din,
621
         full          => pioCplD_full,
622
--         rd_clk        => trn_clk,
623
         rd_en         => pioCplD_RE_i,
624
         dout          => pioCplD_Qout_wire,
625
         prog_empty    => open,
626
         empty         => pioCplD_empty_i
627
       );
628
 
629
 
630
-- ---------------------------------------------
631
--  Request for arbitration
632
-- 
633
   Synch_Req_Proc:
634
   process (local_Reset, trn_clk )
635
   begin
636
      if local_Reset = '1' then
637
         pioCplD_RE_i     <= '0';
638
         pioCplD_Qout_i   <= (OTHERS=>'0');
639
         pioCplD_Qout_reg <= (OTHERS=>'0');
640
         pioCplD_Leng     <= (0=>'1', OTHERS=>'0');
641
         pioCplD_Req_i    <= '0';
642
         FSM_REQ_pio      <= REQST_IDLE;
643
 
644
      elsif trn_clk'event and trn_clk = '1' then
645
 
646
         case FSM_REQ_pio  is
647
 
648
           when REQST_IDLE  =>
649
             if pioCplD_empty_i = '0' then
650
               pioCplD_RE_i   <= '1';
651
               pioCplD_Req_i  <= '0';
652
               pioCplD_Qout_i <= pioCplD_Qout_i;
653
               FSM_REQ_pio    <= REQST_1Read;
654
             else
655
               pioCplD_RE_i   <= '0';
656
               pioCplD_Req_i  <= '0';
657
               pioCplD_Qout_i <= pioCplD_Qout_i;
658
               FSM_REQ_pio    <= REQST_IDLE;
659
             end if;
660
 
661
           when REQST_1Read  =>
662
             pioCplD_RE_i   <= '0';
663
             pioCplD_Req_i  <= '0';
664
             pioCplD_Qout_i <= pioCplD_Qout_i;
665
             FSM_REQ_pio    <= REQST_Decision;
666
 
667
           when REQST_Decision  =>
668
             pioCplD_Qout_reg  <= pioCplD_Qout_wire;
669
             pioCplD_Leng      <= pioCplD_Qout_wire(C_CHBUF_LENG_BIT_TOP downto C_CHBUF_LENG_BIT_BOT);
670
             pioCplD_Qout_i    <= pioCplD_Qout_i;
671
--             if pioCplD_Qout_wire(C_CHBUF_FMT_BIT_TOP) = '1'  -- Has Payload
672
--               and pioCplD_Qout_wire(C_CHBUF_CPLD_BAR_BIT_TOP downto C_CHBUF_CPLD_BAR_BIT_BOT)
673
--                   =CONV_STD_LOGIC_VECTOR(CINT_FIFO_SPACE_BAR, C_ENCODE_BAR_NUMBER) 
674
--               then
675
--               pioCplD_RE_i  <= '0';
676
--               pioCplD_Req_i <= '0';
677
--               FSM_REQ_pio   <= REQST_Quantity;
678
--             else
679
               pioCplD_RE_i  <= '0';
680
               pioCplD_Req_i <= '1';
681
               FSM_REQ_pio   <= REQST_nFIFO_Req;
682
--             end if;
683
 
684
           when REQST_nFIFO_Req  =>
685
             if pioCplD_RE = '1' then
686
               pioCplD_RE_i   <= '0';
687
               pioCplD_Qout_i <= pioCplD_Qout_reg;
688
               pioCplD_Req_i  <= '0';
689
               FSM_REQ_pio    <= REQST_IDLE;
690
             else
691
               pioCplD_RE_i   <= '0';
692
               pioCplD_Qout_i <= pioCplD_Qout_i;
693
               pioCplD_Req_i  <= '1';
694
               FSM_REQ_pio    <= REQST_nFIFO_Req;
695
             end if;
696
 
697
--           when REQST_Quantity  =>
698
--             if FIFO_Empty='1' then
699
--               pioCplD_RE_i   <= '0';
700
--               pioCplD_Req_i  <= '0';
701
--               pioCplD_Qout_i <= pioCplD_Qout_i;
702
--               FSM_REQ_pio    <= REQST_Quantity;
703
--             else
704
--               pioCplD_RE_i   <= '0';
705
--               pioCplD_Qout_i <= pioCplD_Qout_i;
706
--               pioCplD_Req_i  <= '1';
707
--               FSM_REQ_pio    <= REQST_FIFO_Req;
708
--             end if;
709
--
710
--           when REQST_FIFO_Req  =>
711
--             if FIFO_Empty='1' then
712
--               pioCplD_RE_i   <= '0';
713
--               pioCplD_Req_i  <= '0';
714
--               pioCplD_Qout_i <= pioCplD_Qout_i;
715
--               FSM_REQ_pio    <= REQST_Quantity;
716
--             elsif pioCplD_RE = '1' then
717
--               pioCplD_RE_i   <= '0';
718
--               pioCplD_Qout_i <= pioCplD_Qout_reg;
719
--               pioCplD_Req_i  <= '0';
720
--               FSM_REQ_pio    <= REQST_IDLE;
721
--             else
722
--               pioCplD_RE_i   <= '0';
723
--               pioCplD_Qout_i <= pioCplD_Qout_i;
724
--               pioCplD_Req_i  <= '1';
725
--               FSM_REQ_pio    <= REQST_FIFO_Req;
726
--             end if;
727
 
728
           when OTHERS  =>
729
             pioCplD_RE_i     <= '0';
730
             pioCplD_Qout_i   <= (OTHERS=>'0');
731
             pioCplD_Qout_reg <= (OTHERS=>'0');
732
             pioCplD_Leng     <= (OTHERS=>'1');
733
             pioCplD_Req_i    <= '0';
734
             FSM_REQ_pio      <= REQST_IDLE;
735
 
736
         end case;
737
 
738
      end if;
739
   end process;
740
 
741
 
742
 
743
-- ---------------------------------------------
744
--  Delay of Empty and prog_Full
745
-- 
746
   Synch_Delay_empty_and_full:
747
   process ( trn_clk )
748
   begin
749
      if trn_clk'event and trn_clk = '1' then
750
         pioCplD_empty_r1      <= pioCplD_empty_i;
751
         pioCplD_prog_full_r1  <= pioCplD_prog_Full;
752
      end if;
753
   end process;
754
 
755
 
756
end architecture Behavioral;

powered by: WebSVN 2.1.0

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