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

Subversion Repositories rio

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

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

Line No. Rev Author Line
1 33 magro732
-------------------------------------------------------------------------------
2 36 magro732
-- 
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
-- Contains a platform to build endpoints on.
10
-- 
11
-- To Do:
12
-- -
13
-- 
14
-- Author(s): 
15
-- - Magnus Rosenius, magro732@opencores.org 
16
-- 
17
-------------------------------------------------------------------------------
18
-- 
19
-- Copyright (C) 2013 Authors and OPENCORES.ORG 
20
-- 
21
-- This source file may be used and distributed without 
22
-- restriction provided that this copyright statement is not 
23
-- removed from the file and that any derivative work contains 
24
-- the original copyright notice and the associated disclaimer. 
25
-- 
26
-- This source file is free software; you can redistribute it 
27
-- and/or modify it under the terms of the GNU Lesser General 
28
-- Public License as published by the Free Software Foundation; 
29
-- either version 2.1 of the License, or (at your option) any 
30
-- later version. 
31
-- 
32
-- This source is distributed in the hope that it will be 
33
-- useful, but WITHOUT ANY WARRANTY; without even the implied 
34
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
35
-- PURPOSE. See the GNU Lesser General Public License for more 
36
-- details. 
37
-- 
38
-- You should have received a copy of the GNU Lesser General 
39
-- Public License along with this source; if not, download it 
40
-- from http://www.opencores.org/lgpl.shtml 
41
-- 
42
-------------------------------------------------------------------------------
43
 
44
-------------------------------------------------------------------------------
45 33 magro732
-- RioLogicalCommon.
46
-------------------------------------------------------------------------------
47
-- Ingress:
48 35 magro732
-- * Removes in-the-middle and trailing CRC.
49 33 magro732
-- * Forwards packets to logical-layer handlers depending on ftype and
50
--   transaction (output as address).
51
-- * Outputs header and deviceIDs in seperate accesses to facilitate 8- and
52
--   16-bit deviceAddress support. All fields are right-justified.
53
-- Egress:
54 35 magro732
-- * Adds in-the-middle and trailing CRC.
55 33 magro732
-- * Receives packets from logical-layer handlers.
56 35 magro732
-- * Receives header and deviceIDs in seperate accesses to facilitate 8- and
57
--   16-bit deviceAddress support. All fields are right-justified.
58 33 magro732
-------------------------------------------------------------------------------
59
-- REMARK: Egress; Places packets in different queues depending on the packet priority?
60 44 magro732
-- REMARK: Do not use Wishbone, use request/grant scheme instead?
61
-- REMARK: 8-bit deviceId has not been verified, fix.
62 36 magro732
library ieee;
63
use ieee.std_logic_1164.all;
64
use ieee.numeric_std.all;
65
use work.rio_common.all;
66
 
67
 
68 38 magro732
-------------------------------------------------------------------------------
69
-- 
70
-------------------------------------------------------------------------------
71 36 magro732
entity RioLogicalCommon is
72
  port(
73
    clk : in std_logic;
74
    areset_n : in std_logic;
75
    enable : in std_logic;
76
 
77
    readFrameEmpty_i : in std_logic;
78
    readFrame_o : out std_logic;
79
    readContent_o : out std_logic;
80
    readContentEnd_i : in std_logic;
81
    readContentData_i : in std_logic_vector(31 downto 0);
82 39 magro732
 
83 36 magro732
    writeFrameFull_i : in std_logic;
84
    writeFrame_o : out std_logic;
85
    writeFrameAbort_o : out std_logic;
86
    writeContent_o : out std_logic;
87
    writeContentData_o : out std_logic_vector(31 downto 0);
88
 
89 39 magro732
    masterCyc_o : out std_logic;
90
    masterStb_o : out std_logic;
91
    masterAdr_o : out std_logic_vector(7 downto 0);
92
    masterDat_o : out std_logic_vector(31 downto 0);
93
    masterAck_i : in std_logic;
94
 
95
    slaveCyc_i : in std_logic;
96
    slaveStb_i : in std_logic;
97
    slaveDat_i : in std_logic_vector(31 downto 0);
98
    slaveAck_o : out std_logic);
99 36 magro732
end entity;
100
 
101
 
102 38 magro732
-------------------------------------------------------------------------------
103
-- 
104
-------------------------------------------------------------------------------
105 36 magro732
architecture RioLogicalCommon of RioLogicalCommon is
106
 
