return Cat(iter(r))
-@ResetInserter()
-@CEInserter()
-class Counter(Module):
- def __init__(self, *args, increment=1, **kwargs):
- self.value = Signal(*args, **kwargs)
- self.width = len(self.value)
- self.sync += self.value.eq(self.value+increment)
-
class Status(Module):
def __init__(self, endpoint):
self.sop = sop = Signal()
header_words = (header.length*8)//dw
load = Signal()
shift = Signal()
- counter = Counter(max=max(header_words, 2))
- self.submodules += counter
+ counter = Signal(max=max(header_words, 2))
+ counter_reset = Signal()
+ counter_ce = Signal()
+ self.sync += \
+ If(counter_reset,
+ counter.eq(0)
+ ).Elif(Counter.ce,
+ counter.eq(counter + 1)
+ )
self.comb += header.encode(sink, self.header)
if header_words == 1:
fsm.act("IDLE",
sink.ack.eq(1),
- counter.reset.eq(1),
+ counter_reset.eq(1),
If(sink.stb & sink.sop,
sink.ack.eq(0),
source.stb.eq(1),
source.data.eq(header_reg[dw:2*dw]),
If(source.stb & source.ack,
shift.eq(1),
- counter.ce.eq(1),
- If(counter.value == header_words-2,
+ counter._e.eq(1),
+ If(counter == header_words-2,
NextState("COPY")
)
)
header_words = (header.length*8)//dw
shift = Signal()
- counter = Counter(max=max(header_words, 2))
- self.submodules += counter
+ counter = Signal(max=max(header_words, 2))
+ counter_reset = Signal()
+ counter_ce = Signal()
+ self.sync += \
+ If(counter_reset,
+ counter.eq(0)
+ ).Elif(Counter.ce,
+ counter.eq(counter + 1)
+ )
if header_words == 1:
self.sync += \
fsm.act("IDLE",
sink.ack.eq(1),
- counter.reset.eq(1),
+ counter_reset.eq(1),
If(sink.stb,
shift.eq(1),
NextState(idle_next_state)
fsm.act("RECEIVE_HEADER",
sink.ack.eq(1),
If(sink.stb,
- counter.ce.eq(1),
+ counter_ce.eq(1),
shift.eq(1),
- If(counter.value == header_words-2,
+ If(counter == header_words-2,
NextState("COPY")
)
)