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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [gmac/] [mac/] [g_deferral_rx.v] - Blame information for rev 12

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

powered by: WebSVN 2.1.0

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