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

Subversion Repositories pcie_sg_dma

[/] [pcie_sg_dma/] [branches/] [Virtex6/] [ML605_ISE13.3/] [MySource/] [rx_usDMA_Channel.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 barabba
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Design Name: 
6
-- Module Name:    usDMA_Transact - Behavioral 
7
-- Project Name: 
8
-- Target Devices: 
9
-- Tool versions: 
10
-- Description: 
11
--
12
-- Dependencies: 
13
--
14
-- Revision 1.20 - DMA engine shared out.   12.02.2007
15
--
16
-- Revision 1.10 - x4 timing constraints met.   02.02.2007
17
--
18
-- Revision 1.04 - Timing improved.     17.01.2007
19
--
20
-- Revision 1.02 - FIFO added.    20.12.2006
21
--
22
-- Revision 1.00 - first release. 14.12.2006
23
-- 
24
-- Additional Comments: 
25
--
26
----------------------------------------------------------------------------------
27
 
28
library IEEE;
29
use IEEE.STD_LOGIC_1164.ALL;
30
use IEEE.STD_LOGIC_ARITH.ALL;
31
use IEEE.STD_LOGIC_UNSIGNED.ALL;
32
 
33
library work;
34
use work.abb64Package.all;
35
 
36
-- Uncomment the following library declaration if instantiating
37
-- any Xilinx primitives in this code.
38
--library UNISIM;
39
--use UNISIM.VComponents.all;
40
 
41
entity usDMA_Transact is
42
    port (
43
      -- Around the Channel Buffer
44
      usTlp_Req          : OUT std_logic;
45
      usTlp_RE           : IN  std_logic;
46
      usTlp_Qout         : OUT std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
47
      us_FC_stop         : IN  std_logic;
48
      us_Last_sof        : IN  std_logic;
49
      us_Last_eof        : IN  std_logic;
50
      FIFO_Data_Count    : IN  std_logic_vector(C_FIFO_DC_WIDTH downto 0);
51
      FIFO_Reading       : IN  std_logic;
52
 
53
      -- Upstream reset from MWr channel
54
      usDMA_Channel_Rst  : IN  std_logic;
55
 
56
      -- Upstream Registers from MWr Channel
57
      DMA_us_PA          : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
58
      DMA_us_HA          : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
59
      DMA_us_BDA         : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
60
      DMA_us_Length      : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
61
      DMA_us_Control     : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
62
      usDMA_BDA_eq_Null  : IN  std_logic;
63
      us_MWr_Param_Vec   : IN  std_logic_vector(6-1   downto 0);
64
 
65
      -- Calculation in advance, for better timing
66
      usHA_is_64b        : IN  std_logic;
67
      usBDA_is_64b       : IN  std_logic;
68
 
69
      -- Calculation in advance, for better timing
70
      usLeng_Hi19b_True  : IN  std_logic;
71
      usLeng_Lo7b_True   : IN  std_logic;
72
 
73
      -- from Cpl/D channel
74
      usDMA_dex_Tag      : IN  std_logic_vector(C_TAG_WIDTH-1 downto 0);
75
 
76
      -- Upstream Control Signals from MWr Channel
77
      usDMA_Start        : IN  std_logic;   -- out of 1st dex
78
      usDMA_Stop         : IN  std_logic;   -- out of 1st dex
79
 
80
      -- Upstream Control Signals from CplD Channel
81
      usDMA_Start2       : IN  std_logic;   -- out of consecutive dex
82
      usDMA_Stop2        : IN  std_logic;   -- out of consecutive dex
83
 
84
      -- Upstream DMA Acknowledge to the start command
85
      DMA_Cmd_Ack        : OUT std_logic;
86
 
87
      -- To Interrupt module
88
      DMA_Done           : OUT std_logic;
89
      DMA_TimeOut        : OUT std_logic;
90
      DMA_Busy           : OUT std_logic;
91
 
92
      -- To Registers' Group
93
      DMA_us_Status      : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
94
 
95
      -- Additional
96
      cfg_dcommand       : IN  std_logic_vector(C_CFG_COMMAND_DWIDTH-1 downto 0);
97
 
98
       -- Common ports
99
      trn_clk            : IN  std_logic
100
    );
101
 
102
end entity usDMA_Transact;
103
 
104
 
105
 
106
architecture Behavioral of usDMA_Transact is
107
 
108
  -- Upstream DMA channel
109
  signal  Local_Reset_i        : std_logic;
110
  signal  DMA_Status_i         : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
111
 
112
  signal  cfg_MPS              : std_logic_vector(C_CFG_MPS_BIT_TOP-C_CFG_MPS_BIT_BOT downto 0);
113
 
114
 
115
  signal  usDMA_MWr_Tag        : std_logic_vector(C_TAG_WIDTH-1 downto  0);
116
 
117
 
118
  -- DMA calculation
119
  COMPONENT DMA_Calculate
120
    PORT(
121
      -- Downstream Registers from MWr Channel
122
      DMA_PA             : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);  -- EP   (local)
123
      DMA_HA             : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);  -- Host (remote)
