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 32

Go to most recent revision | 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
    output  rx_ack,
34
    output  rx_done,
35
 
36
    input   reset,
37
    input   clk
38
  );
39
 
40
  //---------------------------------------------------
41
  //  state machine binary definitions
42
  enum reg [4:0]
43
    {
44
      IDLE    = 5'b0_0001,
45
      ACK     = 5'b0_0010,
46
      RX      = 5'b0_0100,
47
      PENDING = 5'b0_1000,
48
      ERROR   = 5'b1_0000
49
    } state, next_state;
50
 
51
 
52
  //---------------------------------------------------
53
  //  state machine flop
54
  always_ff @(posedge clk)
55
    if(reset)
56
      state <= IDLE;
57
    else
58
      state <= next_state;
59
 
60
 
61
  //---------------------------------------------------
62
  //  state machine
63
  always_comb
64
    case(state)
65
      IDLE:     if(rx)
66
                  next_state <= ACK;
67
                else
68
                  next_state <= IDLE;
69
 
70
      ACK:      next_state <= RX;
71
 
72
      RX:       if(rx)
73
                  next_state <= RX;
74
                else if(rx_data_valid)
75
                  next_state <= PENDING;
76
                else
77
                  next_state <= IDLE;
78
 
79
      PENDING:  if(rx_data_valid)
80
                  next_state <= PENDING;
81
                else
82
                  next_state <= IDLE;
83
 
84
      ERROR:    next_state <= IDLE;
85
 
86
      default:  next_state <= ERROR;
87
 
88
    endcase
89
 
90
 
91
  // --------------------------------------------------------------------
92
  //
93
  assign rx_ack = (state == ACK);
94
  assign rx_done = (state != IDLE) & (next_state == IDLE);
95
 
96
 
97
// --------------------------------------------------------------------
98
//
99
endmodule
100
 

powered by: WebSVN 2.1.0

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