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/] [ipcore_dir_ISE13.3/] [tmp/] [backup_v6_pcie_v1_6/] [v6_pcie_v1_6/] [simulation/] [dsport/] [pci_exp_usrapp_rx.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 barabba
 
2
-------------------------------------------------------------------------------
3
--
4
-- (c) Copyright 2009-2010 Xilinx, Inc. All rights reserved.
5
--
6
-- This file contains confidential and proprietary information
7
-- of Xilinx, Inc. and is protected under U.S. and
8
-- international copyright and other intellectual property
9
-- laws.
10
--
11
-- DISCLAIMER
12
-- This disclaimer is not a license and does not grant any
13
-- rights to the materials distributed herewith. Except as
14
-- otherwise provided in a valid license issued to you by
15
-- Xilinx, and to the maximum extent permitted by applicable
16
-- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
17
-- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
18
-- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
19
-- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
20
-- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
21
-- (2) Xilinx shall not be liable (whether in contract or tort,
22
-- including negligence, or under any other theory of
23
-- liability) for any loss or damage of any kind or nature
24
-- related to, arising under or in connection with these
25
-- materials, including for any direct, or any indirect,
26
-- special, incidental, or consequential loss or damage
27
-- (including loss of data, profits, goodwill, or any type of
28
-- loss or damage suffered as a result of any action brought
29
-- by a third party) even if such damage or loss was
30
-- reasonably foreseeable or Xilinx had been advised of the
31
-- possibility of the same.
32
--
33
-- CRITICAL APPLICATIONS
34
-- Xilinx products are not designed or intended to be fail-
35
-- safe, or for use in any application requiring fail-safe
36
-- performance, such as life-support or safety devices or
37
-- systems, Class III medical devices, nuclear facilities,
38
-- applications related to the deployment of airbags, or any
39
-- other applications that could lead to death, personal
40
-- injury, or severe property or environmental damage
41
-- (individually and collectively, "Critical
42
-- Applications"). Customer assumes the sole risk and
43
-- liability of any use of Xilinx products in Critical
44
-- Applications, subject only to applicable laws and
45
-- regulations governing limitations on product liability.
46
--
47
-- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
48
-- PART OF THIS FILE AT ALL TIMES.
49
--
50
-------------------------------------------------------------------------------
51
-- Project    : Virtex-6 Integrated Block for PCI Express
52
-- File       : pci_exp_usrapp_rx.vhd
53
-- Version    : 1.6
54
--
55
--------------------------------------------------------------------------------
56
 
57
library ieee;
58
use ieee.std_logic_1164.all;
59
use ieee.std_logic_textio.all;
60
use ieee.numeric_std.all;
61
 
62
library std;
63
use std.textio.all;
64
 
65
entity pci_exp_usrapp_rx is
66
 
67
generic (
68
 
69
 
70
  TRN_RX_TIMEOUT  : INTEGER :=10000
71
 
72
);
73
 
74
port (
75
 
76
  trn_rdst_rdy_n           : out std_logic;
77
  trn_rnp_ok_n             : out std_logic;
78
  trn_rd                   : in std_logic_vector ((64 - 1) downto 0 );
79
  trn_rrem_n               : in std_logic_vector ((8 - 1) downto 0 );
80
  trn_rsof_n               : in std_logic;
81
  trn_reof_n               : in std_logic;
82
  trn_rsrc_rdy_n           : in std_logic;
83
  trn_rsrc_dsc_n           : in std_logic;
84
  trn_rerrfwd_n            : in std_logic;
85
  trn_rbar_hit_n           : in std_logic_vector ((7 - 1) downto 0 );
86
 
87
  trn_clk                  : in std_logic;
88
  trn_reset_n              : in std_logic;
89
  trn_lnk_up_n             : in std_logic;
90
 
91
  --sim_time                 : in TIME;
92
  rx_tx_read_data          : out std_logic_vector(31 downto 0);
93
  rx_tx_read_data_valid    : out std_logic;
94
  tx_rx_read_data_valid    : in std_logic
95
 
96
 
97
 
98
);
99
 
100
end pci_exp_usrapp_rx;
101
 
102
architecture rtl of pci_exp_usrapp_rx is
103
 
104
type BYTE_ARRAY is array (999 downto 0) of std_logic_vector(7 downto 0);
105
 
106
constant TRN_RX_RESET      : std_logic_vector(4 downto 0) := "00001";
107
constant TRN_RX_DOWN       : std_logic_vector(4 downto 0) := "00010";
108
constant TRN_RX_IDLE       : std_logic_vector(4 downto 0) := "00100";
109
constant TRN_RX_ACTIVE     : std_logic_vector(4 downto 0) := "01000";
110
constant TRN_RX_SRC_DSC    : std_logic_vector(4 downto 0) := "10000";
111
 
112
constant PCI_EXP_MEM_READ32            : std_logic_vector(6 downto 0) := "0000000";
113
constant PCI_EXP_IO_READ               : std_logic_vector(6 downto 0) := "0000010";
114
constant PCI_EXP_CFG_READ0             : std_logic_vector(6 downto 0) := "0000100";
115
constant PCI_EXP_COMPLETION_WO_DATA    : std_logic_vector(6 downto 0) := "0001010";
116
constant PCI_EXP_MEM_READ64            : std_logic_vector(6 downto 0) := "0100000";
117
constant PCI_EXP_MSG_NODATA            : std_logic_vector(6 downto 3) := "0110";
118
constant PCI_EXP_MEM_WRITE32           : std_logic_vector(6 downto 0) := "1000000";
119
constant PCI_EXP_IO_WRITE              : std_logic_vector(6 downto 0) := "1000010";
120
constant PCI_EXP_CFG_WRITE0            : std_logic_vector(6 downto 0) := "1000100";
121
constant PCI_EXP_COMPLETION_DATA       : std_logic_vector(6 downto 0) := "1001010";
122
constant PCI_EXP_MEM_WRITE64           : std_logic_vector(6 downto 0) := "1100000";
123
constant PCI_EXP_MSG_DATA              : std_logic_vector(6 downto 3) := "1110";
124
 
125
constant COMPLETER_ID_CFG : std_logic_vector(15 downto 0) := X"01A0";
126
 
127
 
128
-- Global variables
129
 
130
shared variable frame_store_rx         : BYTE_ARRAY;
131
shared variable frame_store_rx_idx     : INTEGER;
132
shared variable next_trn_rx_timeout    : INTEGER;
133
 
134
signal trn_rdst_rdy_n_c       : std_logic;
135
signal trn_rnp_ok_n_c         : std_logic;
136
signal read_data_valid_int    : std_logic;
137
signal read_data_valid_int_d : std_logic; -- added to prevent race condition
138
signal trn_rx_state           : std_logic_vector(4 downto 0);
139
 
140
file RX_file : TEXT open write_mode is "rx.dat";
141
 
142
 
143
 
144
--************************************************************
145
--     Proc : writeNowToRx
146
--     Inputs : Text String
147
--     Outputs : None
148
--     Description : Displays text string to Rx file pre-appended with
149
--         current simulation time..
150
--   *************************************************************/
151
 
152
procedure writeNowToRx (
153
 
154
  text_string                 : in string
155
 
156
) is
157
 
158
  variable L      : line;
159
 
160
begin
161
 
162
  write (L, String'("[ "));
163
  write (L, now);
164
  write (L, String'(" ] : "));
165
  write (L, text_string);
166
  writeline (rx_file, L);
167
 
168
end writeNowToRx;
169
 
170
 
171
--************************************************************
172
--     Proc : writeNowToScreen
173
--     Inputs : Text String
174
--     Outputs : None
175
--     Description : Displays current simulation time and text string to
176
--          standard output.
177
--   *************************************************************
178
 
179
procedure writeNowToScreen (
180
 
181
  text_string                 : in string
182
 
183
) is
184
 
185
  variable L      : line;
186
 
187
begin
188
 
189
  write (L, String'("[ "));
190
  write (L, now);
191
  write (L, String'(" ] : "));
192
  write (L, text_string);
193
  writeline (output, L);
194
 
195
end writeNowToScreen;
196
 
197
 
198
--************************************************************
199
--     Proc : writeHexToRx
200
--     Inputs : hex value with bit width that is multiple of 4
201
--     Outputs : None
202
--     Description : Displays nibble aligned hex value to Rx file
203
--
204
--   *************************************************************
205
 
206
procedure writeHexToRx (
207
 
208
  text_string                 : in string;
209
  hexValue                  : in std_logic_vector
210
 
211
) is
212
 
213
  variable L      : line;
214
 
215
begin
216
 
217
  write (L, text_string);
218
  hwrite(L, hexValue);
219
  writeline (rx_file, L);
220
 
221
end writeHexToRx;
222
 
223
 
224
--************************************************************
225
--     Proc : PROC_READ_DATA
226
--     Inputs : None
227
--     Outputs : None
228
--     Description : Consume clocks.
229
--   *************************************************************/
230
 
231
procedure PROC_READ_DATA (
232
 
233
  last                  : in INTEGER;
234
  trn_d                 : in std_logic_vector (63 downto 0);
235
  trn_rem               : in std_logic_vector (7 downto 0)
236
 
237
) is
238
 
239
  variable i            : INTEGER;
240
  variable data_byte    : std_logic_vector (7 downto 0);
241
  variable remain       : INTEGER;
242
  variable hi_index     : INTEGER;
243
  variable low_index    : INTEGER;
244
  variable my_line      : line;
245
 
246
begin
247
 
248
  hi_index := 63;
249
  low_index := 56;
250
  if (last = 1) then
251
    if (trn_rem = X"0F") then
252
      remain := 4;
253
    else
254
      remain := 8;
255
    end if;
256
  else
257
      remain := 8;
258
  end if;
259
 
260
  for i in 0 to (remain - 1) loop
261
 
262
    data_byte := trn_d( hi_index downto low_index);
263
    hi_index := hi_index - 8;
264
    low_index := low_index - 8;
265
    frame_store_rx(frame_store_rx_idx) := data_byte;
266
    frame_store_rx_idx := frame_store_rx_idx + 1;
267
 
268
  end loop;
269
 
270
end PROC_READ_DATA;
271
 
272
 
273
--************************************************************
274
--  Proc : PROC_DECIPHER_FRAME
275
--  Inputs : None
276
-- Outputs : fmt, tlp_type, traffic_class, td, ep, attr, length
277
--  Description : Deciphers frame
278
--  *************************************************************/
279
 
280
procedure PROC_DECIPHER_FRAME (
281
 
282
  fmt                   : out std_logic_vector (1 downto 0);
283
  tlp_type              : out std_logic_vector (4 downto 0);
284
  traffic_class         : out std_logic_vector (2 downto 0);
285
  td                    : out std_logic;
286
  ep                    : out std_logic;
287
  attr                  : out std_logic_vector (1 downto 0);
288
  length                : out std_logic_vector (9 downto 0)
289
 
290
) is
291
 
292
begin
293
 
294
  fmt := frame_store_rx(0)(6 downto 5);
295
  tlp_type := frame_store_rx(0)(4 downto 0);
296
  traffic_class := frame_store_rx(1)(6 downto 4);
297
  td := frame_store_rx(2)(7);
298
  ep := frame_store_rx(2)(6);
299
  attr := frame_store_rx(2)(5 downto 4);
300
  length(9 downto 8) := frame_store_rx(2)(1 downto 0);
301
  length(7 downto 0) := frame_store_rx(3);
302
 
303
end PROC_DECIPHER_FRAME;
304
 
305
 
306
-- ************************************************************
307
--  Proc : PROC_3DW
308
--  Inputs : fmt, type, traffic_class, td, ep, attr, length,
309
--  payload,
310
--  Outputs : None
311
--  Description : Gets variables and prints frame
312
--  *************************************************************/
313
 
314
procedure PROC_3DW (
315
 
316
  fmt                           : in std_logic_vector (1 downto 0);
317
  tlp_type                      : in std_logic_vector (4 downto 0);
318
  traffic_class                 : in std_logic_vector (2 downto 0);
319
  td                            : in std_logic;
320
  ep                            : in std_logic;
321
  attr                          : in std_logic_vector (1 downto 0);
322
  length                        : in std_logic_vector (9 downto 0);
323
  payload                       : in INTEGER;
324
  signal rx_tx_read_data        : out std_logic_vector(31 downto 0);
325
  signal read_data_valid_int    : out std_logic
326
 
327
) is
328
 
329
  variable requester_id         : std_logic_vector (15 downto 0);
330
  variable tag                  : std_logic_vector (7 downto 0);
331
  variable byte_enables         : std_logic_vector (7 downto 0);
332
  variable address_low          : std_logic_vector (31 downto 0);
333
  variable completer_id         : std_logic_vector (15 downto 0);
334
  variable register_address     : std_logic_vector (9 downto 0);
335
  variable completion_status    : std_logic_vector (2 downto 0);
336
  variable i                    : INTEGER;
337
  variable L                    : line;
338
  variable fmt_type             : std_logic_vector (6 downto 0);
339
 
340
begin
341
 
342
  writeHexToRx (String'("     Traffic Class: 0x"), '0' & traffic_class);
343
  write (L, String'("     TD: ")); write(L,  td); writeline (rx_file, L);
344
  write (L, String'("     EP: ")); write(L, ep); writeline (rx_file, L);
345
  writeHexToRx (String'("     Attributes: 0x"), "00" & attr);
346
  writeHexToRx (String'("     Length: 0x"), "00" & length);
347
 
348
 
349
  fmt_type := fmt & tlp_type;
350
  case (fmt_type) is
351
 
352
    when PCI_EXP_CFG_READ0 | PCI_EXP_CFG_WRITE0 =>
353
 
354
      requester_id := frame_store_rx(4) & frame_store_rx(5);
355
      tag := frame_store_rx(6);
356
      byte_enables := frame_store_rx(7);
357
      completer_id := frame_store_rx(8) & frame_store_rx(9);
358
      register_address(9 downto 8) := frame_store_rx(10)(1 downto 0);
359
      register_address(7 downto 0) := frame_store_rx(11);
360
 
361
      writeHexToRx ( String'("     Requester Id: 0x"), requester_id);
362
      writeHexToRx ( String'("     Tag: 0x"), tag);
363
      writeHexToRx ( String'("     Last and First Byte Enables: 0x"), byte_enables);
364
      writeHexToRx ( String'("     Completer Id: 0x"), completer_id);
365
      writeHexToRx (String'("     Register Address: 0x"), "00" & register_address);
366
 
367
      if (payload = 1) then
368
 
369
        write (L, String'("")); writeline(rx_file, L);
370
        for i in 12 to (frame_store_rx_idx - 1) loop
371
          writeHexToRx ( String'("     0x"), frame_store_rx(i));
372
        end loop;
373
 
374
      end if;
375
      write (L, String'("")); writeline(rx_file, L);
376
 
377
    when PCI_EXP_COMPLETION_WO_DATA | PCI_EXP_COMPLETION_DATA=>
378
 
379
      completer_id := frame_store_rx(4) & frame_store_rx(5);
380
      completion_status(2 downto 0) := frame_store_rx(6)(7 downto 5);
381
      requester_id := frame_store_rx(8) & frame_store_rx(9);
382
      tag := frame_store_rx(10);
383
 
384
      writeHexToRx ( String'("     Completer Id: 0x"), completer_id);
385
      writeHexToRx ( String'("     Completion Status: 0x"), '0' & completion_status);
386
      writeHexToRx ( String'("     Requester Id: 0x"), requester_id);
387
      writeHexToRx ( String'("     Tag: 0x"), tag);
388
 
389
      if (payload = 1) then
390
 
391
        write (L, String'("")); writeline(rx_file, L);
392
        for i in 12 to (frame_store_rx_idx - 1) loop
393
          writeHexToRx ( String'("     0x"), frame_store_rx(i));
394
        end loop;
395
 
396
        rx_tx_read_data <= frame_store_rx(15) & frame_store_rx(14) &
397
        frame_store_rx(13) & frame_store_rx(12);
398
        read_data_valid_int <= '1';
399
 
400
      end if;
401
      write (L, String'("")); writeline(rx_file, L);
402
 
403
    when others =>
404
 
405
      requester_id := frame_store_rx(4) & frame_store_rx(5);
406
      tag := frame_store_rx(6);
407
      byte_enables := frame_store_rx(7);
408
      address_low(31 downto 24) := frame_store_rx(8);
409
      address_low(23 downto 16) := frame_store_rx(9);
410
      address_low(15 downto 8) := frame_store_rx(10);
411
      address_low( 7 downto 0) := frame_store_rx(11);
412
 
413
      writeHexToRx ( String'("     Requester Id: 0x"), requester_id);
414
      writeHexToRx ( String'("     Tag: 0x"), tag);
415
      writeHexToRx ( String'("     Last and First Byte Enables: 0x"), byte_enables);
416
      writeHexToRx ( String'("     Address Low: 0x"), address_low);
417
 
418
      if (payload = 1) then
419
 
420
        write (L, String'("")); writeline(rx_file, L);
421
        for i in 12 to (frame_store_rx_idx - 1) loop
422
          writeHexToRx ( String'("     0x"), frame_store_rx(i));
423
        end loop;
424
 
425
      end if;
426
      write (L, String'("")); writeline(rx_file, L);
427
 
428
  end case;
429
 
430
end PROC_3DW;
431
 
432
 
433
-- ************************************************************
434
--  Proc : PROC_4DW
435
--  Inputs : fmt, type, traffic_class, td, ep, attr, length
436
--  payload
437
--  Outputs : None
438
--  Description : Gets variables and prints frame
439
--  *************************************************************/
440
 
441
procedure PROC_4DW (
442
 
443
  fmt                      : in std_logic_vector (1 downto 0);
444
  tlp_type                 : in std_logic_vector (4 downto 0);
445
  traffic_class            : in std_logic_vector (2 downto 0);
446
  td                       : in std_logic;
447
  ep                       : in std_logic;
448
  attr                     : in std_logic_vector (1 downto 0);
449
  length                   : in std_logic_vector (9 downto 0);
450
  payload                  : in INTEGER
451
 
452
) is
453
  variable requester_id    : std_logic_vector (15 downto 0);
454
  variable tag             : std_logic_vector (7 downto 0);
455
  variable byte_enables    : std_logic_vector (7 downto 0);
456
  variable message_code    : std_logic_vector (7 downto 0);
457
  variable address_high    : std_logic_vector (31 downto 0);
458
  variable address_low     : std_logic_vector (31 downto 0);
459
  variable msg_type        : std_logic_vector (2 downto 0);
460
  variable i               : INTEGER;
461
  variable L               : line;
462
  variable fmt_type        : std_logic_vector (6 downto 0);
463
 
464
begin
465
 
466
 
467
  writeHexToRx (String'("     Traffic Class: 0x"), '0' & traffic_class);
468
  write (L, String'("     TD: ")); write(L,  td); writeline (rx_file, L);
469
  write (L, String'("     EP: ")); write(L, ep); writeline (rx_file, L);
470
  writeHexToRx (String'("     Attributes: 0x"), "00" & attr);
471
  writeHexToRx (String'("     Length: 0x"), "00" & length);
472
 
473
  requester_id := frame_store_rx(4) & frame_store_rx(5);
474
  tag := frame_store_rx(6);
475
  byte_enables := frame_store_rx(7);
476
  message_code := frame_store_rx(7);
477
  address_high(31 downto 24) := frame_store_rx(8);
478
  address_high(23 downto 16) := frame_store_rx(9) ;
479
  address_high(15 downto 8) := frame_store_rx(10);
480
  address_high(7 downto 0) := frame_store_rx(11);
481
  address_low(31 downto 24) := frame_store_rx(12);
482
  address_low(23 downto 16) := frame_store_rx(13);
483
  address_low(15 downto 8) := frame_store_rx(14) ;
484
  address_low(7 downto 0) := frame_store_rx(15);
485
 
486
 
487
  writeHexToRx ( String'("     Requester Id: 0x"), requester_id);
488
  writeHexToRx ( String'("     Tag: 0x"), tag);
489
 
490
  fmt_type := fmt & tlp_type;
491
 
492
  if ((fmt_type(6 downto 3) = PCI_EXP_MSG_NODATA)
493
     or (fmt_type(6 downto 3) = PCI_EXP_MSG_DATA)) then
494
 
495
    msg_type := tlp_type(2 downto 0);
496
    writeHexToRx ( String'("     Message Type: 0x"), '0' & msg_type);
497
    writeHexToRx ( String'("     Message Code: 0x"), message_code);
498
    writeHexToRx ( String'("     Address High: 0x"), address_high);
499
    writeHexToRx ( String'("     Address Low:  0x"), address_low);
500
 
501
    if (payload = 1) then
502
 
503
      write (L, String'("")); writeline(rx_file, L);
504
      for i in 16 to (frame_store_rx_idx - 1) loop
505
 
506
        writeHexToRx ( String'("     0x"), frame_store_rx(i));
507
 
508
      end loop;
509
 
510
    end if;
511
    write (L, String'("")); writeline(rx_file, L);
512
 
513
  else
514
 
515
    case (fmt_type) is
516
 
517
      when PCI_EXP_MEM_READ64 | PCI_EXP_MEM_WRITE64 =>
518
 
519
        writeHexToRx ( String'("     Last and First Byte Enables: 0x"), byte_enables);
520
        writeHexToRx ( String'("     Address High: 0x"), address_high);
521
        writeHexToRx ( String'("     Address Low:  0x"), address_low);
522
 
523
        if (payload = 1) then
524
 
525
          write (L, String'("")); writeline(rx_file, L);
526
          for i in 16 to (frame_store_rx_idx - 1) loop
527
 
528
            writeHexToRx ( String'("     0x"), frame_store_rx(i));
529
 
530
          end loop;
531
 
532
        end if;
533
 
534
        write (L, String'("")); writeline(rx_file, L);
535
 
536
      when others =>
537
 
538
        write (L, String'(": Not a vaild frame")); writeline (rx_file, L); write (L, String'("")); writeline(rx_file, L);
539
        assert (false)
540
          report "Simulation Ended"
541
          severity failure;
542
 
543
    end  case;
544
 
545
  end if;
546
 
547
end PROC_4DW;
548
 
549
 
550
--************************************************************
551
--  Proc : PROC_PARSE_FRAME
552
--  Inputs : None
553
--  Outputs : None
554
--  Description : Parse frame data
555
--  *************************************************************/
556
 
557
procedure PROC_PARSE_FRAME  (
558
 
559
  signal rx_tx_read_data        : out std_logic_vector(31 downto 0);
560
  signal read_data_valid_int    : out std_logic
561
 
562
) is
563
 
564
  variable fmt                  : std_logic_vector (1 downto 0);
565
  variable tlp_type             : std_logic_vector (4 downto 0);
566
  variable traffic_class        : std_logic_vector (2 downto 0);
567
  variable td                   : std_logic;
568
  variable ep                   : std_logic;
569
  variable attr                 : std_logic_vector (1 downto 0);
570
  variable length               : std_logic_vector (9 downto 0);
571
  variable payload              : INTEGER;
572
  variable reqester_id          : std_logic_vector(15 downto 0);
573
  variable completer_id         : std_logic_vector(15 downto 0);
574
  variable tag                  : std_logic_vector(7 downto 0);
575
  variable byte_enables         : std_logic_vector(7 downto 0);
576
  variable message_code         : std_logic_vector(7 downto 0);
577
  variable address_low          : std_logic_vector(31 downto 0);
578
  variable address_high         : std_logic_vector(31 downto 0);
579
  variable register_address     : std_logic_vector (9 downto 0);
580
  variable completion_status    : std_logic_vector (2 downto 0);
581
  variable log_file_ptr         : std_logic_vector (31 downto 0);
582
  variable frame_store_idx      : INTEGER;
583
  variable fmt_type             : std_logic_vector (6 downto 0);
584
  variable L                    : line;
585
 
586
begin
587
 
588
  writeNowToScreen ( String'("PROC_PARSE_FRAME on Receive"));
589
 
590
  PROC_DECIPHER_FRAME (fmt, tlp_type, traffic_class, td, ep, attr, length);
591
 
592
  -- decode the packets received based on fmt and type
593
  fmt_type := fmt & tlp_type;
594
 
595
  if (fmt_type(6 downto 3) = PCI_EXP_MSG_NODATA) then
596
 
597
    writeNowToRx("Message With No Data Frame");
598
    payload := 0;
599
    PROC_4DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload);
600
 
601
  elsif (fmt_type(6 downto 3) = PCI_EXP_MSG_DATA) then
602
 
603
    writeNowToRx("Message With Data Frame");
604
    payload := 1;
605
    PROC_4DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload);
606
 
607
  else
608
 
609
    case (fmt_type) is
610
 
611
      when PCI_EXP_MEM_READ32 =>
612
 
613
        writeNowToRx("Memory Read-32 Frame");
614
        payload := 0;
615
        PROC_3DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload, rx_tx_read_data, read_data_valid_int );
616
 
617
      when PCI_EXP_IO_READ =>
618
 
619
        writeNowToRx("IO Read Frame");
620
        payload := 0;
621
        PROC_3DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload, rx_tx_read_data, read_data_valid_int );
622
 
623
      when PCI_EXP_CFG_READ0 =>
624
 
625
        writeNowToRx("Config Read Type 0 Frame");
626
        payload := 0;
627
        PROC_3DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload, rx_tx_read_data, read_data_valid_int );
628
 
629
      when PCI_EXP_COMPLETION_WO_DATA =>
630
 
631
        writeNowToRx("Completion Without Data Frame");
632
        payload := 0;
633
        PROC_3DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload, rx_tx_read_data, read_data_valid_int );
634
 
635
      when PCI_EXP_MEM_READ64 =>
636
 
637
        writeNowToRx("Memory Read-64 Frame");
638
        payload := 0;
639
        PROC_4DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload); --, rx_tx_read_data, rx_tx_read_data_valid );
640
 
641
      when PCI_EXP_MEM_WRITE32 =>
642
 
643
        writeNowToRx("Memory Write-32 Frame");
644
        payload := 1;
645
        PROC_3DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload, rx_tx_read_data, read_data_valid_int );
646
 
647
      when PCI_EXP_IO_WRITE =>
648
 
649
        writeNowToRx("IO Write Frame");
650
        payload := 1;
651
        PROC_3DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload, rx_tx_read_data, read_data_valid_int );
652
 
653
      when PCI_EXP_CFG_WRITE0 =>
654
 
655
        writeNowToRx("Config Write Type 0 Frame");
656
        payload := 1;
657
        PROC_3DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload, rx_tx_read_data, read_data_valid_int );
658
 
659
      when PCI_EXP_COMPLETION_DATA =>
660
 
661
        writeNowToRx("Completion With Data Frame");
662
        payload := 1;
663
        PROC_3DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload, rx_tx_read_data, read_data_valid_int );
664
 
665
      when PCI_EXP_MEM_WRITE64 =>
666
 
667
        writeNowToRx("Memory Write-64 Frame");
668
        payload := 1;
669
        PROC_4DW(fmt, tlp_type, traffic_class, td, ep, attr, length, payload);
670
 
671
      when others =>
672
 
673
        writeNowToRx("Not a vaild frame. fmt_type = ");
674
        write (L, fmt_type);
675
        writeline (rx_file, L);
676
        assert (false)
677
          report "Simulation Ended"
678
          severity failure;
679
 
680
    end case;
681
 
682
  end if;
683
 
684
  frame_store_rx_idx := 0; -- reset frame pointer
685
 
686
end PROC_PARSE_FRAME;
687
 
688
 
689
begin
690
 
691
trn_rdst_rdy_n      <= trn_rdst_rdy_n_c;
692
trn_rnp_ok_n        <= '0';
693
trn_rdst_rdy_n_c    <= '0';
694
 
695
-- Transaction Receive User Interface State Machine
696
 
697
process (trn_clk, trn_reset_n)
698
begin
699
 
700
  if (trn_reset_n = '0' ) then
701
 
702
    trn_rx_state  <= TRN_RX_RESET;
703
    frame_store_rx_idx := 0;
704
    rx_tx_read_data <= X"FFFFFFFF";
705
    read_data_valid_int <= '0';
706
 
707
  else
708
 
709
    if (trn_clk'event and trn_clk = '1') then
710
 
711
      case (trn_rx_state) is
712
 
713
        when TRN_RX_RESET =>
714
 
715
          if (trn_reset_n = '0') then
716
 
717
            trn_rx_state <= TRN_RX_RESET;
718
 
719
          else
720
 
721
            trn_rx_state <= TRN_RX_DOWN;
722
 
723
          end if;
724
 
725
        when TRN_RX_DOWN =>
726
 
727
          if (trn_lnk_up_n = '1') then
728
 
729
            trn_rx_state <= TRN_RX_DOWN;
730
 
731
          else
732
 
733
            trn_rx_state <= TRN_RX_IDLE;
734
 
735
          end if;
736
 
737
        when TRN_RX_IDLE =>
738
 
739
          read_data_valid_int <= '0';
740
          if (trn_reset_n = '0') then
741
 
742
            trn_rx_state <= TRN_RX_RESET;
743
 
744
          elsif (trn_lnk_up_n = '1') then
745
 
746
            trn_rx_state <= TRN_RX_DOWN;
747
 
748
          elsif ((trn_rsof_n = '0') and (trn_rsrc_rdy_n = '0') and (trn_rdst_rdy_n_c = '0')) then
749
 
750
            PROC_READ_DATA (0, trn_rd, trn_rrem_n);
751
            trn_rx_state <= TRN_RX_ACTIVE;
752
 
753
          else
754
 
755
            trn_rx_state <= TRN_RX_IDLE;
756
 
757
          end if;
758
 
759
        when TRN_RX_ACTIVE =>
760
 
761
          if (trn_reset_n = '0') then
762
 
763
            trn_rx_state <= TRN_RX_RESET;
764
 
765
          elsif (trn_lnk_up_n = '1') then
766
 
767
            trn_rx_state <= TRN_RX_DOWN;
768
 
769
          elsif ((trn_rsrc_rdy_n = '0') and (trn_reof_n = '0') and (trn_rdst_rdy_n_c = '0')) then
770
 
771
            PROC_READ_DATA (1, trn_rd, trn_rrem_n);
772
            PROC_PARSE_FRAME  (rx_tx_read_data , read_data_valid_int);
773
            trn_rx_state <= TRN_RX_IDLE;
774
 
775
          elsif ((trn_rsrc_rdy_n = '0') and (trn_rdst_rdy_n_c = '0')) then
776
 
777
            PROC_READ_DATA (0, trn_rd, trn_rrem_n);
778
            trn_rx_state <= TRN_RX_ACTIVE;
779
 
780
          elsif ((trn_rsrc_rdy_n = '0') and (trn_reof_n = '0') and (trn_rsrc_dsc_n = '0')) then
781
 
782
            PROC_READ_DATA (1, trn_rd, trn_rrem_n);
783
            PROC_PARSE_FRAME  (rx_tx_read_data , read_data_valid_int);
784
            trn_rx_state <= TRN_RX_SRC_DSC;
785
 
786
          else
787
 
788
            trn_rx_state <= TRN_RX_ACTIVE;
789
 
790
          end if;
791
 
792
        when TRN_RX_SRC_DSC =>
793
 
794
          if (trn_reset_n = '0') then
795
 
796
            trn_rx_state <= TRN_RX_RESET;
797
 
798
          elsif (trn_lnk_up_n = '1') then
799
 
800
            trn_rx_state <= TRN_RX_DOWN;
801
 
802
          else
803
 
804
            trn_rx_state <= TRN_RX_IDLE;
805
 
806
          end if;
807
 
808
        when others =>
809
 
810
          trn_rx_state <= TRN_RX_RESET;
811
 
812
      end case;
813
 
814
    end if;
815
 
816
  end if;
817
 
818
end process;
819
 
820
 
821
process (trn_clk, trn_reset_n)
822
begin
823
 
824
  if (trn_reset_n = '0' ) then
825
 
826
    next_trn_rx_timeout  := TRN_RX_TIMEOUT;
827
 
828
  else
829
 
830
    if (trn_clk'event and trn_clk = '1') then
831
 
832
      if (next_trn_rx_timeout = 0) then
833
 
834
        assert (false)
835
          report "RX Simulation Timeout."
836
          severity failure;
837
 
838
      elsif (trn_lnk_up_n = '0') then
839
 
840
        next_trn_rx_timeout := next_trn_rx_timeout - 1;
841
 
842
      end if;
843
 
844
    end if;
845
 
846
  end if;
847
 
848
end process;
849
 
850
 
851
--  Following is used to allow rx to tx communication to occur over two trn clocks - avoiding race conditions
852
process (trn_clk)
853
begin
854
 
855
  if (trn_clk'event and trn_clk = '1') then
856
 
857
     read_data_valid_int_d <= read_data_valid_int;
858
  end if;
859
 
860
end process;
861
 
862
 
863
process (trn_clk)
864
begin
865
 
866
  if (trn_clk'event and trn_clk = '1') then
867
 
868
    if (trn_lnk_up_n = '0') then
869
 
870
      if ((tx_rx_read_data_valid = '1' ) and ((read_data_valid_int = '1') or (read_data_valid_int_d = '1'))) then
871
 
872
        rx_tx_read_data_valid <= '1';
873
 
874
      else
875
 
876
        rx_tx_read_data_valid <= '0';
877
 
878
      end if;
879
 
880
    end if;
881
 
882
  end if;
883
 
884
end process;
885
 
886
end; -- pci_exp_usrapp_rx

powered by: WebSVN 2.1.0

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