107
  component RioLogicalCommonIngress is
108
    port(
109
      clk : in std_logic;
110
      areset_n : in std_logic;
111
 
112
      readFrameEmpty_i : in std_logic;
113
      readFrame_o : out std_logic;
114
      readContent_o : out std_logic;
115
      readContentEnd_i : in std_logic;
116
      readContentData_i : in std_logic_vector(31 downto 0);
117
 
118
      masterCyc_o : out std_logic;
119
      masterStb_o : out std_logic;
120
      masterAdr_o : out std_logic_vector(7 downto 0);
121
      masterDat_o : out std_logic_vector(31 downto 0);
122
      masterAck_i : in std_logic);
123
  end component;
124
 
125
  component RioLogicalCommonEgress is
126
    port(
127
      clk : in std_logic;
128
      areset_n : in std_logic;
129
 
130
      writeFrameFull_i : in std_logic;
131
      writeFrame_o : out std_logic;
132
      writeFrameAbort_o : out std_logic;
133
      writeContent_o : out std_logic;
134
      writeContentData_o : out std_logic_vector(31 downto 0);
135
 
136
      slaveCyc_i : in std_logic;
137
      slaveStb_i : in std_logic;
138
      slaveDat_i : in std_logic_vector(31 downto 0);
139
      slaveAck_o : out std_logic);
140
  end component;
141
 
142
begin
143
 
144 38 magro732
  Ingress: RioLogicalCommonIngress
145
    port map(
146
      clk=>clk, areset_n=>areset_n,
147
      readFrameEmpty_i=>readFrameEmpty_i,
148
      readFrame_o=>readFrame_o,
149
      readContent_o=>readContent_o,
150
      readContentEnd_i=>readContentEnd_i,
151
      readContentData_i=>readContentData_i,
152 39 magro732
      masterCyc_o=>masterCyc_o,
153
      masterStb_o=>masterStb_o,
154
      masterAdr_o=>masterAdr_o,
155
      masterDat_o=>masterDat_o,
156
      masterAck_i=>masterAck_i);
157 38 magro732
 
158 36 magro732
  Egress: RioLogicalCommonEgress
159
    port map(
160
      clk=>clk, areset_n=>areset_n,
161
      writeFrameFull_i=>writeFrameFull_i,
162
      writeFrame_o=>writeFrame_o,
163
      writeFrameAbort_o=>writeFrameAbort_o,
164
      writeContent_o=>writeContent_o,
165
      writeContentData_o=>writeContentData_o,
166 39 magro732
      slaveCyc_i=>slaveCyc_i,
167
      slaveStb_i=>slaveStb_i,
168
      slaveDat_i=>slaveDat_i,
169
      slaveAck_o=>slaveAck_o);
170 36 magro732
 
171
end architecture;
172
 
173
 
174
 
175 34 magro732
-------------------------------------------------------------------------------
176
-- RioLogicalCommonIngress.
177
-------------------------------------------------------------------------------
178 35 magro732
-- REMARK: Check the destination address to see if it matches the one configured???
179 36 magro732
-- REMARK: Remove the acknowledge on all accesses on the master bus.
180
-- REMARK: Add component declarations to riocommon.vhd.
181 33 magro732
library ieee;
182 34 magro732
use ieee.std_logic_1164.all;
183 33 magro732
use ieee.numeric_std.all;
184
use work.rio_common.all;
185
 
186
-------------------------------------------------------------------------------
187
-- Entity for RioLogicalCommonIngress.
188
-------------------------------------------------------------------------------
189
entity RioLogicalCommonIngress is
190
  port(
191
    clk : in std_logic;
192
    areset_n : in std_logic;
193
 
194
    readFrameEmpty_i : in std_logic;
195
    readFrame_o : out std_logic;
196
    readContent_o : out std_logic;
197
    readContentEnd_i : in std_logic;
198
    readContentData_i : in std_logic_vector(31 downto 0);
199
 
200
    masterCyc_o : out std_logic;
201
    masterStb_o : out std_logic;
202 35 magro732
    masterAdr_o : out std_logic_vector(7 downto 0);
203
    masterDat_o : out std_logic_vector(31 downto 0);
204 33 magro732
    masterAck_i : in std_logic);
205
end entity;
206
 
207
 
