neuron.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:myhdl-experiments 作者: CodeReclaimers 项目源码 文件源码
def iz_test_bench(a, b, c, d, dt, Fshift):
    max_val = 1 << (Fshift + 7)

    I = Signal(intbv(0, min=-max_val, max=max_val))
    output = Signal(bool(0))

    clk = Signal(bool(0))
    reset = ResetSignal(1, active=0, async=True)

    neuron_instance = neuron_module(clk, reset, I, output, a, b, c, d, dt, Fshift)

    @always(delay(50))
    def clkgen():
        clk.next = not clk

    @instance
    def stimulus():
        I.next = 0
        yield delay(10000)
        I.next = to_fixed(10.0, Fshift)
        yield delay(100000)
        I.next = 0
        yield delay(10000)

        pylab.figure(1)
        pylab.subplot(311)
        pylab.title("MyHDL Izhikevitch neuron (chattering)")
        pylab.plot(t_values, v_values, label="v")
        pylab.ylabel('membrane potential (mv)')
        pylab.grid()
        pylab.subplot(312)
        pylab.plot(t_values, u_values, label="u")
        pylab.ylabel("recovery variable")
        pylab.grid()
        pylab.subplot(313)
        pylab.plot(t_values, I_values, label="I")
        pylab.grid()
        pylab.ylabel("input current")
        pylab.xlabel("time (usec)")
        pylab.show()

        raise StopSimulation

    return clkgen, stimulus, neuron_instance


# Uncomment definitions of a, b, c, d to choose different neuron types.

# Regular spiking
#a, b, c, d = 0.02, 0.2, -65.0, 8.0

# Fast spiking
#a, b, c, d = 0.1, 0.2, -65.0, 2.0

#intrinsically bursting
#a, b, c, d =0.02, 0.2, -55.0, 4.0

# chattering
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号