Exemplo n.º 1
0
def test_regular_packed():
    """Maximum rate with packing:
    Each clock cycle a full (filled with 3 spikes) spike packet."""

    import numpy as np
    import pyNN.hardware.spikey as pynn

    duration = 1000.0  # ms
    h = 1e3 / 5000.0 / 2.0  # 0.1 ms
    spikeTimes = np.arange(0, duration + h / 2.0, h)

    pynn.setup()

    stim = pynn.Population(256, pynn.SpikeSourceArray)
    # spikes have to be distributed over blocks of line drivers for efficient
    # packing
    stim[0].set_parameters(spike_times=spikeTimes)
    stim[64].set_parameters(spike_times=spikeTimes)
    stim[128].set_parameters(spike_times=spikeTimes)
    neuron = pynn.Population(1, pynn.IF_facets_hardware1)
    pynn.Projection(stim,
                    neuron,
                    method=pynn.AllToAllConnector(weights=0),
                    target='inhibitory')
    neuron.record()

    pynn.run(duration)
    lost, sent = pynn.getInputSpikes()
    print 'Number of input spikes (lost, sent)', lost, sent
    assert lost == 0, 'There should not be any spikes lost!'

    pynn.end()
Exemplo n.º 2
0
def test_poisson():
    """Test with Poisson source."""

    import pyNN.hardware.spikey as pynn

    duration = 1000.0  # ms
    rate = 5000.0  # 1/s
    poissonParam = {'start': 0, 'duration': duration, 'rate': rate}
    limLost = 1.0  # %

    pynn.setup()

    stim = pynn.Population(1, pynn.SpikeSourcePoisson, poissonParam)
    neuron = pynn.Population(1, pynn.IF_facets_hardware1)
    pynn.Projection(stim,
                    neuron,
                    method=pynn.AllToAllConnector(weights=0),
                    target='inhibitory')
    neuron.record()

    pynn.run(duration)
    lost, sent = pynn.getInputSpikes()
    print 'Number of input spikes (lost, sent, %lost)', lost, sent, float(
        lost) / sent * 1e2

    assert float(lost) / sent * 1e2 < limLost, 'Too many spikes lost!'

    pynn.end()
Exemplo n.º 3
0
def test_regular():
    """Maximum rate without packing:
    Each second clock cycle a minimal loaded (filled with 1 spikes) spike packet."""

    import numpy as np
    import pyNN.hardware.spikey as pynn
    import time

    np.random.seed(int(time.time()))
    lineDriverNo = np.random.random_integers(0, 255)
    print 'Using line driver number', lineDriverNo

    duration = 1000.0  # ms
    h = 1e3 / 5000.0  # 0.2 ms

    pynn.setup()

    stim = pynn.Population(256, pynn.SpikeSourceArray)
    stim[lineDriverNo].set_parameters(
        spike_times=np.arange(0, duration + h / 2.0, h))
    neuron = pynn.Population(1, pynn.IF_facets_hardware1)
    pynn.Projection(stim,
                    neuron,
                    method=pynn.AllToAllConnector(weights=0),
                    target='inhibitory')
    neuron.record()

    pynn.run(duration)
    lost, sent = pynn.getInputSpikes()
    print 'Number of input spikes (lost, sent)', lost, sent
    assert lost == 0, 'There should not be any spikes lost!'

    pynn.end()
Exemplo n.º 4
0
def testRegularMaxPacked():
    '''Maximum rate with packing:

    Each clock cycle a full (filled with 3 spikes) spike packet.'''

    import numpy as np
    import pyNN.hardware.spikey as pynn

    duration = 10000.0  # ms
    h = 1e3 / 5000.0 / 2.0  # 10kHz for each of 3 sources = 30kHz
    spikeTimes = np.arange(0, duration + h / 2.0, h)

    pynn.setup()

    stim = pynn.Population(256, pynn.SpikeSourceArray)
    stim[0].set_parameters(spike_times=spikeTimes)
    stim[63].set_parameters(spike_times=spikeTimes)
    stim[127].set_parameters(spike_times=spikeTimes)
    neuron = pynn.Population(1, pynn.IF_facets_hardware1)
    pynn.Projection(stim,
                    neuron,
                    method=pynn.AllToAllConnector(weights=0),
                    target='inhibitory')
    neuron.record()

    pynn.run(duration)
    print 'no out spikes:', len(neuron.getSpikes())
    lost, sent = pynn.getInputSpikes()
    print 'no in spikes (lost, sent)', lost, sent
    assert lost == 0, 'there should not be any spikes lost!'

    pynn.end()
        def run(noNeurons):
            runtime = 1000.0

            import numpy as np
            import pyNN.hardware.spikey as pynn
            pynn.setup()

            neurons = pynn.Population(noNeurons, pynn.IF_facets_hardware1)
            neurons.record()
            stim = pynn.Population(10, pynn.SpikeSourcePoisson, {
                'rate': 20.0,
                'duration': runtime
            })
            prj = pynn.Projection(stim, neurons, pynn.AllToAllConnector())
            prj.setWeights(pynn.maxExcWeight())

            pynn.run(runtime)
            spikes = neurons.getSpikes([])
            # for neuron in np.unique(spikes[:,0]):
            # print 'neuron', int(neuron), 'has', len(spikes[spikes[:,0] ==
            # neuron]), 'spikes'
            noSpikes = len(spikes)
            lost, sent = pynn.getInputSpikes()
            pynn.end()

            print 'no neurons / spikes in / lost / out:', noNeurons + 1, sent, lost, noSpikes

            return noSpikes
Exemplo n.º 6
0
def maxRuntime(runtime):
    '''Maximum runtime:
    Limited by wrap around of counter (after approx. 6600s).
    Can be extended to infinitly long runtimes by considering wrap around.
    Subtract/Add offset to in/out spike times for each wrap around.'''

    rate = 1.0
    weight = 1.0

    poissonParam = {'start': 0, 'duration': runtime, 'rate': rate}

    pynn.setup()

    stim = pynn.Population(1, pynn.SpikeSourcePoisson, poissonParam)
    neuron = pynn.Population(1, pynn.IF_facets_hardware1)
    prj = pynn.Projection(stim,
                          neuron,
                          pynn.AllToAllConnector(weights=pynn.minInhWeight() *
                                                 weight),
                          target='inhibitory')

    neuron.record()

    pynn.run(runtime)
    spikes = neuron.getSpikes()
    lost, sent = pynn.getInputSpikes()

    print 'spikes in / out', sent, len(spikes)

    pynn.end()
Exemplo n.º 7
0
def maxSpikesOut(runtime):
    '''Maximum number of spikes that can be received:
    Should be limited by memory size on FPGA board (128MB approx. 100e6 spikes, other half for ADC).'''

    neuronParams = {
        'v_reset': -80.0,  # mV
        'e_rev_I': -80.0,  # mV
        'v_rest': -45.0,  # mV / rest above threshold
        'v_thresh': -55.0,  # mV
        'g_leak': 20.0,  # nS / without Scherzer calib approx. tau_m = 2ms
    }

    pynn.setup()

    neuron = pynn.Population(192, pynn.IF_facets_hardware1, neuronParams)
    neuron.record()

    pynn.run(runtime)

    spikes = neuron.getSpikes()[:, 1]
    lost, sent = pynn.getInputSpikes()

    print 'spikes in / out', sent, len(spikes)

    pynn.end()
Exemplo n.º 8
0
def maxSpikesIn(runtime):
    '''Maximum number of spikes that can be sent:
    Should be limited by memory size on FPGA board (256MB => 256x1024x1024x8/32x3 approx. 200e6 spikes).'''

    rate = 10.0
    weight = 1.0

    poissonParam = {'start': 0, 'duration': runtime, 'rate': rate}

    pynn.setup()

    stim = pynn.Population(256, pynn.SpikeSourcePoisson, poissonParam)
    neuron = pynn.Population(192, pynn.IF_facets_hardware1)
    prj = pynn.Projection(stim,
                          neuron,
                          pynn.AllToAllConnector(weights=pynn.minInhWeight() *
                                                 weight),
                          target='inhibitory')

    neuron.record()

    pynn.run(runtime)
    spikes = neuron.getSpikes()
    lost, sent = pynn.getInputSpikes()

    print 'spikes in / out', sent, len(spikes)

    pynn.end()