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

Subversion Repositories srdydrdy_lib

[/] [srdydrdy_lib/] [trunk/] [external/] [ethernet_tri_mode/] [miim/] [eth_shiftreg.v] - Blame information for rev 26

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

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

powered by: WebSVN 2.1.0

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