remove unused port
[debian/gnuradio] / usrp2 / fpga / eth / rtl / verilog / miim / eth_clockgen.v
1 //////////////////////////////////////////////////////////////////////\r
2 ////                                                              ////\r
3 ////  eth_clockgen.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_clockgen.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:45  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.3  2002/01/23 10:28:16  mohor\r
57 // Link in the header changed.\r
58 //\r
59 // Revision 1.2  2001/10/19 08:43:51  mohor\r
60 // eth_timescale.v changed to timescale.v This is done because of the\r
61 // simulation of the few cores in a one joined project.\r
62 //\r
63 // Revision 1.1  2001/08/06 14:44:29  mohor\r
64 // A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).\r
65 // Include files fixed to contain no path.\r
66 // File names and module names changed ta have a eth_ prologue in the name.\r
67 // File eth_timescale.v is used to define timescale\r
68 // All pin names on the top module are changed to contain _I, _O or _OE at the end.\r
69 // Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O\r
70 // and Mdo_OE. The bidirectional signal must be created on the top level. This\r
71 // is done due to the ASIC tools.\r
72 //\r
73 // Revision 1.1  2001/07/30 21:23:42  mohor\r
74 // Directory structure changed. Files checked and joind together.\r
75 //\r
76 // Revision 1.3  2001/06/01 22:28:55  mohor\r
77 // This files (MIIM) are fully working. They were thoroughly tested. The testbench is not updated.\r
78 //\r
79 //\r
80 \r
81 module eth_clockgen(Clk, Reset, Divider, MdcEn, MdcEn_n, Mdc);\r
82 \r
83 //parameter Tp=1;\r
84 \r
85 input       Clk;              // Input clock (Host clock)\r
86 input       Reset;            // Reset signal\r
87 input [7:0] Divider;          // Divider (input clock will be divided by the Divider[7:0])\r
88 \r
89 output      Mdc;              // Output clock\r
90 output      MdcEn;            // Enable signal is asserted for one Clk period before Mdc rises.\r
91 output      MdcEn_n;          // Enable signal is asserted for one Clk period before Mdc falls.\r
92 \r
93 reg         Mdc;\r
94 reg   [7:0] Counter;\r
95 \r
96 wire        CountEq0;\r
97 wire  [7:0] CounterPreset;\r
98 wire  [7:0] TempDivider;\r
99 \r
100 \r
101 assign TempDivider[7:0]   = (Divider[7:0]<2)? 8'h02 : Divider[7:0]; // If smaller than 2\r
102 assign CounterPreset[7:0] = (TempDivider[7:0]>>1) -1;               // We are counting half of period\r
103 \r
104 \r
105 // Counter counts half period\r
106 always @ (posedge Clk or posedge Reset)\r
107 begin\r
108   if(Reset)\r
109     Counter[7:0] <= 8'h1;\r
110   else\r
111     begin\r
112       if(CountEq0)\r
113         begin\r
114           Counter[7:0] <= CounterPreset[7:0];\r
115         end\r
116       else\r
117         Counter[7:0] <= Counter - 8'h1;\r
118     end\r
119 end\r
120 \r
121 \r
122 // Mdc is asserted every other half period\r
123 always @ (posedge Clk or posedge Reset)\r
124 begin\r
125   if(Reset)\r
126     Mdc <= 1'b0;\r
127   else\r
128     begin\r
129       if(CountEq0)\r
130         Mdc <= ~Mdc;\r
131     end\r
132 end\r
133 \r
134 \r
135 assign CountEq0 = Counter == 8'h0;\r
136 assign MdcEn = CountEq0 & ~Mdc;\r
137 assign MdcEn_n = CountEq0 & Mdc;\r
138 \r
139 endmodule\r
140 \r
141 \r