change submodules/specials/clock_domains syntax
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 22 Jan 2015 15:02:41 +0000 (16:02 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 22 Jan 2015 15:04:53 +0000 (16:04 +0100)
26 files changed:
litesata/__init__.py
litesata/common.py
litesata/core/__init__.py
litesata/core/command/__init__.py
litesata/core/link/__init__.py
litesata/core/link/cont.py
litesata/core/link/crc.py
litesata/core/link/scrambler.py
litesata/core/transport/__init__.py
litesata/frontend/arbiter.py
litesata/frontend/bist.py
litesata/frontend/crossbar.py
litesata/phy/__init__.py
litesata/phy/ctrl.py
litesata/phy/datapath.py
litesata/phy/k7/crg.py
litesata/test/bist_tb.py
litesata/test/command_tb.py
litesata/test/cont_tb.py
litesata/test/crc_tb.py
litesata/test/hdd.py
litesata/test/link_tb.py
litesata/test/phy_datapath_tb.py
litesata/test/scrambler_tb.py
targets/bist.py
targets/core.py

index d3f86a55b8c8fed97a3ea062e0117fbdea536393..124e028169e29dc02641d1b9f8cded3e937c3b0d 100644 (file)
@@ -12,10 +12,10 @@ class LiteSATA(Module, AutoCSR):
                self.phy = phy
 
                # core
-               self.core = LiteSATACore(self.phy, buffer_depth)
+               self.submodules.core = LiteSATACore(self.phy, buffer_depth)
 
                # frontend
-               self.crossbar = LiteSATACrossbar(self.core)
+               self.submodules.crossbar = LiteSATACrossbar(self.core)
                if with_bist:
-                       self.bist = LiteSATABIST(self.crossbar, with_bist_csr)
+                       self.submodules.bist = LiteSATABIST(self.crossbar, with_bist_csr)
 
index 18f5603c95e3f149398a0ed7ea7ba06c31e14776..d16536627b3f86abf17eeca8fc57650a66bc461e 100644 (file)
@@ -1,6 +1,7 @@
 import math
 
 from migen.fhdl.std import *
+from migen.fhdl.decorators import ModuleDecorator
 from migen.genlib.resetsync import *
 from migen.genlib.fsm import *
 from migen.genlib.record import *
@@ -266,9 +267,9 @@ class Timeout(Module):
                self.sync += value.eq(value+1)
                self.comb += self.reached.eq(value == length)
 
-class BufferizeEndpoints(Module):
+class BufferizeEndpoints(ModuleDecorator):
        def __init__(self, submodule, *args):
-               self.submodule = submodule
+               ModuleDecorator.__init__(self, submodule)
 
                endpoints = get_endpoints(submodule)
                sinks = {}
@@ -294,12 +295,6 @@ class BufferizeEndpoints(Module):
                        self.comb += Record.connect(source, buf.d)
                        setattr(self, name, buf.q)
 
-       def __getattr__(self, name):
-               return getattr(self.submodule, name)
-
-       def __dir__(self):
-               return dir(self.submodule)
-
 class EndpointPacketStatus(Module):
        def __init__(self, endpoint):
                self.start = Signal()
@@ -334,14 +329,16 @@ class PacketBuffer(Module):
                def cmd_description():
                        layout = [("error", 1)]
                        return EndpointDescription(layout)
-               self.cmd_fifo = cmd_fifo = SyncFIFO(cmd_description(), cmd_depth)
+               cmd_fifo = SyncFIFO(cmd_description(), cmd_depth)
+               self.submodules += cmd_fifo
                self.comb += [
                        cmd_fifo.sink.stb.eq(sink_status.done),
                        cmd_fifo.sink.error.eq(sink.error)
                ]
 
                # data
-               self.data_fifo =  data_fifo = SyncFIFO(description, data_depth, buffered=True)
+               data_fifo = SyncFIFO(description, data_depth, buffered=True)
+               self.submodules += data_fifo
                self.comb += [
                        Record.connect(self.sink, data_fifo.sink),
                        data_fifo.sink.stb.eq(self.sink.stb & cmd_fifo.sink.ack),
@@ -350,6 +347,7 @@ class PacketBuffer(Module):
 
                # output packets
                self.fsm = fsm = FSM(reset_state="IDLE")
+               self.submodules += fsm
                fsm.act("IDLE",
                        If(cmd_fifo.source.stb,
                                NextState("SEEK_SOP")
index ce7dc90374aab80d59fe0ff698c6029703381db3..e318c5f257d974cd2fd5da944f901263e78b8351 100644 (file)
@@ -5,7 +5,7 @@ from litesata.core.command import LiteSATACommand
 
 class LiteSATACore(Module):
        def __init__(self, phy, buffer_depth):
-               self.link = LiteSATALink(phy, buffer_depth)
-               self.transport = LiteSATATransport(self.link)
-               self.command = LiteSATACommand(self.transport)
+               self.submodules.link = LiteSATALink(phy, buffer_depth)
+               self.submodules.transport = LiteSATATransport(self.link)
+               self.submodules.command = LiteSATACommand(self.transport)
                self.sink, self.source = self.command.sink, self.command.source
index 3a330839938870b1ffcb97ad7ebcaeba8de2e06f..0229befac761afc850bba51b7b27cebde9d1a7d0 100644 (file)
@@ -31,13 +31,15 @@ class LiteSATACommandTX(Module):
                        transport.sink.data.eq(sink.data)
                ]
 
-               self.dwords_counter = dwords_counter = Counter(max=fis_max_dwords)
+               dwords_counter = Counter(max=fis_max_dwords)
+               self.submodules += dwords_counter
 
                is_write = Signal()
                is_read = Signal()
                is_identify = Signal()
 
                self.fsm = fsm = FSM(reset_state="IDLE")
+               self.submodules += fsm
                fsm.act("IDLE",
                        sink.ack.eq(0),
                        If(sink.stb & sink.sop,
@@ -128,14 +130,15 @@ class LiteSATACommandRX(Module):
                is_identify = Signal()
                is_dma_activate = Signal()
                read_ndwords = Signal(max=sectors2dwords(2**16))
-               self.dwords_counter = dwords_counter = Counter(max=sectors2dwords(2**16))
+               dwords_counter = Counter(max=sectors2dwords(2**16))
+               self.submodules += dwords_counter
                read_done = Signal()
 
                self.sync += \
                        If(from_tx.read,
                                read_ndwords.eq(from_tx.count*sectors2dwords(1)-1)
                        )
-               self.comb += read_done.eq(self.dwords_counter.value == read_ndwords)
+               self.comb += read_done.eq(dwords_counter.value == read_ndwords)
 
                d2h_error = Signal()
                clr_d2h_error = Signal()
@@ -158,8 +161,9 @@ class LiteSATACommandRX(Module):
                        )
 
                self.fsm = fsm = FSM(reset_state="IDLE")
+               self.submodules += fsm
                fsm.act("IDLE",
-                       self.dwords_counter.reset.eq(1),
+                       dwords_counter.reset.eq(1),
                        transport.source.ack.eq(1),
                        clr_d2h_error.eq(1),
                        clr_read_error.eq(1),
@@ -236,7 +240,7 @@ class LiteSATACommandRX(Module):
                        source.data.eq(transport.source.data),
                        transport.source.ack.eq(source.ack),
                        If(source.stb & source.ack,
-                               self.dwords_counter.ce.eq(~read_done),
+                               dwords_counter.ce.eq(~read_done),
                                If(source.eop,
                                        If(is_identify,
                                                NextState("IDLE")
@@ -266,8 +270,8 @@ class LiteSATACommandRX(Module):
 
 class LiteSATACommand(Module):
        def __init__(self, transport):
-               self.tx = LiteSATACommandTX(transport)
-               self.rx = LiteSATACommandRX(transport)
+               self.submodules.tx = LiteSATACommandTX(transport)
+               self.submodules.rx = LiteSATACommandRX(transport)
                self.comb += [
                        self.rx.to_tx.connect(self.tx.from_rx),
                        self.tx.to_rx.connect(self.rx.from_tx)
index b6abd9dfbc33f25cb764cb03bd03da8ed6de1922..2be405418dc8e50d240dfa2e4f735e3133277ab8 100644 (file)
@@ -17,6 +17,7 @@ class LiteSATALinkTX(Module):
                ###
 
                self.fsm = fsm = FSM(reset_state="IDLE")
+               self.submodules += fsm
 
                # insert CRC
                crc = LiteSATACRCInserter(link_description(32))
@@ -34,7 +35,8 @@ class LiteSATALinkTX(Module):
 
                # inserter CONT and scrambled data between
                # CONT and next primitive
-               self.cont  = cont = BufferizeEndpoints(LiteSATACONTInserter(phy_description(32)), "source")
+               cont = BufferizeEndpoints(LiteSATACONTInserter(phy_description(32)), "source")
+               self.submodules += cont
 
                # datas / primitives mux
                insert = Signal(32)
@@ -116,9 +118,11 @@ class LiteSATALinkRX(Module):
                ###
 
                self.fsm = fsm = FSM(reset_state="IDLE")
+               self.submodules += fsm
 
                # CONT remover
-               self.cont = cont = BufferizeEndpoints(LiteSATACONTRemover(phy_description(32)), "source")
+               cont = BufferizeEndpoints(LiteSATACONTRemover(phy_description(32)), "source")
+               self.submodules += cont
                self.comb += Record.connect(phy.source, cont.sink)
 
                # datas / primitives detection
@@ -130,10 +134,12 @@ class LiteSATALinkRX(Module):
                        )
 
                # descrambler
-               self.scrambler = scrambler = LiteSATAScrambler(link_description(32))
+               scrambler = LiteSATAScrambler(link_description(32))
+               self.submodules += scrambler
 
                # check CRC
-               self.crc = crc = LiteSATACRCChecker(link_description(32))
+               crc = LiteSATACRCChecker(link_description(32))
+               self.submodules += crc
 
                sop = Signal()
                eop = Signal()
@@ -235,10 +241,10 @@ class LiteSATALinkRX(Module):
 
 class LiteSATALink(Module):
        def __init__(self, phy, buffer_depth):
-               self.tx_buffer = PacketBuffer(link_description(32), buffer_depth)
-               self.tx = LiteSATALinkTX(phy)
-               self.rx = LiteSATALinkRX(phy)
-               self.rx_buffer = PacketBuffer(link_description(32), buffer_depth, almost_full=3*buffer_depth//4)
+               self.submodules.tx_buffer = PacketBuffer(link_description(32), buffer_depth)
+               self.submodules.tx = LiteSATALinkTX(phy)
+               self.submodules.rx = LiteSATALinkRX(phy)
+               self.submodules.rx_buffer = PacketBuffer(link_description(32), buffer_depth, almost_full=3*buffer_depth//4)
                self.comb += [
                        Record.connect(self.tx_buffer.source, self.tx.sink),
                        Record.connect(self.rx.to_tx, self.tx.from_rx),
index dff6a28faf0e07dca442d038b96ec32da4509976..0984374b5f2882acc496d0d35e1a61d6f14b12d8 100644 (file)
@@ -8,7 +8,8 @@ class LiteSATACONTInserter(Module):
 
                ###
 
-               self.counter = counter = Counter(max=4)
+               counter = Counter(max=4)
+               self.submodules += counter
 
                is_data = Signal()
                was_data = Signal()
@@ -37,7 +38,8 @@ class LiteSATACONTInserter(Module):
                )
 
                # scrambler
-               self.scrambler = scrambler = InsertReset(Scrambler())
+               scrambler = InsertReset(Scrambler())
+               self.submodules += scrambler
 
                # Datapath
                self.comb += [
index 89e4a13b0e3e1230c81d37b9589e453f50c3949c..d73b047d0c70809ecf554ba48564691ca77646a4 100644 (file)
@@ -95,15 +95,16 @@ class LiteSATACRC(Module):
 
                ###
 
-               self.engine = CRCEngine(self.width, self.polynom)
+               engine = CRCEngine(self.width, self.polynom)
+               self.submodules += engine
                reg_i = Signal(self.width, reset=self.init)
-               self.sync += reg_i.eq(self.engine.next)
+               self.sync += reg_i.eq(engine.next)
                self.comb += [
-                       self.engine.d.eq(self.d),
-                       self.engine.last.eq(reg_i),
+                       engine.d.eq(self.d),
+                       engine.last.eq(reg_i),
 
                        self.value.eq(reg_i),
-                       self.error.eq(self.engine.next != self.check)
+                       self.error.eq(engine.next != self.check)
                ]
 
 class LiteSATACRCInserter(CRCInserter):
index 4b5b9960a848874d18802f32b0d8045f0c9e2600..99ad98ce0a50762b3cccb7ee80327f62bfbf40a8 100644 (file)
@@ -72,9 +72,10 @@ class LiteSATAScrambler(Module):
 
                ###
 
-               self.scrambler = Scrambler()
+               scrambler = Scrambler()
+               self.submodules += scrambler
                self.comb += [
-                       self.scrambler.ce.eq(sink.stb & sink.ack),
+                       scrambler.ce.eq(sink.stb & sink.ack),
                        Record.connect(sink, source),
-                       source.d.eq(sink.d ^ self.scrambler.value)
+                       source.d.eq(sink.d ^ scrambler.value)
                ]
index 7799a0d92c062d3550c7cd432863fbfae2f253b0..a066fb7c0309349e92e64957ce13a6db921a4f76 100644 (file)
@@ -30,7 +30,8 @@ class LiteSATATransportTX(Module):
                cmd_ndwords = max(fis_reg_h2d_cmd_len, fis_data_cmd_len)
                encoded_cmd = Signal(cmd_ndwords*32)
 
-               self.counter = counter = Counter(max=cmd_ndwords+1)
+               counter = Counter(max=cmd_ndwords+1)
+               self.submodules += counter
 
                cmd_len = Signal(counter.width)
                cmd_with_data = Signal()
@@ -46,6 +47,7 @@ class LiteSATATransportTX(Module):
                        return test_type(name, sink.type)
 
                self.fsm = fsm = FSM(reset_state="IDLE")
+               self.submodules += fsm
                fsm.act("IDLE",
                        sink.ack.eq(0),
                        counter.reset.eq(1),
@@ -131,7 +133,8 @@ class LiteSATATransportRX(Module):
                                                  fis_pio_setup_d2h_cmd_len, fis_data_cmd_len)
                encoded_cmd = Signal(cmd_ndwords*32)
 
-               self.counter = counter = Counter(max=cmd_ndwords+1)
+               counter = Counter(max=cmd_ndwords+1)
+               self.submodules += counter
 
                cmd_len = Signal(counter.width)
 
@@ -144,6 +147,7 @@ class LiteSATATransportRX(Module):
                        return test_type(name, link.source.d[:8])
 
                self.fsm = fsm = FSM(reset_state="IDLE")
+               self.submodules += fsm
 
                data_sop = Signal()
                fis_type = Signal(8)
@@ -248,6 +252,6 @@ class LiteSATATransportRX(Module):
 
 class LiteSATATransport(Module):
        def __init__(self, link):
-               self.tx = LiteSATATransportTX(link)
-               self.rx = LiteSATATransportRX(link)
+               self.submodules.tx = LiteSATATransportTX(link)
+               self.submodules.rx = LiteSATATransportRX(link)
                self.sink, self.source = self.tx.sink, self.rx.source
index 73eafaa31dfb5e72779bbb2b7bc1d0dafc0a15b1..64bedf294f315e0586c6f6c6f5088422c72b7233 100644 (file)
@@ -6,6 +6,7 @@ from migen.genlib.roundrobin import *
 class LiteSATAArbiter(Module):
        def __init__(self, users, master):
                self.rr = RoundRobin(len(users))
+               self.submodules += self.rr
                self.grant = self.rr.grant
                cases = {}
                for i, slave in enumerate(users):
index ae6d2999ca379ec5b3c1ecbaf6521a460a4478c2..aa1dbdcd6fdf162c4ca5486d71856e50da04f7c2 100644 (file)
@@ -19,15 +19,18 @@ class LiteSATABISTGenerator(Module):
 
                source, sink = user_port.sink, user_port.source
 
-               self.counter = counter = Counter(bits_sign=32)
+               counter = Counter(bits_sign=32)
+               self.submodules += counter
 
-               self.scrambler = scrambler = InsertReset(Scrambler())
+               scrambler = scrambler = InsertReset(Scrambler())
+               self.submodules += scrambler
                self.comb += [
                        scrambler.reset.eq(counter.reset),
                        scrambler.ce.eq(counter.ce)
                ]
 
                self.fsm = fsm = FSM(reset_state="IDLE")
+               self.submodules += fsm
                fsm.act("IDLE",
                        self.done.eq(1),
                        counter.reset.eq(1),
@@ -79,21 +82,24 @@ class LiteSATABISTChecker(Module):
 
                source, sink = user_port.sink, user_port.source
 
-               self.counter = counter = Counter(bits_sign=32)
-               self.error_counter = Counter(self.errors, bits_sign=32)
+               counter = Counter(bits_sign=32)
+               error_counter = Counter(self.errors, bits_sign=32)
+               self.submodules += counter, error_counter
 
-               self.scrambler = scrambler = InsertReset(Scrambler())
+               scrambler = InsertReset(Scrambler())
+               self.submodules += scrambler
                self.comb += [
                        scrambler.reset.eq(counter.reset),
                        scrambler.ce.eq(counter.ce)
                ]
 
                self.fsm = fsm = FSM(reset_state="IDLE")
+               self.submodules += self.fsm
                fsm.act("IDLE",
                        self.done.eq(1),
                        counter.reset.eq(1),
                        If(self.start,
-                               self.error_counter.reset.eq(1),
+                               error_counter.reset.eq(1),
                                NextState("SEND_CMD")
                        )
                )
@@ -128,7 +134,7 @@ class LiteSATABISTChecker(Module):
                        If(sink.stb,
                                counter.ce.eq(1),
                                If(sink.data != expected_data,
-                                       self.error_counter.ce.eq(~sink.last)
+                                       error_counter.ce.eq(~sink.last)
                                ),
                                If(sink.eop,
                                        If(sink.last,
@@ -156,7 +162,8 @@ class LiteSATABISTUnitCSR(Module, AutoCSR):
 
                ###
 
-               self.bist_unit = bist_unit
+               self.submodules += bist_unit
+
                start = self._start.r & self._start.re
                done = self._done.status
                loops = self._loops.storage
@@ -171,16 +178,17 @@ class LiteSATABISTUnitCSR(Module, AutoCSR):
                ]
 
                self.fsm = fsm = FSM(reset_state="IDLE")
-               self.loop_counter = Counter(bits_sign=8)
+               loop_counter = Counter(bits_sign=8)
+               self.submodules += fsm, loop_counter
                fsm.act("IDLE",
                        self._done.status.eq(1),
-                       self.loop_counter.reset.eq(1),
+                       loop_counter.reset.eq(1),
                        If(start,
                                NextState("CHECK")
                        )
                )
                fsm.act("CHECK",
-                       If(self.loop_counter.value < loops,
+                       If(loop_counter.value < loops,
                                NextState("START")
                        ).Else(
                                NextState("IDLE")
@@ -192,15 +200,16 @@ class LiteSATABISTUnitCSR(Module, AutoCSR):
                )
                fsm.act("WAIT_DONE",
                        If(bist_unit.done,
-                               self.loop_counter.ce.eq(1),
+                               loop_counter.ce.eq(1),
                                NextState("CHECK")
                        )
                )
 
-               self.cycles_counter = Counter(self._cycles.status)
+               cycles_counter = Counter(self._cycles.status)
+               self.submodules += cycles_counter
                self.sync += [
-                       self.cycles_counter.reset.eq(start),
-                       self.cycles_counter.ce.eq(~fsm.ongoing("IDLE"))
+                       cycles_counter.reset.eq(start),
+                       cycles_counter.ce.eq(~fsm.ongoing("IDLE"))
                ]
 
 class LiteSATABISTIdentify(Module):
@@ -208,8 +217,9 @@ class LiteSATABISTIdentify(Module):
                self.start = Signal()
                self.done  = Signal()
 
-               self.fifo = fifo = SyncFIFO([("data", 32)], 512, buffered=True)
-               self.source = self.fifo.source
+               fifo = SyncFIFO([("data", 32)], 512, buffered=True)
+               self.submodules += fifo
+               self.source = fifo.source
 
                ###
 
@@ -259,7 +269,7 @@ class LiteSATABISTIdentifyCSR(Module, AutoCSR):
 
                ###
 
-               self.bist_identify = bist_identify
+               self.submodules += bist_identify
                self.comb += [
                        bist_identify.start.eq(self._start.r & self._start.re),
                        self._done.status.eq(bist_identify.done),
@@ -275,10 +285,7 @@ class LiteSATABIST(Module, AutoCSR):
                checker = LiteSATABISTChecker(crossbar.get_port())
                identify = LiteSATABISTIdentify(crossbar.get_port())
                if with_csr:
-                       self.generator = LiteSATABISTUnitCSR(generator)
-                       self.checker = LiteSATABISTUnitCSR(checker)
-                       self.identify = LiteSATABISTIdentifyCSR(identify)
-               else:
-                       self.generator = generator
-                       self.checker = checker
-                       self.identify = identify
+                       generator = LiteSATABISTUnitCSR(generator)
+                       checker = LiteSATABISTUnitCSR(checker)
+                       identify = LiteSATABISTIdentifyCSR(identify)
+               self.submodules += generator, checker, identify
index d916209c04a0f31c45c19d0eb8b1036d93a81568..22170449a2b8e99c60effd2e57af6795e028dc4e 100644 (file)
@@ -23,4 +23,5 @@ class LiteSATACrossbar(Module):
                return ports
 
        def do_finalize(self):
-               self.arbiter = LiteSATAArbiter(self.users, self.master)
+               arbiter = LiteSATAArbiter(self.users, self.master)
+               self.submodules += arbiter
\ No newline at end of file
index 5978250d51b48ec059626ded68be52966fae258c..7af74b2db26c0c3f65b28716324f8a5720a3ec36 100644 (file)
@@ -10,15 +10,15 @@ class LiteSATAPHY(Module):
                if device[:3] == "xc7": # Kintex 7
                        from litesata.phy.k7.trx import K7LiteSATAPHYTRX
                        from litesata.phy.k7.crg import K7LiteSATAPHYCRG
-                       self.trx = K7LiteSATAPHYTRX(pads, revision)
-                       self.crg = K7LiteSATAPHYCRG(pads, self.trx, revision, clk_freq)
+                       self.submodules.trx = K7LiteSATAPHYTRX(pads, revision)
+                       self.submodules.crg = K7LiteSATAPHYCRG(pads, self.trx, revision, clk_freq)
                else:
                        msg = "Device" + device + "not (yet) supported."
                        raise NotImplementedError(msg)
 
                # Control
-               self.ctrl = LiteSATAPHYCtrl(self.trx, self.crg, clk_freq)
+               self.submodules.ctrl = LiteSATAPHYCtrl(self.trx, self.crg, clk_freq)
 
                # Datapath
-               self.datapath = LiteSATAPHYDatapath(self.trx, self.ctrl)
+               self.submodules.datapath = LiteSATAPHYDatapath(self.trx, self.ctrl)
                self.sink, self.source = self.datapath.sink, self.datapath.source
index 23d64085426c9b5f787acb7f34e2ea0b56d47e81..fc48a65c683c48d2f37bb57f28515f5eaf879863 100644 (file)
@@ -25,6 +25,7 @@ class LiteSATAPHYCtrl(Module):
                non_align_cnt = Signal(4)
 
                self.fsm = fsm = FSM(reset_state="RESET")
+               self.submodules += fsm
                fsm.act("RESET",
                        trx.tx_idle.eq(1),
                        retry_timeout.reset.eq(1),
@@ -128,10 +129,11 @@ class LiteSATAPHYCtrl(Module):
                        self.ready.eq(1),
                )
 
-               self.reset_timeout = Timeout(clk_freq//16)
+               reset_timeout = Timeout(clk_freq//16)
+               self.submodules += reset_timeout
                self.comb += [
-                       self.reset_timeout.ce.eq(~self.ready),
-                       self.need_reset.eq(self.reset_timeout.reached)
+                       reset_timeout.ce.eq(~self.ready),
+                       self.need_reset.eq(reset_timeout.reached)
                ]
 
                self.comb +=  \
index c47e7529a6e2d77c6e4dc3b917d1d5ede2109fc4..60f554428d9e93c420fcb5fec310f241a6b3d356 100644 (file)
@@ -2,8 +2,8 @@ from litesata.common import *
 
 class LiteSATAPHYDatapathRX(Module):
        def __init__(self):
-               self.sink = Sink(phy_description(16))
-               self.source = Source(phy_description(32))
+               self.sink = sink = Sink(phy_description(16))
+               self.source = source = Source(phy_description(32))
 
                ###
 
@@ -12,26 +12,27 @@ class LiteSATAPHYDatapathRX(Module):
                last_charisk = Signal(2)
                last_data = Signal(16)
                self.sync.sata_rx += \
-                       If(self.sink.stb & self.sink.ack,
-                               If(self.sink.charisk != 0,
-                                       byte_alignment.eq(self.sink.charisk[1])
+                       If(sink.stb & sink.ack,
+                               If(sink.charisk != 0,
+                                       byte_alignment.eq(sink.charisk[1])
                                ),
-                               last_charisk.eq(self.sink.charisk),
-                               last_data.eq(self.sink.data)
+                               last_charisk.eq(sink.charisk),
+                               last_data.eq(sink.data)
                        )
                converter = Converter(phy_description(16), phy_description(32), reverse=False)
-               self.converter = InsertReset(RenameClockDomains(converter, "sata_rx"))
+               converter = InsertReset(RenameClockDomains(converter, "sata_rx"))
+               self.submodules += converter
                self.comb += [
-                       self.converter.sink.stb.eq(self.sink.stb),
+                       converter.sink.stb.eq(sink.stb),
                        If(byte_alignment,
-                               self.converter.sink.charisk.eq(Cat(last_charisk[1], self.sink.charisk[0])),
-                               self.converter.sink.data.eq(Cat(last_data[8:], self.sink.data[:8]))
+                               converter.sink.charisk.eq(Cat(last_charisk[1], sink.charisk[0])),
+                               converter.sink.data.eq(Cat(last_data[8:], sink.data[:8]))
                        ).Else(
-                               self.converter.sink.charisk.eq(self.sink.charisk),
-                               self.converter.sink.data.eq(self.sink.data)
+                               converter.sink.charisk.eq(sink.charisk),
+                               converter.sink.data.eq(sink.data)
                        ),
-                       self.sink.ack.eq(self.converter.sink.ack),
-                       self.converter.reset.eq(self.converter.source.charisk[2:] != 0)
+                       sink.ack.eq(converter.sink.ack),
+                       converter.reset.eq(converter.source.charisk[2:] != 0)
                ]
 
        # clock domain crossing
@@ -42,16 +43,17 @@ class LiteSATAPHYDatapathRX(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.fifo = RenameClockDomains(fifo, {"write": "sata_rx", "read": "sys"})
+               fifo = RenameClockDomains(fifo, {"write": "sata_rx", "read": "sys"})
+               self.submodules += fifo
                self.comb += [
-                       Record.connect(self.converter.source, fifo.sink),
-                       Record.connect(fifo.source, self.source)
+                       Record.connect(converter.source, fifo.sink),
+                       Record.connect(fifo.source, source)
                ]
 
 class LiteSATAPHYDatapathTX(Module):
        def __init__(self):
-               self.sink = Sink(phy_description(32))
-               self.source = Source(phy_description(16))
+               self.sink = sink = Sink(phy_description(32))
+               self.source = source = Source(phy_description(16))
 
                ###
 
@@ -62,15 +64,17 @@ class LiteSATAPHYDatapathTX(Module):
                # requirements:
                # source destination is always able to accept data (ack always 1)
                fifo = AsyncFIFO(phy_description(32), 4)
-               self.fifo = RenameClockDomains(fifo, {"write": "sys", "read": "sata_tx"})
-               self.comb += Record.connect(self.sink, fifo.sink)
+               fifo = RenameClockDomains(fifo, {"write": "sys", "read": "sata_tx"})
+               self.submodules += fifo
+               self.comb += Record.connect(sink, fifo.sink)
 
        # width convertion (32 to 16)
                converter = Converter(phy_description(32), phy_description(16), reverse=False)
-               self.converter =  RenameClockDomains(converter, "sata_tx")
+               converter = RenameClockDomains(converter, "sata_tx")
+               self.submodules += converter
                self.comb += [
-                       Record.connect(self.fifo.source, self.converter.sink),
-                       Record.connect(self.converter.source, self.source)
+                       Record.connect(fifo.source, converter.sink),
+                       Record.connect(converter.source, source)
                ]
 
 class LiteSATAPHYAlignInserter(Module):
@@ -125,33 +129,35 @@ class LiteSATAPHYAlignRemover(Module):
 
 class LiteSATAPHYDatapath(Module):
        def __init__(self, trx, ctrl):
-               self.sink = Sink(phy_description(32))
-               self.source = Source(phy_description(32))
+               self.sink = sink = Sink(phy_description(32))
+               self.source = source = Source(phy_description(32))
 
                ###
 
        # TX path
-               self.align_inserter = LiteSATAPHYAlignInserter(ctrl)
-               self.mux = Multiplexer(phy_description(32), 2)
-               self.tx = LiteSATAPHYDatapathTX()
+               align_inserter = LiteSATAPHYAlignInserter(ctrl)
+               mux = Multiplexer(phy_description(32), 2)
+               tx = LiteSATAPHYDatapathTX()
+               self.submodules += align_inserter, mux, tx
                self.comb += [
-                       self.mux.sel.eq(ctrl.ready),
-                       Record.connect(self.sink, self.align_inserter.sink),
-                       Record.connect(ctrl.source, self.mux.sink0),
-                       Record.connect(self.align_inserter.source, self.mux.sink1),
-                       Record.connect(self.mux.source, self.tx.sink),
-                       Record.connect(self.tx.source, trx.sink)
+                       mux.sel.eq(ctrl.ready),
+                       Record.connect(sink, align_inserter.sink),
+                       Record.connect(ctrl.source, mux.sink0),
+                       Record.connect(align_inserter.source, mux.sink1),
+                       Record.connect(mux.source, tx.sink),
+                       Record.connect(tx.source, trx.sink)
                ]
 
        # RX path
-               self.rx = LiteSATAPHYDatapathRX()
-               self.demux = Demultiplexer(phy_description(32), 2)
-               self.align_remover = LiteSATAPHYAlignRemover()
+               rx = LiteSATAPHYDatapathRX()
+               demux = Demultiplexer(phy_description(32), 2)
+               align_remover = LiteSATAPHYAlignRemover()
+               self.submodules += rx, demux, align_remover
                self.comb += [
-                       self.demux.sel.eq(ctrl.ready),
-                       Record.connect(trx.source, self.rx.sink),
-                       Record.connect(self.rx.source, self.demux.sink),
-                       Record.connect(self.demux.source0, ctrl.sink),
-                       Record.connect(self.demux.source1, self.align_remover.sink),
-                       Record.connect(self.align_remover.source, self.source)
+                       demux.sel.eq(ctrl.ready),
+                       Record.connect(trx.source, rx.sink),
+                       Record.connect(rx.source, demux.sink),
+                       Record.connect(demux.source0, ctrl.sink),
+                       Record.connect(demux.source1, align_remover.sink),
+                       Record.connect(align_remover.source, source)
                ]
index c3267c6c7949e07bb98d2295673fed37a0e3b8a7..9830b45b9147f5b88d23236bcab6e0b30ea38bc5 100644 (file)
@@ -5,8 +5,8 @@ class K7LiteSATAPHYCRG(Module):
                self.reset = Signal()
                self.ready = Signal()
 
-               self.cd_sata_tx = ClockDomain()
-               self.cd_sata_rx = ClockDomain()
+               self.clock_domains.cd_sata_tx = ClockDomain()
+               self.clock_domains.cd_sata_rx = ClockDomain()
 
        # CPLL
                # (SATA3) 150MHz / VCO @ 3GHz / Line rate @ 6Gbps
index e96b3c034bceef84b7778e08cf70523ccff6458d..483ffb7d73b6fd0797fd4927db1ac861552734bc 100644 (file)
@@ -7,13 +7,13 @@ from litesata.test.common import *
 
 class TB(Module):
        def __init__(self):
-               self.hdd = HDD(
+               self.submodules.hdd = HDD(
                                link_debug=False, link_random_level=0,
                                transport_debug=False, transport_loopback=False,
                                hdd_debug=True)
-               self.controller = LiteSATA(self.hdd.phy)
-               self.generator = LiteSATABISTGenerator(self.controller.crossbar.get_port())
-               self.checker = LiteSATABISTChecker(self.controller.crossbar.get_port())
+               self.submodules.controller = LiteSATA(self.hdd.phy)
+               self.submodules.generator = LiteSATABISTGenerator(self.controller.crossbar.get_port())
+               self.submodules.checker = LiteSATABISTChecker(self.controller.crossbar.get_port())
 
        def gen_simulation(self, selfp):
                hdd = self.hdd
index 566902fd8c00e28b391150aafb2c497895c7e7b7..2bcc820e9b79d75d00c2d85715c371d3258039a3 100644 (file)
@@ -53,19 +53,19 @@ class CommandLogger(PacketLogger):
 
 class TB(Module):
        def __init__(self):
-               self.hdd = HDD(
+               self.submodules.hdd = HDD(
                                link_debug=False, link_random_level=50,
                                transport_debug=False, transport_loopback=False,
                                hdd_debug=True)
-               self.core = LiteSATACore(self.hdd.phy, buffer_depth=512)
+               self.submodules.core = LiteSATACore(self.hdd.phy, buffer_depth=512)
 
-               self.streamer = CommandStreamer()
-               self.streamer_randomizer = Randomizer(command_tx_description(32), level=50)
+               self.submodules.streamer = CommandStreamer()
+               self.submodules.streamer_randomizer = Randomizer(command_tx_description(32), level=50)
 
-               self.logger = CommandLogger()
-               self.logger_randomizer = Randomizer(command_rx_description(32), level=50)
+               self.submodules.logger = CommandLogger()
+               self.submodules.logger_randomizer = Randomizer(command_rx_description(32), level=50)
 
-               self.pipeline = Pipeline(
+               self.submodules.pipeline = Pipeline(
                        self.streamer,
                        self.streamer_randomizer,
                        self.core,
index bbd69011f1ac106fca590ddedd140b313a6e47ba..cdbb9bf2dd209ff7027699f012b408573e22010c 100644 (file)
@@ -32,14 +32,14 @@ class ContLogger(PacketLogger):
 
 class TB(Module):
        def __init__(self):
-               self.streamer = ContStreamer()
-               self.streamer_randomizer = Randomizer(phy_description(32), level=50)
-               self.inserter = LiteSATACONTInserter(phy_description(32))
-               self.remover = LiteSATACONTRemover(phy_description(32))
-               self.logger_randomizer = Randomizer(phy_description(32), level=50)
-               self.logger = ContLogger()
+               self.submodules.streamer = ContStreamer()
+               self.submodules.streamer_randomizer = Randomizer(phy_description(32), level=50)
+               self.submodules.inserter = LiteSATACONTInserter(phy_description(32))
+               self.submodules.remover = LiteSATACONTRemover(phy_description(32))
+               self.submodules.logger_randomizer = Randomizer(phy_description(32), level=50)
+               self.submodules.logger = ContLogger()
 
-               self.pipeline = Pipeline(
+               self.submodules.pipeline = Pipeline(
                        self.streamer,
                        self.streamer_randomizer,
                        self.inserter,
index a36ec83974432dbee09b34f77e4d51fe45402f55..3799f75549dca8fc093178a4998fb357b2fb3f48 100644 (file)
@@ -7,7 +7,7 @@ from litesata.test.common import *
 
 class TB(Module):
        def __init__(self, length, random):
-               self.crc = LiteSATACRC()
+               self.submodules.crc = LiteSATACRC()
                self.length = length
                self.random = random
 
index 6e897f8e1a7aa02ec19d0cb98d7cdf251017d155..cab36265b33f170f337f5c731db65d15e4c40d7b 100644 (file)
@@ -56,8 +56,8 @@ class PHYSink(Module):
 class PHYLayer(Module):
        def __init__(self):
 
-               self.rx = PHYSink()
-               self.tx = PHYSource()
+               self.submodules.rx = PHYSink()
+               self.submodules.tx = PHYSource()
 
                self.source = self.tx.source
                self.sink = self.rx.sink
@@ -439,10 +439,10 @@ class HDD(Module):
                        hdd_debug=False,
                        ):
                ###
-               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.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.command.set_hdd(self)
 
index 17abe2c89650868813073d0a23ddb553ea627f47..def4e14dbb4c2c3c18ca4de69cb7934eb023e409 100644 (file)
@@ -14,18 +14,18 @@ class LinkLogger(PacketLogger):
 
 class TB(Module):
        def __init__(self):
-               self.hdd = HDD(
+               self.submodules.hdd = HDD(
                                link_debug=False, link_random_level=50,
                                transport_debug=False, transport_loopback=True)
-               self.link = InsertReset(LiteSATALink(self.hdd.phy, buffer_depth=512))
+               self.submodules.link = InsertReset(LiteSATALink(self.hdd.phy, buffer_depth=512))
 
-               self.streamer = LinkStreamer()
-               self.streamer_randomizer = Randomizer(link_description(32), level=50)
+               self.submodules.streamer = LinkStreamer()
+               self.submodules.streamer_randomizer = Randomizer(link_description(32), level=50)
 
-               self.logger_randomizer = Randomizer(link_description(32), level=50)
-               self.logger = LinkLogger()
+               self.submodules.logger_randomizer = Randomizer(link_description(32), level=50)
+               self.submodules.logger = LinkLogger()
 
-               self.pipeline = Pipeline(
+               self.submodules.pipeline = Pipeline(
                        self.streamer,
                        self.streamer_randomizer,
                        self.link,
index 71071035a5f0664e92eeff31de8efd1f01fe8c29..a1c2d4c58002acf2df9462e246fab7b344a217ae 100644 (file)
@@ -1,5 +1,5 @@
 from litesata.common import *
-from litesata.phy.datapath import liteSATAPHYDatapath
+from litesata.phy.datapath import LiteSATAPHYDatapath
 
 from litesata.test.common import *
 
@@ -45,8 +45,8 @@ class CTRL(Module):
 class TB(Module):
        def __init__(self):
                # use sys_clk for each clock_domain
-               self.cd_sata_rx = ClockDomain()
-               self.cd_sata_tx = ClockDomain()
+               self.clock_domains.cd_sata_rx = ClockDomain()
+               self.clock_domains.cd_sata_tx = ClockDomain()
                self.comb += [
                        self.cd_sata_rx.clk.eq(ClockSignal()),
                        self.cd_sata_rx.rst.eq(ResetSignal()),
@@ -54,15 +54,15 @@ class TB(Module):
                        self.cd_sata_tx.rst.eq(ResetSignal()),
                ]
 
-               self.streamer = DataStreamer()
-               self.streamer_randomizer = Randomizer(phy_description(32), level=10)
-               self.trx = TRX()
-               self.ctrl = CTRL()
-               self.datapath = LiteSATAPHYDatapath(self.trx, self.ctrl)
-               self.logger_randomizer = Randomizer(phy_description(32), level=10)
-               self.logger = DataLogger()
+               self.submodules.streamer = DataStreamer()
+               self.submodules.streamer_randomizer = Randomizer(phy_description(32), level=10)
+               self.submodules.trx = TRX()
+               self.submodules.ctrl = CTRL()
+               self.submodules.datapath = LiteSATAPHYDatapath(self.trx, self.ctrl)
+               self.submodules.logger_randomizer = Randomizer(phy_description(32), level=10)
+               self.submodules.logger = DataLogger()
 
-               self.pipeline = Pipeline(
+               self.submodules.pipeline = Pipeline(
                        self.streamer,
                        self.streamer_randomizer,
                        self.datapath,
index bf29e50cce89ab73b88f38c2f516096ffb978ab8..11d626b15e3bcda3e9c96bf96f798c57c56330eb 100644 (file)
@@ -7,7 +7,7 @@ from litesata.test.common import *
 
 class TB(Module):
        def __init__(self, length):
-               self.scrambler = InsertReset(Scrambler())
+               self.submodules.scrambler = InsertReset(Scrambler())
                self.length = length
 
        def get_c_values(self, length):
index f7ff733fbbae8b5a4ffc2a5d2a5016a53fc7c569..a62fdf0068af11b4205225a5df4750596cce2efb 100644 (file)
@@ -18,7 +18,7 @@ from litesata import LiteSATA
 
 class _CRG(Module):
        def __init__(self, platform):
-               self.cd_sys = ClockDomain()
+               self.clock_domains.cd_sys = ClockDomain()
                self.reset = Signal()
 
                clk200 = platform.request("clk200")
@@ -63,16 +63,16 @@ class GenSoC(Module):
        cpu_type = None
        def __init__(self, platform, clk_freq):
                # UART <--> Wishbone bridge
-               self.uart2wb = UART2Wishbone(platform.request("serial"), clk_freq, baud=921600)
+               self.submodules.uart2wb = UART2Wishbone(platform.request("serial"), clk_freq, baud=921600)
 
                # CSR bridge   0x00000000 (shadow @0x00000000)
-               self.wishbone2csr = wishbone2csr.WB2CSR(bus_csr=csr.Interface(self.csr_data_width))
+               self.submodules.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.identifier = identifier.Identifier(0, int(clk_freq), 0)
+               self.submodules.identifier = identifier.Identifier(0, int(clk_freq), 0)
 
        def add_cpu_memory_region(self, name, origin, length):
                self.cpu_memory_regions.append((name, origin, length))
@@ -82,14 +82,14 @@ class GenSoC(Module):
 
        def do_finalize(self):
                # Wishbone
-               self.wishbonecon = wishbone.InterconnectShared(self._wb_masters,
+               self.submodules.wishbonecon = wishbone.InterconnectShared(self._wb_masters,
                        self._wb_slaves, register=True)
 
                # CSR
-               self.csrbankarray = csrgen.BankArray(self,
+               self.submodules.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.csrcon = csr.Interconnect(self.wishbone2csr.csr, self.csrbankarray.get_buses())
+               self.submodules.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:
@@ -136,15 +136,15 @@ class BISTSoC(GenSoC, AutoCSR):
        def __init__(self, platform, export_mila=False):
                clk_freq = 166*1000000
                GenSoC.__init__(self, platform, clk_freq)
-               self.crg = _CRG(platform)
+               self.submodules.crg = _CRG(platform)
 
                # SATA PHY/Core/Frontend
-               self.sata_phy = LiteSATAPHY(platform.device, platform.request("sata"), "SATA2", clk_freq)
+               self.submodules.sata_phy = LiteSATAPHY(platform.device, platform.request("sata"), "SATA2", clk_freq)
                self.comb += self.crg.reset.eq(self.sata_phy.ctrl.need_reset) # XXX FIXME
-               self.sata = LiteSATA(self.sata_phy, with_bist=True, with_bist_csr=True)
+               self.submodules.sata = LiteSATA(self.sata_phy, with_bist=True, with_bist_csr=True)
 
                # Status Leds
-               self.leds = BISTLeds(platform, self.sata_phy)
+               self.submodules.leds = BISTLeds(platform, self.sata_phy)
 
 class BISTSoCDevel(BISTSoC, AutoCSR):
        csr_map = {
@@ -198,7 +198,7 @@ class BISTSoCDevel(BISTSoC, AutoCSR):
                        self.sata_core_command_tx_fsm_state,
                )
 
-               self.mila = MiLa(depth=2048, dat=Cat(*debug))
+               self.submodules.mila = MiLa(depth=2048, dat=Cat(*debug))
                self.mila.add_port(Term)
                if export_mila:
                        mila_filename = os.path.join("test", "mila.csv")
index 3036a542fec54344f40066a0ec5200585db03678..b876e243cd77fab7f2ebb6984876231defaa85f0 100644 (file)
@@ -6,7 +6,7 @@ from litesata import LiteSATA
 
 class _CRG(Module):
        def __init__(self, platform):
-               self.cd_sys = ClockDomain()
+               self.clock_domains.cd_sys = ClockDomain()
 
 class LiteSATACore(Module):
        default_platform = "verilog_backend"
@@ -16,15 +16,14 @@ class LiteSATACore(Module):
                self.crg = _CRG(platform)
 
                # SATA PHY/Core/Frontend
-               self.sata_phy = LiteSATAPHY(platform.device, platform.request("sata"), "SATA2", clk_freq)
-               self.sata = LiteSATA(self.sata_phy)
+               self.submodules.sata_phy = LiteSATAPHY(platform.device, platform.request("sata"), "SATA2", clk_freq)
+               self.submodules.sata = LiteSATA(self.sata_phy)
 
                # Get user ports from crossbar
                self.user_ports = self.sata.crossbar.get_ports(4)
 
        def get_ios(self):
-               # clock / reset
-               ios = {self.crg.cd_sys.clk, self.crg.cd_sys.rst}
+               ios = set()
 
                # Transceiver
                for e in dir(self.sata_phy.pads):