Last active
December 10, 2015 17:16
-
-
Save gbin/5d5b2d995dba854ac62c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from myhdl import always, always_comb, always_seq, Signal, ResetSignal, toVerilog, toVHDL, delay, traceSignals, Simulation, now, intbv, concat | |
def chenillar(clk, reset, leds, direction): | |
@always(clk.posedge) | |
def scroll(): | |
if bool(direction): | |
leds.next = leds >> 1 | |
if leds == 0b1: | |
direction.next = 0 | |
else: | |
leds.next = leds << 1 | |
if leds == 0b10000000: | |
direction.next = 1 | |
return scroll | |
def convert(): | |
clk = Signal(False) | |
direction = Signal(False) | |
reset = ResetSignal(False, True, async=True) | |
leds = Signal(intbv(0,0,0b100000000)) | |
toVerilog.timescale = "100ms/1ms" | |
toVerilog(chenillar, clk, reset, leds, direction) | |
convert() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment