This post is about MDIO which is a part of MIIM (interface between MAC and PHY in ethernet 802 standard).
wiki provide some details (but the main reference is 802 spec)
Management Data Input/Output (MDIO), also known as Serial Management Interface (SMI) or Media Independent Interface Management (MIIM), is a serial bus defined for the Ethernet family of IEEE 802.3 standards for the Media Independent Interface, or MII. The MII connects Media Access Control (MAC) devices with Ethernet physical layer (PHY) circuits. The MAC device controlling the MDIO is called the Station Management Entity (SME).
Frame and signals Link to heading
MDIO is one of the 2-wire family(similar to I2C):
- MDC
- MDIO
MDIO frame has the following fields:
- Start (2’b01)
- Write/read (2’b01 or 2’b10)
- PHY address (5’bxxxxx)
- Register address (5’bxxxxx)
- turnaround (2’b10)
- data (16’hxxxx)
TX Example Link to heading
The following waveform and snippet show a simple example of MDIO TX:
module mdio_tx(
input clk,
input rst,
input en,
input write,
input [4:0] phy_addr,
input [4:0] reg_addr,
input [15:0] reg_data,
output reg busy
);
wire shift_bit;
wire [31:0] shift_reg_wire = {2'b01 , write, ~write, phy_addr, reg_addr, 2'b10, reg_data};
reg [31:0] shift_reg;
always @(posedge clk) begin
if(en) begin
shift_reg <= {2'b01 , write, ~write, phy_addr, reg_addr, 2'b10, reg_data};
end
else
shift_reg[31:0] <= {shift_reg[30:0], 1'b0};
end
assign shift_bit = shift_reg[31];
endmodule
The Standard defines registers that PHY implements to be 802 compliant(I am not going to copy them here). But that’s for another post.