SATAPHYDatapathTX: use Converter and simplify

This commit is contained in:
Florent Kermarrec 2014-12-19 17:13:03 +01:00
parent 8bb40241fa
commit 0ab7ca6f28
1 changed files with 11 additions and 20 deletions

View File

@ -2,6 +2,7 @@ from lib.sata.common import *
from migen.genlib.misc import chooser from migen.genlib.misc import chooser
from migen.flow.plumbing import Multiplexer, Demultiplexer from migen.flow.plumbing import Multiplexer, Demultiplexer
from migen.actorlib.structuring import Converter
class SATAPHYDatapathRX(Module): class SATAPHYDatapathRX(Module):
def __init__(self): def __init__(self):
@ -64,6 +65,7 @@ class SATAPHYDatapathRX(Module):
fifo.sink.stb.eq(valid), fifo.sink.stb.eq(valid),
fifo.sink.data.eq(data), fifo.sink.data.eq(data),
fifo.sink.charisk.eq(charisk), fifo.sink.charisk.eq(charisk),
self.sink.ack.eq(fifo.sink.ack)
] ]
self.comb += Record.connect(fifo.source, self.source) self.comb += Record.connect(fifo.source, self.source)
@ -82,35 +84,22 @@ class SATAPHYDatapathTX(Module):
# source destination is always able to accept data (ack always 1) # source destination is always able to accept data (ack always 1)
fifo = AsyncFIFO(phy_description(32), 4) fifo = AsyncFIFO(phy_description(32), 4)
self.fifo = RenameClockDomains(fifo, {"write": "sys", "read": "sata_tx"}) self.fifo = RenameClockDomains(fifo, {"write": "sys", "read": "sata_tx"})
self.comb += Record.connect(self.sink, fifo.sink) self.comb += Record.connect(self.sink, fifo.sink),
# 32 to 16 # width convertion (32 to 16)
mux = Signal() self.converter = Converter(phy_description(32), phy_description(16), reverse=True)
last = Signal()
self.comb += [ self.comb += [
last.eq(mux == 1), Record.connect(self.fifo.source, self.converter.sink),
self.source.stb.eq(fifo.source.stb), Record.connect(self.converter.source, self.source)
fifo.source.ack.eq(last),
]
self.sync.sata_tx += [
If(self.source.stb,
If(last,
mux.eq(0)
).Else(
mux.eq(mux + 1)
)
)
]
self.comb += [
chooser(fifo.source.data, mux, self.source.data),
chooser(fifo.source.charisk, mux, self.source.charisk)
] ]
class SATAPHYAlignInserter(Module): class SATAPHYAlignInserter(Module):
def __init__(self, ctrl): def __init__(self, ctrl):
self.sink = sink = Sink(phy_description(32)) self.sink = sink = Sink(phy_description(32))
self.source = source = Source(phy_description(32)) self.source = source = Source(phy_description(32))
### ###
# send 2 ALIGN every 256 DWORDs # send 2 ALIGN every 256 DWORDs
# used for clock compensation between # used for clock compensation between
# HOST and device # HOST and device
@ -141,7 +130,9 @@ class SATAPHYAlignRemover(Module):
def __init__(self): def __init__(self):
self.sink = sink = Sink(phy_description(32)) self.sink = sink = Sink(phy_description(32))
self.source = source = Source(phy_description(32)) self.source = source = Source(phy_description(32))
### ###
charisk_match = sink.charisk == 0b0001 charisk_match = sink.charisk == 0b0001
data_match = sink.data == primitives["ALIGN"] data_match = sink.data == primitives["ALIGN"]