link_tb: simplify using implicit submodules collect
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 19 Dec 2014 00:23:04 +0000 (01:23 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 19 Dec 2014 00:23:04 +0000 (01:23 +0100)
lib/sata/test/common.py
lib/sata/test/link_tb.py

index e1819f986c779355b70752191f1336968e6743e3..b79442a63b5265cc8a2131bc7636fed5b38209da 100644 (file)
@@ -98,7 +98,7 @@ class PacketLogger(Module):
                if selfp.sink.stb == 1 and selfp.sink.eop == 1:
                        self.packet.done = True
 
-class AckRandomizer(Module):
+class Randomizer(Module):
        def __init__(self, description, level=0):
                self.level = level
 
index cf97ff0489e81c4ebe238620d2a41aa86c0b37af..778b171c987c941a3d2b91410af361ad6d1d3abd 100644 (file)
@@ -4,6 +4,8 @@ from lib.sata.link import SATALink
 from lib.sata.test.common import *
 from lib.sata.test.hdd import *
 
+from migen.actorlib.structuring import *
+
 class LinkStreamer(PacketStreamer):
        def __init__(self):
                PacketStreamer.__init__(self, link_description(32), LinkTXPacket)
@@ -14,23 +16,24 @@ class LinkLogger(PacketLogger):
 
 class TB(Module):
        def __init__(self):
-               self.submodules.hdd = HDD(
+               self.hdd = HDD(
                                link_debug=False, link_random_level=50,
                                transport_debug=False, transport_loopback=True)
-               self.submodules.link = SATALink(self.hdd.phy)
-
-               self.submodules.streamer = LinkStreamer()
-               streamer_ack_randomizer = AckRandomizer(link_description(32), level=50)
-               self.submodules += streamer_ack_randomizer
-               self.submodules.logger = LinkLogger()
-               logger_ack_randomizer = AckRandomizer(link_description(32), level=50)
-               self.submodules += logger_ack_randomizer
-               self.comb += [
-                       Record.connect(self.streamer.source, streamer_ack_randomizer.sink),
-                       Record.connect(streamer_ack_randomizer.source, self.link.sink),
-                       Record.connect(self.link.source, logger_ack_randomizer.sink),
-                       Record.connect(logger_ack_randomizer.source, self.logger.sink)
-               ]
+               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
+               )
 
        def gen_simulation(self, selfp):
                for i in range(8):