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

Subversion Repositories pcie_sg_dma

[/] [pcie_sg_dma/] [trunk/] [rtl/] [rx_dsDMA_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:    dsDMA_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 dsDMA_Transact is
34
    port (
35
      -- downstream DMA Channel Buffer
36
      MRd_dsp_Req        : OUT std_logic;
37
      MRd_dsp_RE         : IN  std_logic;
38
      MRd_dsp_Qout       : OUT std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
39
 
40
      -- Downstream reset from MWr channel
41
      dsDMA_Channel_Rst  : IN  std_logic;
42
 
43
      -- Downstream Registers from MWr Channel
44
      DMA_ds_PA          : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
45
      DMA_ds_HA          : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
46
      DMA_ds_BDA         : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
47
      DMA_ds_Length      : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
48
      DMA_ds_Control     : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
49
      dsDMA_BDA_eq_Null  : IN  std_logic;
50
 
51
      -- Calculation in advance, for better timing
52
      dsHA_is_64b        : IN  std_logic;
53
      dsBDA_is_64b       : IN  std_logic;
54
 
55
      -- Calculation in advance, for better timing
56
      dsLeng_Hi19b_True  : IN  std_logic;
57
      dsLeng_Lo7b_True   : IN  std_logic;
58
 
59
      -- from Cpl/D channel
60
      dsDMA_dex_Tag      : IN  std_logic_vector(C_TAG_WIDTH-1 downto 0);
61
 
62
      -- Downstream Control Signals from MWr Channel
63
      dsDMA_Start        : IN  std_logic;   -- out of 1st dex
64
      dsDMA_Stop         : IN  std_logic;   -- out of 1st dex
65
 
66
 
67
      -- Downstream Control Signals from CplD Channel
68
      dsDMA_Start2       : IN  std_logic;   -- out of consecutive dex
69
      dsDMA_Stop2        : IN  std_logic;   -- out of consecutive dex
70
 
71
      -- Downstream DMA Acknowledge to the start command
72
      DMA_Cmd_Ack        : OUT std_logic;
73
 
74
      -- Downstream Handshake Signals with CplD Channel for Busy/Done
75
      Tag_Map_Clear      : IN  std_logic_vector(C_TAG_MAP_WIDTH-1 downto 0);
76
      FC_pop             : IN  std_logic;
77
 
78
      -- Downstream tRAM port A write request
79
      tRAM_weB           : OUT std_logic;
80
      tRAM_AddrB         : OUT std_logic_vector(C_TAGRAM_AWIDTH-1 downto 0);
81
      tRAM_dinB          : OUT std_logic_vector(C_TAGRAM_DWIDTH-1 downto 0);
82
 
83
      -- To Interrupt module
84
      DMA_Done           : OUT std_logic;
85
      DMA_TimeOut        : OUT std_logic;
86
      DMA_Busy           : OUT std_logic;
87
 
88
      -- To Tx Port
89
      DMA_ds_Status      : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
90
 
91
      -- Additional
92
      cfg_dcommand       : IN  std_logic_vector(C_CFG_COMMAND_DWIDTH-1 downto 0);
93
 
94
      -- Common ports
95
      trn_clk            : IN  std_logic;
96
      trn_reset_n        : IN  std_logic
97
    );
98
 
99
end entity dsDMA_Transact;
100
 
101
 
102
 
103
architecture Behavioral of dsDMA_Transact is
104
 
105
  signal  FC_push              : std_logic;
106
  signal  FC_counter           : std_logic_vector(C_TAGRAM_AWIDTH-1 downto 0);
107
  signal  dsFC_stop            : std_logic;
108
  signal  dsFC_stop_128B       : std_logic;
109
  signal  dsFC_stop_256B       : std_logic;
110
  signal  dsFC_stop_512B       : std_logic;
111
  signal  dsFC_stop_1024B      : std_logic;
112
  signal  dsFC_stop_2048B      : std_logic;
113
  signal  dsFC_stop_4096B      : std_logic;
114
 
115
  -- Reset
116
  signal  Local_Reset_i        : std_logic;
117
 
118
  signal  cfg_MRS              : std_logic_vector(C_CFG_MRS_BIT_TOP-C_CFG_MRS_BIT_BOT downto 0);
119
 
120
  -- Tag RAM port B write
121
  signal  tRAM_dinB_i          : std_logic_vector(C_TAGRAM_DWIDTH-1 downto 0);
122
  signal  tRAM_AddrB_i         : std_logic_vector(C_TAGRAM_AWIDTH-1 downto 0);
123
  signal  tRAM_weB_i           : std_logic;
124
 
125
 
126
  -- DMA calculation
127
  COMPONENT DMA_Calculate
128
    PORT(
129
      -- Downstream Registers from MWr Channel
130
      DMA_PA             : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);  -- EP   (local)
131
      DMA_HA             : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);  -- Host (remote)
132
      DMA_BDA            : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
133
      DMA_Length         : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
134
      DMA_Control        : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
135
 
136
      -- Calculation in advance, for better timing
137
      HA_is_64b          : IN  std_logic;
138
      BDA_is_64b         : IN  std_logic;
139
 
140
      -- Calculation in advance, for better timing
141
      Leng_Hi19b_True    : IN  std_logic;
142
      Leng_Lo7b_True     : IN  std_logic;
143
 
144
 
145
      -- Parameters fed to DMA_FSM
146
      DMA_PA_Loaded      : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
147
      DMA_PA_Var         : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
148
      DMA_HA_Var         : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
149
 
150
      DMA_BDA_fsm        : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
151
      BDA_is_64b_fsm     : OUT std_logic;
152
      DMA_0_Leng         : OUT std_logic;
153
 
154
      -- Only for downstream channel
155
      DMA_PA_Snout       : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
156
      DMA_BAR_Number     : OUT std_logic_vector(C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0);
157
 
158
      -- 
159
      DMA_Snout_Length   : OUT std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
160
      DMA_Body_Length    : OUT std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
161
      DMA_Tail_Length    : OUT std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG+1 downto 0);
162
 
163
 
164
      -- Engine control signals
165
      DMA_Start          : IN  std_logic;
166
      DMA_Start2         : IN  std_logic;   -- out of consecutive dex
167
 
168
      -- Control signals to FSM
169
      No_More_Bodies     : OUT std_logic;
170
      ThereIs_Snout      : OUT std_logic;
171
      ThereIs_Body       : OUT std_logic;
172
      ThereIs_Tail       : OUT std_logic;
173
      ThereIs_Dex        : OUT std_logic;
174
      HA64bit            : OUT std_logic;
175
      Addr_Inc           : OUT std_logic;
176
 
177
      -- FSM indicators
178
      State_Is_LoadParam : IN  std_logic;
179
      State_Is_Snout     : IN  std_logic;
180
      State_Is_Body      : IN  std_logic;
181
--      State_Is_Tail      : IN  std_logic;
182
 
183
      -- Additional
184
      Param_Max_Cfg      : IN  std_logic_vector(2 downto 0);
185
 
186
      -- Common ports
187
      dma_clk            : IN  std_logic;
188
      dma_reset          : IN  std_logic
189
      );
190
  END COMPONENT;
191
 
192
  signal  dsDMA_PA_Loaded      : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
193
  signal  dsDMA_PA_Var         : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
194
  signal  dsDMA_HA_Var         : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
195
 
196
  signal  dsDMA_BDA_fsm        : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
197
  signal  dsBDA_is_64b_fsm     : std_logic;
198
 
199
  signal  dsDMA_PA_snout       : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
200
 
201
  signal  dsDMA_BAR_Number     : std_logic_vector(C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0);
202
 
203
  signal  dsDMA_Snout_Length   : std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
204
  signal  dsDMA_Body_Length    : std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
205
  signal  dsDMA_Tail_Length    : std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG+1 downto 0);
206
 
207
  signal  dsNo_More_Bodies     : std_logic;
208
  signal  dsThereIs_Snout      : std_logic;
209
  signal  dsThereIs_Body       : std_logic;
210
  signal  dsThereIs_Tail       : std_logic;
211
  signal  dsThereIs_Dex        : std_logic;
212
  signal  dsHA64bit            : std_logic;
213
  signal  ds_AInc              : std_logic;
214
 
215
  -- DMA state machine
216
  COMPONENT DMA_FSM
217
    PORT(
218
      -- Fixed information for 1st header of TLP: MRd/MWr
219
      TLP_Has_Payload    : IN  std_logic;
220
      TLP_Hdr_is_4DW     : IN  std_logic;
221
      DMA_Addr_Inc       : IN  std_logic;
222
 
223
      DMA_BAR_Number     : IN  std_logic_vector(C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0);
224
 
225
      -- FSM control signals
226
      DMA_Start          : IN  std_logic;
227
      DMA_Start2         : IN  std_logic;
228
      DMA_Stop           : IN  std_logic;
229
      DMA_Stop2          : IN  std_logic;
230
 
231
      No_More_Bodies     : IN  std_logic;
232
      ThereIs_Snout      : IN  std_logic;
233
      ThereIs_Body       : IN  std_logic;
234
      ThereIs_Tail       : IN  std_logic;
235
      ThereIs_Dex        : IN  std_logic;
236
 
237
      -- Parameters to be written into ChBuf
238
      DMA_PA_Loaded      : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
239
      DMA_PA_Var         : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
240
      DMA_HA_Var         : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
241
 
242
      DMA_BDA_fsm        : IN  std_logic_vector(C_DBUS_WIDTH-1 downto 0);
243
      BDA_is_64b_fsm     : IN  std_logic;
244
 
245
      DMA_Snout_Length   : IN  std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
246
      DMA_Body_Length    : IN  std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
247
      DMA_Tail_Length    : IN  std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG+1 downto 0);
