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

Subversion Repositories rio

[/] [rio/] [branches/] [2.0.0-development/] [rtl/] [vhdl/] [RioLogicalPackets.vhd] - Blame information for rev 47

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

Line No. Rev Author Line
1 46 magro732
-------------------------------------------------------------------------------
2
-- 
3
-- RapidIO IP Library Core
4
-- 
5
-- This file is part of the RapidIO IP library project
6
-- http://www.opencores.org/cores/rio/
7
-- 
8
-- Description
9
-- Containing RapidIO packet parsers and generators.
10
-- 
11
-- To Do:
12
-- - Add support for maint-request and response in both directions.
13
-- - Add support for portWrite in both directions.
14
-- - Add generic to disable support for specified packets.
15
-- - Dont set complete before the packet is ready in inbound packet
16
--   handler.
17
-- - Add error indication if erronous sizes are received.
18
-- 
19
-- Author(s): 
20
-- - Magnus Rosenius, magro732@opencores.org 
21
-- 
22
-------------------------------------------------------------------------------
23
-- 
24
-- Copyright (C) 2014 Authors and OPENCORES.ORG 
25
-- 
26
-- This source file may be used and distributed without 
27
-- restriction provided that this copyright statement is not 
28
-- removed from the file and that any derivative work contains 
29
-- the original copyright notice and the associated disclaimer. 
30
-- 
31
-- This source file is free software; you can redistribute it 
32
-- and/or modify it under the terms of the GNU Lesser General 
33
-- Public License as published by the Free Software Foundation; 
34
-- either version 2.1 of the License, or (at your option) any 
35
-- later version. 
36
-- 
37
-- This source is distributed in the hope that it will be 
38
-- useful, but WITHOUT ANY WARRANTY; without even the implied 
39
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
40
-- PURPOSE. See the GNU Lesser General Public License for more 
41
-- details. 
42
-- 
43
-- You should have received a copy of the GNU Lesser General 
44
-- Public License along with this source; if not, download it 
45
-- from http://www.opencores.org/lgpl.shtml 
46
-- 
47
-------------------------------------------------------------------------------
48
 
49
 
50
-------------------------------------------------------------------------------
51
-- MaintenanceInbound
52
-------------------------------------------------------------------------------
53
library ieee;
54
use ieee.std_logic_1164.all;
55
use ieee.numeric_std.all;
56
use work.rio_common.all;
57
 
58
 
59
-------------------------------------------------------------------------------
60
-- Entity for MaintenanceInbound.
61
-------------------------------------------------------------------------------
62
entity MaintenanceInbound is
63
  port(
64
    clk : in std_logic;
65
    areset_n : in std_logic;
66
    enable : in std_logic;
67
 
68
    readRequestReady_o : out std_logic;
69
    writeRequestReady_o : out std_logic;
70
    readResponseReady_o : out std_logic;
71
    writeResponseReady_o : out std_logic;
72
    portWriteReady_o : out std_logic;
73
    vc_o : out std_logic;
74
    crf_o : out std_logic;
75
    prio_o : out std_logic_vector(1 downto 0);
76
    tt_o : out std_logic_vector(1 downto 0);
77
    dstid_o : out std_logic_vector(31 downto 0);
78
    srcid_o : out std_logic_vector(31 downto 0);
79 47 magro732
    size_o : out std_logic_vector(3 downto 0);
80
    status_o : out std_logic_vector(3 downto 0);
81 46 magro732
    tid_o : out std_logic_vector(7 downto 0);
82
    hop_o : out std_logic_vector(7 downto 0);
83
    offset_o : out std_logic_vector(20 downto 0);
84
    wdptr_o : out std_logic;
85 47 magro732
    payloadLength_o : out std_logic_vector(2 downto 0);
86
    payloadIndex_i : in std_logic_vector(2 downto 0);
87
    payload_o : out std_logic_vector(63 downto 0);
88 46 magro732
    done_i : in std_logic;
89
 
90
    inboundCyc_i : in std_logic;
91
    inboundStb_i : in std_logic;
92
    inboundAdr_i : in std_logic_vector(7 downto 0);
93
    inboundDat_i : in std_logic_vector(31 downto 0);
94
    inboundAck_o : out std_logic);
