use new implicit submodules collection and Pipeline
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 19 Dec 2014 00:35:18 +0000 (01:35 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 19 Dec 2014 00:35:18 +0000 (01:35 +0100)
16 files changed:
lib/sata/__init__.py
lib/sata/command/__init__.py
lib/sata/common.py
lib/sata/link/__init__.py
lib/sata/link/crc.py
lib/sata/link/scrambler.py
lib/sata/phy/__init__.py
lib/sata/phy/datapath.py
lib/sata/test/bist_tb.py
lib/sata/test/command_tb.py
lib/sata/test/crc_tb.py
lib/sata/test/hdd.py
lib/sata/test/link_tb.py
lib/sata/test/scrambler_tb.py
lib/sata/transport/__init__.py
targets/test.py

index ddb481b6a8afbb754a090d8cf4da2201088bedac..69a12bf6ef310c99039142b4889943ed53ecd8be 100644 (file)
@@ -5,8 +5,8 @@ from lib.sata.command import SATACommand
 
 class SATACON(Module):
        def __init__(self, phy, sector_size=512, max_count=8):
-               self.submodules.link = SATALink(phy)
-               self.submodules.transport = SATATransport(self.link)
-               self.submodules.command = SATACommand(self.transport, sector_size=sector_size, max_count=max_count)
+               self.link = SATALink(phy)
+               self.transport = SATATransport(self.link)
+               self.command = SATACommand(self.transport, sector_size=sector_size, max_count=max_count)
                self.sink, self.source = self.command.sink, self.command.source
 
index f3cd5623d24a4506d3dce29b5401eb9bc06b3581..cc9fc1d20bb8fe7c8e3ee7860c1bcdadc1e29bb4 100644 (file)
@@ -119,7 +119,7 @@ class SATACommandRX(Module):
                ###
 
                cmd_fifo = SyncFIFO(command_rx_cmd_description(32), 2) # Note: ideally depth=1
-               data_fifo = InsertReset(FIFO(command_rx_data_description(32), sector_size*max_count//4, buffered=True))
+               data_fifo = InsertReset(SyncFIFO(command_rx_data_description(32), sector_size*max_count//4, buffered=True))
                self.submodules += cmd_fifo, data_fifo
 
                def test_type(name):
@@ -271,8 +271,8 @@ class SATACommand(Module):
        def __init__(self, transport, sector_size=512, max_count=4):
                if max_count*sector_size > 8192:
                        raise ValueError("sector_size * max_count must be <= 8192")
-               self.submodules.tx = SATACommandTX(transport, sector_size)
-               self.submodules.rx = SATACommandRX(transport, sector_size, max_count)
+               self.tx = SATACommandTX(transport, sector_size)
+               self.rx = SATACommandRX(transport, sector_size, max_count)
                self.comb += [
                        self.rx.to_tx.connect(self.tx.from_rx),
                        self.tx.to_rx.connect(self.rx.from_tx)
index 404bddb58726dbffe6a637f1503142b8fe2e71ee..2bd5c0900d294ec7bfce5750da337dca36ea09e4 100644 (file)
@@ -4,6 +4,7 @@ from migen.genlib.fsm import *
 from migen.genlib.record import *
 from migen.flow.actor import *
 from migen.actorlib.fifo import *
+from migen.actorlib.structuring import Pipeline
 
 # PHY / Link Layers
 primitives = {
index 44fdfe0160e749fef548f2fb0add6397d8df7775..4182643d77c52864750a4011a0e6b7128a0f458d 100644 (file)
@@ -147,7 +147,7 @@ class SATALinkRX(Module):
                        )
 
                # small fifo to manage HOLD
-               self.submodules.fifo = SyncFIFO(link_description(32), 32)
+               self.fifo = SyncFIFO(link_description(32), 32)
 
                # graph
                self.sync += \
@@ -210,7 +210,7 @@ class SATALinkRX(Module):
 
 class SATALink(Module):
        def __init__(self, phy):
-               self.submodules.tx = SATALinkTX(phy)
-               self.submodules.rx = SATALinkRX(phy)
+               self.tx = SATALinkTX(phy)
+               self.rx = SATALinkRX(phy)
                self.comb += Record.connect(self.rx.to_tx, self.tx.from_rx)
                self.sink, self.source = self.tx.sink, self.rx.source
index a702a2106e4230a3e644b2154010bad19810d1dc..72157ce535abfebe0580cf7b8a2d394d2425d48b 100644 (file)
@@ -95,7 +95,7 @@ class SATACRC(Module):
 
                ###
 
-               self.submodules.engine = CRCEngine(self.width, self.polynom)
+               self.engine = CRCEngine(self.width, self.polynom)
                reg_i = Signal(self.width, reset=self.init)
                self.sync += reg_i.eq(self.engine.next)
                self.comb += [
index 446faeeb80ac56cf9f6004117bb07e798f4c5e30..d2b473f869dd12f3bfae64c6813175f7737d540b 100644 (file)
@@ -75,7 +75,7 @@ class SATAScrambler(Module):
 
                ###
 
-               self.submodules.scrambler = Scrambler()
+               self.scrambler = Scrambler()
                self.comb += [
                        self.scrambler.ce.eq(sink.stb & sink.ack),
                        Record.connect(sink, source),
index ec6d5e465f2513452634d5a363293fde01ebf587..37ad32fdcea67797d965d6a6af9aec497b688850 100644 (file)
@@ -8,17 +8,17 @@ class SATAPHY(Module):
                if device_family == "k7":
                        from lib.sata.phy.k7.trx import K7SATAPHYTRX
                        from lib.sata.phy.k7.crg import K7SATAPHYCRG
-                       self.submodules.trx = K7SATAPHYTRX(pads, speed)
-                       self.submodules.crg = K7SATAPHYCRG(pads, self.trx, clk_freq, speed)
+                       self.trx = K7SATAPHYTRX(pads, speed)
+                       self.crg = K7SATAPHYCRG(pads, self.trx, clk_freq, speed)
                else:
                        raise NotImplementedError(device_family + "device family not implemented")
 
        # Control
                if host:
-                       self.submodules.ctrl = SATAPHYHostCtrl(self.trx, self.crg, clk_freq)
+                       self.ctrl = SATAPHYHostCtrl(self.trx, self.crg, clk_freq)
                else:
-                       self.submodules.ctrl = SATAPHYDeviceCtrl(self.trx, self.crg, clk_freq)
+                       self.ctrl = SATAPHYDeviceCtrl(self.trx, self.crg, clk_freq)
 
        # Datapath
-               self.submodules.datapath = SATAPHYDatapath(self.trx, self.ctrl)
+               self.datapath = SATAPHYDatapath(self.trx, self.ctrl)
                self.sink, self.source = self.datapath.sink, self.datapath.source
index 34149a676889de10463ab679db84cad0c308fc21..6da4693f9fa53ef4b7d5cf7e245964d1cad4f459 100644 (file)
@@ -58,7 +58,7 @@ class SATAPHYDatapathRX(Module):
                # due to the convertion ratio of 2, sys_clk need to be > sata_rx/2
                # source destination is always able to accept data (ack always 1)
                fifo = AsyncFIFO(phy_description(32), 4)
-               self.submodules.fifo = RenameClockDomains(fifo, {"write": "sata_rx", "read": "sys"})
+               self.fifo = RenameClockDomains(fifo, {"write": "sata_rx", "read": "sys"})
                self.comb += [
                        fifo.sink.stb.eq(valid),
                        fifo.sink.data.eq(data),
@@ -80,7 +80,7 @@ class SATAPHYDatapathTX(Module):
                # requirements:
                # source destination is always able to accept data (ack always 1)
                fifo = AsyncFIFO(phy_description(32), 4)
-               self.submodules.fifo = RenameClockDomains(fifo, {"write": "sys", "read": "sata_tx"})
+               self.fifo = RenameClockDomains(fifo, {"write": "sys", "read": "sata_tx"})
                self.comb += Record.connect(self.sink, fifo.sink)
 
                # 32 to 16
index dd17fc2ecdafc8c2f452eff843745561b135db55..77e45908e4411df2132836a572ee2582521a0adf 100644 (file)
@@ -7,16 +7,18 @@ from lib.sata.test.common import *
 
 class TB(Module):
        def __init__(self):
-               self.submodules.hdd = HDD(
+               self.hdd = HDD(
                                link_debug=False, link_random_level=0,
                                transport_debug=False, transport_loopback=False,
                                hdd_debug=True)
-               self.submodules.controller = SATACON(self.hdd.phy)
-               self.submodules.bist = SATABIST()
-               self.comb += [
-                       self.bist.source.connect(self.controller.sink),
-                       self.controller.source.connect(self.bist.sink)
-               ]
+               self.controller = SATACON(self.hdd.phy)
+               self.bist = SATABIST()
+
+               self.pipeline = Pipeline(
+                       self.bist,
+                       self.controller,
+                       self.bist
+               )
 
        def gen_simulation(self, selfp):
                hdd = self.hdd
index cd1e073ecd2f1a2feae1b1c9c8c124488702bd71..fd6c3a1eed8437b3cca201d68d7851e498d64fad 100644 (file)
@@ -61,26 +61,27 @@ class CommandLogger(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=False,
                                hdd_debug=True)
-               self.submodules.link = SATALink(self.hdd.phy)
-               self.submodules.transport = SATATransport(self.link)
-               self.submodules.command = SATACommand(self.transport)
+               self.link = SATALink(self.hdd.phy)
+               self.transport = SATATransport(self.link)
+               self.command = SATACommand(self.transport)
 
-               self.submodules.streamer = CommandStreamer()
-               streamer_ack_randomizer = AckRandomizer(command_tx_description(32), level=50)
-               self.submodules += streamer_ack_randomizer
-               self.submodules.logger = CommandLogger()
-               logger_ack_randomizer = AckRandomizer(command_rx_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.command.sink),
-                       Record.connect(self.command.source, logger_ack_randomizer.sink),
-                       Record.connect(logger_ack_randomizer.source, self.logger.sink)
-               ]
+               self.streamer = CommandStreamer()
+               self.streamer_randomizer = Randomizer(command_tx_description(32), level=50)
+
+               self.logger = CommandLogger()
+               self.logger_randomizer = Randomizer(command_rx_description(32), level=50)
+
+               self.pipeline = Pipeline(
+                       self.streamer,
+                       self.streamer_randomizer,
+                       self.command,
+                       self.logger_randomizer,
+                       self.logger
+               )
 
        def gen_simulation(self, selfp):
                hdd = self.hdd
index 4fb47fffdaef034ee9495637ead3636a6a316633..2b974fbb9f0047eea1e2f646146b8976885c628e 100644 (file)
@@ -7,7 +7,7 @@ from lib.sata.test.common import *
 
 class TB(Module):
        def __init__(self, length, random):
-               self.submodules.crc = SATACRC()
+               self.crc = SATACRC()
                self.length = length
                self.random = random
 
index 371d4c1a73a6208c86c84d58934cde8c79eebc4a..33652fceb71645b5befd1f962c5ad1ca25c0f7cb 100644 (file)
@@ -56,8 +56,8 @@ class PHYSink(Module):
 class PHYLayer(Module):
        def __init__(self):
 
-               self.submodules.rx = PHYSink()
-               self.submodules.tx = PHYSource()
+               self.rx = PHYSink()
+               self.tx = PHYSource()
 
                self.source = self.tx.source
                self.sink = self.rx.sink
@@ -440,10 +440,10 @@ class HDD(Module):
                        hdd_debug=False, hdd_sector_size=512,
                        ):
                ###
-               self.submodules.phy = PHYLayer()
-               self.submodules.link = LinkLayer(self.phy, link_debug, link_random_level)
-               self.submodules.transport = TransportLayer(self.link, transport_debug, transport_loopback)
-               self.submodules.command = CommandLayer(self.transport)
+               self.phy = PHYLayer()
+               self.link = LinkLayer(self.phy, link_debug, link_random_level)
+               self.transport = TransportLayer(self.link, transport_debug, transport_loopback)
+               self.command = CommandLayer(self.transport)
 
                self.command.set_hdd(self)
 
index 778b171c987c941a3d2b91410af361ad6d1d3abd..4c8e689d331d0fb3db18fc596f872478471ca382 100644 (file)
@@ -4,8 +4,6 @@ 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)
index 42fdf699ab7ea6e290f590bf7a5c982da4d4980c..69d7b63e0b89f289cef9c5d6d0f2ee5eb65d9992 100644 (file)
@@ -7,7 +7,7 @@ from lib.sata.test.common import *
 
 class TB(Module):
        def __init__(self, length):
-               self.submodules.scrambler = InsertReset(Scrambler())
+               self.scrambler = InsertReset(Scrambler())
                self.length = length
 
        def get_c_values(self, length):
index dd0e4f933c048f2de7ddfc59528228a82959b83b..abb07cc4957e87fcfc0d30607a6d86dcb2cc410e 100644 (file)
@@ -231,6 +231,6 @@ class SATATransportRX(Module):
 
 class SATATransport(Module):
        def __init__(self, link):
-               self.submodules.tx = SATATransportTX(link)
-               self.submodules.rx = SATATransportRX(link)
+               self.tx = SATATransportTX(link)
+               self.rx = SATATransportRX(link)
                self.sink, self.source = self.tx.sink, self.rx.source
index 6ea4defc6f584e879754843dc75cd7ae8c5183f5..431fce2e2fa6a3ef97cb38eb715b83512896da65 100644 (file)
@@ -60,17 +60,17 @@ class UART2WB(Module):
        interrupt_map = {}
        cpu_type = None
        def __init__(self, platform, clk_freq):
-               self.submodules.uart2wb = UART2Wishbone(platform.request("serial"), clk_freq)
+               self.uart2wb = UART2Wishbone(platform.request("serial"), clk_freq)
 
                # CSR bridge   0x00000000 (shadow @0x00000000)
-               self.submodules.wishbone2csr = wishbone2csr.WB2CSR(bus_csr=csr.Interface(self.csr_data_width))
+               self.wishbone2csr = wishbone2csr.WB2CSR(bus_csr=csr.Interface(self.csr_data_width))
                self._wb_masters = [self.uart2wb.wishbone]
                self._wb_slaves = [(lambda a: a[23:25] == 0, self.wishbone2csr.wishbone)]
                self.cpu_csr_regions = [] # list of (name, origin, busword, csr_list/Memory)
 
 
                # CSR
-               self.submodules.identifier = identifier.Identifier(0, int(clk_freq), 0)
+               self.identifier = identifier.Identifier(0, int(clk_freq), 0)
 
        def add_wb_master(self, wbm):
                if self.finalized:
@@ -90,14 +90,14 @@ class UART2WB(Module):
 
        def do_finalize(self):
                # Wishbone
-               self.submodules.wishbonecon = wishbone.InterconnectShared(self._wb_masters,
+               self.wishbonecon = wishbone.InterconnectShared(self._wb_masters,
                        self._wb_slaves, register=True)
 
                # CSR
-               self.submodules.csrbankarray = csrgen.BankArray(self,
+               self.csrbankarray = csrgen.BankArray(self,
                        lambda name, memory: self.csr_map[name if memory is None else name + "_" + memory.name_override],
                        data_width=self.csr_data_width)
-               self.submodules.csrcon = csr.Interconnect(self.wishbone2csr.csr, self.csrbankarray.get_buses())
+               self.csrcon = csr.Interconnect(self.wishbone2csr.csr, self.csrbankarray.get_buses())
                for name, csrs, mapaddr, rmap in self.csrbankarray.banks:
                        self.add_cpu_csr_region(name, 0xe0000000+0x800*mapaddr, flen(rmap.bus.dat_w), csrs)
                for name, memory, mapaddr, mmap in self.csrbankarray.srams:
@@ -109,15 +109,15 @@ class SimDesign(UART2WB):
        def __init__(self, platform, export_mila=False):
                clk_freq = 200*1000000
                UART2WB.__init__(self, platform, clk_freq)
-               self.submodules.crg = _CRG(platform)
+               self.crg = _CRG(platform)
 
-               self.submodules.sata_phy_host = SATAPHY(platform.request("sata_host"), clk_freq, host=True)
+               self.sata_phy_host = SATAPHY(platform.request("sata_host"), clk_freq, host=True)
                self.comb += [
                        self.sata_phy_host.sink.stb.eq(1),
                        self.sata_phy_host.sink.data.eq(primitives["SYNC"]),
                        self.sata_phy_host.sink.charisk.eq(0b0001)
                ]
-               self.submodules.sata_phy_device = SATAPHY(platform.request("sata_device"), clk_freq, host=False)
+               self.sata_phy_device = SATAPHY(platform.request("sata_device"), clk_freq, host=False)
                self.comb += [
                        self.sata_phy_device.sink.stb.eq(1),
                        self.sata_phy_device.sink.data.eq(primitives["SYNC"]),
@@ -155,8 +155,8 @@ class VeryBasicPHYStim(Module, AutoCSR):
                self._tx_primitive = CSRStorage(32)
                self._rx_primitive = CSRStatus(32)
 
-               self.submodules.cont_inserter = SATACONTInserter(phy_description(32))
-               self.submodules.cont_remover = SATACONTRemover(phy_description(32))
+               self.cont_inserter = SATACONTInserter(phy_description(32))
+               self.cont_remover = SATACONTRemover(phy_description(32))
                self.comb += [
                        self.cont_inserter.source.connect(phy.sink),
                        phy.source.connect(self.cont_remover.sink)
@@ -185,12 +185,12 @@ class TestDesign(UART2WB, AutoCSR):
        def __init__(self, platform, mila=True, export_mila=False):
                clk_freq = 200*1000000
                UART2WB.__init__(self, platform, clk_freq)
-               self.submodules.crg = _CRG(platform)
+               self.crg = _CRG(platform)
 
-               self.submodules.sata_phy = SATAPHY(platform.request("sata_host"), clk_freq, host=True, speed="SATA1")
-               self.submodules.stim = VeryBasicPHYStim(self.sata_phy)
+               self.sata_phy = SATAPHY(platform.request("sata_host"), clk_freq, host=True, speed="SATA1")
+               self.stim = VeryBasicPHYStim(self.sata_phy)
 
-               self.submodules.clock_leds = ClockLeds(platform)
+               self.clock_leds = ClockLeds(platform)
 
                if mila:
                        import os
@@ -231,7 +231,7 @@ class TestDesign(UART2WB, AutoCSR):
                        self.comb += platform.request("user_led", 2).eq(crg.ready)
                        self.comb += platform.request("user_led", 3).eq(ctrl.ready)
 
-                       self.submodules.mila = MiLa(depth=512, dat=Cat(*debug))
+                       self.mila = MiLa(depth=512, dat=Cat(*debug))
                        self.mila.add_port(Term)
 
                        if export_mila: