2014-12-14 04:45:26 -05:00
|
|
|
from lib.sata.common import *
|
2014-12-12 08:35:48 -05:00
|
|
|
from lib.sata.link import SATALink
|
2014-11-11 12:47:34 -05:00
|
|
|
|
2014-12-05 11:48:01 -05:00
|
|
|
from lib.sata.test.common import *
|
2014-12-18 07:15:39 -05:00
|
|
|
from lib.sata.test.hdd import *
|
2014-11-11 12:47:34 -05:00
|
|
|
|
2014-12-18 19:23:04 -05:00
|
|
|
from migen.actorlib.structuring import *
|
|
|
|
|
2014-12-18 07:15:39 -05:00
|
|
|
class LinkStreamer(PacketStreamer):
|
2014-12-05 14:26:09 -05:00
|
|
|
def __init__(self):
|
2014-12-18 07:15:39 -05:00
|
|
|
PacketStreamer.__init__(self, link_description(32), LinkTXPacket)
|
2014-11-11 12:47:34 -05:00
|
|
|
|
2014-12-18 07:15:39 -05:00
|
|
|
class LinkLogger(PacketLogger):
|
2014-12-05 14:26:09 -05:00
|
|
|
def __init__(self):
|
2014-12-18 07:15:39 -05:00
|
|
|
PacketLogger.__init__(self, link_description(32), LinkRXPacket)
|
2014-11-11 12:47:34 -05:00
|
|
|
|
|
|
|
class TB(Module):
|
|
|
|
def __init__(self):
|
2014-12-18 19:23:04 -05:00
|
|
|
self.hdd = HDD(
|
2014-12-15 14:00:19 -05:00
|
|
|
link_debug=False, link_random_level=50,
|
2014-12-14 10:20:22 -05:00
|
|
|
transport_debug=False, transport_loopback=True)
|
2014-12-18 19:23:04 -05:00
|
|
|
self.link = InsertReset(SATALink(self.hdd.phy))
|
|
|
|
|
|
|
|
self.streamer = LinkStreamer()
|
|
|
|
self.streamer_randomizer = Randomizer(link_description(32), level=50)
|
|
|
|
|
|
|
|
self.logger_randomizer = Randomizer(link_description(32), level=50)
|
|
|
|
self.logger = LinkLogger()
|
|
|
|
|
|
|
|
self.pipeline = Pipeline(
|
|
|
|
self.streamer,
|
|
|
|
self.streamer_randomizer,
|
|
|
|
self.link,
|
|
|
|
self.logger_randomizer,
|
|
|
|
self.logger
|
|
|
|
)
|
2014-11-11 12:47:34 -05:00
|
|
|
|
|
|
|
def gen_simulation(self, selfp):
|
2014-11-12 12:20:34 -05:00
|
|
|
for i in range(8):
|
2014-12-06 08:35:18 -05:00
|
|
|
streamer_packet = LinkTXPacket([i for i in range(64)])
|
2014-12-14 10:20:22 -05:00
|
|
|
yield from self.streamer.send(streamer_packet)
|
2014-12-05 14:26:09 -05:00
|
|
|
yield from self.logger.receive()
|
2014-12-06 08:35:18 -05:00
|
|
|
|
|
|
|
# check results
|
|
|
|
s, l, e = check(streamer_packet, self.logger.packet)
|
|
|
|
print("shift "+ str(s) + " / length " + str(l) + " / errors " + str(e))
|
2014-12-05 14:26:09 -05:00
|
|
|
|
2014-11-11 12:47:34 -05:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2014-12-05 15:27:26 -05:00
|
|
|
run_simulation(TB(), ncycles=2048, vcd_name="my.vcd", keep_files=True)
|