Example #1
0
    def __init__(self, x, y, app_id, base_address=None):
        """
        :param int x:
            The x-coordinate of the chip to allocate on, between 0 and 255
        :param int y:
            The y-coordinate of the chip to allocate on, between 0 and 255
        :param int app_id: The ID of the application, between 0 and 255
        :param base_address: The start address in SDRAM to which the block
            needs to be deallocated, or none if deallocating via app_id
        :type base_address: int or None
        """

        if base_address is not None:
            super().__init__(
                SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                          destination_port=0,
                          destination_cpu=0,
                          destination_chip_x=x,
                          destination_chip_y=y),
                SCPRequestHeader(command=SCPCommand.CMD_ALLOC),
                argument_1=(AllocFree.FREE_SDRAM_BY_POINTER.value
                            ),  # @UndefinedVariable
                argument_2=base_address)
            self._read_n_blocks_freed = False
        else:
            super().__init__(
                SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                          destination_port=0,
                          destination_cpu=0,
                          destination_chip_x=x,
                          destination_chip_y=y),
                SCPRequestHeader(command=SCPCommand.CMD_ALLOC),
                argument_1=(app_id << 8 | AllocFree.FREE_SDRAM_BY_APP_ID.value
                            ))  # @UndefinedVariable
            self._read_n_blocks_freed = True
    def __init__(self, power_command, boards, delay=0.0, board_to_send_to=0):
        """
        .. note::
            There is currently a bug in the BMP that means some boards don't\
            respond to power commands not sent to BMP 0. Thus changing the\
            board_to_send_to parameter is not recommended!

        :param PowerCommand power_command: The power command being sent
        :param boards: The boards on the same backplane to power on or off
        :type boards: int or list(int)
        :param float delay:
            Number of seconds delay between power state changes of
            the different boards.
        :param int board_to_send_to:
            The optional board to send the command to if this is to be sent
            to a frame of boards.

            .. note::
                Leave this at the default because of hardware bugs.
        """

        if board_to_send_to != 0:
            logger.warning(
                "There is currently a bug in the BMP that means some boards"
                " don't respond to power commands not sent to BMP 0.  Thus "
                "changing the board_to_send_to is not recommended!")

        arg1 = (int(delay * 1000) << 16) | power_command.value
        arg2 = self.get_board_mask(boards)

        super().__init__(board_to_send_to,
                         SCPRequestHeader(command=SCPCommand.CMD_BMP_POWER),
                         argument_1=arg1,
                         argument_2=arg2)
 def __init__(self, x, y, p, timeout_mantissa, timeout_exponent):
     """
     :param x: The x-coordinate of a chip, between 0 and 255
     :type x: int
     :param y: The y-coordinate of a chip, between 0 and 255
     :type y: int
     :param p: \
         The processor running the extra monitor vertex, between 0 and 17
     :type p: int
     :param timeout_mantissa: \
         The mantissa of the timeout value, between 0 and 15
     :type timeout_mantissa: int
     :param timeout_exponent: \
         The exponent of the timeout value, between 0 and 15
     :type timeout_exponent: int
     """
     # pylint: disable=too-many-arguments
     super(SetRouterEmergencyTimeoutMessage, self).__init__(
         SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                   destination_port=(
                       SDP_PORTS.EXTRA_MONITOR_CORE_REINJECTION.value),
                   destination_cpu=p,
                   destination_chip_x=x,
                   destination_chip_y=y),
         SCPRequestHeader(
             command=ReinjectorSCPCommands.SET_ROUTER_EMERGENCY_TIMEOUT),
         argument_1=(timeout_mantissa & 0xF) |
         ((timeout_exponent & 0xF) << 4))
    def __init__(self,
                 x,
                 y,
                 p,
                 current_time,
                 run_time,
                 infinite_run,
                 destination_port,
                 expect_response=True):
        # pylint: disable=too-many-arguments
        sdp_flags = SDPFlag.REPLY_NOT_EXPECTED
        if expect_response:
            sdp_flags = SDPFlag.REPLY_EXPECTED

        super(SCPUpdateRuntimeRequest, self).__init__(
            SDPHeader(flags=sdp_flags,
                      destination_port=destination_port,
                      destination_cpu=p,
                      destination_chip_x=x,
                      destination_chip_y=y),
            SCPRequestHeader(
                command=SDP_RUNNING_MESSAGE_CODES.SDP_NEW_RUNTIME_ID_CODE),
            argument_1=run_time,
            argument_2=infinite_run,
            argument_3=current_time,
            data=struct.pack("<B", int(bool(expect_response))))
    def __init__(self, nearest_neighbour_id, n_blocks, x=None, y=None):
        """
        :param int nearest_neighbour_id:
            The ID of the packet, between 0 and 127
        :param int n_blocks:
            The number of blocks of data that will be sent, between 0 and 255
        :param int x: The x-coordinate of the chip to load the data on to. If
            not specified, the data will be loaded on to all chips
        :param int y: The y-coordinate of the chip to load the data on to. If
            not specified, the data will be loaded on to all chips
        """
        key = ((_NNP_FLOOD_FILL_START << 24) | (nearest_neighbour_id << 16) |
               (n_blocks << 8))
        data = 0xFFFF
        if x is not None and y is not None:
            m = ((y & 3) * 4) + (x & 3)
            data = (((x & 0xfc) << 24) + ((y & 0xfc) << 16) + (3 << 16) +
                    (1 << m))

        super().__init__(SDPHeader(
            flags=SDPFlag.REPLY_EXPECTED,
            destination_port=0,
            destination_cpu=0,
            destination_chip_x=self.DEFAULT_DEST_X_COORD,
            destination_chip_y=self.DEFAULT_DEST_Y_COORD),
                         SCPRequestHeader(command=SCPCommand.CMD_NNP),
                         argument_1=key,
                         argument_2=data,
                         argument_3=_NNP_FORWARD_RETRY)
