@@ -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
0 commit comments