Exemple #1
0
    clk_per_bit = int(clk_freq // spi_freq)

    if len(sys.argv) < 2 or sys.argv[1] == "sim":
        m = Module()

        m.submodules.loopback = loopback = SpiMaster(clk_per_bit, 8)

        m.d.comb += loopback.miso.eq(loopback.mosi)

        sim = sim.Simulator(m)
        sim.add_clock(1.0 / clk_freq)

        sim.add_sync_process(_test_loopback(loopback))

        with sim.write_vcd("spi.vcd", "spi.gtkw", traces=loopback.ports()):
            sim.run()
            # while sim.advance():
            #     input("ENTER to continue...")
    elif sys.argv[1] == "build":
        class Board(TinyFPGABXPlatform):
            p = "p1"

        class SpiTest(Elaboratable):
            def __init__(self):
                pass

            def elaborate(self, platform: Platform) -> Module:
                m = Module()

                clk_freq = int(platform.default_clk_frequency)
                m.submodules.dshot = spi = SpiMaster(clk_per_bit, 8)
Exemple #2
0
 def run(fragment, process):
     sim = nmigen.sim.Simulator(fragment)
     sim.add_sync_process(process)
     sim.add_clock(1 / 10e6)
     with sim.write_vcd(vcd_path(request.node)):
         sim.run()