edu.byu.ece.edif.tools.flatten
Class FlattenedEdifCell

java.lang.Object
  extended by edu.byu.ece.edif.core.NamedPropertyObject
      extended by edu.byu.ece.edif.core.EdifCell
          extended by edu.byu.ece.edif.tools.flatten.FlattenedEdifCell
All Implemented Interfaces:
EdifOut, Properties, Trimable, java.io.Serializable
Direct Known Subclasses:
HalfLatchFlattenedEdifCell

public class FlattenedEdifCell
extends EdifCell

Represents a flattened EdifCell object; that is, an EdifCell with no subcells, composed entirely of primitives. This class will create a new FlattenedEdifCell object during construction that represents a flattened version of the original EdifCell passed into the constructor. This class maintains associations between instances in the flattened cell to the corresponding instances in the original cell by using FlattenedEdifCellInstances which contain references to HierarchicalInstance objects which contain information about the hierarchy of the original cell. A map is also maintained from original EdifNets to their corresponding new EdifNets (more than one original net will map to the same new net).

See Also:
Serialized Form

Field Summary
protected  java.util.Map<HierarchicalNet,EdifNet> _hierarchyNetsToFlatNets
           
protected  HierarchyNaming _naming
          The naming scheme to be used by this flattened cell
protected  java.util.Map<HierarchicalInstance,FlattenedEdifCellInstance> _nodesToFlatInstances
          A mapping from HierarchicalInstance nodes to their counterpart FlattenedEdifCellInstance.
protected  java.util.Set<EdifCell> _noFlatten
           
protected  EdifCell _originalCell
          A reference to the original EdifCell from which the flattened version was created
protected  FlatteningNode _topFlatteningNode
          A reference to the top InstanceNode
 
Fields inherited from class edu.byu.ece.edif.core.EdifCell
serialVersionUID
 
Constructor Summary
  FlattenedEdifCell(EdifCell cell)
          Construct a new FlattenedEdifCell based on the given EdifCell and in the same library, with a default hierarchy naming scheme.
  FlattenedEdifCell(EdifCell cell, HierarchyNaming naming)
          Construct a new FlattenedEdifCell based on the given EdifCell and in the same library, with the given hierarchy naming scheme
  FlattenedEdifCell(EdifCell cell, java.util.Set<EdifCell> noFlatten)
          Construct a new FlattenedEdifCell based on the given EdifCell and in the same library, with a default hierarchy naming scheme.
  FlattenedEdifCell(EdifCell cell, java.lang.String suffix)
          Construct a new FlattenedEdifCell based on the given EdifCell and in the same library, with a default hierarchy naming scheme.
  FlattenedEdifCell(EdifCell cell, java.lang.String suffix, java.util.Set<EdifCell> noFlatten)
          Construct a new FlattenedEdifCell based on the given EdifCell and in the same library, with a default hierarchy naming scheme.
  FlattenedEdifCell(EdifLibrary lib, EdifCell cell, HierarchyNaming naming, java.util.Set<EdifCell> noFlatten)
          Construct a new FlattenedEdifCell based on the given EdifCell and in the given library, with the given hierarchy naming scheme.
  FlattenedEdifCell(EdifLibrary lib, EdifCell cell, java.lang.String suffix, HierarchyNaming naming, java.util.Set<EdifCell> noFlatten)
          Construct a new FlattenedEdifCell based on the given EdifCell and in the given library, with the given hierarchy naming scheme.
protected FlattenedEdifCell(EdifLibrary lib, java.lang.String cellName, EdifCellInterface cellInterface)
          Construct a new, empty FlattenedEdifCell with the given EdifCell as the "original cell" but without any properties, instances, etc.
 
Method Summary
protected  void flatten()
          Execute the flattening process.
 java.util.Set<HierarchicalInstance> getAllHierarchicalInstances()
           
