}
from_rx = [
- ("dma_activate", 1)
+ ("dma_activate", 1),
+ ("data", 1),
+ ("reg_d2h", 1)
]
class SATACommandTX(Module):
transport.sink.data.eq(sink.data),
sink.ack.eq(transport.sink.ack),
If(sink.stb & sink.ack & sink.eop,
- NextState("IDLE")
+ NextState("WAIT_REG_D2H")
)
)
fsm.act("SEND_READ_DMA_CMD",
transport.sink.command.eq(regs["READ_DMA_EXT"]),
sink.ack.eq(transport.sink.ack),
If(sink.stb & sink.ack,
- NextState("IDLE")
+ NextState("WAIT_DATA")
)
)
fsm.act("SEND_IDENTIFY_CMD",
transport.sink.command.eq(regs["IDENTIFY_DEVICE_DMA"]),
sink.ack.eq(transport.sink.ack),
If(sink.stb & sink.ack,
+ NextState("WAIT_DATA")
+ )
+ )
+ fsm.act("WAIT_DATA",
+ If(self.from_rx.data,
+ NextState("WAIT_REG_D2H")
+ )
+ )
+ fsm.act("WAIT_REG_D2H",
+ NextState("IDLE"),
+ If(self.from_rx.reg_d2h,
NextState("IDLE")
)
)
###
- self.comb += [
- transport.source.ack.eq(1),
- # XXX for test
- If(transport.source.stb & (transport.source.type == fis_types["DMA_ACTIVATE_D2H"]),
- self.to_tx.dma_activate.eq(1)
- ),
- If(transport.source.stb & (transport.source.type == fis_types["DATA"]),
- source.stb.eq(1),
- source.sop.eq(transport.source.sop),
- source.eop.eq(transport.source.eop),
- source.data.eq(transport.source.data),
+ def test_type(name):
+ return transport.source.type == fis_types[name]
+
+ dma_activate = Signal()
+ data = Signal()
+ reg_d2h = Signal()
+
+ self.comb += \
+ If(transport.source.stb,
+ If(test_type("REG_D2H"),
+ # XXX add checks
+ reg_d2h.eq(1),
+ transport.source.ack.eq(1)
+ ).Elif(test_type("DMA_ACTIVATE_D2H"),
+ # XXX add checks
+ dma_activate.eq(1),
+ transport.source.ack.eq(1)
+ ).Elif(test_type("DATA"),
+ source.stb.eq(1),
+ source.sop.eq(transport.source.sop),
+ source.eop.eq(transport.source.eop),
+ source.data.eq(transport.source.data),
+ data.eq(source.eop & source.ack),
+ transport.source.ack.eq(source.ack)
+ ).Else(
+ transport.source.ack.eq(1)
+ )
)
+
+ self.comb += [
+ self.to_tx.dma_activate.eq(dma_activate),
+ self.to_tx.data.eq(data),
+ self.to_tx.reg_d2h.eq(reg_d2h)
]
class SATACommand(Module):
def __init__(self, transport):
self.submodules.tx = SATACommandTX(transport)
self.submodules.rx = SATACommandRX(transport)
- self.sink, self.source = self.tx.sink, self.rx.source
self.comb += self.rx.to_tx.connect(self.tx.from_rx)
+ self.sink, self.source = self.tx.sink, self.rx.source