248
 
249
      -- Busy/Done conditions
250
      Done_Condition_1   : IN  std_logic;
251
      Done_Condition_2   : IN  std_logic;
252
      Done_Condition_3   : IN  std_logic;
253
      Done_Condition_4   : IN  std_logic;
254
      Done_Condition_5   : IN  std_logic;
255
      Done_Condition_6   : IN  std_logic;
256
 
257
 
258
      -- Channel buffer write
259
      us_MWr_Param_Vec   : IN  std_logic_vector(6-1   downto 0);
260
      ChBuf_aFull        : IN  std_logic;
261
      ChBuf_WrEn         : OUT std_logic;
262
      ChBuf_WrDin        : OUT std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
263
 
264
 
265
      -- FSM indicators
266
      State_Is_LoadParam : OUT std_logic;
267
      State_Is_Snout     : OUT std_logic;
268
      State_Is_Body      : OUT std_logic;
269
      State_Is_Tail      : OUT std_logic;
270
      DMA_Cmd_Ack        : OUT std_logic;
271
 
272
      -- To Tx Port
273
      ChBuf_ValidRd      : IN  std_logic;
274
      BDA_nAligned       : OUT std_logic;
275
      DMA_TimeOut        : OUT std_logic;
276
      DMA_Busy           : OUT std_logic;
277
      DMA_Done           : OUT std_logic;
278
--      DMA_Done_Rise      : OUT std_logic;
279
 
280
      -- Tags
281
      Pkt_Tag            : IN  std_logic_vector(C_TAG_WIDTH-1 downto 0);
282
      Dex_Tag            : IN  std_logic_vector(C_TAG_WIDTH-1 downto 0);
283
 
284
      -- Common ports
285
      dma_clk            : IN  std_logic;
286
      dma_reset          : IN  std_logic
287
    );
288
  END COMPONENT;
289
 
290
  signal  Tag_DMA_dsp          : std_logic_vector(C_TAG_WIDTH-1 downto  0);
291
 
292
  -- FSM state indicators
293
  signal  dsState_Is_LoadParam : std_logic;
294
  signal  dsState_Is_Snout     : std_logic;
295
  signal  dsState_Is_Body      : std_logic;
296
  signal  dsState_Is_Tail      : std_logic;
297
 
298
  signal  dsChBuf_ValidRd      : std_logic;
299
  signal  dsBDA_nAligned       : std_logic;
300
  signal  dsDMA_TimeOut_i      : std_logic;
301
  signal  dsDMA_Busy_i         : std_logic;
302
  signal  dsDMA_Done_i         : std_logic;
303
 
304
  signal  DMA_Status_i         : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
305
 
306
  ---------------------------------------------------------------
307
  --    Done state identification uses 2^C_TAGRAM_AWIDTH bits, 2 stages logic
308
  signal  Tag_Map_Bits         : std_logic_vector(C_TAG_MAP_WIDTH-1 downto 0);
309
  signal  Tag_Map_filling      : std_logic_vector(C_SUB_TAG_MAP_WIDTH-1 downto 0);
310
  signal  All_CplD_have_come   : std_logic;
311
 
312
 
313
  -- Built-in single-port fifo as downstream DMA channel buffer
314
  --   128-bit wide, for 64-bit address
315
  component v5sfifo_15x128
316
    port (
317
          clk                  : IN  std_logic;
318
          rst                  : IN  std_logic;
319
          prog_full            : OUT std_logic;
320
--          wr_clk             : IN  std_logic;
321
          wr_en                : IN  std_logic;
322
          din                  : IN  std_logic_VECTOR(C_CHANNEL_BUF_WIDTH-1 downto 0);
323
          full                 : OUT std_logic;
324
--          rd_clk             : IN  std_logic;
325
          rd_en                : IN  std_logic;
326
          dout                 : OUT std_logic_VECTOR(C_CHANNEL_BUF_WIDTH-1 downto 0);
327
          prog_empty           : OUT std_logic;
328
          empty                : OUT std_logic
329
    );
