def mkLed():
    m = Module('blinkled')
    clk = m.Input('CLK')
    rst = m.Input('RST')
    valid = m.OutputReg('valid', initval=0)
    count = m.Reg('count', width=32, initval=0)

    up = m.Wire('up')
    down = m.Wire('down')
    m.Assign(up(1))
    m.Assign(down(0))
    
    fsm = FSM(m, 'fsm', clk, rst)
    
    for i in range(4):
        fsm.goto_next()

    # condition alias
    c = count >= 16

    # assert valid if the condition is satisfied
    # then de-assert 3 cycles later with same condition
    fsm.add( valid(up), cond=c, keep=3, eager_val=True, lazy_cond=True)
    fsm.add( valid(down), cond=c, delay=3, eager_val=True, lazy_cond=True)
    fsm.goto_next(cond=c)
    
    for i in range(8):
        fsm.goto_next()

    # condition alias
    c = count >= 32

    # assert valid 1 cycle later if the condition is satisfied now
    # then de-assert 4 cycles later with same condition
    for i in range(8):
        fsm.add( valid(up), cond=c, delay=1, keep=3, eager_val=True, lazy_cond=True)
        fsm.add( valid(down), cond=c, delay=4, eager_val=True, lazy_cond=True)
        fsm.goto_next(cond=c)
    
    fsm.make_always(reset=[count.reset()], body=[count(count+1)])

    return m
dataset/ETHPy150Open PyHDI/veriloggen/tests/extension/fsm_/delayed_eager_val_lazy_cond/fsm_delayed_eager_val_lazy_cond.py/mkLed/original