from lambdasoc.periph import Peripheral
-# for Migen compat
-def timeline(m, trigger, events):
- lastevent = max([e[0] for e in events])
- counter = Signal(range(lastevent+1))
-
- # insert counter reset if it doesn't naturally overflow
- # (test if lastevent+1 is a power of 2)
- with m.If(((lastevent & (lastevent + 1)) != 0) & (counter == lastevent)):
- m.d.sync += counter.eq(0)
- with m.Elif(counter != 0):
- m.d.sync += counter.eq(counter + 1)
- with m.Elif(trigger):
- m.d.sync += counter.eq(1)
-
- def get_cond(e):
- if e[0] == 0:
- return trigger & (counter == 0)
- else:
- return counter == e[0]
- for ev in events:
- with m.If(get_cond(ev)):
- m.d.sync += ev[1]
-
-
# HyperRAM ASIC PHY -----------------------------------------------------------
class HyperRAMASICPhy(Elaboratable):