2015-02-28 04:53:51 -05:00
|
|
|
from misoclib.mem.litesata.common import *
|
|
|
|
from misoclib.mem.litesata.core.link import LiteSATALink
|
2014-11-11 12:47:34 -05:00
|
|
|
|
2015-02-28 04:53:51 -05:00
|
|
|
from misoclib.mem.litesata.test.common import *
|
|
|
|
from misoclib.mem.litesata.test.hdd import *
|
2014-11-11 12:47:34 -05:00
|
|
|
|
2015-04-13 09:12:39 -04:00
|
|
|
|
2014-12-18 07:15:39 -05:00
|
|
|
class LinkStreamer(PacketStreamer):
|
2015-04-13 08:55:26 -04:00
|
|
|
def __init__(self):
|
|
|
|
PacketStreamer.__init__(self, link_description(32), LinkTXPacket)
|
2014-11-11 12:47:34 -05:00
|
|
|
|
2015-04-13 09:12:39 -04:00
|
|
|
|
2014-12-18 07:15:39 -05:00
|
|
|
class LinkLogger(PacketLogger):
|
2015-04-13 08:55:26 -04:00
|
|
|
def __init__(self):
|
|
|
|
PacketLogger.__init__(self, link_description(32), LinkRXPacket)
|
2014-11-11 12:47:34 -05:00
|
|
|
|
2015-04-13 09:12:39 -04:00
|
|
|
|
2014-11-11 12:47:34 -05:00
|
|
|
class TB(Module):
|
2015-04-13 08:55:26 -04:00
|
|
|
def __init__(self):
|
|
|
|
self.submodules.hdd = HDD(
|
|
|
|
link_debug=False, link_random_level=50,
|
|
|
|
transport_debug=False, transport_loopback=True)
|
|
|
|
self.submodules.link = InsertReset(LiteSATALink(self.hdd.phy, buffer_depth=512))
|
2014-12-18 19:23:04 -05:00
|
|
|
|
2015-04-13 08:55:26 -04:00
|
|
|
self.submodules.streamer = LinkStreamer()
|
|
|
|
self.submodules.streamer_randomizer = Randomizer(link_description(32), level=50)
|
2014-12-18 19:23:04 -05:00
|
|
|
|
2015-04-13 08:55:26 -04:00
|
|
|
self.submodules.logger_randomizer = Randomizer(link_description(32), level=50)
|
|
|
|
self.submodules.logger = LinkLogger()
|
2014-12-18 19:23:04 -05:00
|
|
|
|
2015-04-13 08:55:26 -04:00
|
|
|
self.submodules.pipeline = Pipeline(
|
|
|
|
self.streamer,
|
|
|
|
self.streamer_randomizer,
|
|
|
|
self.link,
|
|
|
|
self.logger_randomizer,
|
|
|
|
self.logger
|
|
|
|
)
|
2014-11-11 12:47:34 -05:00
|
|
|
|
2015-04-13 08:55:26 -04:00
|
|
|
def gen_simulation(self, selfp):
|
|
|
|
for i in range(8):
|
|
|
|
streamer_packet = LinkTXPacket([i for i in range(64)])
|
|
|
|
yield from self.streamer.send(streamer_packet)
|
|
|
|
yield from self.logger.receive()
|
2014-12-06 08:35:18 -05:00
|
|
|
|
2015-04-13 08:55:26 -04: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__":
|
2015-04-13 08:55:26 -04:00
|
|
|
run_simulation(TB(), ncycles=2048, vcd_name="my.vcd", keep_files=True)
|