diff --git a/rtl/mdio_regs.v b/rtl/mdio_regs.v index 9c4e30d..354ed68 100644 --- a/rtl/mdio_regs.v +++ b/rtl/mdio_regs.v @@ -28,8 +28,11 @@ module mdio_regs ( output reg link_monitor_test ); - /* The current price of a CID is $805... */ - parameter [23:0] OUI = 0; + /* + * A test OUI in "canonical" form. Don't use this! It's just here to + * test the bit-reversal logic (as seen in 802 8.2.2). + */ + parameter [23:0] OUI = 24'hacde48; parameter [5:0] MODEL = 0; parameter [3:0] REVISION = 0; /* @@ -199,14 +202,19 @@ module mdio_regs ( link_status_latched_next = link_status; end ID1: begin - for (i = 0; i < 16; i = i + 1) - data_read_next[i] = OUI[17 - i]; + /* "bit-reverse" the OUI */ + for (i = 6; i < 8; i = i + 1) + data_read_next[i - 6] = OUI[7 - i]; + for (i = 0; i < 8; i = i + 1) + data_read_next[i + 2] = OUI[15 - i]; + for (i = 0; i < 6; i = i + 1) + data_read_next[i + 10] = OUI[23 - i]; end ID2: begin data_read_next[3:0] = REVISION; data_read_next[9:4] = MODEL; for (i = 0; i < 6; i = i + 1) - data_read_next[i + 4] = OUI[23 - i]; + data_read_next[i + 10] = OUI[7 - i]; end NWCR: if (ENABLE_COUNTERS) begin data_read_next = nwc; diff --git a/tb/mdio_regs.py b/tb/mdio_regs.py index c78ce83..09de515 100644 --- a/tb/mdio_regs.py +++ b/tb/mdio_regs.py @@ -116,10 +116,10 @@ async def test_mdio(regs): assert await xfer(BMSR) & BMSR_LSTATUS await xfer(PHYID1, 0xffff) - assert await xfer(PHYID1) == 0 + assert await xfer(PHYID1) == 0xd5ec await xfer(PHYID2, 0xffff) - assert await xfer(PHYID2) == 0 + assert await xfer(PHYID2) == 0x4800 # I'm pretty sure this register will never be implemented assert await xfer(EXTSTATUS) is None