edu.byu.ece.edif.tools.replicate.nmr
Class AbstractDeviceUtilizationTracker

java.lang.Object
  extended by edu.byu.ece.edif.tools.replicate.nmr.AbstractDeviceUtilizationTracker
All Implemented Interfaces:
DeviceUtilizationTracker
Direct Known Subclasses:
XilinxDeviceUtilizationTracker

public abstract class AbstractDeviceUtilizationTracker
extends java.lang.Object
implements DeviceUtilizationTracker

An abstract implementation of a device utilization tracker.

Version:
$Id: AbstractDeviceUtilizationTracker.java 162 2008-04-02 21:45:37Z jamesfcarroll $
Author:
Keith Morgan

Field Summary
protected  java.util.HashMap<java.lang.String,java.lang.Double> _cachedCurrentUtilizationMap
           
protected  java.util.HashMap<java.lang.String,java.lang.Double> _currentUtilizationMap
           
protected  java.util.HashMap<java.lang.String,java.lang.Integer> _maxUtilizationMap
           
protected  int _numInstances
           
protected  int _origNumInstances
           
protected  ResourceMapper _resourceMapper
           
protected  double coverage_factor
           
 
Constructor Summary
AbstractDeviceUtilizationTracker()
           
 
Method Summary
protected  void _init(EdifCell cell)
           
protected  void addResourceForTracking(java.lang.String resourceType, double currentUtilization, int maxUtilization)
           
 void addSingleCell(EdifCell cell)
           
 void addSingleInstance(EdifCellInstance eci)
          This function adds the instance eci to the normal cell instances list and adds the appropriate utilization to the device utilization count.
 void addSingleInstances(java.util.Collection<EdifCellInstance> ecis)
          This function adds a collection of instances to add to the normal cell instances list.
protected  void cacheCurrentUtilization()
           
 int getResourceLimit(EdifCell cell)
           
 int getResourceLimit(EdifCellInstance eci)
           
protected  int getResourceLimit(java.lang.String resourceType)
           
 double getResourceUtilization(EdifCell cell)
           
 double getResourceUtilization(EdifCellInstance eci)
           
protected  double getResourceUtilization(java.lang.String resourceType)
           
 double getResourceUtilizationRatio(EdifCell cell)
           
 double getResourceUtilizationRatio(EdifCellInstance eci)
           
 double getResourceUtilizationRatio(java.lang.String resourceType)
          Return the utilization ratio of the given resource type, which is calculated as from the current usage of resource divided by the resource limit
 void nmrCell(EdifCell cell, int replicationFactor)
           
 void nmrInstance(EdifCellInstance eci, int replicationFactor)
          This function adds the instance eci to the list of instances to be replicated.
private  void nmrInstances(java.util.Collection<EdifCellInstance> ecis, boolean skipEstimatedStops, boolean skipHardStops, int replicationFactor, java.util.Collection<EdifCellInstance> actuallyReplicated)
          Adds the instances in the collection ecis for replication.
 void nmrInstancesAsManyAsPossible(java.util.Collection<EdifCellInstance> ecis, int replicationFactor, java.util.Collection<EdifCellInstance> actuallyReplicated)
          Adds as many instances as it can from the collection ecis for replication, skipping instances which cause estimated stops and/or hard stops.
 void nmrInstancesAtomic(java.util.Collection<EdifCellInstance> ecis, int replicationFactor)
          Adds all instances in the collection ecis for replication.
 void removeNMRInstance(EdifCellInstance eci, int replicationFactor)
          This function removes the instance eci from the list of instances to be replicated.
 void removeNMRInstances(java.util.Collection<EdifCellInstance> ecis, int replicationFactor)
          This function removes a collection of instances from the list of instances to be replicated.
 void removeSingleInstance(EdifCellInstance eci)
          This function removes the utilization corresponding to eci from the device utilization count.
 void removeSingleInstances(java.util.Collection<EdifCellInstance> ecis)
          This function removes a collection of instances from the normal list of cell instances.
protected  void restoreCurrentUtilization()
           
protected  void setDesiredCoverageFactor(double factorValue)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.byu.ece.edif.tools.replicate.nmr.DeviceUtilizationTracker
decrementResourceCount, incrementResourceCount
 

Field Detail

coverage_factor

protected double coverage_factor

_cachedCurrentUtilizationMap

protected java.util.HashMap<java.lang.String,java.lang.Double> _cachedCurrentUtilizationMap

_currentUtilizationMap

protected java.util.HashMap<java.lang.String,java.lang.Double> _currentUtilizationMap

_maxUtilizationMap

protected java.util.HashMap<java.lang.String,java.lang.Integer> _maxUtilizationMap

_numInstances

protected int _numInstances

_origNumInstances

protected int _origNumInstances

_resourceMapper

protected ResourceMapper _resourceMapper
Constructor Detail

AbstractDeviceUtilizationTracker