static FlattenedEdifCell getFlatCell(java.lang.String[] args)
          Given an array of command-line argument strings, return a FlattenedEdifCell base on the top cell of the specified file.
 FlattenedEdifCellInstance getFlatInstance(HierarchicalInstance hierarchyNode)
           
 FlattenedEdifCellInstance getFlatInstance(java.lang.String hierarchicalName)
          Given a string representing the full hierarchical name of an original, unflattened instance, get the FlattenedEdifCellInstance that corresponds to it.
 EdifNet getFlatNet(HierarchicalNet hierarchicalNet)
          Given a HierarchicalNet, return the corresponding net in the FlattenedEdifCell
 EdifNet getFlatNet(java.lang.String hierarchicalName)
          Given the original hierarchical name of a net, return the corresponding net in the FlattenedEdifCell.
 HierarchicalInstance getHierarchicalInstance(java.lang.String hierarchicalName)
          Given a string representing the full hierarchical name of an original, unflattened instance, get the HierarchicalInstance node that corresponds to it.
 HierarchicalNet getHierarchicalNet(java.lang.String hierarchicalName)
          Given the original hierarchical name of a net, return the corresponding HierarchicalNet.
 HierarchyNaming getHierarchyNaming()
           
 java.util.Map<HierarchicalInstance,FlattenedEdifCellInstance> getInstanceHierarchyMap()
           
 java.util.Collection<FlattenedEdifCellInstance> getInstancesWithin(java.lang.String hierarchicalName)
          Given a string representing the full hierarchical name of an instance from the original EdifCell, get a Collection of FlattenedEdifCellInstances that are leaf instances that would be "within" the given original instance.
 java.util.Collection<FlattenedEdifCellInstance> getInstancesWithinCellTypes(java.util.Collection<java.lang.String> cellTypes)
          Given a Collection of Strings representing cell types, get a Collection of all instances that would have fallen within any instance of the given types.
protected  java.util.Collection<FlattenedEdifCellInstance> getInstancesWithinNode(HierarchicalInstance instanceNode)
          Given a HierarchicalInstance node, get a Collection of FlattenedEdifCellInstances that are leaf instances that would be "within" the original instance associated with the node.
 java.util.Map<HierarchicalNet,EdifNet> getNetHierarchyMap()
           
 EdifCell getOriginalCell()
           
 FlatteningNode getTopFlatteningNode()
           
 HierarchicalInstance getTopInstanceNode()
           
static void main(java.lang.String[] args)
           
protected  java.util.Collection<FlatteningNode> processSubCells(java.util.Map<EdifCellInstance,FlatteningNode> oldInstanceToFlatteningNode, java.util.Map<EdifCellInstance,EdifCellInstance> oldToNewInstances, FlatteningNode currentNode)
          Process the subCells in the current cell being traversed.
 
Methods inherited from class edu.byu.ece.edif.core.EdifCell
addBlackBoxResource, addNet, addPort, addPort, addPortUniqueName, addPortUniqueName, addSubCell, addSubCellUniqueName, cellInstanceIterator, contains, contains, contains, copyCellInternals, deleteNet, deletePort, deleteSubCell, deleteSubCell, equalsInterface, equalsName, findCellInstancesOf, getBlackBoxResources, getCellInstance, getCellInstanceList, getDanglingNets, getDanglingNets, getHierarchicalPrimitiveList, getInnerCells, getInputPorts, getInstance, getInstancedCellTypes, getInstancePortNet, getInterface, getLibrary, getMatchingPort, getNet, getNetList, getOutputPorts, getPort, getPortList, getPortRefs, getSafeCellInstanceList, getSortedNetList, getSortedPortList, getSortedPropertyList, getSortedSubCellList, getSubCellList, getUnconnectedInnerPorts, getUnconnectedInstances, getUnconnectedOuterPorts, getUniqueInstanceNameable, getUniqueInstanceNameable, getUniqueNetNameable, getUniqueNetNameable, isBlackBox, isFlat, isLeafCell, isPrimitive, modifyCellType, netListIterator, setInterface, setPrimitive, tagAsPrimitive, toEdif, toString, trimToSize
 
Methods inherited from class edu.byu.ece.edif.core.NamedPropertyObject
addProperty, addProperty, addPropertyList, copyProperties, equals, equalsProperties, getEdifNameable, getName, getOldName, getProperty, getPropertyList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_nodesToFlatInstances

protected java.util.Map<HierarchicalInstance,FlattenedEdifCellInstance> _nodesToFlatInstances
A mapping from HierarchicalInstance nodes to their counterpart FlattenedEdifCellInstance. Not all nodes will be mapped because not all instances in the original cell are instances of leaf cells


_hierarchyNetsToFlatNets

protected java.util.Map<HierarchicalNet,EdifNet> _hierarchyNetsToFlatNets

_naming

protected HierarchyNaming _naming
The naming scheme to be used by this flattened cell


_originalCell

protected EdifCell _originalCell
A reference to the original EdifCell from which the flattened version was created


_topFlatteningNode

protected FlatteningNode _topFlatteningNode
A reference to the top InstanceNode


_noFlatten

protected java.util.Set<EdifCell> _noFlatten
Constructor Detail

FlattenedEdifCell

public FlattenedEdifCell(EdifCell cell)
                  throws EdifNameConflictException,
                         InvalidEdifNameException
Construct a new FlattenedEdifCell based on the given EdifCell and in the same library, with a default hierarchy naming scheme.

Throws:
InvalidEdifNameException
EdifNameConflictException

FlattenedEdifCell

public FlattenedEdifCell(EdifCell cell,
                         java.util.Set<EdifCell> noFlatten)
                  throws EdifNameConflictException,
                         InvalidEdifNameException
Construct a new FlattenedEdifCell based on the given EdifCell and in the same library, with a default hierarchy naming scheme. Do not flatten cells in the provided set.

Throws:
InvalidEdifNameException
EdifNameConflictException

FlattenedEdifCell

public FlattenedEdifCell(EdifCell cell,
                         java.lang.String suffix)
                  throws EdifNameConflictException,
                         InvalidEdifNameException
Construct a new FlattenedEdifCell based on the given EdifCell and in the same library, with a default hierarchy naming scheme.

Throws:
InvalidEdifNameException
EdifNameConflictException

FlattenedEdifCell

public FlattenedEdifCell(EdifCell cell,
                         java.lang.String suffix,
                         java.util.Set<EdifCell> noFlatten)
                  throws EdifNameConflictException,
                         InvalidEdifNameException
Construct a new FlattenedEdifCell based on the given EdifCell and in the same library, with a default hierarchy naming scheme. Do not flatten cells in the provided set.

Throws:
InvalidEdifNameException
EdifNameConflictException

FlattenedEdifCell

public FlattenedEdifCell(EdifCell cell,
                         HierarchyNaming naming)
                  throws EdifNameConflictException,
                         InvalidEdifNameException
Construct a new FlattenedEdifCell based on the given EdifCell and in the same library, with the given hierarchy naming scheme

Parameters:
cell - the EdifCell to flatten
naming - the HierarchyNaming scheme to use
Throws:
EdifNameConflictException
InvalidEdifNameException

FlattenedEdifCell

public FlattenedEdifCell(EdifLibrary lib,
                         EdifCell cell,
                         HierarchyNaming naming,
                         java.util.Set<EdifCell> noFlatten)
                  throws EdifNameConflictException,
                         InvalidEdifNameException
Construct a new FlattenedEdifCell based on the given EdifCell and in the given library, with the given hierarchy naming scheme. Do not flatten cells in the provided set.

Parameters:
lib - the library to construct the FlattenedEdifCell in
cell - the EdifCell to flatten
naming - the HierarchyNaming scheme to use
Throws:
EdifNameConflictException
InvalidEdifNameException

FlattenedEdifCell

public FlattenedEdifCell(EdifLibrary lib,
                         EdifCell cell,
                         java.lang.String suffix,
                         HierarchyNaming naming,
                         java.util.Set<EdifCell> noFlatten)
                  throws EdifNameConflictException,
                         InvalidEdifNameException
Construct a new FlattenedEdifCell based on the given EdifCell and in the given library, with the given hierarchy naming scheme. Do not flatten cells in the provided set.

Parameters:
lib - the library to construct the FlattenedEdifCell in
cell - the EdifCell to flatten
naming - the HierarchyNaming scheme to use
Throws:
EdifNameConflictException
InvalidEdifNameException

FlattenedEdifCell

protected FlattenedEdifCell(EdifLibrary lib,
                            java.lang.String cellName,
                            EdifCellInterface cellInterface)
                     throws EdifNameConflictException,
                            InvalidEdifNameException
Construct a new, empty FlattenedEdifCell with the given EdifCell as the "original cell" but without any properties, instances, etc. copied and in the given library, and without any of the internal. This constructor should only be used in conjunction with a subclass which fills in the missing information.

Parameters:
lib - the library to construct the FlattenedEdifCell in
cellName - the name of the new EdifCell to create
cellInterface - The Interface of the cell to be created
Throws:
EdifNameConflictException
InvalidEdifNameException
Method Detail

getAllHierarchicalInstances

public java.util.Set<HierarchicalInstance> getAllHierarchicalInstances()
Returns:
the Set of all HierarchicalInstance nodes in the flat cell

getFlatCell

public static FlattenedEdifCell getFlatCell(java.lang.String[] args)
Given an array of command-line argument strings, return a FlattenedEdifCell base on the top cell of the specified file.

Returns:
a FlattenedEdifCell based on the top cell of the specified file

getFlatInstance

public FlattenedEdifCellInstance getFlatInstance(HierarchicalInstance hierarchyNode)
Returns:
the FlattenedEdifCellInstance which corresponds to the given HierarchicalInstance

getFlatInstance

