示例#1
0
    def __init__(self, spinnaker_link_id):

        AbstractVirtualVertex.__init__(self,
                                       6,
                                       spinnaker_link_id,
                                       "External Munich Motor",
                                       max_atoms_per_core=6)
    def __init__(self, machine_time_step, timescale_factor, spikes_per_second,
                 ring_buffer_sigma, n_neurons, label, spinnaker_link_id):

        if n_neurons != 20:
            print "Warning, this device has 20 neurons"

        AbstractVirtualVertex.__init__(self, n_neurons, spinnaker_link_id,
                                       label, n_neurons)
        AbstractOutgoingEdgeSameContiguousKeysRestrictor.__init__(self)
    def __init__(self, machine_time_step, timescale_factor, spikes_per_second,
                 ring_buffer_sigma, n_neurons, label,
                 spinnaker_link_id):

        if n_neurons != 20:
            print "Warning, this device has 20 neurons"

        AbstractVirtualVertex.__init__(self, n_neurons, spinnaker_link_id,
                                       label, n_neurons)
        AbstractOutgoingEdgeSameContiguousKeysRestrictor.__init__(self)
    def __init__(self, spinnaker_link_id, msg_key, msg_mask=0xFFFFFFFF):

        self.key = msg_key
        self.mask = msg_mask
        
        AbstractVirtualVertex.__init__(
            self, 1, spinnaker_link_id, "External IO Device",
            max_atoms_per_core=1)
            
        AbstractProvidesOutgoingEdgeConstraints.__init__(self)
    def __init__(self, fixed_key, spinnaker_link_id, machine_time_step,
                 timescale_factor, label=None, n_neurons=None,
                 polarity=PushBotRetinaPolarity.Merged,
                 resolution=PushBotRetinaResolution.Downsample64):

        # Validate number of timestamp bytes
        if not isinstance(polarity, PushBotRetinaPolarity):
            raise exceptions.SpynnakerException(
                "Pushbot retina polarity should be one of those defined in"
                " Polarity enumeration")
        if not isinstance(resolution, PushBotRetinaResolution):
            raise exceptions.SpynnakerException(
                "Pushbot retina resolution should be one of those defined in"
                " Resolution enumeration")

        # Cache resolution
        self._resolution = resolution

        # Build standard routing key from virtual chip coordinates
        self._routing_key = fixed_key
        self._retina_source_key = self._routing_key

        # Calculate number of neurons
        fixed_n_neurons = resolution.value.pixels ** 2

        # If polarity is merged
        if polarity == PushBotRetinaPolarity.Merged:
            # Double number of neurons
            fixed_n_neurons *= 2

            # We need to mask out two coordinates and a polarity bit
            mask_bits = (2 * resolution.value.coordinate_bits) + 1
        # Otherwise
        else:
            # We need to mask out two coordinates
            mask_bits = 2 * resolution.value.coordinate_bits

            # If polarity is up, set polarity bit in routing key
            if polarity == PushBotRetinaPolarity.Up:
                polarity_bit = 1 << (2 * resolution.value.coordinate_bits)
                self._routing_key |= polarity_bit

        # Build routing mask
        self._routing_mask = ~((1 << mask_bits) - 1) & 0xFFFFFFFF

        AbstractVirtualVertex.__init__(
            self, fixed_n_neurons, spinnaker_link_id,
            max_atoms_per_core=fixed_n_neurons, label=label)
        AbstractSendMeMulticastCommandsVertex.__init__(
            self, self._get_commands())

        if n_neurons != fixed_n_neurons and n_neurons is not None:
            print "Warning, the retina will have {} neurons".format(
                fixed_n_neurons)
    def __init__(self,
                 retina_key,
                 spinnaker_link_id,
                 position,
                 machine_time_step,
                 timescale_factor,
                 label=None,
                 n_neurons=None,
                 polarity=None):

        if polarity is None:
            polarity = MunichRetinaDevice.MERGED_POLARITY

        self._fixed_key = (retina_key & 0xFFFF) << 16
        self._fixed_mask = 0xFFFF8000
        if polarity == MunichRetinaDevice.UP_POLARITY:
            self._fixed_key |= 0x4000

        if polarity == MunichRetinaDevice.MERGED_POLARITY:

            # There are 128 x 128 retina "pixels" x 2 polarities
            fixed_n_neurons = 128 * 128 * 2
        else:

            # There are 128 x 128 retina "pixels"
            fixed_n_neurons = 128 * 128
            self._fixed_mask = 0xFFFFC000

        AbstractVirtualVertex.__init__(self,
                                       fixed_n_neurons,
                                       spinnaker_link_id,
                                       max_atoms_per_core=fixed_n_neurons,
                                       label=label)
        AbstractSendMeMulticastCommandsVertex.__init__(
            self, self._get_commands(position))
        AbstractProvidesOutgoingPartitionConstraints.__init__(self)

        self._polarity = polarity
        self._position = position

        if (self._position != self.RIGHT_RETINA
                and self._position != self.LEFT_RETINA):
            raise exceptions.SpynnakerException(
                "The external Retina does not recognise this _position")

        if n_neurons != fixed_n_neurons and n_neurons is not None:
            print "Warning, the retina will have {} neurons".format(
                fixed_n_neurons)
    def __init__(
            self, retina_key, spinnaker_link_id, position, machine_time_step,
            timescale_factor, label=None, n_neurons=None, polarity=None):

        if polarity is None:
            polarity = MunichRetinaDevice.MERGED_POLARITY

        self._fixed_key = (retina_key & 0xFFFF) << 16
        self._fixed_mask = 0xFFFF8000
        if polarity == MunichRetinaDevice.UP_POLARITY:
            self._fixed_key |= 0x4000

        if polarity == MunichRetinaDevice.MERGED_POLARITY:

            # There are 128 x 128 retina "pixels" x 2 polarities
            fixed_n_neurons = 128 * 128 * 2
        else:

            # There are 128 x 128 retina "pixels"
            fixed_n_neurons = 128 * 128
            self._fixed_mask = 0xFFFFC000

        AbstractVirtualVertex.__init__(
            self, fixed_n_neurons, spinnaker_link_id,
            max_atoms_per_core=fixed_n_neurons, label=label)
        AbstractSendMeMulticastCommandsVertex.__init__(
            self, self._get_commands(position))

        self._polarity = polarity
        self._position = position

        if (self._position != self.RIGHT_RETINA and
           self._position != self.LEFT_RETINA):
            raise exceptions.SpynnakerException(
                "The external Retina does not recognise this _position")

        if n_neurons != fixed_n_neurons and n_neurons is not None:
            print "Warning, the retina will have {} neurons".format(
                fixed_n_neurons)
    def __init__(self,
                 mode,
                 retina_key,
                 spinnaker_link_id,
                 polarity,
                 machine_time_step,
                 timescale_factor,
                 label=None,
                 n_neurons=None):
        """
        :param mode: The retina "mode"
        :param retina_key: The value of the top 16-bits of the key
        :param spinnaker_link_id: The spinnaker link to which the retina is\
                connected
        :param polarity: The "polarity" of the retina data
        :param machine_time_step: The time step of the simulation
        :param timescale_factor: The timescale factor of the simulation
        :param label: The label for the population
        :param n_neurons: The number of neurons in the population
        """
        self._polarity = polarity
        self._fixed_key = (retina_key & 0xFFFF) << 16
        self._fixed_mask = 0xFFFF8000
        if polarity == ExternalFPGARetinaDevice.UP_POLARITY:
            self._fixed_key |= 0x4000

        fixed_n_neurons = n_neurons

        if mode == ExternalFPGARetinaDevice.MODE_128:
            if (polarity == ExternalFPGARetinaDevice.UP_POLARITY
                    or polarity == ExternalFPGARetinaDevice.DOWN_POLARITY):
                fixed_n_neurons = 128 * 128
                self._fixed_mask = 0xFFFFC000
            else:
                fixed_n_neurons = 128 * 128 * 2
        elif mode == ExternalFPGARetinaDevice.MODE_64:
            if (polarity == ExternalFPGARetinaDevice.UP_POLARITY
                    or polarity == ExternalFPGARetinaDevice.DOWN_POLARITY):
                fixed_n_neurons = 64 * 64
                self._fixed_mask = 0xFFFFF000
            else:
                fixed_n_neurons = 64 * 64 * 2
        elif mode == ExternalFPGARetinaDevice.MODE_32:
            if (polarity == ExternalFPGARetinaDevice.UP_POLARITY
                    or polarity == ExternalFPGARetinaDevice.DOWN_POLARITY):
                fixed_n_neurons = 32 * 32
                self._fixed_mask = 0xFFFFFC00
            else:
                fixed_n_neurons = 32 * 32 * 2
        elif mode == ExternalFPGARetinaDevice.MODE_16:
            if (polarity == ExternalFPGARetinaDevice.UP_POLARITY
                    or polarity == ExternalFPGARetinaDevice.DOWN_POLARITY):
                fixed_n_neurons = 16 * 16
                self._fixed_mask = 0xFFFFFF00
            else:
                fixed_n_neurons = 16 * 16 * 2
        else:
            raise exceptions.SpynnakerException("the FPGA retina does not "
                                                "recongise this mode")

        if fixed_n_neurons != n_neurons and n_neurons is not None:
            logger.warn(
                "The specified number of neurons for the FPGA retina"
                " device has been ignored {} will be used instead".format(
                    fixed_n_neurons))
        AbstractVirtualVertex.__init__(self,
                                       fixed_n_neurons,
                                       spinnaker_link_id,
                                       max_atoms_per_core=fixed_n_neurons,
                                       label=label)
        AbstractSendMeMulticastCommandsVertex.__init__(
            self,
            commands=[
                MultiCastCommand(0, 0x0000FFFF, 0xFFFF0000, 1, 5, 100),
                MultiCastCommand(-1, 0x0000FFFE, 0xFFFF0000, 0, 5, 100)
            ])
        AbstractProvidesOutgoingPartitionConstraints.__init__(self)
    def __init__(
            self, mode, retina_key, spinnaker_link_id, polarity,
            machine_time_step, timescale_factor, label=None, n_neurons=None):
        """
        :param mode: The retina "mode"
        :param retina_key: The value of the top 16-bits of the key
        :param spinnaker_link_id: The spinnaker link to which the retina is\
                connected
        :param polarity: The "polarity" of the retina data
        :param machine_time_step: The time step of the simulation
        :param timescale_factor: The timescale factor of the simulation
        :param label: The label for the population
        :param n_neurons: The number of neurons in the population
        """
        self._polarity = polarity
        self._fixed_key = (retina_key & 0xFFFF) << 16
        self._fixed_mask = 0xFFFF8000
        if polarity == ExternalFPGARetinaDevice.UP_POLARITY:
            self._fixed_key |= 0x4000

        fixed_n_neurons = n_neurons

        if mode == ExternalFPGARetinaDevice.MODE_128:
            if (polarity == ExternalFPGARetinaDevice.UP_POLARITY or
                    polarity == ExternalFPGARetinaDevice.DOWN_POLARITY):
                fixed_n_neurons = 128 * 128
                self._fixed_mask = 0xFFFFC000
            else:
                fixed_n_neurons = 128 * 128 * 2
        elif mode == ExternalFPGARetinaDevice.MODE_64:
            if (polarity == ExternalFPGARetinaDevice.UP_POLARITY or
                    polarity == ExternalFPGARetinaDevice.DOWN_POLARITY):
                fixed_n_neurons = 64 * 64
                self._fixed_mask = 0xFFFFF000
            else:
                fixed_n_neurons = 64 * 64 * 2
        elif mode == ExternalFPGARetinaDevice.MODE_32:
            if (polarity == ExternalFPGARetinaDevice.UP_POLARITY or
                    polarity == ExternalFPGARetinaDevice.DOWN_POLARITY):
                fixed_n_neurons = 32 * 32
                self._fixed_mask = 0xFFFFFC00
            else:
                fixed_n_neurons = 32 * 32 * 2
        elif mode == ExternalFPGARetinaDevice.MODE_16:
            if (polarity == ExternalFPGARetinaDevice.UP_POLARITY or
                    polarity == ExternalFPGARetinaDevice.DOWN_POLARITY):
                fixed_n_neurons = 16 * 16
                self._fixed_mask = 0xFFFFFF00
            else:
                fixed_n_neurons = 16 * 16 * 2
        else:
            raise exceptions.SpynnakerException("the FPGA retina does not "
                                                "recongise this mode")

        if fixed_n_neurons != n_neurons and n_neurons is not None:
            logger.warn("The specified number of neurons for the FPGA retina"
                        " device has been ignored {} will be used instead"
                        .format(fixed_n_neurons))
        AbstractVirtualVertex.__init__(
            self, fixed_n_neurons, spinnaker_link_id,
            max_atoms_per_core=fixed_n_neurons, label=label)
        AbstractSendMeMulticastCommandsVertex.__init__(self, commands=[
            MultiCastCommand(0, 0x0000FFFF, 0xFFFF0000, 1, 5, 100),
            MultiCastCommand(-1, 0x0000FFFE, 0xFFFF0000, 0, 5, 100)])
