Class MeshSwitch

java.lang.Object
  extended by MeshSwitch
All Implemented Interfaces:
Switch

public class MeshSwitch
extends java.lang.Object
implements Switch

This switch is used for building the Mesh and Torus network. This type of switch is interconnected with different number of switches according to its position. For example if the switch is in the corner then two other switches are connected with this switch in Mesh topology. If in the side line other than the corners then three other switches are connected with this switch and if in the middle of the network then four other adjacent switches are connected with this switch. Along with these adjacent switches every switch in the network is connected with one or four adjacent nodes. Connection with four nodes provides better throughput.

Version:
1.0

Field Summary
private  int address
          This is an int type variable used to hold the address (position) of the switch in the network.
private  InputLinkController[] inputLC
          These are array of InputLinkController used to store the list of input link controller objects instantiated for input communication management with the adjacent nodes and switches.
private  int[] lastVCServedList
          In order to facilitate round-robin service for the virtual channels, this array keeps track of the index of last served virtual channel on different links.
private  boolean[] LinkUseStatus
          This array keeps track of the status of the output links if there are any transmission of flits in a particular simulation cycle.
private  Node[] nodeList
          This is array of Node used to store the list of references of adjacent nodes.
private  int noOfPhysicalLink
          This is an int type variable used to hold the number of physical links attached with the switch to perform communication between adjacent switches and nodes.
private  int noOfVirtualLink
          This is an int type variable used to hold the number of virtual channel used for every physical link.
private  OutputLinkController[] outputLC
          These are array of OutputLinkController used to store the list of output link controller objects instantiated for output communication management with the adjacent nodes and switches.
private  Router router
          This is an object of type Router.
private  int switchIndex
          Index of the switch in the global array of switches in the
private  int[] switchingInfoVector
          This is an array of int variable having the size of noOfPhysicalLink * noOfVirtualLink.
private  MeshSwitch[] switchList
          This is the array of MeshSwitch used to store the list of reference of adjacent switches.
 
Constructor Summary
MeshSwitch(int pLink, int vLink, int address, int noOfAdjNode, int noOfAdjSwitch, int switchIndex)
          Constructor of the MeshSwitch used for mesh and torus topology.
 
Method Summary
 boolean addInputBufferData(int linkNo, Flit flit, int curCycle)
          This method is called by adjacent nodes and switches to store the flit sent to it from output buffer of respective node/switch.
 boolean addOutputBufferData(int linkNo, Flit flit, int vcId, int curCycle)
          Adds a flit to the output buffer on a particular physical link.
private  void createLinkController(int linkCount, int vcCount)
          Instantiates the input and output link controllers.
 void createRouter()
          Instantiates a concrete Router instance for this particular architecture.
private  void createSwitchingInfoVector()
          Instantiates and initializes the switchingInfoVector data structure to hold the path mapping information.
 int determineRoute(int src, int dest)
          Determines the outgoing link to switch a packet orgininated from a source node (src) and destined to the destination node (dest).
private  void forwardFlitToNode(Node adjNode, int linkNo, int curCycle)
           Transfers a flit to an adjacent node.
private  void forwardFlitToSwitch(MeshSwitch adjSwitch, int linkNo, int curCycle)
           Performs the transmission of flit from the virtual channel (output buffer) to physical channel and ultimately the flit is stored in the corresponding virtual channel of the switch.
 int getAddress()
          Returns the address of the switch.
 InputLinkController getInputLinkController(int linkNo)
          Returns the input link controller of the switch on a particular physical link.
