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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [gmac/] [mac/] [g_deferral.v] - Blame information for rev 78

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Tubo 8051 cores MAC Interface Module                        ////
4
////                                                              ////
5
////  This file is part of the Turbo 8051 cores project           ////
6
////  http://www.opencores.org/cores/turbo8051/                   ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Turbo 8051 definitions.                                     ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17 76 dinesha
////  Revision : Mar 2, 2011                                      //// 
18
////                                                              ////
19 12 dinesha
//////////////////////////////////////////////////////////////////////
20
////                                                              ////
21
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
22
////                                                              ////
23
//// This source file may be used and distributed without         ////
24
//// restriction provided that this copyright statement is not    ////
25
//// removed from the file and that any derivative work contains  ////
26
//// the original copyright notice and the associated disclaimer. ////
27
////                                                              ////
28
//// This source file is free software; you can redistribute it   ////
29
//// and/or modify it under the terms of the GNU Lesser General   ////
30
//// Public License as published by the Free Software Foundation; ////
31
//// either version 2.1 of the License, or (at your option) any   ////
32
//// later version.                                               ////
33
////                                                              ////
34
//// This source is distributed in the hope that it will be       ////
35
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
36
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
37
//// PURPOSE.  See the GNU Lesser General Public License for more ////
38
//// details.                                                     ////
39
////                                                              ////
40
//// You should have received a copy of the GNU Lesser General    ////
41
//// Public License along with this source; if not, download it   ////
42
//// from http://www.opencores.org/lgpl.shtml                     ////
43
////                                                              ////
44
//////////////////////////////////////////////////////////////////////
45
 
46
/***************************************************************
47
  Description:
48
  deferral.v : This block performs the deferral algorithm for
49
               half duplex mode, as per the IEEE 802.3 section 4.2.3.2.2
50
               This block also implements the optional two part deferral
51
               mechanism.
52
***********************************************************************/
53
 
54
module g_deferral (
55
                 df2tx_dfl_dn,
56
                 cf2df_dfl_single,
57
                 phy_tx_en,
58
                 phy_tx_er,
59
                 tx_clk,
60
                 app_reset_n);
61
 
62
 
63
  input [7:0] cf2df_dfl_single;           //program with 9.6 ms
64
  input        phy_tx_en;                 //TX frame is done, wait for IPG
65
                                          //used in FULL duplex
66
  input        phy_tx_er;                 //TX Error 
67
  input        tx_clk;              //MII provided tx_clk
68
  input        app_reset_n;
69
 
70
  output       df2tx_dfl_dn;              //when active hold the TX, else
71
                                    //TX can send preamble  
72
 
73
  wire         df2tx_dfl_dn;
74
 
75
  parameter    dfl_idle_st =        6'b000000;
76
  parameter    dfl_dfl_st =         6'b000010;
77
  parameter    dfl_full_tx_dn_st =  6'b010000;
78
  parameter    dfl_wipg_st =        6'b100000;
79
 
80
  reg [5:0]    curr_dfl_st, nxt_dfl_st;
81
  reg          dfl_dn;
82
  reg          strt_dfl;
83
  reg [7:0]   dfl_cntr;
84
 
85
  reg         phy_tx_en_d;
86
 
87
  wire        was_xmitted;
88
 
89
  assign df2tx_dfl_dn = dfl_dn;
90
  /*****************************************************************
91
   * Synchronous process for the FSM to enable and disable TX on
92
   * receive activity
93
   *****************************************************************/
94
  always @(posedge tx_clk or negedge app_reset_n)
95
    begin
96
      if (!app_reset_n)
97
        curr_dfl_st <= dfl_idle_st;
98
      else
99
        curr_dfl_st <= nxt_dfl_st;
100
    end // always @ (posedge tx_clk or negedge app_reset_n)
101
 
102
  /*****************************************************************
103
   * comb        process for the FSM to enable and disable TX on
104
   * receive activity
105
   *****************************************************************/
106
  always @(curr_dfl_st or dfl_cntr
107
           or phy_tx_en or phy_tx_er or was_xmitted)
108
    begin
109
      strt_dfl = 0;
110
      dfl_dn = 0;
111
      nxt_dfl_st = curr_dfl_st;
112
 
113
      case (curr_dfl_st)
114
        dfl_idle_st :
115
          begin
116
            dfl_dn = 1;
117
            if (phy_tx_en)
118
              begin
119
                dfl_dn = 0;
120
                nxt_dfl_st = dfl_full_tx_dn_st;
121
              end // if (phy_tx_en)
122
            else
123
              nxt_dfl_st = dfl_idle_st;
124
          end // case: dfl_idle_st
125
 
126
        dfl_full_tx_dn_st :
127
          begin
128
            // full duplex mode, wait till the current tx
129
            // frame is transmitted and wait for IPG time,
130
            // no need to wait for two part defferal
131
            if (!phy_tx_en && !phy_tx_er)
132
              begin
133
                strt_dfl = 1;
134
                nxt_dfl_st = dfl_wipg_st;
135
              end // if (!phy_tx_en)
136
            else
137
              nxt_dfl_st = dfl_full_tx_dn_st;
138
          end // case: dfl_full_tx_dn_st
139
 
140
        dfl_wipg_st :
141
          begin
142
            // This state is reached when there is no transmit
143
            // in progress. In this state IPG counter should checked
144
            // and upon its expiry indicate deferral done
145
            // to tx_fsm block
146
            if (dfl_cntr == 8'd0)
147
              begin
148
                dfl_dn = 1;
149
                nxt_dfl_st = dfl_idle_st;
150
              end
151
            else
152
              nxt_dfl_st = dfl_wipg_st;
153
          end // case: dfl_wipg_st
154
 
155
        default :
156
          begin
157
            nxt_dfl_st = dfl_idle_st;
158
          end
159
      endcase // case (curr_dfl_st)
160
    end // always @ (curr_dfl_st )
161
 
162
  //counter for the single phase deferral scheme
163
  always @(posedge tx_clk or negedge app_reset_n)
164
    begin
165
      if (!app_reset_n)
166
        dfl_cntr <= 8'd0;
167
      else
168
        begin
169
          if (strt_dfl)
170
            begin
171
               dfl_cntr <= cf2df_dfl_single;
172
            end
173
          else
174
            dfl_cntr <= dfl_cntr - 1;
175
        end // else: !if(app_reset_n)
176
    end // always @ (posedge tx_clk or negedge app_reset_n)
177
 
178
 
179
   // Detect Packet end
180
   assign was_xmitted = (phy_tx_en_d == 1'b1 && phy_tx_en == 1'b0) ? 1'b1 : 1'b0;
181
 
182
 
183
   always @(posedge tx_clk or negedge app_reset_n)
184
     begin
185
       if (!app_reset_n)
186
          phy_tx_en_d <= 1'b0;
187
       else
188
          phy_tx_en_d <= phy_tx_en;
189
     end // always @ (posedge tx_clk or negedge app_reset_n)
190
 
191
 
192
 
193
endmodule // deferral
194
 
195
 
196
 
197
 

powered by: WebSVN 2.1.0

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