330
  end component;
331
 
332
  -- Signal with DMA_downstream channel FIFO
333
  signal  MRd_dsp_din          : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
334
  signal  MRd_dsp_dout         : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
335
  signal  MRd_dsp_re_i         : std_logic;
336
  signal  MRd_dsp_we           : std_logic;
337
  signal  MRd_dsp_empty_i      : std_logic;
338
  signal  MRd_dsp_full         : std_logic;
339
  signal  MRd_dsp_prog_Full    : std_logic;
340
 
341
  signal  MRd_dsp_prog_Full_r1 : std_logic;
342
  signal  MRd_dsp_re_r1        : std_logic;
343
  signal  MRd_dsp_empty_r1     : std_logic;
344
 
345
  -- Request for output arbitration
346
  signal  MRd_dsp_Req_i        : std_logic;
347
 
348
 
349
begin
350
 
351
   -- DMA done signal
352
   DMA_Done          <= dsDMA_Done_i;
353
   DMA_TimeOut       <= dsDMA_TimeOut_i;
354
   DMA_Busy          <= dsDMA_Busy_i;
355
 
356
   -- connecting FIFO's signals
357
   MRd_dsp_Qout      <= MRd_dsp_dout;
358
   MRd_dsp_re_i      <= MRd_dsp_RE;
359
   MRd_dsp_Req       <= MRd_dsp_Req_i;
360
 
361
   --  tag RAM write request signals
362
   tRAM_weB          <= tRAM_weB_i;
363
   tRAM_AddrB        <= tRAM_AddrB_i;
364
   tRAM_dinB         <= tRAM_dinB_i;
365
 
366
 
367
   -- positive local reset
368
--   Local_Reset_i     <= not trn_reset_n or dsDMA_Channel_Rst;
369
   Local_Reset_i     <= dsDMA_Channel_Rst;
370
 
371
   -- Max Read Request Size bits
372
   cfg_MRS           <= cfg_dcommand(C_CFG_MRS_BIT_TOP downto C_CFG_MRS_BIT_BOT);
373
 
374
 
375
   -- Kernel Engine
376
   ds_DMA_Calculation:
377
   DMA_Calculate
378
   PORT MAP(
379
 
380
            DMA_PA             => DMA_ds_PA        ,
381
            DMA_HA             => DMA_ds_HA        ,
382
            DMA_BDA            => DMA_ds_BDA       ,
383
            DMA_Length         => DMA_ds_Length    ,
384
            DMA_Control        => DMA_ds_Control   ,
385
 
386
            HA_is_64b          => dsHA_is_64b        ,
387
            BDA_is_64b         => dsBDA_is_64b       ,
388
 
389
            Leng_Hi19b_True    => dsLeng_Hi19b_True  ,
390
            Leng_Lo7b_True     => dsLeng_Lo7b_True   ,
391
 
392
            DMA_PA_Loaded      => dsDMA_PA_Loaded  ,
393
            DMA_PA_Var         => dsDMA_PA_Var     ,
394
            DMA_HA_Var         => dsDMA_HA_Var     ,
395
 
396
            DMA_BDA_fsm        => dsDMA_BDA_fsm    ,
397
            BDA_is_64b_fsm     => dsBDA_is_64b_fsm ,
398
            DMA_0_Leng         => open             ,
399
 
400
            -- Only for downstream channel
401
            DMA_PA_Snout       => dsDMA_PA_snout   ,
402
            DMA_BAR_Number     => dsDMA_BAR_Number ,
403
 
404
            -- Lengths
405
            DMA_Snout_Length   => dsDMA_Snout_Length ,
406
            DMA_Body_Length    => dsDMA_Body_Length  ,
407
            DMA_Tail_Length    => dsDMA_Tail_Length  ,
408
 
409
            -- Control signals to FSM
410
            No_More_Bodies     => dsNo_More_Bodies   ,
411
            ThereIs_Snout      => dsThereIs_Snout    ,
412
            ThereIs_Body       => dsThereIs_Body     ,
413
            ThereIs_Tail       => dsThereIs_Tail     ,
414
            ThereIs_Dex        => dsThereIs_Dex      ,
415
            HA64bit            => dsHA64bit          ,
416
            Addr_Inc           => ds_AInc            ,
417
 
418
 
419
            DMA_Start          => dsDMA_Start       ,
420
            DMA_Start2         => dsDMA_Start2      ,
421
 
422
            State_Is_LoadParam => dsState_Is_LoadParam ,
423
            State_Is_Snout     => dsState_Is_Snout     ,
424
            State_Is_Body      => dsState_Is_Body      ,
425
--            State_Is_Tail      => dsState_Is_Tail      ,
426
 
427
            Param_Max_Cfg      => cfg_MRS       ,
428
 
429
            dma_clk            => trn_clk       ,
430
            dma_reset          => Local_Reset_i
431
   );