private  int getMeshSwitchOutAdjLinkNo(int linkNo)
          Returns the input physical link number of an adjacent switch, to which this switch in question is connected by an output physical link specified by the parameter 'linkNo'
 int getNoOfPhysicalLink()
          Returns the maximum number of physical links information.
 int getNoOfVirtualLink()
          Returns the number of virtual channel per physical link information.
 int getNumAdjacentNode()
          Returns the number of nodes to which the switch is directly connected.
 int getNumLinkActive()
          Returns the number of physical links for the switch
 OutputLinkController getOutputLinkController(int linkNo)
          Returns the output link controller of the switch on a particular physical link.
 int getSwitchingInfoVector(int dest)
           Returns the input virtual channel information for a packet flowing through the output virtual channel.
 boolean hasFreeSlotInVCBuffer(int linkNo, int vcId)
          Checks whether there is one or more slots in the input virtual channel of an input buffer or not.
 boolean isVCFreeInSwitch(int linkNo, int vcId)
          Checks if the virtual channels in the input buffer of a particular physical link is available to be assigned to a new incoming packet.
 void moveInputBufferToOutputBuffer(int curCycle)
          This method is called by network in every cycle to transfer flit from input buffer to output buffer.
 void moveSwitchOutputBufferToInputBufferOfNodeSwitch(int curCycle)
          This method is called by Network in every cycle to transfer flit from output buffer of the switch to input buffer of adjacent nodes and switches.
 Flit removeInputBufferData(int linkNo, int vcId, int curCycle)
          Removes a flit data from an input virtual channel of the input buffer on a particular physical link.
 Flit removeOutputBufferData(int linkNo, int vcId, int curCycle)
          Removes a flit data from an output virtual channel of the output buffer on a particular physical link.
 void resetSwitchingInfoVector()
          Resets the switching info vector of the Switch instance which keeps track of the assignment of a output virtual channel to a packet on a input virtual channel.
 void setAddress(int addr)
          Sets the address of the switch.
 void setAdjacentNode(Node node, int linkNo)
          Assigns a node reference to which this Switch is connected.
 void setAdjacentSwitch(MeshSwitch meshSwitch, int linkNo)
          Assigns a MeshSwitch reference to which this MeshSwitch is connected.
 void setAdjacentSwitch(Switch meshSwitch, int linkNo)
          Assigns a switch reference to which this Switch is connected.
 void setInputLinkController(int linkNo, InputLinkController iLC)
          Assigns an input link controller to the switch on a particular physical link.
 void setNoOfPhysicalLink(int no)
          Sets the maximum number of physical links information.
 void setNoOfVirtualLink(int noVlink)
          Sets the number of virtual channel per physical link information.
 void setOutputLinkController(int linkNo, OutputLinkController oLC)
          Assigns an output link controller to the switch on a particular physical link.
 boolean setSwitchingInfoVector(int dest, int src)
          Sets the path information for a pair of input virtual channel and output virtual channel.
 void updateStatusAfterCycle(int curCycle)
          Updates the statistical counters for a particular simulation cycle and re-initializes the temporary status variables.
 void updateSwitchOutPathRequest(int curCycle)
          This method is called by network in every cycle to set the request of transferring flit from the input buffer to output buffer of the respective switch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

address

private int address
This is an int type variable used to hold the address (position) of the switch in the network. The address is generated by bit-encoding from the mesh row and column numbers in the network.


switchIndex

private int switchIndex
Index of the switch in the global array of switches in the

See Also:
Network

noOfPhysicalLink

private int noOfPhysicalLink
This is an int type variable used to hold the number of physical links attached with the switch to perform communication between adjacent switches and nodes.


noOfVirtualLink

private int noOfVirtualLink
This is an int type variable used to hold the number of virtual channel used for every physical link.


switchList

private MeshSwitch[] switchList
This is the array of MeshSwitch used to store the list of reference of adjacent switches. This list is used to get the adjacent switches to which this switch will communicate.


nodeList

private Node[] nodeList
This is array of Node used to store the list of references of adjacent nodes. One switch may be connected with multiple Nodes and when any flit is to send or any status of signal is required then the corresponding node’s reference is retrieved from the nodeList.


lastVCServedList

private int[] lastVCServedList
In order to facilitate round-robin service for the virtual channels, this array keeps track of the index of last served virtual channel on different links.


inputLC

private InputLinkController[] inputLC
These are array of InputLinkController used to store the list of input link controller objects instantiated for input communication management with the adjacent nodes and switches. There exists exactly one input link controller for every physical link.


outputLC

private OutputLinkController[] outputLC
These are array of OutputLinkController used to store the list of output link controller objects instantiated for output communication management with the adjacent nodes and switches. There exists exactly one output link controller for every physical link.


LinkUseStatus

private boolean[] LinkUseStatus
This array keeps track of the status of the output links if there are any transmission of flits in a particular simulation cycle.


router

private Router router
This is an object of type Router. Implements Router's determineRoute() method.


switchingInfoVector

private int[] switchingInfoVector
This is an array of int variable having the size of noOfPhysicalLink * noOfVirtualLink. This array is used for switching in crossbar switch i.e. it determines the path from input buffer to output buffer. At index i of this array a value x (>=0) is stored for path selection. Here x is the input virtual channel identifier and i is the output virtual channel identifier. That means the data from input port x is switched (transferred) to the output port i. Here input and output physical and virtual channels are identified as below.

Constructor Detail

MeshSwitch