124
      DMA_BDA            : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
125
      DMA_Length         : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
126
      DMA_Control        : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
127
 
128
      -- Calculation in advance, for better timing
129
      HA_is_64b          : IN  std_logic;
130
      BDA_is_64b         : IN  std_logic;
131
 
132
      -- Calculation in advance, for better timing
133
      Leng_Hi19b_True    : IN  std_logic;
134
      Leng_Lo7b_True     : IN  std_logic;
135
 
136
 
137
      -- Parameters fed to DMA_FSM
138
      DMA_PA_Loaded      : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
139
      DMA_PA_Var         : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
140
      DMA_HA_Var         : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
141
 
142
      DMA_BDA_fsm        : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
143
      BDA_is_64b_fsm     : OUT std_logic;
144
 
145
      -- Only for downstream channel
146
      DMA_PA_Snout       : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
147
      DMA_BAR_Number     : OUT std_logic_vector(C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0);
148
 
149
      -- 
150
      DMA_Snout_Length   : OUT std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
151
      DMA_Body_Length    : OUT std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
152
      DMA_Tail_Length    : OUT std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG+1 downto 0);
153
 
154
 
155
      -- Engine control signals
156
      DMA_Start          : IN  std_logic;
157
      DMA_Start2         : IN  std_logic;   -- out of consecutive dex
158
 
159
      -- Control signals to FSM
160
      No_More_Bodies     : OUT std_logic;
161
      ThereIs_Snout      : OUT std_logic;
162
      ThereIs_Body       : OUT std_logic;
163
      ThereIs_Tail       : OUT std_logic;
164
      ThereIs_Dex        : OUT std_logic;
165
      HA64bit            : OUT std_logic;
166
      Addr_Inc           : OUT std_logic;
167
 
168
      -- FSM indicators
169
      State_Is_LoadParam : IN  std_logic;
170
      State_Is_Snout     : IN  std_logic;
171
      State_Is_Body      : IN  std_logic;
172
--      State_Is_Tail      : IN  std_logic;
173
 
174
 
175
      -- Additional
176
      Param_Max_Cfg      : IN  std_logic_vector(2 downto 0);
177
 
178
      -- Common ports
179
      dma_clk            : IN  std_logic;
180
      dma_reset          : IN  std_logic
181
      );
182
  END COMPONENT;
183
 
184
  signal  usDMA_PA_Loaded      : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
185
  signal  usDMA_PA_Var         : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
186
  signal  usDMA_HA_Var         : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
187
 
188
  signal  usDMA_BDA_fsm        : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
189
  signal  usBDA_is_64b_fsm     : std_logic;
190
 
191
  signal  usDMA_PA_snout       : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
192
 
193
  signal  usDMA_BAR_Number     : std_logic_vector(C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0);
194
 
195
  signal  usDMA_Snout_Length   : std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
196
  signal  usDMA_Body_Length    : std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
197
  signal  usDMA_Tail_Length    : std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG+1 downto 0);
198
 
199
  signal  usNo_More_Bodies     : std_logic;
200
  signal  usThereIs_Snout      : std_logic;
201
  signal  usThereIs_Body       : std_logic;
202
  signal  usThereIs_Tail       : std_logic;
203
  signal  usThereIs_Dex        : std_logic;
204
  signal  usHA64bit            : std_logic;
205
  signal  us_AInc              : std_logic;
206
 
207
 
208
  -- DMA state machine
