Put sources and sinks to sleep based on clock enables

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich
2023-01-24 17:41:36 -08:00
parent 45ee1193cb
commit dd35d734f9
4 changed files with 61 additions and 5 deletions

View File

@@ -169,7 +169,17 @@ class RgmiiSource(Reset):
clock_rising_edge_event = RisingEdge(self.clock)
clock_falling_edge_event = FallingEdge(self.clock)
enable_event = None
if self.enable is not None:
enable_event = RisingEdge(self.enable)
while True:
await clock_falling_edge_event
# send low nibble after falling edge, leading in to rising edge
self.data.value = d & 0x0F
self.ctrl.value = en
await clock_rising_edge_event
# send high nibble after rising edge, leading in to falling edge
@@ -235,11 +245,8 @@ class RgmiiSource(Reset):
self.active = False
self.idle_event.set()
await clock_falling_edge_event
# send low nibble after falling edge, leading in to rising edge
self.data.value = d & 0x0F
self.ctrl.value = en
elif self.enable is not None and not self.enable.value:
await enable_event
class RgmiiSink(Reset):
@@ -345,6 +352,10 @@ class RgmiiSink(Reset):
clock_rising_edge_event = RisingEdge(self.clock)
clock_falling_edge_event = FallingEdge(self.clock)
enable_event = None
if self.enable is not None:
enable_event = RisingEdge(self.enable)
while True:
await clock_rising_edge_event
@@ -412,6 +423,9 @@ class RgmiiSink(Reset):
frame.data.append(d_val)
frame.error.append(er_val)
elif self.enable is not None and not self.enable.value:
await enable_event
class RgmiiPhy:
def __init__(self, txd, tx_ctl, tx_clk, rxd, rx_ctl, rx_clk, reset=None,