Example #6
0
 def __init__(self, x, y, base_address, size, cpu=0):
     """
     :param int x:
         The x-coordinate of the chip to read from, between 0 and 255
     :param int y:
         The y-coordinate of the chip to read from, between 0 and 255
     :param int base_address:
         The positive base address to start the read from
     :param int size: The number of bytes to read, between 1 and 256
     :raise SpinnmanInvalidParameterException:
         * If the chip coordinates are out of range
         * If the base address is not a positive number
         * If the size is out of range
     """
     # pylint: disable=too-many-arguments
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=cpu,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_READ),
                      argument_1=base_address,
                      argument_2=size,
                      argument_3=address_length_dtype[(base_address % 4,
                                                       size % 4)].value)
Example #7
0
 def __init__(self, x, y, link, base_address, data, cpu=0):
     """
     :param int x: The x-coordinate of the chip whose neighbour will be
         written to, between 0 and 255
     :param int y: The y-coordinate of the chip whose neighbour will be
         written to, between 0 and 255
     :param int cpu: The CPU core to use, normally 0
         (or if a BMP, the board slot number)
     :param int link: The link number to write to between 0 and 5
         (or if a BMP, the FPGA between 0 and 2)
     :param int base_address: The base_address to start writing to
     :param bytes data: Up to 256 bytes of data to write
     """
     # pylint: disable=too-many-arguments
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=cpu,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_LINK_WRITE),
                      argument_1=base_address,
                      argument_2=len(data),
                      argument_3=link,
                      data=None)
     self._data_to_write = data
Example #8
0
 def __init__(self, x, y, p, multicast, point_to_point, fixed_route,
              nearest_neighbour):
     """
     :param x: The x-coordinate of a chip, between 0 and 255
     :type x: int
     :param y: The y-coordinate of a chip, between 0 and 255
     :type y: int
     :param p: \
         The processor running the extra monitor vertex, between 0 and 17
     :type p: int
     :param point_to_point: If point to point should be set
     :type point_to_point: bool
     :param multicast: If multicast should be set
     :type multicast: bool
     :param nearest_neighbour: If nearest neighbour should be set
     :type nearest_neighbour: bool
     :param fixed_route: If fixed route should be set
     :type fixed_route: bool
     """
     # pylint: disable=too-many-arguments
     super(SetReinjectionPacketTypesMessage, self).__init__(
         SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                   destination_port=(
                       SDP_PORTS.EXTRA_MONITOR_CORE_REINJECTION.value),
                   destination_cpu=p,
                   destination_chip_x=x,
                   destination_chip_y=y),
         SCPRequestHeader(command=ReinjectorSCPCommands.SET_PACKET_TYPES),
         argument_1=int(bool(multicast)),
         argument_2=int(bool(point_to_point)),
         argument_3=int(bool(fixed_route)),
         data=bytearray(struct.pack("<B", nearest_neighbour)))
 def __init__(self, x, y, base_address, data, cpu=0):
     """
     :param int x: The x-coordinate of the chip, between 0 and 255;
         this is not checked due to speed restrictions
     :param int y: The y-coordinate of the chip, between 0 and 255;
         this is not checked due to speed restrictions
     :param int base_address: The base_address to start writing to
         the base address is not checked to see if its not valid
     :param data: between 1 and 256 bytes of data to write;
         this is not checked due to speed restrictions
     :type data: bytearray or bytes
     """
     # pylint: disable=too-many-arguments
     size = len(data)
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=cpu,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_WRITE),
                      argument_1=base_address,
                      argument_2=size,
                      argument_3=address_length_dtype[(base_address % 4),
                                                      (size % 4)].value,
                      data=None)
     self._data_to_write = data