209
  COMPONENT DMA_FSM
210
    PORT(
211
      -- Fixed information for 1st header of TLP: MRd/MWr
212
      TLP_Has_Payload    : IN  std_logic;
213
      TLP_Hdr_is_4DW     : IN  std_logic;
214
      DMA_Addr_Inc       : IN  std_logic;
215
 
216
      DMA_BAR_Number     : IN  std_logic_vector(C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0);
217
 
218
      -- FSM control signals
219
      DMA_Start          : IN  std_logic;
220
      DMA_Start2         : IN  std_logic;
221
      DMA_Stop           : IN  std_logic;
222
      DMA_Stop2          : IN  std_logic;
223
 
224
      No_More_Bodies     : IN  std_logic;
225
      ThereIs_Snout      : IN  std_logic;
226
      ThereIs_Body       : IN  std_logic;
227
      ThereIs_Tail       : IN  std_logic;
228
      ThereIs_Dex        : IN  std_logic;
229
 
230
      -- Parameters to be written into ChBuf
231
      DMA_PA_Loaded      : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
232
      DMA_PA_Var         : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
233
      DMA_HA_Var         : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
234
 
235
      DMA_BDA_fsm        : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
236
      BDA_is_64b_fsm     : IN  std_logic;
237
 
238
      DMA_Snout_Length   : IN  std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
239
      DMA_Body_Length    : IN  std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
240
      DMA_Tail_Length    : IN  std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG+1 downto 0);
241
 
242
      -- Busy/Done conditions
243
      Done_Condition_1   : IN  std_logic;
244
      Done_Condition_2   : IN  std_logic;
245
      Done_Condition_3   : IN  std_logic;
246
      Done_Condition_4   : IN  std_logic;
247
      Done_Condition_5   : IN  std_logic;
248
 
249
 
250
      -- Channel buffer write
251
      us_MWr_Param_Vec   : IN  std_logic_vector(6-1   downto 0);
252
      ChBuf_aFull        : IN  std_logic;
253
      ChBuf_WrEn         : OUT std_logic;
254
      ChBuf_WrDin        : OUT std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
255
 
256
 
257
      -- FSM indicators
258
      State_Is_LoadParam : OUT std_logic;
259
      State_Is_Snout     : OUT std_logic;
260
      State_Is_Body      : OUT std_logic;
261
      State_Is_Tail      : OUT std_logic;
262
      DMA_Cmd_Ack        : OUT std_logic;
263
 
264
      -- To Tx Port
265
      ChBuf_ValidRd      : IN  std_logic;
266
      BDA_nAligned       : OUT std_logic;
267
      DMA_TimeOut        : OUT std_logic;
268
      DMA_Busy           : OUT std_logic;
269
      DMA_Done           : OUT std_logic;
270
--      DMA_Done_Rise      : OUT std_logic;
271
 
272
      -- Tags
273
      Pkt_Tag            : IN  std_logic_vector(C_TAG_WIDTH-1 downto 0);
274
      Dex_Tag            : IN  std_logic_vector(C_TAG_WIDTH-1 downto 0);
275
 
276
      -- Common ports
277
      dma_clk            : IN  std_logic;
278
      dma_reset          : IN  std_logic
279
    );
280
  END COMPONENT;
281
 
282
 
283
  -- FSM state indicators
284
  signal  usState_Is_LoadParam : std_logic;
285
  signal  usState_Is_Snout     : std_logic;
286
  signal  usState_Is_Body      : std_logic;
287
  signal  usState_Is_Tail      : std_logic;
288
 
289
  signal  usChBuf_ValidRd      : std_logic;
290
  signal  usBDA_nAligned       : std_logic;
291
  signal  usDMA_TimeOut_i      : std_logic;
292
  signal  usDMA_Busy_i         : std_logic;
293
  signal  usDMA_Done_i         : std_logic;
294
 
295
 
296
  -- Built-in single-port fifo as downstream DMA channel buffer
297
  --   128-bit wide, for 64-bit address
298
  component v6_sfifo_15x128