208
-------------------------------------------------------------------------------
209
-- 
210
-------------------------------------------------------------------------------
211
architecture RioLogicalCommonIngress of RioLogicalCommonIngress is
212 36 magro732
  type StateType is (IDLE,
213
                     WAIT_HEADER_0, HEADER_0, HEADER_1,
214
                     SEND_HEADER, SEND_DESTINATION, SEND_SOURCE,
215
                     FORWARD_SHORT, FORWARD_CRC, FORWARD_LONG, FORWARD_LAST,
216
                     END_PACKET);
217
  signal state : StateType;
218 33 magro732
 
219 36 magro732
  signal packetPosition : natural range 0 to 32;
220
  signal packetContent : std_logic_vector(63 downto 0);
221
 
222
  signal tt : std_logic_vector(1 downto 0);
223
  signal ftype : std_logic_vector(3 downto 0);
224
  signal transaction : std_logic_vector(3 downto 0);
225
 
226 33 magro732
begin
227
 
228
  process(clk, areset_n)
229
  begin
230
    if (areset_n = '0') then
231 44 magro732
      state <= IDLE;
232 38 magro732
 
233 36 magro732
      packetPosition <= 0;
234
      packetContent <= (others=>'0');
235 44 magro732
 
236 36 magro732
      tt <= "00";
237
      ftype <= "0000";
238
      transaction <= "0000";
239 38 magro732
 
240
      readContent_o <= '0';
241
      readFrame_o <= '0';
242 44 magro732
 
243
      masterCyc_o <= '0';
244
      masterStb_o <= '0';
245
      masterAdr_o <= (others=>'0');
246
      masterDat_o <= (others=>'0');