Example #10
0
    def __init__(self,
                 x,
                 y,
                 p,
                 run_time,
                 infinite_run,
                 destination_port,
                 expect_response=True):
        sdp_flags = SDPFlag.REPLY_NOT_EXPECTED
        arg3 = 0
        if expect_response:
            sdp_flags = SDPFlag.REPLY_EXPECTED
            arg3 = 1

        AbstractSCPRequest.__init__(
            self,
            SDPHeader(flags=sdp_flags,
                      destination_port=destination_port,
                      destination_cpu=p,
                      destination_chip_x=x,
                      destination_chip_y=y),
            SCPRequestHeader(
                command=SDP_RUNNING_MESSAGE_CODES.SDP_NEW_RUNTIME_ID_CODE),
            argument_1=run_time,
            argument_2=infinite_run,
            argument_3=arg3)
Example #11
0
 def __init__(self, x, y, host, port, tag, strip, use_sender=False):
     """
     :param int x: The x-coordinate of a chip, between 0 and 255
     :param int y: The y-coordinate of a chip, between 0 and 255
     :param bytearray or list[int] host: The host address, \
         as an array of 4 bytes
     :param int port: The port, between 0 and 65535
     :param int tag: The tag, between 0 and 7
     :param bool strip: if the SDP header should be striped from the packet
     :param bool use_sender:
         if the sender IP address and port should be used
     """
     # pylint: disable=too-many-arguments
     strip_value = int(bool(strip))
     sender_value = int(bool(use_sender))
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=0,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_IPTAG),
                      argument_1=(strip_value << 28) | (sender_value << 30)
                      | (_IPTAG_SET << 16) | tag,
                      argument_2=port,
                      argument_3=((host[3] << 24) | (host[2] << 16) |
                                  (host[1] << 8) | host[0]))
Example #12
0
    def __init__(self, x, y, destination_x, destination_y, destination_p, port,
                 tag, sdp_port):
        """
        :param int x: The x-coordinate of a chip, between 0 and 255
        :param int y: The y-coordinate of a chip, between 0 and 255
        :param int destination_x:
            The x-coordinate of the destination chip, between 0 and 255
        :param int destination_y:
            The y-coordinate of the destination chip, between 0 and 255
        :param int destination_p:
            The ID of the destination processor, between 0 and 17
        :param int port: The port, between 0 and 65535
        :param int tag: The tag, between 0 and 7
        """
        # pylint: disable=too-many-arguments
        strip_value = 1
        reverse_value = 1

        arg1 = ((reverse_value << 29) | (strip_value << 28) |
                (_IPTAG_SET << 16) | (sdp_port << 13) | (destination_p << 8) |
                tag)
        arg2 = ((destination_x << 24) | (destination_y << 16) | port)

        super().__init__(
            SDPHeader(
                flags=SDPFlag.REPLY_EXPECTED, destination_port=0,
                destination_cpu=0, destination_chip_x=x,
                destination_chip_y=y),
            SCPRequestHeader(command=SCPCommand.CMD_IPTAG),
            argument_1=arg1,
            argument_2=arg2,
            argument_3=0)
Example #13
0
    def __init__(self, led, action, boards):
        """

        :param led: Number of the LED or an iterable of LEDs to set the
            state of (0-7)
        :type led: int or list(int)
        :param LEDAction action:
            State to set the LED to, either on, off or toggle
        :param boards: Specifies the board to control the LEDs of. This may
            also be an iterable of multiple boards (in the same frame).
        :type boards: int or list(int)
        """

        # set up the led entry for arg1
        if isinstance(led, int):
            leds = [led]
        else:
            leds = led

        # LED setting actions
        arg1 = sum(action.value << (led * 2) for led in leds)

        # Bitmask of boards to control
        arg2 = self.get_board_mask(boards)

        # initialise the request now
        super().__init__(boards,
                         SCPRequestHeader(command=SCPCommand.CMD_LED),
                         argument_1=arg1,
                         argument_2=arg2)
    def __init__(self, app_id, x, y, processors, wait=False):
        """
        :param int app_id: The ID of the application to run, between 16 and 255
        :param int x: The x-coordinate of the chip to run on, between 0 and 255
        :param int y: The y-coordinate of the chip to run on, between 0 and 255
        :param list(int) processors:
            The processors on the chip where the executable should be
            started, between 1 and 17
        :param bool wait:
            True if the processors should enter a "wait" state on starting
        """
        # pylint: disable=too-many-arguments
        processor_mask = 0
        if processors is not None:
            for processor in processors:
                processor_mask |= (1 << processor)

        processor_mask |= (app_id << 24)
        if wait:
            processor_mask |= _WAIT_FLAG

        super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                   destination_port=0,
                                   destination_cpu=0,
                                   destination_chip_x=x,
                                   destination_chip_y=y),
                         SCPRequestHeader(command=SCPCommand.CMD_AR),
                         argument_1=processor_mask)
