java.lang.Object
uk.ac.manchester.spinnaker.machine.Chip
All Implemented Interfaces:
HasChipLocation

public class Chip
extends Object
implements HasChipLocation
A Description of a Spinnaker Chip including its Router.
Author:
Christian-B
See Also:
Python Chip Version, Python Router Version
  • Field Details

    • router

      public final Router router
      A router for the chip.
    • sdram

      public final int sdram
      The size of the SDRAM.
    • ipAddress

      public final InetAddress ipAddress
      The IP address of the chip or null if no Ethernet attached.
    • nearestEthernet

      @Valid public final @Valid ChipLocation nearestEthernet
      The nearest Ethernet-enabled chip coordinates, or null if none known. ("Nearest" here means "on the same board".)
  • Constructor Details

    • Chip

      public Chip​(ChipLocation location, Iterable<Processor> processors, Router router, int sdram, InetAddress ipAddress, List<Integer> tagIds, ChipLocation nearestEthernet)
      Main constructor which sets all parameters.
      Parameters:
      location - The coordinates of the chip's position in the two-dimensional grid of chips.
      processors - An iterable of processor objects.
      router - A router for the chip.
      sdram - The size of the SDRAM.
      ipAddress - The IP address of the chip's Ethernet connection, or null if no Ethernet attached.
      tagIds - List of SDP identifiers available. Can be empty to force empty. If null, will use the default list for Ethernet-enabled chips and empty for non-Ethernet-enabled chips
      nearestEthernet - The nearest Ethernet-enabled chip coordinates or null if none known.
      Throws:
      IllegalArgumentException - Thrown if multiple chips share the same ID.
    • Chip

      public Chip​(ChipLocation location, Iterable<Processor> processors, Router router, int sdram, InetAddress ipAddress, ChipLocation nearestEthernet)
      Constructor which fills in some default values.
      Parameters:
      location - The coordinates of the chip's position in the two-dimensional grid of chips.
      processors - An iterable of processor objects.
      router - A router for the chip.
      sdram - The size of the SDRAM.
      ipAddress - The IP address of the chip's attached Ethernet connection, or null if no Ethernet attached.
      nearestEthernet - The nearest Ethernet-enabled chip coordinates, or null if none known.
      Throws:
      IllegalArgumentException - Thrown if multiple links share the same sourceLinkDirection, or if multiple chips share the same ID.
    • Chip

      public Chip​(ChipLocation location, Iterable<Processor> processors, Router router, InetAddress ipAddress, ChipLocation nearestEthernet)
      Constructor for a chip with non-default processors.
      Parameters:
      location - The coordinates of the chip's position in the two-dimensional grid of chips.
      processors - An iterable of processor objects.
      router - A router for the chip.
      ipAddress - The IP address of the chip or null if no Ethernet attached.
      nearestEthernet - The nearest Ethernet coordinates or null if none known.
      Throws:
      IllegalArgumentException - Indicates another Link with this sourceLinkDirection has already been added.
    • Chip

      public Chip​(ChipLocation location, Router router, InetAddress ipAddress, ChipLocation nearestEthernet)
      Constructor for a chip with the default processors.
      Parameters:
      location - The coordinates of the chip's position in the two-dimensional grid of chips.
      router - A router for the chip.
      ipAddress - The IP address of the chip or null if no Ethernet attached.
      nearestEthernet - The nearest Ethernet-connected chip's coordinates or null if none known.
      Throws:
      IllegalArgumentException - Indicates another link with this sourceLinkDirection has already been added.
  • Method Details

    • getX

      public int getX()
      Specified by:
      getX in interface HasChipLocation
      Returns:
      The X coordinate of the chip.
    • getY

      public int getY()
      Specified by:
      getY in interface HasChipLocation
      Returns:
      The Y coordinate of the chip.
    • asChipLocation

      public ChipLocation asChipLocation()
      Description copied from interface: HasChipLocation
      Converts (if required) this to a simple X, Y tuple.
      Specified by:
      asChipLocation in interface HasChipLocation
      Returns:
      A ChipLocation representation of the X and Y tuple
    • hasUserProcessor

      public boolean hasUserProcessor​(int processorId)
      Determines if a user processor with the given ID exists in the chip.

      Warning: If a monitor processor exists with this ID, this method will return false.

      Parameters:
      processorId - ID of the potential processor.
      Returns:
      True if and only if there is a user processor for this ID.
    • getUserProcessor

      public Processor getUserProcessor​(int processorId)
      Obtains the user processor with this ID, or returns null.

      This method will only check user processors so will return null even if a monitor processor exists with this ID.

      Parameters:
      processorId - ID of the potential processor.
      Returns:
      The processor, or null if not is found.
    • allProcessors

      public List<Processor> allProcessors()
      Return a list off all the processors on this chip. This method will check both the user and monitor processors.

      The processors will be ordered by their ID, which are guaranteed to all be different.

      The current implementation builds a new list on the fly so this list is mutable without affecting the chip. Future implementations could return an unmodifiable list.

      Returns:
      A list of all the processors including both monitor and user.
    • userProcessors

      public Collection<Processor> userProcessors()
      Return a view over the user processors on this chip. Monitor processors are not included so every processor in the list is guaranteed to have the property isMonitor == false!

      The processors will be ordered by their ID, which are guaranteed to all be different.

      Returns:
      A unmodifiable view over the processors.
    • nProcessors

      public int nProcessors()
      The total number of processors.
      Returns:
      The size of the processor collection.
    • nUserProcessors

      public int nUserProcessors()
      The total number of user processors.

      For just the user processors so ignores monitor processors.

      Returns:
      The size of the Processor Collection
    • getFirstUserProcessor

      public Processor getFirstUserProcessor() throws NoSuchElementException
      Get the first processor in the list which is not a monitor core.
      Returns:
      A processor
      Throws:
      NoSuchElementException - If all the Processor(s) are monitors.
    • getTagIds

      public List<Integer> getTagIds()
      Get the IDs of the tags of the chip.
      Returns:
      the tag IDs
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object
    • difference

      public String difference​(Chip other)
      Describes one difference found between this chip and another chip. This method will always return null if no difference is found between the two machines.

      This method returns as soon as it has found a difference; there may be other unspecified differences.

      Warning: This method could change over time, so there is no implied guarantee to the order that variables are checked or to the message that is returned.

      The only guarantee is that null is returned if no difference is detected.

      Parameters:
      other - Another chip to check if it has the same variables.
      Returns:
      null if no difference is detected, otherwise a string describing the difference.