Beispiel #1
0
def build(TheFirmware, mem_size=4096, sim=False, detail=False):
    # for programming from a firmware file
    if detail:
        print("Testing Spork")
    # TODO abstract this plaform set
    platform = TinyFPGABXPlatform()
    # FTDI on the tinybx
    platform.add_resources([
        UARTResource(0,
                     rx="A8",
                     tx="B8",
                     attrs=Attrs(IO_STANDARD="SB_LVCMOS", PULLUP=1)),
        Resource("reset_pin", 0, Pins("A9", dir="i"),
                 Attrs(IO_STANDARD="SB_LVCMOS")),
        # *ButtonResources(pins="10", invert=True, attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
        *LEDResources("blinky",
                      pins="J1 H2 H9 D9",
                      attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
    ])

    # Spork it up
    spork = TestSpork(platform, uart_speed=115200, mem_size=mem_size, sim=sim)

    # Build the firmware
    spork.build()
    if detail:
        print(spork.cpu.map.show())

    f = TheFirmware(spork.cpu.map, start_window=mem_size)
    spork.fw = f
    if detail:
        f.show()
    # Sporkify it !
    code = f.code()
    spork.cpu.firmware(code)
    if detail:
        print(f.hex())
    spork.hex_blob = f.hex()
    return spork
Beispiel #2
0
    print ("1 - TinyFPGA-BX platform created.")
    platform = TinyFPGABXPlatform()

    # Define new pins to platform.
    print ('2 - Define new pins to platform.')
    platform.add_resources ([
        # VGA Signals.
        Resource("pin_9",  0, Pins("E1", dir="o")),
        Resource("pin_10", 0, Pins("G2", dir="o")),
        Resource("pin_11", 0, Pins("H1", dir="o")),
        Resource("pin_12", 0, Pins("J1", dir="o")),
        Resource("pin_13", 0, Pins("H2", dir="o")),

        # LED test
        Resource("pin_14", 0, Pins("H9", dir="o")),

        # Audio signals.
        Resource("pin_19", 0, Pins("B8", dir="o")),
        Resource("pin_20", 0, Pins("A8", dir="o")),

        # Control buttons.
        Resource("pin_21", 0, Pins("B7", dir="i")),
        Resource("pin_22", 0, Pins("A7", dir="i")),
        Resource("pin_23", 0, Pins("B6", dir="i")),
        Resource("pin_24", 0, Pins("A6", dir="i")),
     ])

    # Create 'top' new module.
    print ("3 - Created 'top' module.")
    m = game_pong (platform)
Beispiel #3
0
                m.d.comb += self.left_ch.eq(tick_sound)
                m.d.comb += self.right_ch.eq(tick_sound)

        # New tick sound.
        m.d.sync += divcounter.eq(divcounter + 1)

        return m


if __name__ == "__main__":

    print("\nPrueba del módulo de sonido en una TinyFPGA.\n")
    print("Conecta pines 19 y 20 de la TinyFPGA a los altavoces\n")
    print("derecho e izquierdo.\n")

    # Se elige la plataforma donde sintetizar el módulo.
    platform = TinyFPGABXPlatform()

    # Se conectan los pines (led2 al pin 14).
    platform.add_resources([
        Resource("led2", 0, Pins("H9", dir="o")),
        Resource("pin_19", 0, Pins("B8", dir="o")),
        Resource("pin_20", 0, Pins("A8", dir="o")),
    ])
    module = soundCard(platform)

    # Se elige un tono y el canal para probar.
    module.sound = SOUNDS.goal
    module.channel = CHANNEL.right
    platform.build(module, do_program=False)