public AbstractDeviceUtilizationTracker()
Method Detail

addSingleCell

public void addSingleCell(EdifCell cell)
                   throws OverutilizationEstimatedStopException,
                          OverutilizationHardStopException,
                          UnsupportedResourceTypeException
Specified by:
addSingleCell in interface DeviceUtilizationTracker
Throws:
OverutilizationEstimatedStopException
OverutilizationHardStopException
UnsupportedResourceTypeException

addSingleInstance

public void addSingleInstance(EdifCellInstance eci)
                       throws OverutilizationEstimatedStopException,
                              OverutilizationHardStopException,
                              UnsupportedResourceTypeException
This function adds the instance eci to the normal cell instances list and adds the appropriate utilization to the device utilization count.

Specified by:
addSingleInstance in interface DeviceUtilizationTracker
Parameters:
eci - Instance to add to the instances list.
Throws:
OverutilizationEstimatedStopException
OverutilizationHardStopException
UnsupportedResourceTypeException

addSingleInstances

public void addSingleInstances(java.util.Collection<EdifCellInstance> ecis)
                        throws OverutilizationEstimatedStopException,
                               OverutilizationHardStopException,
                               UnsupportedResourceTypeException
This function adds a collection of instances to add to the normal cell instances list. It also adds the appropriate utilization for each instance in the collection to the device utilization count. If any of the instances cause an overutilization exception, none of the instances will be added.

Specified by:
addSingleInstances in interface DeviceUtilizationTracker
Parameters:
ecis - Collection of instances to add to instances list.
Throws:
OverutilizationEstimatedStopException
OverutilizationHardStopException
UnsupportedResourceTypeException

cacheCurrentUtilization

protected void cacheCurrentUtilization()

restoreCurrentUtilization

protected void restoreCurrentUtilization()

getResourceLimit

public int getResourceLimit(EdifCellInstance eci)
                     throws UnsupportedResourceTypeException
Specified by:
getResourceLimit in interface DeviceUtilizationTracker
Throws:
UnsupportedResourceTypeException

getResourceLimit

public int getResourceLimit(EdifCell cell)
                     throws UnsupportedResourceTypeException
Specified by:
getResourceLimit in interface DeviceUtilizationTracker
Throws:
UnsupportedResourceTypeException

getResourceLimit

protected int getResourceLimit(java.lang.String resourceType)

getResourceUtilization

public double getResourceUtilization(EdifCellInstance eci)
                              throws UnsupportedResourceTypeException
Specified by:
getResourceUtilization in interface DeviceUtilizationTracker
Throws:
UnsupportedResourceTypeException

getResourceUtilization

public double getResourceUtilization(EdifCell cell)
                              throws UnsupportedResourceTypeException
Specified by:
getResourceUtilization in interface DeviceUtilizationTracker
Throws:
UnsupportedResourceTypeException

getResourceUtilization

protected double getResourceUtilization(java.lang.String resourceType)
                                 throws UnsupportedResourceTypeException
Throws:
UnsupportedResourceTypeException

getResourceUtilizationRatio

public double getResourceUtilizationRatio(EdifCellInstance eci)
                                   throws UnsupportedResourceTypeException
Throws:
UnsupportedResourceTypeException

getResourceUtilizationRatio

public double getResourceUtilizationRatio(EdifCell cell)
                                   throws UnsupportedResourceTypeException
Throws:
UnsupportedResourceTypeException

getResourceUtilizationRatio

public double getResourceUtilizationRatio(java.lang.String resourceType)
                                   throws UnsupportedResourceTypeException
Return the utilization ratio of the given resource type, which is calculated as from the current usage of resource divided by the resource limit

Parameters:
resourceType - String name of the specified resource
Returns:
the utilization ratio of the given resource type, which is calculated as from the current usage of resource divided by the resource limit
Throws:
UnsupportedResourceTypeException

removeSingleInstance

public void removeSingleInstance(EdifCellInstance eci)
                          throws UnsupportedResourceTypeException
This function removes the utilization corresponding to eci from the device utilization count.

Specified by:
removeSingleInstance in interface DeviceUtilizationTracker
Parameters:
eci - Instance to remove from instances list.
Throws:
UnsupportedResourceTypeException

removeSingleInstances

public void removeSingleInstances(java.util.Collection<EdifCellInstance> ecis)
                           throws UnsupportedResourceTypeException
This function removes a collection of instances from the normal list of cell instances. It also removes the utilization corresponding to each eci from the device utilization count.

Specified by:
removeSingleInstances in interface DeviceUtilizationTracker
Parameters:
ecis - Collection of instances to be removed.
Throws:
UnsupportedResourceTypeException

removeNMRInstance

public void removeNMRInstance(EdifCellInstance eci,
                              int replicationFactor)
                       throws UnsupportedResourceTypeException
This function removes the instance eci from the list of instances to be replicated.