Example #15
0
 def __init__(self, board):
     """
     :param int board: which board to request the ADC register from
     """
     super().__init__(
         board,
         SCPRequestHeader(command=SCPCommand.CMD_BMP_INFO),
         argument_1=BMPInfo.ADC)
Example #16
0
 def __init__(self, board):
     """
     :param int board: The board to get the version from
     :raise SpinnmanInvalidParameterException:
         * If the chip coordinates are out of range
         * If the processor is out of range
     """
     super().__init__(board, SCPRequestHeader(command=SCPCommand.CMD_VER))
 def __init__(self, x, y):
     scp_header = SCPRequestHeader(command=SCPResult.RC_OK)
     sdp_header = SDPHeader(flags=SDPFlag.REPLY_NOT_EXPECTED,
                            destination_port=0,
                            destination_cpu=0,
                            destination_chip_x=x,
                            destination_chip_y=y)
     utils.update_sdp_header_for_udp_send(sdp_header, 0, 0)
     SDPMessage.__init__(self, sdp_header, data=scp_header.bytestring)
 def __init__(self, x, y, sequence=0):  # pragma: no cover
     scp_header = SCPRequestHeader(command=SCPResult.RC_OK,
                                   sequence=sequence)
     sdp_header = SDPHeader(flags=SDPFlag.REPLY_NOT_EXPECTED,
                            destination_port=0,
                            destination_cpu=0,
                            destination_chip_x=x,
                            destination_chip_y=y)
     utils.update_sdp_header_for_udp_send(sdp_header, 0, 0)
     super().__init__(sdp_header, data=scp_header.bytestring)
Example #19
0
 def __init__(self, x, y, version):
     self._scp_header = SCPRequestHeader(command=SCPResult.RC_OK)
     self._version_descriptor = b"BC&MP/Test\0" + version + b"\0"
     self._y = y
     self._x = x
     sdp_header = SDPHeader(flags=SDPFlag.REPLY_NOT_EXPECTED,
                            destination_port=0,
                            destination_cpu=0,
                            destination_chip_x=x,
                            destination_chip_y=y)
     utils.update_sdp_header_for_udp_send(sdp_header, 0, 0)
     super(SCPVerMessage, self).__init__(sdp_header)
Example #20
0
 def __init__(self, x, y):
     """
     :param int x: The x-coordinate of a chip, between 0 and 255
     :param int y: The y-coordinate of a chip, between 0 and 255
     """
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=0,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_IPTAG),
                      argument_1=(_IPTAG_INFO << 16),
                      argument_2=_IPTAG_MAX)
    def __init__(self, x, y, p):
        # pylint: disable=too-many-arguments

        super(_ClearIOBUFRequest, self).__init__(
            SDPHeader(
                flags=SDPFlag.REPLY_EXPECTED,
                destination_cpu=p,
                destination_chip_x=x,
                destination_chip_y=y,
                destination_port=SDP_PORTS.RUNNING_COMMAND_SDP_PORT.value),
            SCPRequestHeader(
                command=SDP_RUNNING_MESSAGE_CODES.SDP_CLEAR_IOBUF_CODE),
            argument_3=int(True))
 def __init__(self, fpga_num, addr, value, board):
     """
     :param int fpga_num: FPGA number (0, 1 or 2) to communicate with.
     :param int addr: Register address to read or write to (will be rounded
         down to the nearest 32-bit word boundary).
     :param int value: A 32-bit int value to write to the register
     """
     super().__init__(board,
                      SCPRequestHeader(command=SCPCommand.CMD_LINK_WRITE),
                      argument_1=addr & (~0x3),
                      argument_2=4,
                      argument_3=fpga_num,
                      data=_ONE_WORD.pack(value))
