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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [PCIe/] [src/] [RIFFA/] [riffa_chnl_tx_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_tx_fsm
30
  (
31
    input   tx_ready,
32
    output  tx,
33
    input   tx_ack,
34
    input   tx_done,
35
 
36
    input   reset,
37
    input   clk
38
  );
39
 
40
  //---------------------------------------------------
41
  //  state machine binary definitions
42
  enum reg [3:0]
43
    {
44
      IDLE    = 4'b0001,
45
      ACK     = 4'b0010,
46
      TX      = 4'b0100,
47
      ERROR   = 4'b1000
48
    } state, next_state;
49
 
50
 
51
  //---------------------------------------------------
52
  //  state machine flop
53
  always_ff @(posedge clk)
54
    if(reset)
55
      state <= IDLE;
56
    else
57
      state <= next_state;
58
 
59
 
60
  //---------------------------------------------------
61
  //  state machine
62
  always_comb
63
    case(state)
64
      IDLE:     if(tx_ready)
65
                  next_state <= ACK;
66
                else
67
                  next_state <= IDLE;
68
 
69
      ACK:      if(tx_ack)
70
                  next_state <= TX;
71
                else
72
                  next_state <= ACK;
73
 
74
      TX:       if(~tx_done)
75
                  next_state <= TX;
76
                else
77
                  next_state <= IDLE;
78
 
79
      ERROR:    next_state <= IDLE;
80
 
81
      default:  next_state <= ERROR;
82
 
83
    endcase
84
 
85
 
86
  // --------------------------------------------------------------------
87
  //
88
  assign tx = (state == ACK) | (state == TX);
89
 
90
 
91
// --------------------------------------------------------------------
92
//
93
endmodule
94
 

powered by: WebSVN 2.1.0

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