3df6c560a69df724d2d15334ac835dcab8f13f9b
[debian/gnuradio] / usrp2 / fpga / eth / rtl / verilog / miim / eth_outputcontrol.v
1 //////////////////////////////////////////////////////////////////////\r
2 ////                                                              ////\r
3 ////  eth_outputcontrol.v                                         ////\r
4 ////                                                              ////\r
5 ////  This file is part of the Ethernet IP core project           ////\r
6 ////  http://www.opencores.org/projects/ethmac/                   ////\r
7 ////                                                              ////\r
8 ////  Author(s):                                                  ////\r
9 ////      - Igor Mohor (igorM@opencores.org)                      ////\r
10 ////                                                              ////\r
11 ////  All additional information is avaliable in the Readme.txt   ////\r
12 ////  file.                                                       ////\r
13 ////                                                              ////\r
14 //////////////////////////////////////////////////////////////////////\r
15 ////                                                              ////\r
16 //// Copyright (C) 2001 Authors                                   ////\r
17 ////                                                              ////\r
18 //// This source file may be used and distributed without         ////\r
19 //// restriction provided that this copyright statement is not    ////\r
20 //// removed from the file and that any derivative work contains  ////\r
21 //// the original copyright notice and the associated disclaimer. ////\r
22 ////                                                              ////\r
23 //// This source file is free software; you can redistribute it   ////\r
24 //// and/or modify it under the terms of the GNU Lesser General   ////\r
25 //// Public License as published by the Free Software Foundation; ////\r
26 //// either version 2.1 of the License, or (at your option) any   ////\r
27 //// later version.                                               ////\r
28 ////                                                              ////\r
29 //// This source is distributed in the hope that it will be       ////\r
30 //// useful, but WITHOUT ANY WARRANTY; without even the implied   ////\r
31 //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////\r
32 //// PURPOSE.  See the GNU Lesser General Public License for more ////\r
33 //// details.                                                     ////\r
34 ////                                                              ////\r
35 //// You should have received a copy of the GNU Lesser General    ////\r
36 //// Public License along with this source; if not, download it   ////\r
37 //// from http://www.opencores.org/lgpl.shtml                     ////\r
38 ////                                                              ////\r
39 //////////////////////////////////////////////////////////////////////\r
40 //\r
41 // CVS Revision History\r
42 //\r
43 // $Log: eth_outputcontrol.v,v $\r
44 // Revision 1.2  2005/12/13 12:54:49  maverickist\r
45 // first simulation passed\r
46 //\r
47 // Revision 1.1.1.1  2005/12/13 01:51:45  Administrator\r
48 // no message\r
49 //\r
50 // Revision 1.2  2005/04/27 15:58:46  Administrator\r
51 // no message\r
52 //\r
53 // Revision 1.1.1.1  2004/12/15 06:38:54  Administrator\r
54 // no message\r
55 //\r
56 // Revision 1.4  2002/07/09 20:11:59  mohor\r
57 // Comment removed.\r
58 //\r
59 // Revision 1.3  2002/01/23 10:28:16  mohor\r
60 // Link in the header changed.\r
61 //\r
62 // Revision 1.2  2001/10/19 08:43:51  mohor\r
63 // eth_timescale.v changed to timescale.v This is done because of the\r
64 // simulation of the few cores in a one joined project.\r
65 //\r
66 // Revision 1.1  2001/08/06 14:44:29  mohor\r
67 // A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).\r
68 // Include files fixed to contain no path.\r
69 // File names and module names changed ta have a eth_ prologue in the name.\r
70 // File eth_timescale.v is used to define timescale\r
71 // All pin names on the top module are changed to contain _I, _O or _OE at the end.\r
72 // Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O\r
73 // and Mdo_OE. The bidirectional signal must be created on the top level. This\r
74 // is done due to the ASIC tools.\r
75 //\r
76 // Revision 1.1  2001/07/30 21:23:42  mohor\r
77 // Directory structure changed. Files checked and joind together.\r
78 //\r
79 // Revision 1.3  2001/06/01 22:28:56  mohor\r
80 // This files (MIIM) are fully working. They were thoroughly tested. The testbench is not updated.\r
81 //\r
82 //\r
83 \r
84 module eth_outputcontrol(Clk, Reset, InProgress, ShiftedBit, BitCounter, WriteOp, NoPre, MdcEn_n, Mdo, MdoEn);\r
85 \r
86 input         Clk;                // Host Clock\r
87 input         Reset;              // General Reset\r
88 input         WriteOp;            // Write Operation Latch (When asserted, write operation is in progress)\r
89 input         NoPre;              // No Preamble (no 32-bit preamble)\r
90 input         InProgress;         // Operation in progress\r
91 input         ShiftedBit;         // This bit is output of the shift register and is connected to the Mdo signal\r
92 input   [6:0] BitCounter;         // Bit Counter\r
93 input         MdcEn_n;            // MII Management Data Clock Enable signal is asserted for one Clk period before Mdc falls.\r
94 \r
95 output        Mdo;                // MII Management Data Output\r
96 output        MdoEn;              // MII Management Data Output Enable\r
97 \r
98 wire          SerialEn;\r
99 \r
100 reg           MdoEn_2d;\r
101 reg           MdoEn_d;\r
102 reg           MdoEn;\r
103 \r
104 reg           Mdo_2d;\r
105 reg           Mdo_d;\r
106 reg           Mdo;                // MII Management Data Output\r
107 \r
108 \r
109 \r
110 // Generation of the Serial Enable signal (enables the serialization of the data)\r
111 assign SerialEn =  WriteOp & InProgress & ( BitCounter>31 | ( ( BitCounter == 0 ) & NoPre ) )\r
112                 | ~WriteOp & InProgress & (( BitCounter>31 & BitCounter<46 ) | ( ( BitCounter == 0 ) & NoPre ));\r
113 \r
114 \r
115 // Generation of the MdoEn signal\r
116 always @ (posedge Clk or posedge Reset)\r
117 begin\r
118   if(Reset)\r
119     begin\r
120       MdoEn_2d <= 1'b0;\r
121       MdoEn_d <= 1'b0;\r
122       MdoEn <= 1'b0;\r
123     end\r
124   else\r
125     begin\r
126       if(MdcEn_n)\r
127         begin\r
128           MdoEn_2d <= SerialEn | InProgress & BitCounter<32;\r
129           MdoEn_d <= MdoEn_2d;\r
130           MdoEn <= MdoEn_d;\r
131         end\r
132     end\r
133 end\r
134 \r
135 \r
136 // Generation of the Mdo signal.\r
137 always @ (posedge Clk or posedge Reset)\r
138 begin\r
139   if(Reset)\r
140     begin\r
141       Mdo_2d <= 1'b0;\r
142       Mdo_d <= 1'b0;\r
143       Mdo <= 1'b0;\r
144     end\r
145   else\r
146     begin\r
147       if(MdcEn_n)\r
148         begin\r
149           Mdo_2d <= ~SerialEn & BitCounter<32;\r
150           Mdo_d <= ShiftedBit | Mdo_2d;\r
151           Mdo <= Mdo_d;\r
152         end\r
153     end\r
154 end\r
155 \r
156 \r
157 \r
158 endmodule\r