Example #23
0
 def __init__(self, app_id):
     """
     :param int app_id: The ID of the application, between 0 and 255
     """
     super().__init__(SDPHeader(
         flags=SDPFlag.REPLY_EXPECTED,
         destination_port=0,
         destination_cpu=0,
         destination_chip_x=self.DEFAULT_DEST_X_COORD,
         destination_chip_y=self.DEFAULT_DEST_Y_COORD),
                      SCPRequestHeader(command=SCPCommand.CMD_NNP),
                      argument_1=(0x3f << 16),
                      argument_2=(5 << 28) | _get_data(app_id, Signal.STOP),
                      argument_3=(1 << 31) + (0x3f << 8))
Example #24
0
 def __init__(self, x, y, tag_timeout):
     """
     :param int x: The x-coordinate of the chip to run on, between 0 and 255
     :param int y: The y-coordinate of the chip to run on, between 0 and 255
     :param IPTAG_TIME_OUT_WAIT_TIMES tag_timeout: The timeout value
     """
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=0,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_IPTAG),
                      argument_1=_IPTAG_TTO,
                      argument_2=tag_timeout.value)
Example #25
0
    def __init__(self, x, y, p, destination_port, expect_response=True):
        # pylint: disable=too-many-arguments
        sdp_flags = SDPFlag.REPLY_NOT_EXPECTED
        if expect_response:
            sdp_flags = SDPFlag.REPLY_EXPECTED

        super(SCPClearIOBUFRequest, self).__init__(
            SDPHeader(flags=sdp_flags,
                      destination_port=destination_port,
                      destination_cpu=p,
                      destination_chip_x=x,
                      destination_chip_y=y),
            SCPRequestHeader(
                command=SDP_RUNNING_MESSAGE_CODES.SDP_CLEAR_IOBUF_CODE),
            argument_3=int(bool(expect_response)))
Example #26
0
 def __init__(self, x, y, tag):
     """
     :param int x: The x-coordinate of a chip, between 0 and 255
     :param int y: The y-coordinate of a chip, between 0 and 255
     :param int tag: The tag to get details of, between 0 and 7
     :param int tag: The tag, between 0 and 7
     """
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=0,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_IPTAG),
                      argument_1=(_IPTAG_GET << 16) | tag,
                      argument_2=1)
Example #27
0
 def __init__(self, x, y):
     """
     :param int x: The x-coordinate of the chip, between 0 and 255
     :param int y: The y-coordinate of the chip, between 0 and 255
     :raise SpinnmanInvalidParameterException:
         * If x is out of range
         * If y is out of range
     """
     super().__init__(
         SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                   destination_port=0,
                   destination_cpu=0,
                   destination_chip_x=x,
                   destination_chip_y=y),
         SCPRequestHeader(command=SCPCommand.CMD_RTR))
Example #28
0
    def __init__(self, x, y, p):
        """
        :param int x: The x-coordinate of a chip, between 0 and 255
        :param int y: The y-coordinate of a chip, between 0 and 255
        :param int p:
            The processor running the extra monitor vertex, between 0 and 17
        """

        super(GetReinjectionStatusMessage, self).__init__(
            SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                      destination_port=(
                          SDP_PORTS.EXTRA_MONITOR_CORE_REINJECTION.value),
                      destination_cpu=p,
                      destination_chip_x=x,
                      destination_chip_y=y),
            SCPRequestHeader(command=ReinjectorSCPCommands.GET_STATUS))
Example #29
0
    def __init__(self, app_id, state):
        """

        :param int app_id: The ID of the application, between 0 and 255
        :param CPUState state: The state to count
        """
        super().__init__(
            SDPHeader(
                flags=SDPFlag.REPLY_EXPECTED, destination_port=0,
                destination_cpu=0,
                destination_chip_x=self.DEFAULT_DEST_X_COORD,
                destination_chip_y=self.DEFAULT_DEST_Y_COORD),
            SCPRequestHeader(command=SCPCommand.CMD_SIG),
            argument_1=_COUNT_SIGNAL_TYPE,
            argument_2=_get_data(app_id, state),
            argument_3=_ALL_CORE_MASK)
 def __init__(self, x, y, p):
     """
     :param int x: The x-coordinate of a chip, between 0 and 255
     :param int y: The y-coordinate of a chip, between 0 and 255
     :param int p:
         The processor running the extra monitor vertex, between 0 and 17
     """
     # pylint: disable=too-many-arguments
     super(ClearReinjectionQueueMessage, self).__init__(
         SDPHeader(
             flags=SDPFlag.REPLY_EXPECTED,
             destination_port=(
                 SDP_PORTS.EXTRA_MONITOR_CORE_REINJECTION.value),
             destination_cpu=p, destination_chip_x=x,
             destination_chip_y=y),
         SCPRequestHeader(command=ReinjectorSCPCommands.CLEAR))