2015-01-19 12:40:32 -05:00
|
|
|
from migen.genlib.resetsync import AsyncResetSynchronizer
|
|
|
|
|
|
|
|
from litesata.common import *
|
|
|
|
from litesata.phy import LiteSATAPHY
|
|
|
|
from litesata import LiteSATA
|
|
|
|
|
|
|
|
class LiteSATACore(Module):
|
|
|
|
default_platform = "verilog_backend"
|
2015-01-22 11:15:12 -05:00
|
|
|
def __init__(self, platform, clk_freq=166*1000000, nports=4):
|
|
|
|
self.clk_freq = clk_freq
|
2015-01-19 12:40:32 -05:00
|
|
|
|
|
|
|
# SATA PHY/Core/Frontend
|
2015-01-22 11:15:12 -05:00
|
|
|
self.submodules.sata_phy = LiteSATAPHY(platform.device, platform.request("sata"), "sata_gen2", clk_freq)
|
2015-01-25 05:23:39 -05:00
|
|
|
self.submodules.sata = LiteSATA(self.sata_phy, with_bist=True)
|
2015-01-19 12:40:32 -05:00
|
|
|
|
|
|
|
# Get user ports from crossbar
|
2015-01-22 11:15:12 -05:00
|
|
|
self.user_ports = self.sata.crossbar.get_ports(nports)
|
2015-01-19 12:40:32 -05:00
|
|
|
|
|
|
|
def get_ios(self):
|
2015-01-22 10:02:41 -05:00
|
|
|
ios = set()
|
2015-01-19 12:40:32 -05:00
|
|
|
|
|
|
|
# Transceiver
|
|
|
|
for e in dir(self.sata_phy.pads):
|
|
|
|
obj = getattr(self.sata_phy.pads, e)
|
|
|
|
if isinstance(obj, Signal):
|
|
|
|
ios = ios.union({obj})
|
|
|
|
|
2015-01-25 05:23:39 -05:00
|
|
|
# Status
|
|
|
|
ios = ios.union({
|
|
|
|
self.sata_phy.crg.ready,
|
|
|
|
self.sata_phy.ctrl.ready
|
|
|
|
})
|
|
|
|
|
|
|
|
# BIST
|
|
|
|
if hasattr(self.sata, "bist"):
|
|
|
|
for bist_unit in ["generator", "checker"]:
|
|
|
|
for signal in ["start", "sector", "count", "random", "done", "aborted", "errors"]:
|
|
|
|
ios = ios.union({getattr(getattr(self.sata.bist, bist_unit), signal)})
|
|
|
|
ios = ios.union({
|
|
|
|
self.sata.bist.identify.start,
|
|
|
|
self.sata.bist.identify.done,
|
|
|
|
self.sata.bist.identify.source.stb,
|
|
|
|
self.sata.bist.identify.source.data,
|
|
|
|
self.sata.bist.identify.source.ack
|
|
|
|
})
|
|
|
|
|
2015-01-19 12:40:32 -05:00
|
|
|
# User ports
|
|
|
|
def _iter_layout(layout):
|
|
|
|
for e in layout:
|
|
|
|
if isinstance(e[1], list):
|
|
|
|
yield from _iter_layout(e[1])
|
|
|
|
else:
|
|
|
|
yield e
|
|
|
|
|
2015-01-22 04:45:11 -05:00
|
|
|
for port in self.user_ports:
|
2015-01-22 10:52:26 -05:00
|
|
|
for endpoint in [port.sink, port.source]:
|
|
|
|
for e in _iter_layout(endpoint.layout):
|
|
|
|
obj = getattr(endpoint, e[0])
|
2015-01-19 12:40:32 -05:00
|
|
|
ios = ios.union({obj})
|
|
|
|
return ios
|
|
|
|
|
|
|
|
|
|
|
|
default_subtarget = LiteSATACore
|