299
    port (
300
          clk                  : IN  std_logic;
301
          rst                  : IN  std_logic;
302
          prog_full            : OUT std_logic;
303
--          wr_clk             : IN  std_logic;
304
          wr_en                : IN  std_logic;
305
          din                  : IN  std_logic_VECTOR(C_CHANNEL_BUF_WIDTH-1 downto 0);
306
          full                 : OUT std_logic;
307
--          rd_clk             : IN  std_logic;
308
          rd_en                : IN  std_logic;
309
          dout                 : OUT std_logic_VECTOR(C_CHANNEL_BUF_WIDTH-1 downto 0);
310
          prog_empty           : OUT std_logic;
311
          empty                : OUT std_logic
312
    );
313
  end component;
314
 
315
 
316
  -- Signal with DMA_upstream channel abstract buffer
317
  signal  usTlp_din            : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
318
  signal  usTlp_Qout_wire      : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
319
  signal  usTlp_Qout_reg       : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
320
  signal  usTlp_Qout_i         : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
321
  signal  usTlp_RE_i           : std_logic;
322
  signal  usTlp_RE_i_r1        : std_logic;
323
  signal  usTlp_we             : std_logic;
324
  signal  usTlp_empty_i        : std_logic;
325
  signal  usTlp_full           : std_logic;
326
  signal  usTlp_prog_Full      : std_logic;
327
 
328
  signal  usTlp_pempty         : std_logic;
329
  signal  usTlp_Npempty_r1     : std_logic;
330
  signal  usTlp_Nempty_r1      : std_logic;
331
  signal  usTlp_empty_r1       : std_logic;
332
  signal  usTlp_empty_r2       : std_logic;
333
  signal  usTlp_empty_r3       : std_logic;
334
  signal  usTlp_empty_r4       : std_logic;
335
  signal  usTlp_prog_Full_r1   : std_logic;
336
 
337
  -- Request for output arbitration
338
  signal  usTlp_Req_i          : std_logic;
339
  signal  usTlp_nReq_r1        : std_logic;
340
  signal  FIFO_Reading_r1      : std_logic;
341
  signal  FIFO_Reading_r2      : std_logic;
342
  signal  FIFO_Reading_r3p     : std_logic;
343
  signal  usTlp_MWr_Leng       : std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0);
344
 
345
  -- Busy/Done state bits generation
346
  type FSM_Request is         (
347
                                 REQST_Idle
348
                               , REQST_1Read
349
                               , REQST_Decision
350
                               , REQST_nFIFO_Req
351
                               , REQST_Quantity
352
                               , REQST_FIFO_Req
353
                               );
354
 
355
  signal FSM_REQ_us           : FSM_Request;
356
 
357
begin
358
 
359
   -- DMA done signal
360
   DMA_Done           <= usDMA_Done_i;
361
   DMA_TimeOut        <= usDMA_TimeOut_i;
362
   DMA_Busy           <= usDMA_Busy_i;
363
 
364
   -- connecting FIFO's signals
365
   usTlp_Qout         <= usTlp_Qout_i;
366
   usTlp_Req          <= usTlp_Req_i and not FIFO_Reading_r3p;
367
 
368
 
369
   -- positive local reset
370
   Local_Reset_i      <= usDMA_Channel_Rst;
371
 
372
   -- Max Payload Size bits
373
   cfg_MPS            <= cfg_dcommand(C_CFG_MPS_BIT_TOP downto C_CFG_MPS_BIT_BOT);
374
 
375
 
376
   -- Kernel Engine
377
   us_DMA_Calculation:
378
   DMA_Calculate