public MeshSwitch(int pLink,
                  int vLink,
                  int address,
                  int noOfAdjNode,
                  int noOfAdjSwitch,
                  int switchIndex)
Constructor of the MeshSwitch used for mesh and torus topology. The parameters imply number of Physical link, number of virtual channel per physical channel, address of this switch, number of nodes attached with this switch, number of switches attached with this switch and position of this switch in the list of switches respectively.

Parameters:
pLink - Number of physical links
vLink - Number of virtual channels per physical link
address - Address of the switch
noOfAdjNode - Number of adjacent nodes
noOfAdjSwitch - Number of adjacent switches
switchIndex - index of this switch in the global array of switches in the
See Also:
Network.createMeshNetwork()
Method Detail

setNoOfPhysicalLink

public void setNoOfPhysicalLink(int no)
Description copied from interface: Switch
Sets the maximum number of physical links information.

Specified by:
setNoOfPhysicalLink in interface Switch
Parameters:
no - maximum number of physical links

getNoOfPhysicalLink

public int getNoOfPhysicalLink()
Description copied from interface: Switch
Returns the maximum number of physical links information.

Specified by:
getNoOfPhysicalLink in interface Switch
Returns:
maximum number of physical links

setNoOfVirtualLink

public void setNoOfVirtualLink(int noVlink)
Description copied from interface: Switch
Sets the number of virtual channel per physical link information.

Specified by:
setNoOfVirtualLink in interface Switch
Parameters:
noVlink - number of virtual channel per physical link

getNoOfVirtualLink

public int getNoOfVirtualLink()
Description copied from interface: Switch
Returns the number of virtual channel per physical link information.

Specified by:
getNoOfVirtualLink in interface Switch
Returns:
number of virtual channel per physical link

setAddress

public void setAddress(int addr)
Description copied from interface: Switch
Sets the address of the switch.

Specified by:
setAddress in interface Switch
Parameters:
addr - address of the switch

getAddress

public int getAddress()
Description copied from interface: Switch
Returns the address of the switch.

Specified by:
getAddress in interface Switch
Returns:
address of the switch

createRouter

public void createRouter()
Description copied from interface: Switch
Instantiates a concrete Router instance for this particular architecture.

Specified by:
createRouter in interface Switch

createLinkController

private void createLinkController(int linkCount,
                                  int vcCount)
Instantiates the input and output link controllers.

Parameters:
linkCount - number of physical links
vcCount - number of virtual channels per link

setAdjacentNode

public void setAdjacentNode(Node node,
                            int linkNo)
Description copied from interface: Switch
Assigns a node reference to which this Switch is connected.

Specified by:
setAdjacentNode in interface Switch
Parameters:
node - Node
linkNo - the physical link number that connects the node
See Also:
Node

getNumAdjacentNode

public int getNumAdjacentNode()
Returns the number of nodes to which the switch is directly connected.

Specified by:
getNumAdjacentNode in interface Switch
Returns:
number of adjacent nodes

setAdjacentSwitch

public void setAdjacentSwitch(MeshSwitch meshSwitch,
                              int linkNo)
Assigns a MeshSwitch reference to which this MeshSwitch is connected.

Parameters:
meshSwitch - adjacent switch reference
linkNo - the physical link number that connects these two switches

getInputLinkController

public InputLinkController getInputLinkController(int linkNo)
Description copied from interface: Switch
Returns the input link controller of the switch on a particular physical link.

Specified by:
getInputLinkController in interface Switch
Parameters:
linkNo - link number
Returns:
input link controller reference of the switch on the link 'linkNo'
See Also:
InputLinkController

setInputLinkController

public void setInputLinkController(int linkNo,
                                   InputLinkController iLC)
Description copied from interface: Switch
Assigns an input link controller to the switch on a particular physical link.

Specified by:
setInputLinkController in interface Switch
Parameters:
linkNo - link number
iLC - input link controller
See Also:
InputLinkController

getOutputLinkController

public OutputLinkController getOutputLinkController(int linkNo)
Description copied from interface: Switch
Returns the output link controller of the switch on a particular physical link.

Specified by:
getOutputLinkController in interface Switch
Parameters:
linkNo - link number
Returns:
output link controller reference of the switch on the link 'linkNo'

setOutputLinkController

public void setOutputLinkController(int linkNo,
                                    OutputLinkController oLC)
Description copied from interface: Switch
Assigns an output link controller to the switch on a particular physical link.

Specified by:
setOutputLinkController in interface Switch
Parameters:
linkNo - link number
oLC - output link controller

createSwitchingInfoVector