95
end entity;
96
 
97
 
98
-------------------------------------------------------------------------------
99
-- Architecture for MaintenanceInbound.
100
-------------------------------------------------------------------------------
101
architecture MaintenanceInbound of MaintenanceInbound is
102
 
103
  type StateType is (RECEIVE_PACKET, READY);
104
  signal state : StateType;
105
 
106
  signal wdptr : std_logic;
107
  signal size : std_logic_vector(3 downto 0);
108
 
109
  signal inboundAck : std_logic;
110 47 magro732
  signal readRequestComplete : std_logic;
111
  signal writeRequestComplete : std_logic;
112
  signal readResponseComplete : std_logic;
113
  signal writeResponseComplete : std_logic;
114 46 magro732
 
115 47 magro732
  signal packetIndex : natural range 0 to 21;
116
  signal packetData : std_logic_vector(47 downto 0);
117 46 magro732
 
118
  signal memoryWrite : std_logic;
119 47 magro732
  signal memoryAddress : std_logic_vector(2 downto 0);
120
  signal memoryDataIn : std_logic_vector(63 downto 0);
121 46 magro732
 
122
begin
123
 
124 47 magro732
  readRequestReady_o <= readRequestComplete when (state = READY) else '0';
125
  writeRequestReady_o <= writeRequestComplete when (state = READY) else '0';
126
  readResponseReady_o <= readResponseComplete when (state = READY) else '0';
127
  writeResponseReady_o <= writeResponseComplete when (state = READY) else '0';
128 46 magro732
  portWriteReady_o <= '0';
129
 
130
  inboundAck_o <= inboundAck;
131
  MaintenanceRequest: process(clk, areset_n)
132
  begin
133
    if (areset_n = '0') then
134
      inboundAck <= '0';
135
 
136 47 magro732
      readRequestComplete <= '0';
137
      writeRequestComplete <= '0';
138
      readResponseComplete <= '0';
139
      writeResponseComplete <= '0';
140 46 magro732
 
141
      vc_o <= '0';
142
      crf_o <= '0';
143
      prio_o <= "00";
144
      tt_o <= "00";
145
      dstid_o <= (others=>'0');
146
      srcid_o <= (others=>'0');
147 47 magro732
      status_o <= (others=>'0');
148 46 magro732
      tid_o <= (others=>'0');
149
      hop_o <= (others=>'0');
150
      offset_o <= (others=>'0');
151
 
152
      wdptr <= '0';
153
      size <= (others=>'0');
154
 
155
      packetIndex <= 0;
156
      memoryWrite <= '0';
157
      memoryAddress <= (others=>'0');
158
      memoryDataIn <= (others=>'0');