379
   PORT MAP(
380
 
381
            DMA_PA             => DMA_us_PA        ,
382
            DMA_HA             => DMA_us_HA        ,
383
            DMA_BDA            => DMA_us_BDA       ,
384
            DMA_Length         => DMA_us_Length    ,
385
            DMA_Control        => DMA_us_Control   ,
386
 
387
            HA_is_64b          => usHA_is_64b        ,
388
            BDA_is_64b         => usBDA_is_64b       ,
389
 
390
 
391
            Leng_Hi19b_True    => usLeng_Hi19b_True  ,
392
            Leng_Lo7b_True     => usLeng_Lo7b_True   ,
393
 
394
 
395
            DMA_PA_Loaded      => usDMA_PA_Loaded  ,
396
            DMA_PA_Var         => usDMA_PA_Var     ,
397
            DMA_HA_Var         => usDMA_HA_Var     ,
398
 
399
            DMA_BDA_fsm        => usDMA_BDA_fsm    ,
400
            BDA_is_64b_fsm     => usBDA_is_64b_fsm ,
401
 
402
            -- Only for downstream channel
403
            DMA_PA_Snout       => usDMA_PA_snout   ,
404
            DMA_BAR_Number     => usDMA_BAR_Number ,
405
 
406
            -- Lengths
407
            DMA_Snout_Length   => usDMA_Snout_Length ,
408
            DMA_Body_Length    => usDMA_Body_Length  ,
409
            DMA_Tail_Length    => usDMA_Tail_Length  ,
410
 
411
 
412
            -- Control signals to FSM
413
            No_More_Bodies     => usNo_More_Bodies   ,
414
            ThereIs_Snout      => usThereIs_Snout    ,
415
            ThereIs_Body       => usThereIs_Body     ,
416
            ThereIs_Tail       => usThereIs_Tail     ,
417
            ThereIs_Dex        => usThereIs_Dex      ,
418
            HA64bit            => usHA64bit          ,
419
            Addr_Inc           => us_AInc            ,
420
 
421
 
422
            DMA_Start          => usDMA_Start       ,
423
            DMA_Start2         => usDMA_Start2      ,
424
 
425
            State_Is_LoadParam => usState_Is_LoadParam ,
426
            State_Is_Snout     => usState_Is_Snout     ,
427
            State_Is_Body      => usState_Is_Body      ,
428
--            State_Is_Tail      => usState_Is_Tail      ,
429
 
430
 
431
            Param_Max_Cfg      => cfg_MPS       ,
432
 
433
            dma_clk            => trn_clk       ,
434
            dma_reset          => Local_Reset_i
435
   );
436
 
437
 
438
   -- Kernel FSM
439
   us_DMA_StateMachine:
440
   DMA_FSM
441
   PORT MAP(
442
            TLP_Has_Payload    => '1'               ,
443
            TLP_Hdr_is_4DW     => usHA64bit         ,
444
            DMA_Addr_Inc       => us_AInc           ,
445
 
446
            DMA_BAR_Number     => usDMA_BAR_Number  ,
447
 
448
            DMA_Start          => usDMA_Start       ,
449
            DMA_Start2         => usDMA_Start2      ,
450
            DMA_Stop           => usDMA_Stop        ,
451
            DMA_Stop2          => usDMA_Stop2       ,
452
 
453
            -- Control signals to FSM
454
            No_More_Bodies     => usNo_More_Bodies   ,
455
            ThereIs_Snout      => usThereIs_Snout    ,
456
            ThereIs_Body       => usThereIs_Body     ,
457
            ThereIs_Tail       => usThereIs_Tail     ,
458
            ThereIs_Dex        => usThereIs_Dex      ,
459
 
460
 
461
            DMA_PA_Loaded      => usDMA_PA_Loaded  ,
462
            DMA_PA_Var         => usDMA_PA_Var     ,
463
            DMA_HA_Var         => usDMA_HA_Var     ,
464
 
465
            DMA_BDA_fsm        => usDMA_BDA_fsm    ,
466
            BDA_is_64b_fsm     => usBDA_is_64b_fsm ,
467
 
468
 
469
            DMA_Snout_Length   => usDMA_Snout_Length ,
470
            DMA_Body_Length    => usDMA_Body_Length  ,
471
            DMA_Tail_Length    => usDMA_Tail_Length  ,
472
 
473
 
474
            ChBuf_ValidRd      => usChBuf_ValidRd    ,
475
            BDA_nAligned       => usBDA_nAligned     ,
476
            DMA_TimeOut        => usDMA_TimeOut_i    ,
477
            DMA_Busy           => usDMA_Busy_i       ,
478
            DMA_Done           => usDMA_Done_i       ,
479
--            DMA_Done_Rise      => open             ,
480
 
481
            Pkt_Tag            => usDMA_MWr_Tag      ,
482
            Dex_Tag            => usDMA_dex_Tag      ,
483
 
484
 
485
            Done_Condition_1   => '1'                ,
486
            Done_Condition_2   => usTlp_empty_r3     ,
487
            Done_Condition_3   => usTlp_nReq_r1      ,
488
            Done_Condition_4   => us_Last_sof        ,
489
            Done_Condition_5   => us_Last_eof        ,
490
 
491
            us_MWr_Param_Vec   => us_MWr_Param_Vec   ,
492
            ChBuf_aFull        => usTlp_Npempty_r1   ,  -- usTlp_prog_Full_r1 ,
493
            ChBuf_WrEn         => usTlp_we           ,
494
            ChBuf_WrDin        => usTlp_din          ,
495
 
496
            State_Is_LoadParam => usState_Is_LoadParam ,
497
            State_Is_Snout     => usState_Is_Snout     ,
498
            State_Is_Body      => usState_Is_Body      ,
499
            State_Is_Tail      => usState_Is_Tail      ,
500
 
501
            DMA_Cmd_Ack        => DMA_Cmd_Ack     ,
502
 
503
 
504
            dma_clk            => trn_clk         ,
505
            dma_reset          => Local_Reset_i
506
   );