432
 
433
 
434
   -- Kernel FSM
435
   ds_DMA_StateMachine:
436
   DMA_FSM
437
   PORT MAP(
438
            TLP_Has_Payload    => '0'               ,
439
            TLP_Hdr_is_4DW     => dsHA64bit         ,
440
            DMA_Addr_Inc       => '0'               ,    -- of any value
441
 
442
            DMA_BAR_Number     => dsDMA_BAR_Number  ,
443
 
444
            DMA_Start          => dsDMA_Start       ,
445
            DMA_Start2         => dsDMA_Start2      ,
446
            DMA_Stop           => dsDMA_Stop        ,
447
            DMA_Stop2          => dsDMA_Stop2       ,
448
 
449
            -- Control signals to FSM
450
            No_More_Bodies     => dsNo_More_Bodies   ,
451
            ThereIs_Snout      => dsThereIs_Snout    ,
452
            ThereIs_Body       => dsThereIs_Body     ,
453
            ThereIs_Tail       => dsThereIs_Tail     ,
454
            ThereIs_Dex        => dsThereIs_Dex      ,
455
 
456
            DMA_PA_Loaded      => dsDMA_PA_Loaded  ,
457
            DMA_PA_Var         => dsDMA_PA_Var     ,
458
            DMA_HA_Var         => dsDMA_HA_Var     ,
459
 
460
            DMA_BDA_fsm        => dsDMA_BDA_fsm    ,
461
            BDA_is_64b_fsm     => dsBDA_is_64b_fsm ,
462
 
463
            DMA_Snout_Length   => dsDMA_Snout_Length ,
464
            DMA_Body_Length    => dsDMA_Body_Length  ,
465
            DMA_Tail_Length    => dsDMA_Tail_Length  ,
466
 
467
            ChBuf_ValidRd      => dsChBuf_ValidRd,
468
            BDA_nAligned       => dsBDA_nAligned ,
469
            DMA_TimeOut        => dsDMA_TimeOut_i,
470
            DMA_Busy           => dsDMA_Busy_i   ,
471
            DMA_Done           => dsDMA_Done_i   ,
472
--            DMA_Done_Rise      => open         ,
473
 
474
            Pkt_Tag            => Tag_DMA_dsp        ,
475
            Dex_Tag            => dsDMA_dex_Tag      ,
476
 
477
            Done_Condition_1   => '1' ,
478
            Done_Condition_2   => MRd_dsp_empty_r1   ,
479
            Done_Condition_3   => '1' ,
480
            Done_Condition_4   => '1' ,
481
            Done_Condition_5   => All_CplD_have_come ,
482
            Done_Condition_6   => '1' ,
483
 
484
            us_MWr_Param_Vec   => "000000"             ,
485
            ChBuf_aFull        => MRd_dsp_prog_Full_r1 ,
486
            ChBuf_WrEn         => MRd_dsp_we        ,
487
            ChBuf_WrDin        => MRd_dsp_din       ,
488
 
489
            State_Is_LoadParam => dsState_Is_LoadParam ,
490
            State_Is_Snout     => dsState_Is_Snout     ,
491
            State_Is_Body      => dsState_Is_Body      ,
492
            State_Is_Tail      => dsState_Is_Tail      ,
493
 
494
            DMA_Cmd_Ack        => DMA_Cmd_Ack     ,
495
 
496
            dma_clk            => trn_clk       ,
497
            dma_reset          => Local_Reset_i
498
   );
499
 
500
   dsChBuf_ValidRd     <= MRd_dsp_RE;   -- MRd_dsp_re_i and not MRd_dsp_empty_i;
501
 
502
-- -------------------------------------------------
503
--
504
   DMA_ds_Status       <= DMA_Status_i;
505
-- 
506
-- Synchronous output: DMA_Status
507
-- 
508
   DS_DMA_Status_Concat:
509
   process ( trn_clk, Local_Reset_i)
510
   begin
511
      if Local_Reset_i = '1' then
512
         DMA_Status_i <= (OTHERS =>'0');
513
 
514
      elsif trn_clk'event and trn_clk = '1' then
515
 
