1 |
6 |
julius |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// eth_shiftreg.v ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the Ethernet IP core project ////
|
6 |
570 |
olof |
//// http://www.opencores.org/project,ethmac ////
|
7 |
6 |
julius |
//// ////
|
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 |
403 |
julius |
// $Log: not supported by cvs2svn $
|
44 |
6 |
julius |
// Revision 1.5 2002/08/14 18:16:59 mohor
|
45 |
|
|
// LinkFail signal was not latching appropriate bit.
|
46 |
|
|
//
|
47 |
|
|
// Revision 1.4 2002/03/02 21:06:01 mohor
|
48 |
|
|
// LinkFail signal was not latching appropriate bit.
|
49 |
|
|
//
|
50 |
|
|
// Revision 1.3 2002/01/23 10:28:16 mohor
|
51 |
|
|
// Link in the header changed.
|
52 |
|
|
//
|
53 |
|
|
// Revision 1.2 2001/10/19 08:43:51 mohor
|
54 |
|
|
// eth_timescale.v changed to timescale.v This is done because of the
|
55 |
|
|
// simulation of the few cores in a one joined project.
|
56 |
|
|
//
|
57 |
|
|
// Revision 1.1 2001/08/06 14:44:29 mohor
|
58 |
|
|
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
|
59 |
|
|
// Include files fixed to contain no path.
|
60 |
|
|
// File names and module names changed ta have a eth_ prologue in the name.
|
61 |
|
|
// File eth_timescale.v is used to define timescale
|
62 |
|
|
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
|
63 |
|
|
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
|
64 |
|
|
// and Mdo_OE. The bidirectional signal must be created on the top level. This
|
65 |
|
|
// is done due to the ASIC tools.
|
66 |
|
|
//
|
67 |
|
|
// Revision 1.1 2001/07/30 21:23:42 mohor
|
68 |
|
|
// Directory structure changed. Files checked and joind together.
|
69 |
|
|
//
|
70 |
|
|
// Revision 1.3 2001/06/01 22:28:56 mohor
|
71 |
|
|
// This files (MIIM) are fully working. They were thoroughly tested. The testbench is not updated.
|
72 |
|
|
//
|
73 |
|
|
//
|
74 |
|
|
|
75 |
|
|
`include "timescale.v"
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
module eth_shiftreg(Clk, Reset, MdcEn_n, Mdi, Fiad, Rgad, CtrlData, WriteOp, ByteSelect,
|
79 |
|
|
LatchByte, ShiftedBit, Prsd, LinkFail);
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
parameter Tp=1;
|
83 |
|
|
|
84 |
|
|
input Clk; // Input clock (Host clock)
|
85 |
|
|
input Reset; // Reset signal
|
86 |
|
|
input MdcEn_n; // Enable signal is asserted for one Clk period before Mdc falls.
|
87 |
|
|
input Mdi; // MII input data
|
88 |
|
|
input [4:0] Fiad; // PHY address
|
89 |
|
|
input [4:0] Rgad; // Register address (within the selected PHY)
|
90 |
|
|
input [15:0]CtrlData; // Control data (data to be written to the PHY)
|
91 |
|
|
input WriteOp; // The current operation is a PHY register write operation
|
92 |
|
|
input [3:0] ByteSelect; // Byte select
|
93 |
|
|
input [1:0] LatchByte; // Byte select for latching (read operation)
|
94 |
|
|
|
95 |
|
|
output ShiftedBit; // Bit shifted out of the shift register
|
96 |
|
|
output[15:0]Prsd; // Read Status Data (data read from the PHY)
|
97 |
|
|
output LinkFail; // Link Integrity Signal
|
98 |
|
|
|
99 |
|
|
reg [7:0] ShiftReg; // Shift register for shifting the data in and out
|
100 |
|
|
reg [15:0]Prsd;
|
101 |
|
|
reg LinkFail;
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
// ShiftReg[7:0] :: Shift Register Data
|
107 |
|
|
always @ (posedge Clk or posedge Reset)
|
108 |
|
|
begin
|
109 |
|
|
if(Reset)
|
110 |
|
|
begin
|
111 |
403 |
julius |
ShiftReg[7:0] <= 8'h0;
|
112 |
|
|
Prsd[15:0] <= 16'h0;
|
113 |
|
|
LinkFail <= 1'b0;
|
114 |
6 |
julius |
end
|
115 |
|
|
else
|
116 |
|
|
begin
|
117 |
|
|
if(MdcEn_n)
|
118 |
|
|
begin
|
119 |
|
|
if(|ByteSelect)
|
120 |
|
|
begin
|
121 |
439 |
julius |
/* verilator lint_off CASEINCOMPLETE */
|
122 |
6 |
julius |
case (ByteSelect[3:0]) // synopsys parallel_case full_case
|
123 |
403 |
julius |
4'h1 : ShiftReg[7:0] <= {2'b01, ~WriteOp, WriteOp, Fiad[4:1]};
|
124 |
|
|
4'h2 : ShiftReg[7:0] <= {Fiad[0], Rgad[4:0], 2'b10};
|
125 |
|
|
4'h4 : ShiftReg[7:0] <= CtrlData[15:8];
|
126 |
|
|
4'h8 : ShiftReg[7:0] <= CtrlData[7:0];
|
127 |
439 |
julius |
endcase // case (ByteSelect[3:0])
|
128 |
|
|
/* verilator lint_on CASEINCOMPLETE */
|
129 |
6 |
julius |
end
|
130 |
|
|
else
|
131 |
|
|
begin
|
132 |
403 |
julius |
ShiftReg[7:0] <= {ShiftReg[6:0], Mdi};
|
133 |
6 |
julius |
if(LatchByte[0])
|
134 |
|
|
begin
|
135 |
403 |
julius |
Prsd[7:0] <= {ShiftReg[6:0], Mdi};
|
136 |
6 |
julius |
if(Rgad == 5'h01)
|
137 |
403 |
julius |
LinkFail <= ~ShiftReg[1]; // this is bit [2], because it is not shifted yet
|
138 |
6 |
julius |
end
|
139 |
|
|
else
|
140 |
|
|
begin
|
141 |
|
|
if(LatchByte[1])
|
142 |
403 |
julius |
Prsd[15:8] <= {ShiftReg[6:0], Mdi};
|
143 |
6 |
julius |
end
|
144 |
|
|
end
|
145 |
|
|
end
|
146 |
|
|
end
|
147 |
|
|
end
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
assign ShiftedBit = ShiftReg[7];
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
endmodule
|