507
 
508
   usChBuf_ValidRd     <= usTlp_RE;  -- usTlp_RE_i and not usTlp_empty_i;
509
 
510
-- -------------------------------------------------
511
-- 
512
   DMA_us_Status       <= DMA_Status_i;
513
-- 
514
-- Synchronous output: DMA_Status_i
515
-- 
516
   US_DMA_Status_Concat:
517
   process ( trn_clk, Local_Reset_i)
518
   begin
519
      if Local_Reset_i = '1' then
520
         DMA_Status_i <= (OTHERS =>'0');
521
      elsif trn_clk'event and trn_clk = '1' then
522
 
523
         DMA_Status_i <= (
524
                          CINT_BIT_DMA_STAT_NALIGN  => usBDA_nAligned,
525
                          CINT_BIT_DMA_STAT_TIMEOUT => usDMA_TimeOut_i,
526
                          CINT_BIT_DMA_STAT_BDANULL => usDMA_BDA_eq_Null,
527
                          CINT_BIT_DMA_STAT_BUSY    => usDMA_Busy_i,
528
                          CINT_BIT_DMA_STAT_DONE    => usDMA_Done_i,
529
                          Others                    => '0'
530
                         );
531
 
532
      end if;
533
   end process;
534
 
535
 
536
-- -----------------------------------
537
-- Synchronous Register: usDMA_MWr_Tag
538
   FSM_usDMA_usDMA_MWr_Tag:
539
   process ( trn_clk, Local_Reset_i)
540
   begin
541
      if Local_Reset_i = '1' then
542
         usDMA_MWr_Tag     <= C_TAG0_DMA_US_MWR;
543
 
544
      elsif trn_clk'event and trn_clk = '1' then
545
 
546
         if    usState_Is_Snout='1'
547
            or usState_Is_Body='1'
548
            or usState_Is_Tail='1'
549
            then
550
                -- Only 4 lower bits increment, higher 4 stay
551
            usDMA_MWr_Tag(C_TAG_WIDTH-C_TAG_DECODE_BITS-1 downto 0)
552
         <= usDMA_MWr_Tag(C_TAG_WIDTH-C_TAG_DECODE_BITS-1 downto 0)
553
          + CONV_STD_LOGIC_VECTOR(1, C_TAG_WIDTH-C_TAG_DECODE_BITS);
554
         else
555
            usDMA_MWr_Tag <= usDMA_MWr_Tag;
556
         end if;
557
 
558
      end if;
559
   end process;
560
 
561
 
562
   -- -------------------------------------------------
563
   -- us MWr/MRd TLP Buffer
564
   -- -------------------------------------------------
565
   US_TLP_Buffer:
566
   v6_sfifo_15x128
567
      port map (
568
         clk           => trn_clk,
569
         rst           => Local_Reset_i,
570
         prog_full     => usTlp_prog_Full ,
571
--         wr_clk        => trn_clk,
572
         wr_en         => usTlp_we,
573
         din           => usTlp_din,
574
         full          => usTlp_full,
575
--         rd_clk        => trn_clk,
576
         rd_en         => usTlp_RE_i,
577
         dout          => usTlp_Qout_wire,
578
         prog_empty    => usTlp_pempty,
579
         empty         => usTlp_empty_i
580
       );
581
 
582
-- ---------------------------------------------
583
--  Synchronous delay
584
-- 
585
   Synch_Delay_ren_Qout:
586
   process (Local_Reset_i, trn_clk )
587
   begin
588
      if Local_Reset_i = '1' then
589
         FIFO_Reading_r1 <= '0';
590
         FIFO_Reading_r2 <= '0';
591
         FIFO_Reading_r3p<= '0';
592
         usTlp_RE_i_r1   <= '0';
593
         usTlp_nReq_r1   <= '0';
594
         usTlp_Qout_reg  <= (OTHERS=>'0');
595
         usTlp_MWr_Leng  <= (OTHERS=>'0');
596
 
597
      elsif trn_clk'event and trn_clk = '1' then
598
         FIFO_Reading_r1 <= FIFO_Reading;
599
         FIFO_Reading_r2 <= FIFO_Reading_r1;
600
         FIFO_Reading_r3p<= FIFO_Reading_r1 or FIFO_Reading_r2;
601
         usTlp_RE_i_r1  <= usTlp_RE_i;
602
         usTlp_nReq_r1  <= not usTlp_Req_i;
603
         if usTlp_RE_i_r1='1' then
604
            usTlp_Qout_reg <= usTlp_Qout_wire;
605
            usTlp_MWr_Leng <= usTlp_Qout_wire(C_CHBUF_LENG_BIT_TOP downto C_CHBUF_LENG_BIT_BOT);
606
         else
607
            usTlp_Qout_reg <= usTlp_Qout_reg;
608
            usTlp_MWr_Leng <= usTlp_MWr_Leng;
609
         end if;
610
 
611
      end if;
612
   end process;
613
 
614
 
615
-- ---------------------------------------------
616
--  Request for arbitration
617
-- 
618
   Synch_Req_Proc:
619
   process (Local_Reset_i, trn_clk )
620
   begin
621
      if Local_Reset_i = '1' then
622
         usTlp_RE_i     <= '0';
623
         usTlp_Req_i    <= '0';
624
         FSM_REQ_us     <= REQST_IDLE;
625
 
626
      elsif trn_clk'event and trn_clk = '1' then
627
 
628
         case FSM_REQ_us  is
629
 
630
           when REQST_IDLE  =>
631
             if usTlp_empty_i = '0' then
632
               usTlp_RE_i   <= '1';
633
               usTlp_Req_i  <= '0';
634
               FSM_REQ_us   <= REQST_1Read;
635
             else
636
               usTlp_RE_i   <= '0';
637
               usTlp_Req_i  <= '0';
638
               FSM_REQ_us   <= REQST_IDLE;
639
             end if;
640
 
641
           when REQST_1Read  =>
642
             usTlp_RE_i   <= '0';
643
             usTlp_Req_i  <= '0';
644
             FSM_REQ_us   <= REQST_Decision;
645
 
646
           when REQST_Decision  =>
647
             if usTlp_Qout_wire(C_CHBUF_FMT_BIT_TOP) = '1'  -- Has Payload
648
               and usTlp_Qout_wire(C_CHBUF_DMA_BAR_BIT_TOP downto C_CHBUF_DMA_BAR_BIT_BOT)
649
                   =CONV_STD_LOGIC_VECTOR(CINT_FIFO_SPACE_BAR, C_ENCODE_BAR_NUMBER)
650
               then
651
               usTlp_RE_i  <= '0';
652
               usTlp_Req_i <= '0';
653
               FSM_REQ_us  <= REQST_Quantity;
654
             else
655
               usTlp_RE_i  <= '0';
656
               usTlp_Req_i <=  not usDMA_Stop
657
                           and not usDMA_Stop2
658
                           and not us_FC_stop;
659
               FSM_REQ_us  <= REQST_nFIFO_Req;
660
             end if;
661
 
662
           when REQST_nFIFO_Req  =>
663
             if usTlp_RE = '1' then
664
               usTlp_RE_i   <= '0';
665
               usTlp_Req_i  <= '0';
666
               FSM_REQ_us   <= REQST_IDLE;
667
             else
668
               usTlp_RE_i   <= '0';
669
               usTlp_Req_i  <=  not usDMA_Stop
670
                            and not usDMA_Stop2
671
                            and not us_FC_stop;
672
               FSM_REQ_us   <= REQST_nFIFO_Req;
673
             end if;