516
         DMA_Status_i <= (
517
                          CINT_BIT_DMA_STAT_NALIGN  => dsBDA_nAligned,
518
                          CINT_BIT_DMA_STAT_TIMEOUT => dsDMA_TimeOut_i,
519
                          CINT_BIT_DMA_STAT_BDANULL => dsDMA_BDA_eq_Null,
520
                          CINT_BIT_DMA_STAT_BUSY    => dsDMA_Busy_i,
521
                          CINT_BIT_DMA_STAT_DONE    => dsDMA_Done_i,
522
                          Others                    => '0'
523
                         );
524
 
525
      end if;
526
   end process;
527
 
528
 
529
-- -------------------------------------------------------------
530
-- Synchronous reg: tRAM_weB
531
--                  tRAM_AddrB
532
--                  tRAM_dinB
533
--
534
   FSM_dsDMA_tRAM_PortB:
535
   process ( trn_clk, Local_Reset_i)
536
   begin
537
      if Local_Reset_i = '1' then
538
         tRAM_weB_i     <= '0';
539
         tRAM_AddrB_i   <= (OTHERS =>'1');
540
         tRAM_dinB_i    <= (OTHERS =>'0');
541
      elsif trn_clk'event and trn_clk = '1' then
542
 
543
         tRAM_AddrB_i   <= Tag_DMA_dsp(C_TAGRAM_AWIDTH-1 downto 0);
544
 
545
         tRAM_weB_i     <= dsState_Is_Snout
546
                        or dsState_Is_Body
547
                        or dsState_Is_Tail;
548
 
549
         if    dsState_Is_Snout='1' then
550
               tRAM_dinB_i  <=
551
                               ds_AInc           -- DMA_ds_Control(CINT_BIT_DMA_CTRL_AINC)
552
                             & dsDMA_BAR_Number  -- (C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0)
553
                             & dsDMA_PA_snout(C_TAGBAR_BIT_BOT-1 downto 2)&"00"
554
                             ;
555
         elsif dsState_Is_Body='1' then
556
               tRAM_dinB_i  <=
557
                               ds_AInc           -- DMA_ds_Control(CINT_BIT_DMA_CTRL_AINC)
558
                             & dsDMA_BAR_Number  -- (C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0)
559
                             & dsDMA_PA_Var(C_TAGBAR_BIT_BOT-1 downto 2) &"00"
560
                             ;
561
         elsif dsState_Is_Tail='1' then
562
               tRAM_dinB_i  <=
563
                               ds_AInc           -- DMA_ds_Control(CINT_BIT_DMA_CTRL_AINC)
564
                             & dsDMA_BAR_Number  -- (C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0)
565
                             & dsDMA_PA_Var(C_TAGBAR_BIT_BOT-1 downto 2) &"00"
566
                             ;
567
         else
568
               tRAM_dinB_i  <= (Others=>'0');
569
 
570
         end if;
571
 
572
      end if;
573
   end process;
574
 
575
 
576
-- ------------------------------------------
577
--  Loop:  Tag_Map
578
-- 
579
   Sync_Tag_set_reset_Bits:
580
   process ( trn_clk, Local_Reset_i)
581
   begin
582
      if Local_Reset_i = '1' then
583
         Tag_Map_Bits   <= (Others=>'0');
584
 
585
      elsif trn_clk'event and trn_clk = '1' then
586
 
587
         FOR j IN 0 TO C_TAG_MAP_WIDTH-1 LOOP
588
            if  tRAM_AddrB_i=CONV_STD_LOGIC_VECTOR(j, C_TAGRAM_AWIDTH) and tRAM_weB_i='1' then
589
                Tag_Map_Bits(j)   <= '1';
590
            elsif Tag_Map_Clear(j)='1' then
591
                Tag_Map_Bits(j)   <= '0';
592
            else
593
                Tag_Map_Bits(j)   <= Tag_Map_Bits(j);
594
            end if;
595
         END LOOP;
596
 
597
      end if;
598
   end process;
599
 
600
 
601
-- ------------------------------------------
602
-- Determination: All_CplD_have_come
603
-- 
604
   Sync_Reg_All_CplD_have_come:
605
   process ( trn_clk, Local_Reset_i)
606
   begin
607
      if Local_Reset_i = '1' then
608
         Tag_Map_filling     <= (OTHERS =>'0');
609
         All_CplD_have_come  <= '0';
610
 
611
      elsif trn_clk'event and trn_clk = '1' then
612
 
613
         FOR k IN 0 TO C_SUB_TAG_MAP_WIDTH-1 LOOP
614
            if  Tag_Map_Bits((C_TAG_MAP_WIDTH/C_SUB_TAG_MAP_WIDTH)*(k+1)-1 downto (C_TAG_MAP_WIDTH/C_SUB_TAG_MAP_WIDTH)*k)
