link_tb: simplify using implicit submodules collect

This commit is contained in:
Florent Kermarrec 2014-12-19 01:23:04 +01:00
parent 4f22bc807a
commit a8e1526407
2 changed files with 18 additions and 15 deletions

View File

@ -98,7 +98,7 @@ class PacketLogger(Module):
if selfp.sink.stb == 1 and selfp.sink.eop == 1: if selfp.sink.stb == 1 and selfp.sink.eop == 1:
self.packet.done = True self.packet.done = True
class AckRandomizer(Module): class Randomizer(Module):
def __init__(self, description, level=0): def __init__(self, description, level=0):
self.level = level self.level = level

View File

@ -4,6 +4,8 @@ from lib.sata.link import SATALink
from lib.sata.test.common import * from lib.sata.test.common import *
from lib.sata.test.hdd import * from lib.sata.test.hdd import *
from migen.actorlib.structuring import *
class LinkStreamer(PacketStreamer): class LinkStreamer(PacketStreamer):
def __init__(self): def __init__(self):
PacketStreamer.__init__(self, link_description(32), LinkTXPacket) PacketStreamer.__init__(self, link_description(32), LinkTXPacket)
@ -14,23 +16,24 @@ class LinkLogger(PacketLogger):
class TB(Module): class TB(Module):
def __init__(self): def __init__(self):
self.submodules.hdd = HDD( self.hdd = HDD(
link_debug=False, link_random_level=50, link_debug=False, link_random_level=50,
transport_debug=False, transport_loopback=True) transport_debug=False, transport_loopback=True)
self.submodules.link = SATALink(self.hdd.phy) self.link = InsertReset(SATALink(self.hdd.phy))
self.submodules.streamer = LinkStreamer() self.streamer = LinkStreamer()
streamer_ack_randomizer = AckRandomizer(link_description(32), level=50) self.streamer_randomizer = Randomizer(link_description(32), level=50)
self.submodules += streamer_ack_randomizer
self.submodules.logger = LinkLogger() self.logger_randomizer = Randomizer(link_description(32), level=50)
logger_ack_randomizer = AckRandomizer(link_description(32), level=50) self.logger = LinkLogger()
self.submodules += logger_ack_randomizer
self.comb += [ self.pipeline = Pipeline(
Record.connect(self.streamer.source, streamer_ack_randomizer.sink), self.streamer,
Record.connect(streamer_ack_randomizer.source, self.link.sink), self.streamer_randomizer,
Record.connect(self.link.source, logger_ack_randomizer.sink), self.link,
Record.connect(logger_ack_randomizer.source, self.logger.sink) self.logger_randomizer,
] self.logger
)
def gen_simulation(self, selfp): def gen_simulation(self, selfp):
for i in range(8): for i in range(8):