examples/pytholite: use new APIs
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Tue, 12 Mar 2013 15:59:24 +0000 (16:59 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Tue, 12 Mar 2013 15:59:24 +0000 (16:59 +0100)
examples/pytholite/basic.py
examples/pytholite/uio.py

index 97e20a1d94e146e5d7ff581a77532d16036e1787..c1b4b7805e93e8105fbfc0ee4593a6d4f5ce1057 100644 (file)
@@ -17,8 +17,7 @@ def run_sim(ng):
        g.add_connection(ng, d)
        
        c = CompositeActor(g)
-       fragment = c.get_fragment()
-       sim = Simulator(fragment)
+       sim = Simulator(c)
        sim.run(30)
        del sim
 
@@ -32,6 +31,6 @@ def main():
        run_sim(ng_pytholite)
        
        print("Converting Pytholite to Verilog:")
-       print(verilog.convert(ng_pytholite.get_fragment()))
+       print(verilog.convert(ng_pytholite))
 
 main()
index 01b52e11e51aff23604dc01bf54c1cffbe040b76..9499200e84273f179412e444ae9fb49cda2a2b9a 100644 (file)
@@ -7,6 +7,7 @@ from migen.uio.ioo import UnifiedIOSimulation
 from migen.pytholite.transel import Register
 from migen.pytholite.compiler import make_pytholite
 from migen.sim.generic import Simulator
+from migen.fhdl.module import Module
 from migen.fhdl.specials import Memory
 from migen.fhdl import verilog
 
@@ -29,18 +30,18 @@ class SlaveModel(wishbone.TargetModel):
        def read(self, address):
                return address + 4
 
+class TestBench(Module):
+       def __init__(self, ng):
+               g = DataFlowGraph()
+               d = Dumper(layout)
+               g.add_connection(ng, d)
+               
+               self.submodules.slave = wishbone.Target(SlaveModel())
+               self.submodules.intercon = wishbone.InterconnectPointToPoint(ng.buses["wb"], self.slave.bus)
+               self.submodules.ca = CompositeActor(g)
+
 def run_sim(ng):
-       g = DataFlowGraph()
-       d = Dumper(layout)
-       g.add_connection(ng, d)
-       
-       slave = wishbone.Target(SlaveModel())
-       intercon = wishbone.InterconnectPointToPoint(ng.buses["wb"], slave.bus)
-       
-       c = CompositeActor(g)
-       fragment = slave.get_fragment() + intercon.get_fragment() + c.get_fragment()
-       
-       sim = Simulator(fragment)
+       sim = Simulator(TestBench(ng))
        sim.run(50)
        del sim