615
               = C_ALL_ZEROS((C_TAG_MAP_WIDTH/C_SUB_TAG_MAP_WIDTH)*(k+1)-1 downto (C_TAG_MAP_WIDTH/C_SUB_TAG_MAP_WIDTH)*k)
616
               then
617
                Tag_Map_filling(k)   <= '1';
618
            else
619
                Tag_Map_filling(k)   <= '0';
620
            end if;
621
         END LOOP;
622
 
623
         -- final signal :  All_CplD_have_come
624
         if    Tag_Map_filling=C_ALL_ONES(C_SUB_TAG_MAP_WIDTH-1 downto 0) then
625
             All_CplD_have_come   <= '1';
626
         else
627
             All_CplD_have_come   <= '0';
628
         end if;
629
 
630
 
631
      end if;
632
   end process;
633
 
634
 
635
 
636
-- ------------------------------------------
637
-- Synchronous Output: Tag_DMA_dsp
638
-- 
639
   FSM_dsDMA_Tag_DMA_dsp:
640
   process ( trn_clk, Local_Reset_i)
641
   begin
642
      if Local_Reset_i = '1' then
643
         Tag_DMA_dsp    <= (OTHERS =>'0');
644
 
645
      elsif trn_clk'event and trn_clk = '1' then
646
 
647
         if    dsState_Is_Snout='1'
648
            or dsState_Is_Body='1'
649
            or dsState_Is_Tail='1'
650
            then
651
            Tag_DMA_dsp    <= '0' & dsDMA_BAR_Number(1)
652
                            & ( Tag_DMA_dsp(C_TAGRAM_AWIDTH-1 downto 0)
653
                              + CONV_STD_LOGIC_VECTOR(1, C_TAGRAM_AWIDTH));
654
         else
655
            Tag_DMA_dsp    <= '0' & dsDMA_BAR_Number(1)
656
                            & Tag_DMA_dsp(C_TAGRAM_AWIDTH-1 downto 0);
657
         end if;
658
 
659
      end if;
660
   end process;
661
 
662
 
663
 
664
   -- -------------------------------------------------
665
   -- ds MRd TLP Buffer
666
   -- -------------------------------------------------
667
   DMA_DSP_Buffer:
668
   v5sfifo_15x128
669
      port map (
670
         clk           => trn_clk,
671
         rst           => Local_Reset_i,
672
         prog_full     => MRd_dsp_prog_Full,
673
--         wr_clk        => trn_clk,
674
         wr_en         => MRd_dsp_we,
675
         din           => MRd_dsp_din,
676
         full          => MRd_dsp_full,
677
--         rd_clk        => trn_clk,
678
         rd_en         => MRd_dsp_re_i,
679
         dout          => MRd_dsp_dout,
680
         prog_empty    => open,
681
         empty         => MRd_dsp_empty_i
682
       );
683
 
684
 
685
-- ---------------------------------------------
686
--  Delay of Empty and prog_Full
687
-- 
688
   Synch_Delay_empty_and_full:
689
   process ( trn_clk )
690
   begin
691
      if trn_clk'event and trn_clk = '1' then
692
         MRd_dsp_re_r1        <= MRd_dsp_re_i;
693
         MRd_dsp_empty_r1     <= MRd_dsp_empty_i;
694
         MRd_dsp_prog_Full_r1 <= MRd_dsp_prog_Full;
695
         MRd_dsp_Req_i        <= not MRd_dsp_empty_i
696
                             and not dsDMA_Stop
697
                             and not dsDMA_Stop2
698
                             and not dsFC_stop
699
                             ;
700
      end if;
701
   end process;
702
 
703
 
704
-- ------------------------------------------
705
-- Synchronous: FC_push
706
-- 
707
   Synch_Calc_FC_push:
708
   process ( trn_clk, Local_Reset_i)
709
   begin
710
      if Local_Reset_i = '1' then
711
         FC_push    <= '0';
712
 
713
      elsif trn_clk'event and trn_clk = '1' then
714
 
715
         FC_push    <= MRd_dsp_re_r1 and not MRd_dsp_empty_r1
716
                   and not MRd_dsp_dout(C_CHBUF_TAG_BIT_TOP);
717
 
718
      end if;
719
   end process;
720
 
721
-- ------------------------------------------
722
-- Synchronous: FC_counter
723
-- 
724
   Synch_Calc_FC_counter:
725
   process ( trn_clk, Local_Reset_i)
726
   begin
727
      if Local_Reset_i = '1' then
728
         FC_counter    <= (Others=>'0');
729
 
730
      elsif trn_clk'event and trn_clk = '1' then
