Skip to content

Commit

Permalink
bench/serwb/demo: Demonstrate SerIO integration and pass counter from…
Browse files Browse the repository at this point in the history
… Slave to Master, redirected to Leds.
  • Loading branch information
enjoy-digital committed Feb 28, 2024
1 parent 138f955 commit 0037999
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
12 changes: 9 additions & 3 deletions bench/serwb/demo/ecpix5.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from litex.soc.interconnect import wishbone

from liteiclink.serwb.genphy import SERWBPHY
from liteiclink.serwb.core import SERWBCore
from liteiclink.serwb.core import SERWBCore, SERIOCore

from liteeth.phy.ecp5rgmii import LiteEthPHYRGMII

Expand Down Expand Up @@ -92,6 +92,12 @@ def __init__(self, platform, with_analyzer=False):
# --------------------------
self.bus.add_slave("serwb", self.serwb_master_core.bus, SoCRegion(origin=0x40000000, size=0x20000000))

# SerIO ------------------------------------------------------------------------------------

# SerIO.
# ------
self.serio = SERIOCore(serwb_core=self.serwb_master_core)

# Leds -------------------------------------------------------------------------------------
leds_pads = []
for i in range(4):
Expand All @@ -101,8 +107,8 @@ def __init__(self, platform, with_analyzer=False):
self.comb += [
leds_pads[0].eq(~self.serwb_master_phy.init.ready),
leds_pads[1].eq(~self.serwb_master_phy.init.error),
leds_pads[2].eq(1),
leds_pads[3].eq(1)
leds_pads[2].eq(self.serio.o[0]), # Counter from Slave through SerIO.
leds_pads[3].eq(self.serio.o[1]), # Counter from Slave through SerIO.
]

# Analyzer ---------------------------------------------------------------------------------
Expand Down
15 changes: 14 additions & 1 deletion bench/serwb/demo/icebreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from migen import *

from litex.gen import *
from litex.gen.genlib.misc import WaitTimer

from litex.build.generic_platform import *

Expand All @@ -24,7 +25,7 @@
from litex.soc.cores.ram import Up5kSPRAM

from liteiclink.serwb.genphy import SERWBPHY
from liteiclink.serwb.core import SERWBCore
from liteiclink.serwb.core import SERWBCore, SERIOCore

kB = 1024

Expand Down Expand Up @@ -92,6 +93,18 @@ def __init__(self, platform, with_analyzer=False):
)
self.bus.masters["serwb"] = serwb_bus

# SerIO ------------------------------------------------------------------------------------

# SerIO.
# ------
self.serio = SERIOCore(serwb_core=self.serwb_slave_core)

# Increment Inputs every 100ms as PoC.
# ------------------------------------
self.serio_timer = WaitTimer(100e-3*sys_clk_freq)
self.comb += self.serio_timer.wait.eq(~self.serio_timer.done)
self.sync += If(self.serio_timer.done, self.serio.i.eq(self.serio.i + 1))

# Leds -------------------------------------------------------------------------------------
self.comb += [
platform.request("user_led", 0).eq(self.serwb_slave_phy.init.ready),
Expand Down

0 comments on commit 0037999

Please sign in to comment.