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 35

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 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:      next_state <= RX;
72
      ACK:      if(rx_ready)
73
                  next_state <= RX;
74
                else
75
                  next_state <= ACK;
76 32 qaztronic
 
77
      RX:       if(rx)
78
                  next_state <= RX;
79
                else if(rx_data_valid)
80
                  next_state <= PENDING;
81
                else
82
                  next_state <= IDLE;
83
 
84
      PENDING:  if(rx_data_valid)
85
                  next_state <= PENDING;
86
                else
87
                  next_state <= IDLE;
88
 
89
      ERROR:    next_state <= IDLE;
90
 
91
      default:  next_state <= ERROR;
92
 
93
    endcase
94
 
95
 
96
  // --------------------------------------------------------------------
97
  //
98
  assign rx_ack = (state == ACK);
99
  assign rx_done = (state != IDLE) & (next_state == IDLE);
100
 
101
 
102
// --------------------------------------------------------------------
103
//
104
endmodule
105
 

powered by: WebSVN 2.1.0

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