731
 
732
         if FC_push='1' and FC_pop='0' then
733
            FC_counter    <= FC_counter + '1';
734
         elsif FC_push='0' and FC_pop='1' then
735
            FC_counter    <= FC_counter - '1';
736
         else
737
            FC_counter    <= FC_counter;
738
         end if;
739
 
740
      end if;
741
   end process;
742
 
743
 
744
 
745
-- ------------------------------------------
746
-- Synchronous: dsFC_stop
747
-- 
748
   Synch_Calc_dsFC_stop:
749
   process ( trn_clk, Local_Reset_i)
750
   begin
751
      if Local_Reset_i = '1' then
752
         dsFC_stop_128B     <= '1';
753
         dsFC_stop_256B     <= '1';
754
         dsFC_stop_512B     <= '1';
755
         dsFC_stop_1024B    <= '1';
756
         dsFC_stop_2048B    <= '1';
757
         dsFC_stop_4096B    <= '1';
758
 
759
      elsif trn_clk'event and trn_clk = '1' then
760
 
761
         if FC_counter(C_TAGRAM_AWIDTH-1 downto 0)/=C_ALL_ZEROS(C_TAGRAM_AWIDTH-1 downto 0) then
762
           dsFC_stop_4096B    <= '1';
763
         else
764
           dsFC_stop_4096B    <= '0';
765
         end if;
766
 
767
         if FC_counter(C_TAGRAM_AWIDTH-1 downto 0)/=C_ALL_ZEROS(C_TAGRAM_AWIDTH-1 downto 0) then
768
           dsFC_stop_2048B    <= '1';
769
         else
770
           dsFC_stop_2048B    <= '0';
771
         end if;
772
 
773
         if FC_counter(C_TAGRAM_AWIDTH-1 downto 1)/=C_ALL_ZEROS(C_TAGRAM_AWIDTH-1 downto 1) then
774
           dsFC_stop_1024B    <= '1';
775
         else
776
           dsFC_stop_1024B    <= '0';
777
         end if;
778
 
779
         if FC_counter(C_TAGRAM_AWIDTH-1 downto 2)/=C_ALL_ZEROS(C_TAGRAM_AWIDTH-1 downto 2) then
780
           dsFC_stop_512B    <= '1';
781
         else
782
           dsFC_stop_512B    <= '0';
783
         end if;
784
 
785
         if FC_counter(C_TAGRAM_AWIDTH-1 downto 3)/=C_ALL_ZEROS(C_TAGRAM_AWIDTH-1 downto 3) then
786
           dsFC_stop_256B    <= '1';
787
         else
788
           dsFC_stop_256B    <= '0';
789
         end if;
790
 
791
         if FC_counter(C_TAGRAM_AWIDTH-1 downto 4)/=C_ALL_ZEROS(C_TAGRAM_AWIDTH-1 downto 4) then
792
           dsFC_stop_128B    <= '1';
793
         else
794
           dsFC_stop_128B    <= '0';
795
         end if;
796
 
797
      end if;
798
   end process;
799
 
800
 
801
  -- ------------------------------------------
802
  -- Configuration pamameters: cfg_MRS
803
  --
804
    Syn_Config_Param_cfg_MRS:
805
    process ( trn_clk, Local_Reset_i)
806
    begin
807
       if Local_Reset_i = '1' then  -- 0x0080 Bytes
808
               dsFC_stop      <= '1';
809
 
810
       elsif trn_clk'event and trn_clk = '1' then
811
 
812
          case cfg_MRS is
813
 
814
            when "000" =>  -- 0x0080 Bytes
815
               dsFC_stop      <= dsFC_stop_128B;
816
 
817
            when "001" =>  -- 0x0100 Bytes
818
               dsFC_stop      <= dsFC_stop_256B;
819
 
820
            when "010" =>  -- 0x0200 Bytes
821
               dsFC_stop      <= dsFC_stop_512B;
822
 
823
            when "011" =>  -- 0x0400 Bytes
824
               dsFC_stop      <= dsFC_stop_1024B;
825
 
826
            when "100" =>  -- 0x0800 Bytes
827
               dsFC_stop      <= dsFC_stop_2048B;
828
 
829
            when "101" =>  -- 0x1000 Bytes
830
               dsFC_stop      <= dsFC_stop_4096B;
831
 
832
            when Others => -- as 0x0080 Bytes
833
               dsFC_stop      <= dsFC_stop_128B;
834
 
835
          end case;
836
 
837
       end if;
838
    end process;
839
 
840
end architecture Behavioral;

powered by: WebSVN 2.1.0

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