674
 
675
           when REQST_Quantity  =>
676
             if usTlp_RE = '1' then
677
               usTlp_RE_i   <= '1';
678
               usTlp_Req_i  <= '0';
679
               FSM_REQ_us   <= REQST_Quantity;
680
             elsif FIFO_Data_Count(C_FIFO_DC_WIDTH downto C_TLP_FLD_WIDTH_OF_LENG)=C_ALL_ZEROS(C_FIFO_DC_WIDTH downto C_TLP_FLD_WIDTH_OF_LENG)
681
               and FIFO_Data_Count(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0) < usTlp_MWr_Leng(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0)
682
               then
683
               usTlp_RE_i   <= '0';
684
               usTlp_Req_i  <= '0';
685
               FSM_REQ_us   <= REQST_Quantity;
686
             else
687
               usTlp_RE_i   <= '0';
688
               usTlp_Req_i  <=  not usDMA_Stop
689
                            and not usDMA_Stop2
690
                            and not us_FC_stop;
691
               FSM_REQ_us   <= REQST_FIFO_Req;
692
             end if;
693
 
694
           when REQST_FIFO_Req  =>
695
             if FIFO_Data_Count(C_FIFO_DC_WIDTH downto C_TLP_FLD_WIDTH_OF_LENG)=C_ALL_ZEROS(C_FIFO_DC_WIDTH downto C_TLP_FLD_WIDTH_OF_LENG)
696
               and FIFO_Data_Count(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0) < usTlp_MWr_Leng(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0)
697
               then
698
               usTlp_RE_i   <= '0';
699
               usTlp_Req_i  <= '0';
700
               FSM_REQ_us   <= REQST_Quantity;
701
             elsif usTlp_RE = '1' then
702
               usTlp_RE_i   <= '0';
703
               usTlp_Req_i  <= '0';
704
               FSM_REQ_us   <= REQST_IDLE;
705
             else
706
               usTlp_RE_i   <= '0';
707
               usTlp_Req_i  <=  not usDMA_Stop
708
                            and not usDMA_Stop2
709
                            and not us_FC_stop;
710
               FSM_REQ_us   <= REQST_FIFO_Req;
711
             end if;
712
 
713
           when OTHERS  =>
714
             usTlp_RE_i     <= '0';
715
             usTlp_Req_i    <= '0';
716
             FSM_REQ_us     <= REQST_IDLE;
717
 
718
         end case;
719
 
720
      end if;
721
   end process;
722
 
723
 
724
-- ---------------------------------------------
725
--  Sending usTlp_Qout
726
-- 
727
   Synch_usTlp_Qout:
728
   process (Local_Reset_i, trn_clk )
729
   begin
730
      if Local_Reset_i = '1' then
731
         usTlp_Qout_i   <= (OTHERS=>'0');
732
 
733
      elsif trn_clk'event and trn_clk = '1' then
734
 
735
         if usTlp_RE = '1' then
736
            usTlp_Qout_i  <= usTlp_Qout_reg;
737
         else
738
            usTlp_Qout_i  <= usTlp_Qout_i;
739
         end if;
740
 
741
      end if;
742
   end process;
743
 
744
 
745
-- ---------------------------------------------
746
--  Delay of Empty and prog_Full
747
-- 
748
   Synch_Delay_empty_and_full:
749
   process ( trn_clk )
750
   begin
751
      if trn_clk'event and trn_clk = '1' then
752
         usTlp_Npempty_r1   <= not usTlp_pempty;
753
         usTlp_Nempty_r1    <= not usTlp_empty_i;
754
         usTlp_empty_r1     <= usTlp_empty_i;
755
         usTlp_empty_r2     <= usTlp_empty_r1;
756
         usTlp_empty_r3     <= usTlp_empty_r2;
757
         usTlp_empty_r4     <= usTlp_empty_r3;
758
         usTlp_prog_Full_r1 <= usTlp_prog_Full;
759
--         usTlp_Req_i        <= not usTlp_empty_i 
760
--                           and not usDMA_Stop
761
--                           and not usDMA_Stop2
762
--                           and not us_FC_stop
763
--                           ;
764
      end if;
765
   end process;
766
 
767
 
768
end architecture Behavioral;

powered by: WebSVN 2.1.0

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