159
    elsif (clk'event and clk = '1') then
160
      case state is
161
        when RECEIVE_PACKET =>
162
          ---------------------------------------------------------------------
163
          -- This state waits for a new maintenance packet, receives it
164
          -- and parses it.
165
          ---------------------------------------------------------------------
166
          if (inboundCyc_i = '1') then
167
            if (inboundAck = '0') then
168
              if (inboundStb_i = '1') then
169
                if (inboundAdr_i = x"80") then
170
                  -------------------------------------------------------------
171
                  -- Maintenance Read Request packet parser.
172
                  -------------------------------------------------------------
173
                  case (packetIndex) is
174
                    when 0 =>
175
                      -- x"0000" & ackid & vc & crf & prio & tt & ftype
176
                      vc_o <= inboundDat_i(9);
177
                      crf_o <= inboundDat_i(8);
178
                      prio_o <= inboundDat_i(7 downto 6);
179
                      tt_o <= inboundDat_i(5 downto 4);
180
                      packetIndex <= packetIndex + 1;
181
                    when 1 =>
182
                      -- dstid
183
                      dstid_o <= inboundDat_i;
184
                      packetIndex <= packetIndex + 1;
185
                    when 2 =>
186
                      -- srcid
187
                      srcid_o <= inboundDat_i;
188
                      packetIndex <= packetIndex + 1;
189
                    when 3 =>
190
                      -- transaction & rdsize & srcTID & hop & config_offset(20:13)
191
                      size <= inboundDat_i(27 downto 24);
192
                      tid_o <= inboundDat_i(23 downto 16);
193
                      hop_o <= inboundDat_i(15 downto 8);
194
                      offset_o(20 downto 13) <= inboundDat_i(7 downto 0);
195
                      packetIndex <= packetIndex + 1;
196
                    when 4 =>
197
                      -- config_offset(12:0) & wdptr & rsrv & crc(15:0)
198
                      offset_o(12 downto 0) <= inboundDat_i(31 downto 19);
199
                      wdptr <= inboundDat_i(18);
200
                      packetIndex <= packetIndex + 1;
201 47 magro732
                      readRequestComplete <= '1';
202 46 magro732
                    when others =>
203
                      -- There should be no more content in a maintenance read request.
204
                      -- Discard.
205 47 magro732
                      --report "Received unexpected packet content in read request." severity warning;
206 46 magro732
                  end case;
207
                  inboundAck <= '1';
208
                elsif (inboundAdr_i = x"81") then
209
                  -------------------------------------------------------------
210
                  -- Maintenance Write Request packet parser.
211
                  -------------------------------------------------------------
212
                  case (packetIndex) is
213
                    when 0 =>
214
                      -- x"0000" & ackid & vc & crf & prio & tt & ftype
215
                      vc_o <= inboundDat_i(9);
216
                      crf_o <= inboundDat_i(8);
217
                      prio_o <= inboundDat_i(7 downto 6);
218
                      tt_o <= inboundDat_i(5 downto 4);
219
                      packetIndex <= packetIndex + 1;
220
                    when 1 =>
221
                      -- destId
222
                      dstid_o <= inboundDat_i;
223
                      packetIndex <= packetIndex + 1;
224
                    when 2 =>
225
                      -- srcId
226
                      srcid_o <= inboundDat_i;
227
                      packetIndex <= packetIndex + 1;
228
                    when 3 =>
229
                      -- transaction & wrsize & srcTID & hop & config_offset(20:13)
230
                      size <= inboundDat_i(27 downto 24);
231
                      tid_o <= inboundDat_i(23 downto 16);
232
                      hop_o <= inboundDat_i(15 downto 8);
233
                      offset_o(20 downto 13) <= inboundDat_i(7 downto 0);
234
                      packetIndex <= packetIndex + 1;
235
                    when 4 =>
236
                      -- config_offset(12:0) & wdptr & rsrv & double-word(63:48)
237
                      offset_o(12 downto 0) <= inboundDat_i(31 downto 19);
238
                      wdptr <= inboundDat_i(18);
239 47 magro732
                      packetData(47 downto 32) <= inboundDat_i(15 downto 0);
240 46 magro732
                      packetIndex <= packetIndex + 1;
241 47 magro732
                    when 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 =>
242 46 magro732
                      -- double-word(47:16)
243 47 magro732
                      packetData(31 downto 0) <= inboundDat_i;
244 46 magro732
                      packetIndex <= packetIndex + 1;
245 47 magro732
                    when 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 =>
246 46 magro732
                      -- double-word(15:0) & double-word(63:48)
247 47 magro732
                      packetData(47 downto 32) <= inboundDat_i(15 downto 0);
248 46 magro732
                      packetIndex <= packetIndex + 1;
249
                      memoryWrite <= '1';
250 47 magro732
                      memoryDataIn <= packetData & inboundDat_i(31 downto 16);
251
                      writeRequestComplete <= '1';
252 46 magro732
                    when others =>
253
                      -- There should be no more content in a maintenance write request.
254
                      -- Discard.
255 47 magro732
                      --report "Received unexpected packet content in write request." severity warning;
256 46 magro732
                  end case;
257
                  inboundAck <= '1';
258
                elsif (inboundAdr_i = x"82") then
259
                  -------------------------------------------------------------
260
                  -- Maintenance Read Response packet parser.
261
                  -------------------------------------------------------------
262 47 magro732
                  case (packetIndex) is
263
                    when 0 =>
264
                      -- x"0000" & ackid & vc & crf & prio & tt & ftype
265
                      vc_o <= inboundDat_i(9);
266
                      crf_o <= inboundDat_i(8);
267
                      prio_o <= inboundDat_i(7 downto 6);
268
                      tt_o <= inboundDat_i(5 downto 4);
269
                      packetIndex <= packetIndex + 1;
270
                    when 1 =>
271
                      -- destid
272
                      dstid_o <= inboundDat_i;
273
                      packetIndex <= packetIndex + 1;
274
                    when 2 =>
275
                      -- srcid
276
                      srcid_o <= inboundDat_i;
277
                      packetIndex <= packetIndex + 1;
278
                    when 3 =>
279
                      -- transaction & status & srcTID & hop & reserved(7:0)
280
                      status_o <= inboundDat_i(27 downto 24);
281
                      tid_o <= inboundDat_i(23 downto 16);
282
                      hop_o <= inboundDat_i(15 downto 8);
283
                      packetIndex <= packetIndex + 1;
284
                    when 4 =>
285
                      -- reserved(15:0) & wdptr & rsrv & double-word(63:48)
286
                      packetData(47 downto 32) <= inboundDat_i(15 downto 0);
287
                      packetIndex <= packetIndex + 1;
288
                    when 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 =>
289
                      -- double-word(47:16)
290
                      packetData(31 downto 0) <= inboundDat_i;
291
                      packetIndex <= packetIndex + 1;
292
                    when 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 =>
293
                      -- double-word(15:0) & double-word(63:48)
294
                      packetData(47 downto 32) <= inboundDat_i(15 downto 0);
295
                      packetIndex <= packetIndex + 1;
296
                      memoryWrite <= '1';
297
                      memoryDataIn <= packetData & inboundDat_i(31 downto 16);
298
                      readResponseComplete <= '1';
299
                    when others =>
300
                      -- There should be no more content in a maintenance write request.
301
                      -- Discard.
302
                      --report "Received unexpected packet content in read response." severity warning;
303
                  end case;
304
                  inboundAck <= '1';
305 46 magro732
                elsif (inboundAdr_i = x"83") then
306
                  -------------------------------------------------------------
307
                  -- Maintenance Write Response packet parser.
308
                  -------------------------------------------------------------
309 47 magro732
                  case (packetIndex) is
310
                    when 0 =>
311
                      -- x"0000" & ackid & vc & crf & prio & tt & ftype
312
                      vc_o <= inboundDat_i(9);
313
                      crf_o <= inboundDat_i(8);
314
                      prio_o <= inboundDat_i(7 downto 6);
315
                      tt_o <= inboundDat_i(5 downto 4);
316
                      packetIndex <= packetIndex + 1;
317
                    when 1 =>
318
                      -- dstid
319
                      dstid_o <= inboundDat_i;
320
                      packetIndex <= packetIndex + 1;
321
                    when 2 =>
322
                      -- srcid
323
                      srcid_o <= inboundDat_i;
324
                      packetIndex <= packetIndex + 1;
325
                    when 3 =>
326
                      -- transaction & status & srcTID & hop & reserved(7:0)
327
                      status_o <= inboundDat_i(27 downto 24);
328
                      tid_o <= inboundDat_i(23 downto 16);
329
                      hop_o <= inboundDat_i(15 downto 8);
330
                      packetIndex <= packetIndex + 1;
331
                    when 4 =>
332
                      -- reserved(15:0) & crc(15:0)
333
                      packetIndex <= packetIndex + 1;
334
                      writeResponseComplete <= '1';
335
                    when others =>
336
                      -- There should be no more content in a maintenance read request.
337
                      -- Discard.
338
                      --report "Received unexpected packet content in write response." severity warning;
339
                  end case;
340
                  inboundAck <= '1';
341 46 magro732
                elsif (inboundAdr_i = x"84") then
342
                  -------------------------------------------------------------
343
                  -- Maintenance Port-Write Request packet parser.
344
                  -------------------------------------------------------------
345
                else
346
                  -------------------------------------------------------------
347
                  -- Unsupported maintenance packet.
348
                  -------------------------------------------------------------
349 47 magro732
                  -- Cannot handle these, dont answer.
350 46 magro732
                end if;
351
              end if;
352
            else
353
              if (memoryWrite = '1') then
354
                memoryAddress <= std_logic_vector(unsigned(memoryAddress) + 1);
355
              end if;
356
 
357
              memoryWrite <= '0';
358
              inboundAck <= '0';
359
            end if;
360
          else
361 47 magro732
            if ((readRequestComplete = '1') or (writeRequestComplete = '1') or
362
                (readResponseComplete = '1') or (writeResponseComplete = '1')) then
363 46 magro732
              state <= READY;
364 47 magro732
            else
365
              packetIndex <= 0;
366
              memoryAddress <= (others=>'0');
367 46 magro732
            end if;
368
          end if;
369
 
370
        when READY =>
371
          ---------------------------------------------------------------------
372
          -- Wait for the handler of the packet to signal that it has been
373
          -- processed.
374
          ---------------------------------------------------------------------
375
          if (done_i = '1') then
376 47 magro732
            packetIndex <= 0;
377
            memoryAddress <= (others=>'0');
378
 
379
            readRequestComplete <= '0';
380
            writeRequestComplete <= '0';
381
            readResponseComplete <= '0';
382
            writeResponseComplete <= '0';
383 46 magro732
            state <= RECEIVE_PACKET;
384
          end if;
385
 
386
        when others =>
387
          ---------------------------------------------------------------------
388
          -- 
389
          ---------------------------------------------------------------------
390
 
391
      end case;
392
    end if;
393
  end process;
394
 
395
  -----------------------------------------------------------------------------
396
  -- Transformation of rdsize/wrsize into length of access and byte lanes.
397
  -----------------------------------------------------------------------------
398
 
399
  process(clk, areset_n)
400
  begin
401
    if (areset_n = '0') then
402 47 magro732
      size_o <= (others=>'0');
403
      wdptr_o <= '0';
404 46 magro732
      payloadLength_o <= (others=>'0');
405
    elsif (clk'event and clk = '1') then
406 47 magro732
      if (readRequestComplete = '1') or (writeRequestComplete = '1') then
407
        size_o <= size;
408
        wdptr_o <= wdptr;
409
        payloadLength_o <= memoryAddress;
410
      elsif (readResponseComplete = '1') then
411
        size_o <= size;
412
        wdptr_o <= wdptr;
413
        payloadLength_o <= memoryAddress;
414
      else
415
        size_o <= size;
416
        wdptr_o <= wdptr;
417
        payloadLength_o <= (others=>'0');
418 46 magro732
      end if;
419
    end if;
420
  end process;
421
 
422
  -----------------------------------------------------------------------------
423
  -- Payload content memory.
424
  -----------------------------------------------------------------------------
425
  PayloadMemory: MemorySimpleDualPort
426 47 magro732
    generic map(ADDRESS_WIDTH=>3, DATA_WIDTH=>64)
427 46 magro732
    port map(clkA_i=>clk,
428
             enableA_i=>memoryWrite,
429
             addressA_i=>memoryAddress,
430
             dataA_i=>memoryDataIn,
431
             clkB_i=>clk,
432
             enableB_i=>enable,
433
             addressB_i=>payloadIndex_i,
434
             dataB_o=>payload_o);
435
 
436
end architecture;
437
 
438
 
439
-------------------------------------------------------------------------------
440
-- MaintenanceOutbound.
441
-------------------------------------------------------------------------------
442
library ieee;
443
use ieee.std_logic_1164.all;
444
use ieee.numeric_std.all;
445
use work.rio_common.all;
446
 
447
-------------------------------------------------------------------------------
448
-- Entity for MaintenanceOutbound.
449
-------------------------------------------------------------------------------
450
entity MaintenanceOutbound is
451
  port(
452
    clk : in std_logic;
453
    areset_n : in std_logic;
454
    enable : in std_logic;
455
 
456
    readRequestReady_i : in std_logic;
457
    writeRequestReady_i : in std_logic;
458
    readResponseReady_i : in std_logic;
459
    writeResponseReady_i : in std_logic;
460
    portWriteReady_i : in std_logic;
461
    vc_i : in std_logic;
462
    crf_i : in std_logic;
463
    prio_i : in std_logic_vector(1 downto 0);
464
    tt_i : in std_logic_vector(1 downto 0);
465
    dstid_i : in std_logic_vector(31 downto 0);
466
    srcid_i : in std_logic_vector(31 downto 0);
467 47 magro732
    size_i : in std_logic_vector(3 downto 0);
468 46 magro732
    status_i : in std_logic_vector(3 downto 0);
469
    tid_i : in std_logic_vector(7 downto 0);
470
    hop_i : in std_logic_vector(7 downto 0);
471 47 magro732
    offset_i : in std_logic_vector(20 downto 0);
472 46 magro732
    wdptr_i : in std_logic;
473 47 magro732
    payloadLength_i : in std_logic_vector(2 downto 0);
474
    payloadIndex_o : out std_logic_vector(2 downto 0);
475
    payload_i : in std_logic_vector(63 downto 0);
476 46 magro732
    done_o : out std_logic;
477
 
478
    outboundCyc_o : out std_logic;
479
    outboundStb_o : out std_logic;
480
    outboundDat_o : out std_logic_vector(31 downto 0);
481
    outboundAck_i : in std_logic);
482
end entity;
483
 
484
 
485
-------------------------------------------------------------------------------
486
-- Architecture for MaintenanceOutbound.
487
-------------------------------------------------------------------------------
488
architecture MaintenanceOutbound of MaintenanceOutbound is
489
  type StateType is (WAIT_PACKET,
490 47 magro732
                     READ_REQUEST, WRITE_REQUEST,
491 46 magro732
                     READ_RESPONSE, WRITE_RESPONSE,
492
                     WAIT_COMPLETE, RESPONSE_DONE);
493
  signal state : StateType;
494 47 magro732
  signal packetIndex : natural range 0 to 21;
495
 
496 46 magro732
  signal header : std_logic_vector(31 downto 0);
497
  signal payload : std_logic_vector(15 downto 0);
498 47 magro732
  signal payloadIndex : std_logic_vector(2 downto 0);
499 46 magro732
 
500
begin
501
 
502
  -- unused(31:16) | ackId(15:10) | vc(9) | crf(8) | prio(7:6) | tt(5:4) | ftype(3:0).
503
  header <= x"0000" & "000000" & vc_i & crf_i & prio_i & tt_i & x"8";
504
 
505
  payloadIndex_o <= payloadIndex;
506
 
507
  MaintenanceResponse: process(clk, areset_n)
508
  begin
509
    if (areset_n = '0') then
510
      state <= WAIT_PACKET;
511
      packetIndex <= 0;
512
 
513
      payload <= (others=>'0');
514
      payloadIndex <= (others=>'0');
515
 
516
      outboundCyc_o <= '0';
517
      outboundStb_o <= '0';
518
 
519
      done_o <= '0';
520
    elsif (clk'event and clk = '1') then
521
      if (enable = '1') then
522
        case state is
523
          when WAIT_PACKET =>
524
            -------------------------------------------------------------------
525
            -- 
526
            -------------------------------------------------------------------
527 47 magro732
            payloadIndex <= (others=>'0');
528
            if (readRequestReady_i = '1') then
529 46 magro732
              outboundCyc_o <= '1';
530
              outboundStb_o <= '1';
531
              outboundDat_o <= header;
532
              packetIndex <= 1;
533 47 magro732
              state <= READ_REQUEST;
534
            elsif (writeRequestReady_i = '1') then
535
              outboundCyc_o <= '1';
536
              outboundStb_o <= '1';
537
              outboundDat_o <= header;
538
              packetIndex <= 1;
539
              state <= WRITE_REQUEST;
540
            elsif (readResponseReady_i = '1') then
541
              outboundCyc_o <= '1';
542
              outboundStb_o <= '1';
543
              outboundDat_o <= header;
544
              packetIndex <= 1;
545 46 magro732
              state <= READ_RESPONSE;
546
            elsif (writeResponseReady_i = '1') then
547
              outboundCyc_o <= '1';
548
              outboundStb_o <= '1';
549
              outboundDat_o <= header;
550
              packetIndex <= 1;
551
              state <= WRITE_RESPONSE;
552
            end if;
553
 
554 47 magro732
          when READ_REQUEST =>
555
            ---------------------------------------------------------------------
556
            -- 
557
            ---------------------------------------------------------------------
558
            if (outboundAck_i = '1') then
559
              case (packetIndex) is
560
                when 1 =>
561
                  -- dstid
562
                  outboundDat_o <= dstid_i;
563
                  packetIndex <= packetIndex + 1;
564
                when 2 =>
565
                  -- srcid 
566
                  outboundDat_o <= srcid_i;
567
                  packetIndex <= packetIndex + 1;
568
                when 3 =>
569
                  -- transaction & rdsize & srcTID & hop & config_offset(20:13)
570
                  outboundDat_o <= "0000" & size_i & tid_i & hop_i & offset_i(20 downto 13);
571
                  packetIndex <= packetIndex + 1;
572
                when others =>
573
                  -- config_offset(12:0) & wdptr & rsrv & crc(15:0)
574
                  outboundDat_o <= offset_i(12 downto 0) & wdptr_i & "00" & x"0000";
575
                  packetIndex <= packetIndex + 1;
576
                  state <= WAIT_COMPLETE;
577
              end case;
578
            end if;
579
 
580
          when WRITE_REQUEST =>
581
            ---------------------------------------------------------------------
582
            -- 
583
            ---------------------------------------------------------------------
584
            if (outboundAck_i = '1') then
585
              case (packetIndex) is
586
                when 1 =>
587
                  -- dstid
588
                  outboundDat_o <= dstid_i;
589
                  packetIndex <= packetIndex + 1;
590
                when 2 =>
591
                  -- srcid 
592
                  outboundDat_o <= srcid_i;
593
                  packetIndex <= packetIndex + 1;
594
                when 3 =>
595
                  -- transaction & size & srcTID & hop & config_offset(20:13)
596
                  outboundDat_o <= "0001" & size_i & tid_i & hop_i & offset_i(20 downto 13);
597
                  packetIndex <= packetIndex + 1;
598
                when 4 =>
599
                  -- config_offset(12:0) & wdptr & rsrv & double-wordN(63:48)
600
                  outboundDat_o <= offset_i(12 downto 0) & wdptr_i & "00" & payload_i(63 downto 48);
601
                  packetIndex <= packetIndex + 1;
602
                when 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 =>
603
                  -- double-wordN(47:16)
604
                  outboundDat_o <= payload_i(47 downto 16);
605
                  payload <= payload_i(15 downto 0);
606
                  payloadIndex <= std_logic_vector(unsigned(payloadIndex) + 1);
607
                  packetIndex <= packetIndex + 1;
608
                when 6 | 8 | 10 | 12 | 14 | 16 | 18 =>
609
                  -- double-wordN(15:0) & double-wordN(63:48)
610
                  outboundDat_o <= payload & payload_i(63 downto 48);
611
                  packetIndex <= packetIndex + 1;
612
 
613
                  if (payloadIndex = payloadLength_i) then
614
                    state <= WAIT_COMPLETE;
615
                  end if;
616
                when others =>
617
                  -- double-wordN(15:0) & double-wordN(63:48)
618
                  outboundDat_o <= payload & x"0000";
619
                  state <= WAIT_COMPLETE;
620
              end case;
621
            end if;
622
 
623 46 magro732
          when READ_RESPONSE =>
624
            ---------------------------------------------------------------------
625
            -- 
626
            ---------------------------------------------------------------------
627
            if (outboundAck_i = '1') then
628
              case (packetIndex) is
629
                when 1 =>
630 47 magro732
                  -- dstid
631 46 magro732
                  outboundDat_o <= dstid_i;
632
                  packetIndex <= packetIndex + 1;
633
                when 2 =>
634 47 magro732
                  -- srcid 
635 46 magro732
                  outboundDat_o <= srcid_i;
636
                  packetIndex <= packetIndex + 1;
637
                when 3 =>
638
                  -- transaction & status & targetTID & hop & reserved(7:0)
639
                  outboundDat_o <= "0010" & status_i & tid_i & hop_i & x"00";
640
                  packetIndex <= packetIndex + 1;
641
                when 4 =>
642
                  -- reserved(15:0) & double-wordN(63:48)
643 47 magro732
                  outboundDat_o <= x"0000" & payload_i(63 downto 48);
644 46 magro732
                  packetIndex <= packetIndex + 1;
645 47 magro732
                when 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 =>
646 46 magro732
                  -- double-wordN(47:16)
647 47 magro732
                  outboundDat_o <= payload_i(47 downto 16);
648
                  payload <= payload_i(15 downto 0);
649
                  payloadIndex <= std_logic_vector(unsigned(payloadIndex) + 1);
650 46 magro732
                  packetIndex <= packetIndex + 1;
651 47 magro732
                when 6 | 8 | 10 | 12 | 14 | 16 | 18 =>
652 46 magro732
                  -- double-wordN(15:0) & double-wordN(63:48)
653 47 magro732
                  outboundDat_o <= payload & payload_i(63 downto 48);
654
                  packetIndex <= packetIndex + 1;
655
 
656
                  if (payloadIndex = payloadLength_i) then
657 46 magro732
                    state <= WAIT_COMPLETE;
658
                  end if;
659
                when others =>
660 47 magro732
                  -- double-wordN(15:0) & double-wordN(63:48)
661
                  outboundDat_o <= payload & x"0000";
662
                  state <= WAIT_COMPLETE;
663 46 magro732
              end case;
664
            end if;
665
 
666
          when WRITE_RESPONSE =>
667
            ---------------------------------------------------------------------
668
            -- 
669
            ---------------------------------------------------------------------
670
            if (outboundAck_i = '1') then
671
              case (packetIndex) is
672
                when 1 =>
673 47 magro732
                  -- dstid
674 46 magro732
                  outboundDat_o <= dstid_i;
675
                  packetIndex <= packetIndex + 1;
676
                when 2 =>
677 47 magro732
                  -- srcid 
678 46 magro732
                  outboundDat_o <= srcid_i;
679
                  packetIndex <= packetIndex + 1;
680
                when 3 =>
681
                  -- transaction & status & targetTID & hop & reserved(7:0)
682
                  outboundDat_o <= "0011" & status_i & tid_i & hop_i & x"00";
683
                  packetIndex <= packetIndex + 1;
684
                when others =>
685
                  -- reserved(15:0) & crc(15:0)
686
                  outboundDat_o <= x"00000000";
687
                  packetIndex <= packetIndex + 1;
688
                  state <= WAIT_COMPLETE;
689
              end case;
690
            end if;
691
 
692
          when WAIT_COMPLETE =>
693
            -------------------------------------------------------------------
694
            -- 
695
            -------------------------------------------------------------------
696
            if (outboundAck_i = '1') then
697
              outboundCyc_o <= '0';
698
              outboundStb_o <= '0';
699
              state <= RESPONSE_DONE;
700
            end if;
701
 
702
          when RESPONSE_DONE =>
703
            ---------------------------------------------------------------------
704
            -- 
705
            ---------------------------------------------------------------------
706 47 magro732
            if ((readRequestReady_i = '0') and (writeRequestReady_i = '0') and
707
                (readResponseReady_i = '0') and (writeResponseReady_i = '0')) then
708 46 magro732
              state <= WAIT_PACKET;
709
              done_o <= '0';
710
            else
711
              done_o <= '1';
712
            end if;
713
 
714
          when others =>
715
            ---------------------------------------------------------------------
716
            -- 
717
            ---------------------------------------------------------------------
718
            state <= WAIT_PACKET;
719
 
720
        end case;
721
      end if;
722
    end if;
723
  end process;
724
 
725
end architecture;

powered by: WebSVN 2.1.0

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