247 33 magro732
    elsif (clk'event and clk = '1') then
248
      readContent_o <= '0';
249 38 magro732
      readFrame_o <= '0';
250 33 magro732
 
251
      case state is
252
        when IDLE =>
253
          ---------------------------------------------------------------------
254
          -- 
255
          ---------------------------------------------------------------------
256
          packetPosition <= 0;
257
          if (readFrameEmpty_i = '0') then
258
            readContent_o <= '1';
259
            state <= WAIT_HEADER_0;
260
          end if;
261
 
262
        when WAIT_HEADER_0 =>
263
          ---------------------------------------------------------------------
264
          -- 
265
          ---------------------------------------------------------------------
266
          readContent_o <= '1';
267
          state <= HEADER_0;
268
 
269
        when HEADER_0 =>
270
          ---------------------------------------------------------------------
271
          -- 
272
          ---------------------------------------------------------------------
273
          packetContent <= packetContent(31 downto 0) & readContentData_i;
274
          packetPosition <= packetPosition + 1;
275
          readContent_o <= '1';
276
 
277
          tt <= readContentData_i(21 downto 20);
278
          ftype <= readContentData_i(19 downto 16);
279
 
280
          state <= HEADER_1;
281
 
282
        when HEADER_1 =>
283
          ---------------------------------------------------------------------
284
          -- 
285
          ---------------------------------------------------------------------
286
          packetContent <= packetContent(31 downto 0) & readContentData_i;
287
          packetPosition <= packetPosition + 1;
288
 
289
          if (tt = "00") then
290
            transaction <= readContentData_i(31 downto 28);
291
          elsif (tt = "01") then
292
            transaction <= readContentData_i(15 downto 12);
293
          end if;
294
 
295
          state <= SEND_HEADER;
296
 
297
        when SEND_HEADER =>
298
          ---------------------------------------------------------------------
299
          -- 
300
          ---------------------------------------------------------------------
301 38 magro732
          masterCyc_o <= '1';
302 33 magro732
          masterStb_o <= '1';
303 35 magro732
          masterAdr_o <= ftype & transaction;
304
          masterDat_o <= x"0000" & packetContent(63 downto 48);
305 33 magro732
          packetContent <= packetContent(47 downto 0) & x"0000";
306
 
307
          state <= SEND_DESTINATION;
308
 
309
        when SEND_DESTINATION =>
310
          ---------------------------------------------------------------------
311
          -- 
312
          ---------------------------------------------------------------------
313
          if (masterAck_i = '1') then
314
            if (tt = "00") then
315 35 magro732
              masterDat_o <= x"000000" & packetContent(63 downto 56);
316 33 magro732
              packetContent <= packetContent(55 downto 0) & x"00";
317
            elsif (tt = "01") then
318 35 magro732
              masterDat_o <= x"0000" & packetContent(63 downto 48);
319 38 magro732
              packetContent <= packetContent(47 downto 0) & x"0000";
320 33 magro732
            end if;
321
 
322
            state <= SEND_SOURCE;
323
          end if;
324
 
325
        when SEND_SOURCE =>
326
          ---------------------------------------------------------------------
327
          -- 
328
          ---------------------------------------------------------------------
329
          if (masterAck_i = '1') then
330
            if (tt = "00") then
331 35 magro732
              masterDat_o <= x"000000" & packetContent(63 downto 56);
332 33 magro732
              packetContent <= packetContent(55 downto 0) & x"00";
333
            elsif (tt = "01") then
334 35 magro732
              masterDat_o <= x"0000" & packetContent(63 downto 48);
335 38 magro732
              packetContent <= packetContent(47 downto 32) & readContentData_i & x"0000";
336
              readContent_o <= '1';
337 33 magro732
            end if;
338
 
339 36 magro732
            state <= FORWARD_SHORT;
340 33 magro732
          end if;
341
 
342 36 magro732
        when FORWARD_SHORT =>
343 33 magro732
          ---------------------------------------------------------------------
344
          -- 
345
          ---------------------------------------------------------------------
346
          if (masterAck_i = '1') then
347 38 magro732
            packetPosition <= packetPosition + 1;
348 33 magro732
 
349 38 magro732
            if (tt = "00") then
350
              masterDat_o <= packetContent(63 downto 32);
351
              packetContent <= packetContent(31 downto 0) & readContentData_i;
352
            elsif (tt = "01") then
353
              masterDat_o <= packetContent(63 downto 32);
354
              packetContent <= packetContent(31 downto 16) & readContentData_i & x"0000";
355
            end if;
356 36 magro732
 
357
            if (readContentEnd_i = '0') then
358
              if (packetPosition = 20) then
359
                state <= FORWARD_CRC;
360
              end if;
361
 
362
              readContent_o <= '1';
363
            else
364
              readFrame_o <= '1';
365 44 magro732
              state <= FORWARD_LAST;
366 36 magro732
            end if;
367
          end if;
368 33 magro732
 
369 36 magro732
        when FORWARD_CRC =>
370
          ---------------------------------------------------------------------
371
          -- 
372
          ---------------------------------------------------------------------
373
          if (masterAck_i = '1') then
374
            masterDat_o <= packetContent(63 downto 32);
375
 
376
            packetPosition <= packetPosition + 1;
377
            packetContent <=
378
              packetContent(31 downto 0) & readContentData_i(15 downto 0) & x"0000";
379
 
380
            if (readContentEnd_i = '0') then
381
              readContent_o <= '1';
382
              state <= FORWARD_LONG;
383 33 magro732
            else
384 36 magro732
              readFrame_o <= '1';
385
              state <= FORWARD_LAST;
386 33 magro732
            end if;
387 36 magro732
          end if;
388
 
389
        when FORWARD_LONG =>
390
          ---------------------------------------------------------------------
391
          -- 
392
          ---------------------------------------------------------------------
393
          if (masterAck_i = '1') then
394
            masterDat_o <= packetContent(63 downto 32);
395
 
396
            packetPosition <= packetPosition + 1;
397
            packetContent <=
398
              packetContent(15 downto 0) & readContentData_i & x"0000";
399 33 magro732
 
400
            if (readContentEnd_i = '0') then
401
              readContent_o <= '1';
402
            else
403
              readFrame_o <= '1';
404
              state <= FORWARD_LAST;
405
            end if;
406
          end if;
407
 
408
        when FORWARD_LAST =>
409
          ---------------------------------------------------------------------
410
          -- 
411
          ---------------------------------------------------------------------
412 35 magro732
          -- REMARK: The last always contain the CRC?
413 33 magro732
          if (masterAck_i = '1') then
414 35 magro732
            masterDat_o <= packetContent(63 downto 32);
415 33 magro732
            state <= END_PACKET;
416
          end if;
417
 
418
        when END_PACKET =>
419
          ---------------------------------------------------------------------
420
          -- 
421
          ---------------------------------------------------------------------
422
          if (masterAck_i = '1') then
423 38 magro732
            masterCyc_o <= '0';
424
            masterStb_o <= '0';
425 33 magro732
            state <= IDLE;
426
          end if;
427
 
428
        when others =>
429
          ---------------------------------------------------------------------
430
          -- 
431
          ---------------------------------------------------------------------
432
          state <= IDLE;
433
      end case;
434
    end if;
435
  end process;
436
 
437
end architecture;
438
 
439
 
440 34 magro732
-------------------------------------------------------------------------------
441
-- RioLogicalCommonEgress.
442
-- Only 8-bit and 16-bit deviceId are supported. The first write must contain
443
-- the 16-bit header, the second write must contain the destination address and
444
-- the third must contain the source address.
445 36 magro732
-- CRC is calculated during the transfer and is inserted at byte 81 and 82 and
446 34 magro732
-- appended to the packet when it ends.
447
-------------------------------------------------------------------------------
448
library ieee;
449
use ieee.std_logic_1164.all;
450
use ieee.numeric_std.all;
451
use work.rio_common.all;
452 33 magro732
 
453 34 magro732
-------------------------------------------------------------------------------
454
-- Entity for RioLogicalCommonEgress.
455
-------------------------------------------------------------------------------
456
entity RioLogicalCommonEgress is
457
  port(
458
    clk : in std_logic;
459
    areset_n : in std_logic;
460 33 magro732
 
461 34 magro732
    writeFrameFull_i : in std_logic;
462
    writeFrame_o : out std_logic;
463
    writeFrameAbort_o : out std_logic;
464
    writeContent_o : out std_logic;
465
    writeContentData_o : out std_logic_vector(31 downto 0);
466
 
467
    slaveCyc_i : in std_logic;
468
    slaveStb_i : in std_logic;
469
    slaveDat_i : in std_logic_vector(31 downto 0);
470
    slaveAck_o : out std_logic);
471
end entity;
472
 
473
 
474 33 magro732
-------------------------------------------------------------------------------
475 34 magro732
-- Architecture for RioLogicalCommonEgress.
476
-------------------------------------------------------------------------------
477
architecture RioLogicalCommonEgress of RioLogicalCommonEgress is
478
 
479
  component Crc16CITT is
480
    port(
481
      d_i : in  std_logic_vector(15 downto 0);
482
      crc_i : in  std_logic_vector(15 downto 0);
483
      crc_o : out std_logic_vector(15 downto 0));
484
  end component;
485
 
486 36 magro732
  type StateType is (IDLE,
487
                     HEADER_GET, HEADER_ACK,
488
                     DESTINATION_GET, DESTINATION_ACK,
489
                     SOURCE_GET, SOURCE_ACK,
490 44 magro732
                     CONTENT_GET, CONTENT_ACK,
491
                     CRC_APPEND, CRC_UPDATE, CRC_LAST, SEND_FRAME,
492 36 magro732
                     RESTART_FRAME, WAIT_UPDATE);
493
  signal state : StateType;
494 44 magro732
  signal packetPosition : natural range 0 to 69;
495 36 magro732
 
496 44 magro732
  signal temp : std_logic_vector(15 downto 0);
497
 
498 36 magro732
  signal tt : std_logic_vector(1 downto 0);
499 38 magro732
  signal dstAddr : std_logic_vector(7 downto 0);
500 37 magro732
 
501 44 magro732
  signal writeContent : std_logic;
502
  signal writeContentData1 : std_logic_vector(31 downto 0);
503
  signal writeContentData2 : std_logic_vector(31 downto 0);
504
 
505
  signal crcReset : std_logic;
506 34 magro732
  signal crc16Current, crc16Temp, crc16Next: std_logic_vector(15 downto 0);
507
 
508
begin
509
 
510 44 magro732
  writeContent_o <= writeContent;
511
  writeContentData_o <= writeContentData1;
512
 
513 37 magro732
 
514 34 magro732
  process(clk, areset_n)
515
  begin
516
    if (areset_n = '0') then
517 44 magro732
      crc16Current <= x"0000";
518
    elsif (clk'event and clk = '1') then
519
      if (crcReset = '1') then
520
        crc16Current <= x"ffff";
521
      elsif (writeContent = '1') then
522
        crc16Current <= crc16Next;
523
      end if;
524
    end if;
525
  end process;
526
 
527
  process(clk, areset_n)
528
  begin
529
    if (areset_n = '0') then
530 36 magro732
      state <= IDLE;
531 44 magro732
      packetPosition <= 0;
532 38 magro732
 
533 44 magro732
      tt <= (others=>'0');
534
      dstAddr <= (others=>'0');
535
 
536
      temp <= (others=>'0');
537
      writeContent <= '0';
538
      writeContentData1 <= (others=>'0');
539
      writeContentData2 <= (others=>'0');
540
 
541
      crcReset <= '0';
542
 
543 38 magro732
      slaveAck_o <= '0';
544
 
545
      writeFrame_o <= '0';
546
      writeFrameAbort_o <= '0';
547 34 magro732
    elsif (clk'event and clk = '1') then
548 44 magro732
      writeContent <= '0';
549 34 magro732
      writeFrame_o <= '0';
550
 
551 44 magro732
      crcReset <= '0';
552
 
553 34 magro732
      case state is
554
        when IDLE =>
555
          ---------------------------------------------------------------------
556
          -- 
557
          ---------------------------------------------------------------------
558 35 magro732
          packetPosition <= 0;
559 44 magro732
          crcReset <= '1';
560 34 magro732
          if (writeFrameFull_i = '0') then
561
            state <= HEADER_GET;
562
          end if;
563
 
564 36 magro732
        when HEADER_GET =>
565 34 magro732
          ---------------------------------------------------------------------
566
          -- 
567
          ---------------------------------------------------------------------
568
          if ((slaveCyc_i = '1') and (slaveStb_i = '1')) then
569 44 magro732
            temp <= slaveDat_i(15 downto 0);
570 37 magro732
            tt <= slaveDat_i(5 downto 4);
571
 
572 34 magro732
            slaveAck_o <= '1';
573
            state <= HEADER_ACK;
574
          else
575 38 magro732
            state <= HEADER_GET;
576 34 magro732
          end if;
577
 
578
        when HEADER_ACK =>
579
          ---------------------------------------------------------------------
580
          -- 
581
          ---------------------------------------------------------------------
582
          slaveAck_o <= '0';
583
          state <= DESTINATION_GET;
584
 
585
        when DESTINATION_GET =>
586
          ---------------------------------------------------------------------
587
          -- 
588
          ---------------------------------------------------------------------
589
 
590
          if ((slaveCyc_i = '1') and (slaveStb_i = '1')) then
591 44 magro732
            if (tt = "01") then
592
              writeContentData2 <= temp & slaveDat_i(15 downto 0);
593 34 magro732
            else
594 44 magro732
              report "TT-field not supported." severity error;
595 34 magro732
            end if;
596
 
597
            slaveAck_o <= '1';
598
            state <= DESTINATION_ACK;
599
          else
600
            state <= RESTART_FRAME;
601
          end if;
602
 
603
        when DESTINATION_ACK =>
604
          ---------------------------------------------------------------------
605
          -- 
606
          ---------------------------------------------------------------------
607
          slaveAck_o <= '0';
608
          state <= SOURCE_GET;
609
 
610
        when SOURCE_GET =>
611
          ---------------------------------------------------------------------
612
          -- 
613
          ---------------------------------------------------------------------
614
 
615
          if ((slaveCyc_i = '1') and (slaveStb_i = '1')) then
616 44 magro732
            if (tt = "01") then
617
              temp <= slaveDat_i(15 downto 0);
618 34 magro732
            end if;
619
 
620
            slaveAck_o <= '1';
621
            state <= SOURCE_ACK;
622
          else
623
            state <= RESTART_FRAME;
624
          end if;
625
 
626
        when SOURCE_ACK =>
627
          ---------------------------------------------------------------------
628
          -- 
629
          ---------------------------------------------------------------------
630
          slaveAck_o <= '0';
631
          state <= CONTENT_GET;
632
 
633
        when CONTENT_GET =>
634
          ---------------------------------------------------------------------
635
          -- 
636
          ---------------------------------------------------------------------
637
          if ((slaveCyc_i = '1') and (slaveStb_i = '1')) then
638 44 magro732
            if (packetPosition < 19) then
639
              if (tt = "01") then
640
                writeContentData2 <= temp & slaveDat_i(31 downto 16);
641
                temp <= slaveDat_i(15 downto 0);
642
                slaveAck_o <= '1';
643
              end if;
644
            elsif (packetPosition = 19) then
645
              if (tt = "01") then
646
                writeContentData2 <= crc16Next & temp;
647
              end if;
648 37 magro732
            else
649 44 magro732
              if (tt = "01") then
650
                writeContentData2 <= slaveDat_i;
651
                slaveAck_o <= '1';
652
              end if;
653 34 magro732
            end if;
654 44 magro732
            writeContent <= '1';
655
            writeContentData1 <= writeContentData2;
656
            packetPosition <= packetPosition + 1;
657 34 magro732
            state <= CONTENT_ACK;
658
          else
659
            state <= CRC_APPEND;
660
          end if;
661 44 magro732
 
662 34 magro732
        when CONTENT_ACK =>
663
          ---------------------------------------------------------------------
664
          -- 
665
          ---------------------------------------------------------------------
666 44 magro732
          if (packetPosition = 20) then
667
            if (tt = "01") then
668
              writeContentData2 <= crc16Next & temp;
669
            end if;
670
          end if;
671 34 magro732
          slaveAck_o <= '0';
672 44 magro732
          state <= CONTENT_GET;
673 34 magro732
 
674 44 magro732
        when CRC_APPEND =>
675
          ---------------------------------------------------------------------
676
          -- 
677
          ---------------------------------------------------------------------
678
          if (packetPosition < 19) then
679
            if (tt = "01") then
680
              writeContent <= '1';
681
              writeContentData1 <= writeContentData2;
682 34 magro732
              packetPosition <= packetPosition + 1;
683
            end if;
684 44 magro732
          elsif (packetPosition = 19) then
685
            if (tt = "01") then
686
              writeContent <= '1';
687
              writeContentData1 <= writeContentData2;
688
              packetPosition <= packetPosition + 1;
689
            end if;
690
          else
691
            if (tt = "01") then
692
              writeContentData1 <= writeContentData2(31 downto 16) & x"0000";
693
              packetPosition <= packetPosition + 1;
694
            end if;
695 34 magro732
          end if;
696 44 magro732
          state <= CRC_UPDATE;
697 34 magro732
 
698 44 magro732
        when CRC_UPDATE =>
699
          ---------------------------------------------------------------------
700
          -- 
701
          ---------------------------------------------------------------------
702
          state <= CRC_LAST;
703 34 magro732
 
704 44 magro732
        when CRC_LAST =>
705 34 magro732
          ---------------------------------------------------------------------
706
          -- 
707
          ---------------------------------------------------------------------
708 44 magro732
          if (packetPosition < 19) then
709
            if (tt = "01") then
710
              writeContent <= '1';
711
              writeContentData1 <= crc16Current & x"0000";
712
            end if;
713
          elsif (packetPosition = 19) then
714
            if (tt = "01") then
715
 
716
            end if;
717
          else
718
            if (tt = "01") then
719
              writeContent <= '1';
720
              writeContentData1 <= writeContentData2(31 downto 16) & crc16Temp;
721
              packetPosition <= packetPosition + 1;
722
            end if;
723 34 magro732
          end if;
724 44 magro732
 
725 34 magro732
          state <= SEND_FRAME;
726 44 magro732
 
727 34 magro732
        when SEND_FRAME =>
728
          ---------------------------------------------------------------------
729
          -- 
730
          ---------------------------------------------------------------------
731
          writeFrame_o <= '1';
732
          state <= WAIT_UPDATE;
733
 
734
        when RESTART_FRAME =>
735
          ---------------------------------------------------------------------
736
          -- 
737
          ---------------------------------------------------------------------
738
          writeFrameAbort_o <= '1';
739
          state <= WAIT_UPDATE;
740
 
741
        when WAIT_UPDATE =>
742
          ---------------------------------------------------------------------
743
          -- 
744
          ---------------------------------------------------------------------
745 38 magro732
          writeFrameAbort_o <= '0';
746 34 magro732
          state <= IDLE;
747
 
748
        when others =>
749
          ---------------------------------------------------------------------
750
          -- 
751
          ---------------------------------------------------------------------
752
      end case;
753
    end if;
754
  end process;
755
 
756
  -----------------------------------------------------------------------------
757
  -- Packet CRC calculation.
758
  -----------------------------------------------------------------------------
759
 
760
  Crc16High: Crc16CITT
761
    port map(
762 44 magro732
      d_i=>writeContentData1(31 downto 16), crc_i=>crc16Current, crc_o=>crc16Temp);
763 34 magro732
  Crc16Low: Crc16CITT
764
    port map(
765 44 magro732
      d_i=>writeContentData1(15 downto 0), crc_i=>crc16Temp, crc_o=>crc16Next);
766 34 magro732
 
767
end architecture;

powered by: WebSVN 2.1.0

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