private void createSwitchingInfoVector()
Instantiates and initializes the switchingInfoVector data structure to hold the path mapping information.


resetSwitchingInfoVector

public void resetSwitchingInfoVector()
Resets the switching info vector of the Switch instance which keeps track of the assignment of a output virtual channel to a packet on a input virtual channel.

Specified by:
resetSwitchingInfoVector in interface Switch

addInputBufferData

public boolean addInputBufferData(int linkNo,
                                  Flit flit,
                                  int curCycle)
This method is called by adjacent nodes and switches to store the flit sent to it from output buffer of respective node/switch. The method implemented by simply calling the corresponding input link controller’s addInputBufferData() method.

Specified by:
addInputBufferData in interface Switch
Parameters:
linkNo - the input link controller where the flit arrives.
flit - Flit data
curCycle - current simulation cycle
Returns:
true-if flit can be added, false-otherwise.
See Also:
InputLinkController, InputVCBuffer, Flit

addOutputBufferData

public boolean addOutputBufferData(int linkNo,
                                   Flit flit,
                                   int vcId,
                                   int curCycle)
Description copied from interface: Switch
Adds a flit to the output buffer on a particular physical link.

Specified by:
addOutputBufferData in interface Switch
Parameters:
linkNo - link number
flit - Flit data
vcId - virtual channel number
curCycle - simulation cycle
Returns:
true-if flit can be added, false-otherwise.
See Also:
OutputLinkController.addOutputBufferData(Flit, int, int)

setSwitchingInfoVector

public boolean setSwitchingInfoVector(int dest,
                                      int src)
Description copied from interface: Switch
Sets the path information for a pair of input virtual channel and output virtual channel.

Specified by:
setSwitchingInfoVector in interface Switch
Parameters:
dest - ((output link number * number of VC per link) + output virtual channel number)
src - ((input link number * number of VC per link) + input virtual channel number)
Returns:
true-if the path can be set, false-otherwise
See Also:
InputLinkController.setOutPathRequest(int)

getSwitchingInfoVector

public int getSwitchingInfoVector(int dest)
Description copied from interface: Switch

Returns the input virtual channel information for a packet flowing through the output virtual channel.

This pair of values identify the switching path in the switch for a packet.

Here the input virtual channel information is encoded as ((input link number * number of VC per link) + input virtual channel number) and the output virtual channel information is encoded as ((output link number * number of VC per link) + output virtual channel number).

Specified by:
getSwitchingInfoVector in interface Switch
Parameters:
dest - encoded output virtual channel information
Returns:
encoded input virtual channel information
See Also:
InputLinkController.setOutPathRequest(int)

removeInputBufferData

public Flit removeInputBufferData(int linkNo,
                                  int vcId,
                                  int curCycle)
Description copied from interface: Switch
Removes a flit data from an input virtual channel of the input buffer on a particular physical link.

Specified by:
removeInputBufferData in interface Switch
Parameters:
linkNo - input physical link number
vcId - input virtual channel number
curCycle - simulation cycle
Returns:
Flit
See Also:
InputLinkController.removeInputBufferData(int, int)

removeOutputBufferData

public Flit removeOutputBufferData(int linkNo,
                                   int vcId,
                                   int curCycle)
Description copied from interface: Switch
Removes a flit data from an output virtual channel of the output buffer on a particular physical link.

Specified by:
removeOutputBufferData in interface Switch
Parameters:
linkNo - output physical link number
vcId - output virtual channel number
curCycle - simulation cycle
Returns:
Flit
See Also:
OutputLinkController.removeOutputBufferData(int, int)

determineRoute

public int determineRoute(int src,
                          int dest)
Description copied from interface: Switch
Determines the outgoing link to switch a packet orgininated from a source node (src) and destined to the destination node (dest).

Specified by:
determineRoute in interface Switch
Parameters:
src - address of the source node
dest - address of the destination node
Returns:
outgoing physical link of the switch
See Also:
Router.determineRoute(int, int, int)

hasFreeSlotInVCBuffer

public boolean hasFreeSlotInVCBuffer(int linkNo,
                                     int vcId)
Description copied from interface: Switch
Checks whether there is one or more slots in the input virtual channel of an input buffer or not.

Specified by:
hasFreeSlotInVCBuffer in interface Switch
Parameters:
linkNo - input physical link number
vcId - virtual channel number on the input link
Returns:
true-if more slots are available, false-otherwise
See Also:
InputLinkController.hasFreeSlotInVCBuffer(int)

updateSwitchOutPathRequest

