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 34

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 34 qaztronic
    output  acked,
34 32 qaztronic
    input   tx_ack,
35
    input   tx_done,
36
 
37
    input   reset,
38
    input   clk
39
  );
40
 
41
  //---------------------------------------------------
42
  //  state machine binary definitions
43
  enum reg [3:0]
44
    {
45
      IDLE    = 4'b0001,
46
      ACK     = 4'b0010,
47
      TX      = 4'b0100,
48
      ERROR   = 4'b1000
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(tx_ready)
66
                  next_state <= ACK;
67
                else
68
                  next_state <= IDLE;
69
 
70
      ACK:      if(tx_ack)
71
                  next_state <= TX;
72
                else
73
                  next_state <= ACK;
74
 
75
      TX:       if(~tx_done)
76
                  next_state <= TX;
77
                else
78
                  next_state <= IDLE;
79
 
80
      ERROR:    next_state <= IDLE;
81
 
82
      default:  next_state <= ERROR;
83
 
84
    endcase
85
 
86
 
87
  // --------------------------------------------------------------------
88
  //
89 34 qaztronic
  assign tx     = (state == ACK) | (state == TX);
90
  assign acked  = (state == TX)  | (next_state == TX);
91 32 qaztronic
 
92
 
93
// --------------------------------------------------------------------
94
//
95
endmodule
96
 

powered by: WebSVN 2.1.0

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