Class Chip
- All Implemented Interfaces:
HasChipLocation
public class Chip extends Object implements HasChipLocation
- Author:
- Christian-B
- See Also:
- Python Chip Version, Python Router Version
-
Field Summary
Fields Modifier and Type Field Description InetAddress
ipAddress
The IP address of the chip ornull
if no Ethernet attached.@Valid ChipLocation
nearestEthernet
The nearest Ethernet-enabled chip coordinates, ornull
if none known.Router
router
A router for the chip.int
sdram
The size of the SDRAM. -
Constructor Summary
Constructors Constructor Description Chip(ChipLocation location, Iterable<Processor> processors, Router router, int sdram, InetAddress ipAddress, List<Integer> tagIds, ChipLocation nearestEthernet)
Main constructor which sets all parameters.Chip(ChipLocation location, Iterable<Processor> processors, Router router, int sdram, InetAddress ipAddress, ChipLocation nearestEthernet)
Constructor which fills in some default values.Chip(ChipLocation location, Iterable<Processor> processors, Router router, InetAddress ipAddress, ChipLocation nearestEthernet)
Constructor for a chip with non-default processors.Chip(ChipLocation location, Router router, InetAddress ipAddress, ChipLocation nearestEthernet)
Constructor for a chip with the default processors. -
Method Summary
Modifier and Type Method Description List<Processor>
allProcessors()
Return a list off all the processors on this chip.ChipLocation
asChipLocation()
Converts (if required) this to a simple X, Y tuple.String
difference(Chip other)
Describes one difference found between this chip and another chip.boolean
equals(Object obj)
Processor
getFirstUserProcessor()
Get the first processor in the list which is not a monitor core.List<Integer>
getTagIds()
Get the IDs of the tags of the chip.Processor
getUserProcessor(int processorId)
Obtains the user processor with this ID, or returnsnull
.int
getX()
int
getY()
int
hashCode()
boolean
hasUserProcessor(int processorId)
Determines if a user processor with the given ID exists in the chip.int
nProcessors()
The total number of processors.int
nUserProcessors()
The total number of user processors.String
toString()
Collection<Processor>
userProcessors()
Return a view over the user processors on this chip.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface uk.ac.manchester.spinnaker.machine.HasChipLocation
getScampCore, onSameChipAs
-
Field Details
-
router
A router for the chip. -
sdram
public final int sdramThe size of the SDRAM. -
ipAddress
The IP address of the chip ornull
if no Ethernet attached. -
nearestEthernet
The nearest Ethernet-enabled chip coordinates, ornull
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, ornull
if no Ethernet attached.tagIds
- List of SDP identifiers available. Can be empty to force empty. Ifnull
, will use the default list for Ethernet-enabled chips and empty for non-Ethernet-enabled chipsnearestEthernet
- The nearest Ethernet-enabled chip coordinates ornull
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, ornull
if no Ethernet attached.nearestEthernet
- The nearest Ethernet-enabled chip coordinates, ornull
if none known.- Throws:
IllegalArgumentException
- Thrown if multiple links share the samesourceLinkDirection
, 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 ornull
if no Ethernet attached.nearestEthernet
- The nearest Ethernet coordinates ornull
if none known.- Throws:
IllegalArgumentException
- Indicates another Link with thissourceLinkDirection
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 ornull
if no Ethernet attached.nearestEthernet
- The nearest Ethernet-connected chip's coordinates ornull
if none known.- Throws:
IllegalArgumentException
- Indicates another link with thissourceLinkDirection
has already been added.
-
-
Method Details
-
getX
public int getX()- Specified by:
getX
in interfaceHasChipLocation
- Returns:
- The X coordinate of the chip.
-
getY
public int getY()- Specified by:
getY
in interfaceHasChipLocation
- Returns:
- The Y coordinate of the chip.
-
asChipLocation
Description copied from interface:HasChipLocation
Converts (if required) this to a simple X, Y tuple.- Specified by:
asChipLocation
in interfaceHasChipLocation
- 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
Obtains the user processor with this ID, or returnsnull
.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
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
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 propertyisMonitor == 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
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
Get the IDs of the tags of the chip.- Returns:
- the tag IDs
-
toString
-
hashCode
public int hashCode() -
equals
-
difference
Describes one difference found between this chip and another chip. This method will always returnnull
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.
-