

def mkLed():
    m = Module('blinkled')
    width = m.Parameter('WIDTH', 8)
    clk = m.Input('CLK')
    rst = clk.Input('RST')
    led = m.OutputReg('LED', width, initval=0)
    count = m.Reg('count', 32, initval=0)
    '\n    led = 0\n    while True:\n        count = 0\n        while count < 1024:\n            count += 1\n        led += 1\n    '
    fsm = FSM(m, 'fsm', clk, rst)
    fsm.add(led(0))
    fsm.goto_next()
    init = fsm.current()
    fsm.add(count(0))
    fsm.goto_next()
    head = fsm.current()
    cond = (count < 1024)
    fsm.goto_next(cond=cond)
    fsm.add(count.inc())
    fsm.goto_next()
    fsm.add(count.inc())
    fsm.goto(head)
    fsm.inc()
    tail = fsm.current()
    fsm.goto_from(head, tail, cond=Not(cond))
    fsm.add(led.inc())
    fsm.goto(init)
    m.add_hook(fsm.make_always, args=(), kwargs={
        
    })
    return m

dataset/ETHPy150Open PyHDI/veriloggen/tests/extension/fsm_/hook_nested/fsm_hook_nested.py mkLed/VarMisuse@38/50 `m`->`clk`