示例#10
0
    def __init__(self,
                 fixed_key,
                 spinnaker_link_id,
                 machine_time_step,
                 timescale_factor,
                 label=None,
                 n_neurons=None,
                 polarity=PushBotRetinaPolarity.Merged,
                 resolution=PushBotRetinaResolution.Downsample64):

        # Validate number of timestamp bytes
        if not isinstance(polarity, PushBotRetinaPolarity):
            raise exceptions.SpynnakerException(
                "Pushbot retina polarity should be one of those defined in"
                " Polarity enumeration")
        if not isinstance(resolution, PushBotRetinaResolution):
            raise exceptions.SpynnakerException(
                "Pushbot retina resolution should be one of those defined in"
                " Resolution enumeration")

        # Cache resolution
        self._resolution = resolution

        # Build standard routing key from virtual chip coordinates
        self._routing_key = fixed_key
        self._retina_source_key = self._routing_key

        # Calculate number of neurons
        fixed_n_neurons = resolution.value.pixels**2

        # If polarity is merged
        if polarity == PushBotRetinaPolarity.Merged:
            # Double number of neurons
            fixed_n_neurons *= 2

            # We need to mask out two coordinates and a polarity bit
            mask_bits = (2 * resolution.value.coordinate_bits) + 1
        # Otherwise
        else:
            # We need to mask out two coordinates
            mask_bits = 2 * resolution.value.coordinate_bits

            # If polarity is up, set polarity bit in routing key
            if polarity == PushBotRetinaPolarity.Up:
                polarity_bit = 1 << (2 * resolution.value.coordinate_bits)
                self._routing_key |= polarity_bit

        # Build routing mask
        self._routing_mask = ~((1 << mask_bits) - 1) & 0xFFFFFFFF

        AbstractVirtualVertex.__init__(self,
                                       fixed_n_neurons,
                                       spinnaker_link_id,
                                       max_atoms_per_core=fixed_n_neurons,
                                       label=label)
        AbstractSendMeMulticastCommandsVertex.__init__(self,
                                                       self._get_commands())
        AbstractProvidesOutgoingPartitionConstraints.__init__(self)

        if n_neurons != fixed_n_neurons and n_neurons is not None:
            print "Warning, the retina will have {} neurons".format(
                fixed_n_neurons)
 def __init__(
         self, n_neurons, spinnaker_link, machine_time_step,
         timescale_factor, label=None):
     AbstractVirtualVertex.__init__(
         self, n_neurons, spinnaker_link, label=label,
         max_atoms_per_core=n_neurons)
    def __init__(self, spinnaker_link_id):

        AbstractVirtualVertex.__init__(
            self, 6, spinnaker_link_id,
            "External Munich Motor", max_atoms_per_core=6)