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

Subversion Repositories ethernet_tri_mode

[/] [ethernet_tri_mode/] [trunk/] [rtl/] [verilog/] [miim/] [eth_clockgen.v] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 maverickis
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_clockgen.v                                              ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/projects/ethmac/                   ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////                                                              ////
11
////  All additional information is avaliable in the Readme.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16
//// Copyright (C) 2001 Authors                                   ////
17
////                                                              ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS Revision History
42
//
43
// $Log: not supported by cvs2svn $
44 6 maverickis
// Revision 1.1.1.1  2005/12/13 01:51:45  Administrator
45
// no message
46
//
47 5 maverickis
// Revision 1.2  2005/04/27 15:58:45  Administrator
48
// no message
49
//
50
// Revision 1.1.1.1  2004/12/15 06:38:54  Administrator
51
// no message
52
//
53
// Revision 1.3  2002/01/23 10:28:16  mohor
54
// Link in the header changed.
55
//
56
// Revision 1.2  2001/10/19 08:43:51  mohor
57
// eth_timescale.v changed to timescale.v This is done because of the
58
// simulation of the few cores in a one joined project.
59
//
60
// Revision 1.1  2001/08/06 14:44:29  mohor
61
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
62
// Include files fixed to contain no path.
63
// File names and module names changed ta have a eth_ prologue in the name.
64
// File eth_timescale.v is used to define timescale
65
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
66
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
67
// and Mdo_OE. The bidirectional signal must be created on the top level. This
68
// is done due to the ASIC tools.
69
//
70
// Revision 1.1  2001/07/30 21:23:42  mohor
71
// Directory structure changed. Files checked and joind together.
72
//
73
// Revision 1.3  2001/06/01 22:28:55  mohor
74
// This files (MIIM) are fully working. They were thoroughly tested. The testbench is not updated.
75
//
76
//
77
 
78
`timescale 1ns/10ps
79
 
80
module eth_clockgen(Clk, Reset, Divider, MdcEn, MdcEn_n, Mdc);
81
 
82
parameter Tp=1;
83
 
84
input       Clk;              // Input clock (Host clock)
85
input       Reset;            // Reset signal
86
input [7:0] Divider;          // Divider (input clock will be divided by the Divider[7:0])
87
 
88
output      Mdc;              // Output clock
89
output      MdcEn;            // Enable signal is asserted for one Clk period before Mdc rises.
90
output      MdcEn_n;          // Enable signal is asserted for one Clk period before Mdc falls.
91
 
92
reg         Mdc;
93
reg   [7:0] Counter;
94
 
95
wire        CountEq0;
96
wire  [7:0] CounterPreset;
97
wire  [7:0] TempDivider;
98
 
99
 
100
assign TempDivider[7:0]   = (Divider[7:0]<2)? 8'h02 : Divider[7:0]; // If smaller than 2
101
assign CounterPreset[7:0] = (TempDivider[7:0]>>1) -1;               // We are counting half of period
102
 
103
 
104
// Counter counts half period
105
always @ (posedge Clk or posedge Reset)
106
begin
107
  if(Reset)
108
    Counter[7:0] <= #Tp 8'h1;
109
  else
110
    begin
111
      if(CountEq0)
112
        begin
113
          Counter[7:0] <= #Tp CounterPreset[7:0];
114
        end
115
      else
116
        Counter[7:0] <= #Tp Counter - 8'h1;
117
    end
118
end
119
 
120
 
121
// Mdc is asserted every other half period
122
always @ (posedge Clk or posedge Reset)
123
begin
124
  if(Reset)
125
    Mdc <= #Tp 1'b0;
126
  else
127
    begin
128
      if(CountEq0)
129
        Mdc <= #Tp ~Mdc;
130
    end
131
end
132
 
133
 
134
assign CountEq0 = Counter == 8'h0;
135
assign MdcEn = CountEq0 & ~Mdc;
136
assign MdcEn_n = CountEq0 & Mdc;
137
 
138
endmodule
139
 
140
 

powered by: WebSVN 2.1.0

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