public void updateSwitchOutPathRequest(int curCycle)
This method is called by network in every cycle to set the request of transferring flit from the input buffer to output buffer of the respective switch. For every input physical link attached with the switch input link controller’s setOutPathRequest(curCycle) method is called.

Specified by:
updateSwitchOutPathRequest in interface Switch
Parameters:
curCycle - current simulation cycle
See Also:
InputLinkController.setOutPathRequest(int)

moveInputBufferToOutputBuffer

public void moveInputBufferToOutputBuffer(int curCycle)
This method is called by network in every cycle to transfer flit from input buffer to output buffer. The working process of moving flit from input buffer to output buffer is described below.

Specified by:
moveInputBufferToOutputBuffer in interface Switch
Parameters:
curCycle - current simulation cycle
See Also:
InputLinkController, Network.moveSwitchTrafficFromInputBufferToOutputBuffer(int)

forwardFlitToSwitch

private void forwardFlitToSwitch(MeshSwitch adjSwitch,
                                 int linkNo,
                                 int curCycle)

Performs the transmission of flit from the virtual channel (output buffer) to physical channel and ultimately the flit is stored in the corresponding virtual channel of the switch.

This method is called by moveSwitchOutputBufferToInputBufferOfNodeSwitch(int curCycle) method of this switch to complete transmission between this switch and actual parameter adjSwitch (an adjacent switch) for this current cycle.

The method performs its activities in the order given below.

Parameters:
adjSwitch - adjacent Mesh switch
linkNo - physical link number which connects the switch 'adjSwitch'
curCycle - simulation cycle

forwardFlitToNode

private void forwardFlitToNode(Node adjNode,
                               int linkNo,
                               int curCycle)

Transfers a flit to an adjacent node.

This method is called by moveSwitchOutputBufferToInputBufferOfNodeSwitch(int curCycle) method of this switch to complete transmission between this switch and parameter adjNode for this current cycle.

The method performs its activities in the order given below.

Parameters:
adjNode - node reference
linkNo - physical link number that connects the node to the switch
curCycle - simulation cycle

moveSwitchOutputBufferToInputBufferOfNodeSwitch

public void moveSwitchOutputBufferToInputBufferOfNodeSwitch(int curCycle)
This method is called by Network in every cycle to transfer flit from output buffer of the switch to input buffer of adjacent nodes and switches. For every adjacent nodes forwardFlitToNode(adjNode, linkNo, curCycle) is called and for every adjacent switch forwardFlitToSwitch(adjSwitch, linkNo, curCycle) is called.

Specified by:
moveSwitchOutputBufferToInputBufferOfNodeSwitch in interface Switch
Parameters:
curCycle - simulation cycle
See Also:
Network.moveSwitchTrafficFromOutputBufferToInputBufferOfNodeSwitch(int), forwardFlitToNode(Node, int, int), forwardFlitToSwitch(MeshSwitch, int, int)

isVCFreeInSwitch

public boolean isVCFreeInSwitch(int linkNo,
                                int vcId)
Description copied from interface: Switch
Checks if the virtual channels in the input buffer of a particular physical link is available to be assigned to a new incoming packet.

Specified by:
isVCFreeInSwitch in interface Switch
Parameters:
linkNo - input physical link number
vcId - virtual channel number
Returns:
true-if the virtual channel is free, false-otherwise.
See Also:
InputLinkController.isVCFree(int)

getNumLinkActive

public int getNumLinkActive()
Description copied from interface: Switch
Returns the number of physical links for the switch

Specified by:
getNumLinkActive in interface Switch
Returns:
number of valid physical links

updateStatusAfterCycle

public void updateStatusAfterCycle(int curCycle)
Description copied from interface: Switch
Updates the statistical counters for a particular simulation cycle and re-initializes the temporary status variables.

Specified by:
updateStatusAfterCycle in interface Switch
Parameters:
curCycle - simulation cycle

getMeshSwitchOutAdjLinkNo

private int getMeshSwitchOutAdjLinkNo(int linkNo)
Returns the input physical link number of an adjacent switch, to which this switch in question is connected by an output physical link specified by the parameter 'linkNo'

Parameters:
linkNo - output physical link number of this switch
Returns:
input physical link number

setAdjacentSwitch

public void setAdjacentSwitch(Switch meshSwitch,
                              int linkNo)
Description copied from interface: Switch
Assigns a switch reference to which this Switch is connected.

Specified by:
setAdjacentSwitch in interface Switch
Parameters:
meshSwitch - adjacent switch reference
linkNo - the physical link number that connects these two switches