Skip to content

Commit 85cbd67

Browse files
committed
ethernet: fix clock of tx/rx-enable
1 parent f211725 commit 85cbd67

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/main/scala/devices/xilinx/ethernet/ethernet.scala

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ abstract class EthernetMAC(busWidthBytes: Int, base: BigInt)(implicit p: Paramet
5151
val txen = RegInit(false.B)
5252
val rxen = RegInit(false.B)
5353
val loop = RegInit(0.U(3.W))
54+
val skip = RegInit(false.B)
5455
val last = RegInit(true.B)
5556
val rxQ = Module(new AsyncQueue(new EtherBeat, params=AsyncQueueParams(depth=16)))
5657
val txQ = Module(new AsyncQueue(new EtherBeat, params=AsyncQueueParams(depth=16)))
@@ -79,14 +80,15 @@ abstract class EthernetMAC(busWidthBytes: Int, base: BigInt)(implicit p: Paramet
7980
RegField(1, rxen, RegFieldDesc("rx_en", "RX Enable", reset=Some(0))),
8081
RegField(1),
8182
RegField(1, last, RegFieldDesc("last", "Last frame", reset=Some(1))),
82-
RegField(3, loop, RegFieldDesc("loop", "TX-RX PCS Loopback", reset=Some(0))),
83-
RegField(9),
83+
RegField(3, loop, RegFieldDesc("loop", "TX-RX PCS Loopback", reset=Some(0))),
84+
RegField(1, skip, RegFieldDesc("skip", "Bypass RX-TX directly", reset=Some(0))),
85+
RegField(8),
8486
RegField.r(1, txQ.io.enq.ready, RegFieldDesc("tx_ready", "TX Ready")),
8587
RegField.r(1, rxQ.io.deq.valid, RegFieldDesc("rx_valid", "RX Valid")),
8688
RegField.r(1, port.pcs.tx_reset, RegFieldDesc("tx_reset", "TX Reset")),
8789
RegField.r(1, port.pcs.rx_reset, RegFieldDesc("rx_reset", "RX Reset")),
8890
RegField.r(1, mac.io.tx_axis_tready, RegFieldDesc("mac_ready", "MAC Ready")),
89-
RegField.r(1, port.pcs.rx_lock, RegFieldDesc("rx_lock", "RX Lock")),
91+
// RegField.r(1, port.pcs.rx_lock, RegFieldDesc("rx_lock", "RX Lock")),
9092
RegField.r(1, port.pcs.sfp_detect, RegFieldDesc("sfp_detect", "SFP Detect")))),
9193
16 -> RegFieldGroup("tx", Some("TX Data Queue"), Seq(RegField.w(64, RegWriteFn((valid, data) => {
9294
txQ.io.enq.valid := valid;
@@ -97,18 +99,26 @@ abstract class EthernetMAC(busWidthBytes: Int, base: BigInt)(implicit p: Paramet
9799
rxQ.io.deq.ready := ready
98100
(rxQ.io.deq.valid, rxQ.io.deq.bits.data)}))))) // discards last
99101

100-
txO.ready := mac.io.tx_axis_tready && txen
101-
mac.io.tx_axis_tvalid := txO.valid && txen
102+
val tx_txen = withClockAndReset(port.pcs.tx_clock, port.pcs.tx_reset) { RegNext(RegNext(txen)) }
103+
txO.ready := mac.io.tx_axis_tready && tx_txen
104+
mac.io.tx_axis_tvalid := txO.valid && tx_txen
102105
mac.io.tx_axis_tdata := txO.bits.data
103106
mac.io.tx_axis_tlast := txO.bits.last
104107
mac.io.tx_axis_tkeep := 0xff.U
105108
mac.io.tx_axis_tuser := 0.U
106109

107110
// rxQ.io ready is ignored; loss of packets can happen
108-
rxI.valid := mac.io.rx_axis_tvalid && rxen
111+
val rx_rxen = withClockAndReset(port.pcs.rx_clock, port.pcs.rx_reset) { RegNext(RegNext(rxen)) }
112+
rxI.valid := mac.io.rx_axis_tvalid && rx_rxen
109113
rxI.bits.data := mac.io.rx_axis_tdata
110114
rxI.bits.last := mac.io.rx_axis_tlast
111115
// ignore tkeep/tuser
116+
117+
when (withClockAndReset(port.pcs.tx_clock, port.pcs.tx_reset) { RegNext(RegNext(skip)) } ) {
118+
txO.ready := rxI.ready
119+
rxI.valid := txO.valid
120+
rxI.bits := txO.bits
121+
}
112122
}
113123
}
114124

src/main/scala/shell/xilinx/UltraScaleShell.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ abstract class EthernetUltraScaleOverlay(config: XXVEthernetParams, params: Ethe
5555
pcsIO.rx_lock := macIO.stat_rx_block_lock_0
5656
pcsIO.sfp_detect := Bool(true)
5757

58-
pcsIO.rx_clock := clocks.rx_core_clk_0
58+
pcsIO.rx_clock := clocks.tx_mii_clk_0
5959
pcsIO.rx_reset := clocks.user_rx_reset_0
6060
pcsIO.tx_clock := clocks.tx_mii_clk_0
6161
pcsIO.tx_reset := clocks.user_tx_reset_0

0 commit comments

Comments
 (0)