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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_14/] [rtl/] [verilog/] [eth_clockgen.v] - Blame information for rev 335

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

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

powered by: WebSVN 2.1.0

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