public FlattenedEdifCellInstance getFlatInstance(java.lang.String hierarchicalName)
Given a string representing the full hierarchical name of an original, unflattened instance, get the FlattenedEdifCellInstance that corresponds to it.

Returns:
the FlattenedEdifCellInstance which corresponds to the given full hierarchical name

getHierarchicalInstance

public HierarchicalInstance getHierarchicalInstance(java.lang.String hierarchicalName)
Given a string representing the full hierarchical name of an original, unflattened instance, get the HierarchicalInstance node that corresponds to it.

Parameters:
hierarchicalName - the full hierarchical name of the original instance
Returns:
the HierarchicalInstance node that corresponds to the given name

getFlatNet

public EdifNet getFlatNet(HierarchicalNet hierarchicalNet)
Given a HierarchicalNet, return the corresponding net in the FlattenedEdifCell

Parameters:
hierarchicalNet -

getFlatNet

public EdifNet getFlatNet(java.lang.String hierarchicalName)
Given the original hierarchical name of a net, return the corresponding net in the FlattenedEdifCell.

Parameters:
hierarchicalName -

getHierarchicalNet

public HierarchicalNet getHierarchicalNet(java.lang.String hierarchicalName)
Given the original hierarchical name of a net, return the corresponding HierarchicalNet.

Parameters:
hierarchicalName -

getHierarchyNaming

public HierarchyNaming getHierarchyNaming()
Returns:
the HierarchyNaming scheme used by this FlattenedEdifCell

getInstancesWithin

public java.util.Collection<FlattenedEdifCellInstance> getInstancesWithin(java.lang.String hierarchicalName)
Given a string representing the full hierarchical name of an instance from the original EdifCell, get a Collection of FlattenedEdifCellInstances that are leaf instances that would be "within" the given original instance.

Parameters:
hierarchicalName - a String representing the full hierarchical name of the original instance
Returns:
a Collection of FlattenedEdifCellInstances that correspond to original instances "within" the given instance

getInstancesWithinCellTypes

public java.util.Collection<FlattenedEdifCellInstance> getInstancesWithinCellTypes(java.util.Collection<java.lang.String> cellTypes)
Given a Collection of Strings representing cell types, get a Collection of all instances that would have fallen within any instance of the given types.

Parameters:
cellTypes - a Collection of String representing cell types in the original cell
Returns:
a Collection of FlattenedEdifCellInstances that would have fallen within any instance of the given types.

getOriginalCell

public EdifCell getOriginalCell()
Returns:
a reference to the original, unflattened EdifCell

getTopInstanceNode

public HierarchicalInstance getTopInstanceNode()
Returns:
a reference to the top node of the HierarchicalInstance node hierarchy

getTopFlatteningNode

public FlatteningNode getTopFlatteningNode()

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Parameters:
args - command-line arguments -- first specify the input file; then, use -o for output file, -L to include a search directory, and -f to explicity include an edif file (for black box merging).
Throws:
java.io.IOException

flatten

protected void flatten()
Execute the flattening process. This method fills in this cell with the flattened contents of the original cell.


getInstancesWithinNode

protected java.util.Collection<FlattenedEdifCellInstance> getInstancesWithinNode(HierarchicalInstance instanceNode)
Given a HierarchicalInstance node, get a Collection of FlattenedEdifCellInstances that are leaf instances that would be "within" the original instance associated with the node.

Parameters:
instanceNode - the HierarchicalInstance node corresponding to an original instance
Returns:
a Collection of FlattenedEdifCellInstances that correspond to original instances "within" the instance associated with the given HierarchicalInstance node

processSubCells

protected java.util.Collection<FlatteningNode> processSubCells(java.util.Map<EdifCellInstance,FlatteningNode> oldInstanceToFlatteningNode,
                                                               java.util.Map<EdifCellInstance,EdifCellInstance> oldToNewInstances,
                                                               FlatteningNode currentNode)
Process the subCells in the current cell being traversed. Clone any leaf cells encountered and return other cells in a collection to be added to the traversal list. Add map entries from old instances to InstanceNodes and from old instances to new instances.

Parameters:
oldInstanceToFlatteningNode - map for entries from old instances to InstanceNodes
oldToNewInstances - map for entries from old instances to new instances
currentNode - the node whose contents are being processed
Returns:
a Collection of InstanceNodes to be added to the traversal list

getInstanceHierarchyMap

public java.util.Map<HierarchicalInstance,FlattenedEdifCellInstance> getInstanceHierarchyMap()

getNetHierarchyMap

public java.util.Map<HierarchicalNet,EdifNet> getNetHierarchyMap()