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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [PCIe/] [src/] [RIFFA/] [riffa_chnl_rx_fsm.sv] - Blame information for rev 42

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 32 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2017 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
module
29
  riffa_chnl_rx_fsm
30
  (
31
    input   rx,
32
    input   rx_data_valid,
33 35 qaztronic
    input   rx_ready,
34 32 qaztronic
    output  rx_ack,
35
    output  rx_done,
36
 
37
    input   reset,
38
    input   clk
39
  );
40
 
41
  //---------------------------------------------------
42
  //  state machine binary definitions
43
  enum reg [4:0]
44
    {
45
      IDLE    = 5'b0_0001,
46
      ACK     = 5'b0_0010,
47
      RX      = 5'b0_0100,
48
      PENDING = 5'b0_1000,
49
      ERROR   = 5'b1_0000
50
    } state, next_state;
51
 
52
 
53
  //---------------------------------------------------
54
  //  state machine flop
55
  always_ff @(posedge clk)
56
    if(reset)
57
      state <= IDLE;
58
    else
59
      state <= next_state;
60
 
61
 
62
  //---------------------------------------------------
63
  //  state machine
64
  always_comb
65
    case(state)
66
      IDLE:     if(rx)
67
                  next_state <= ACK;
68
                else
69
                  next_state <= IDLE;
70
 
71 35 qaztronic
      ACK:      if(rx_ready)
72
                  next_state <= RX;
73
                else
74
                  next_state <= ACK;
75 32 qaztronic
 
76
      RX:       if(rx)
77
                  next_state <= RX;
78
                else if(rx_data_valid)
79
                  next_state <= PENDING;
80
                else
81
                  next_state <= IDLE;
82
 
83
      PENDING:  if(rx_data_valid)
84
                  next_state <= PENDING;
85
                else
86
                  next_state <= IDLE;
87
 
88
      ERROR:    next_state <= IDLE;
89
 
90
      default:  next_state <= ERROR;
91
 
92
    endcase
93
 
94
 
95
  // --------------------------------------------------------------------
96
  //
97
  assign rx_ack = (state == ACK);
98
  assign rx_done = (state != IDLE) & (next_state == IDLE);
99
 
100
 
101
// --------------------------------------------------------------------
102
//
103
endmodule
104
 

powered by: WebSVN 2.1.0

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