Specified by:
removeNMRInstance in interface DeviceUtilizationTracker
Parameters:
eci - Instance to remove from replication list.
replicationFactor - represents the n factor of NMR
Throws:
UnsupportedResourceTypeException

removeNMRInstances

public void removeNMRInstances(java.util.Collection<EdifCellInstance> ecis,
                               int replicationFactor)
                        throws UnsupportedResourceTypeException
This function removes a collection of instances from the list of instances to be replicated.

Specified by:
removeNMRInstances in interface DeviceUtilizationTracker
Parameters:
ecis - Collection of instances to be removed.
replicationFactor - the N factor of NMR
Throws:
UnsupportedResourceTypeException

nmrCell

public void nmrCell(EdifCell cell,
                    int replicationFactor)
             throws OverutilizationEstimatedStopException,
                    OverutilizationHardStopException,
                    UnsupportedResourceTypeException
Specified by:
nmrCell in interface DeviceUtilizationTracker
Throws:
OverutilizationEstimatedStopException
OverutilizationHardStopException
UnsupportedResourceTypeException

nmrInstance

public void nmrInstance(EdifCellInstance eci,
                        int replicationFactor)
                 throws OverutilizationEstimatedStopException,
                        OverutilizationHardStopException,
                        UnsupportedResourceTypeException
This function adds the instance eci to the list of instances to be replicated. It also adds the appropriate utilization to the device utilization count. (The utilization is counted twice to account for the two additional resources required for triplication.)

Specified by:
nmrInstance in interface DeviceUtilizationTracker
Parameters:
eci - Instance to add to triplication list.
replicationFactor - factor of replication for NMR (i/e TMR is 3, DWC is 2, etc.)
Throws:
OverutilizationEstimatedStopException
OverutilizationHardStopException
UnsupportedResourceTypeException

nmrInstancesAtomic

public void nmrInstancesAtomic(java.util.Collection<EdifCellInstance> ecis,
                               int replicationFactor)
                        throws OverutilizationEstimatedStopException,
                               OverutilizationHardStopException,
                               UnsupportedResourceTypeException
Adds all instances in the collection ecis for replication. IMPORTANT: Will only replicate all instances if it can, otherwise it will not replicate any of them.

Specified by:
nmrInstancesAtomic in interface DeviceUtilizationTracker
Parameters:
ecis - Collection of instances to be added for replication.
replicationFactor - N factor for NMR
Throws:
OverutilizationEstimatedStopException
OverutilizationHardStopException
UnsupportedResourceTypeException

nmrInstancesAsManyAsPossible

public void nmrInstancesAsManyAsPossible(java.util.Collection<EdifCellInstance> ecis,
                                         int replicationFactor,
                                         java.util.Collection<EdifCellInstance> actuallyReplicated)
                                  throws OverutilizationEstimatedStopException,
                                         OverutilizationHardStopException,
                                         UnsupportedResourceTypeException
Adds as many instances as it can from the collection ecis for replication, skipping instances which cause estimated stops and/or hard stops. (The logic here is that even if there are hard stops there might be soft logic that could still be added and vice-versa.)

Specified by:
nmrInstancesAsManyAsPossible in interface DeviceUtilizationTracker
Parameters:
ecis - Collection of instances to be added for replication.
replicationFactor - N factor for NMR
Throws:
OverutilizationEstimatedStopException
OverutilizationHardStopException
UnsupportedResourceTypeException

nmrInstances

private void nmrInstances(java.util.Collection<EdifCellInstance> ecis,
                          boolean skipEstimatedStops,
                          boolean skipHardStops,
                          int replicationFactor,
                          java.util.Collection<EdifCellInstance> actuallyReplicated)
                   throws OverutilizationEstimatedStopException,
                          OverutilizationHardStopException,
                          UnsupportedResourceTypeException
Adds the instances in the collection ecis for replication. Optionally will ignore instances which cause estimated stops and/or hard stops.

Parameters:
ecis - Collection of instances to be added for replication.
skipEstimatedStops - boolean flag to optionally ignore estimated stops.
skipHardStops - boolean flag to optionally ignore hard stops.
replicationFactor - the N factor in NMR
Throws:
OverutilizationEstimatedStopException
OverutilizationHardStopException
UnsupportedResourceTypeException

toString

public java.lang.String toString()
Specified by:
toString in interface DeviceUtilizationTracker
Overrides:
toString in class java.lang.Object

addResourceForTracking

protected void addResourceForTracking(java.lang.String resourceType,
                                      double currentUtilization,
                                      int maxUtilization)

_init

protected void _init(EdifCell cell)
              throws OverutilizationEstimatedStopException,
                     OverutilizationHardStopException
Throws:
OverutilizationEstimatedStopException
OverutilizationHardStopException

setDesiredCoverageFactor

protected void setDesiredCoverageFactor(double factorValue)