byucc.edif
Class EdifPort

java.lang.Object
  extended bybyucc.edif.NamedPropertyObject
      extended bybyucc.edif.EdifPort
All Implemented Interfaces:
EdifOut, Nameable, Properties, java.io.Serializable

public class EdifPort
extends NamedPropertyObject
implements EdifOut, java.io.Serializable

Represents an Edif port, which belongs to a specific EdifCell. This class specifies a port direction (IN, OUT or INOUT), and a width for support of multi-bit ports.

Note that this object is immutable. Once this object has been created, it cannot be changed.

The purpose of an EdifPort object is to connect a net from the outer level of hierarchy to the inner level of heirarchy.

Sample EDIF code for an EdifPort:

    (cell RAMB4_S2 (cellType GENERIC)
       (view PRIM (viewType NETLIST)
         (interface
           (port (array (rename do "DO[1:0]") 2) (direction OUTPUT))
           (port (array (rename addr "ADDR[10:0]") 11) (direction INPUT))
           (port (array (rename di "DI[1:0]") 2) (direction INPUT))
           (port EN (direction INPUT))
           (port CLK (direction INPUT))
           (port WE (direction INPUT))
           (port RST (direction INPUT))
         )
       )
    )
 

To Do:

Version:
$Id: EdifPort.java,v 1.57 2004/08/27 19:16:42 tsa6 Exp $
Author:
Welson Sun, Mike Wirthlin, Tyler Anderson
See Also:
Serialized Form

Field Summary
(package private)  EdifNet[] _cachedInnerNets
          Inner net: An inner net is the EdifNet array *within* the EdifCell object that are connected to this particular port.
private  int _direction
          The direction of this EdifPort
private  EdifCellInterface _parentInterface
          The EdifCellInterface to which the EdifPort belongs
static int IN
          Constant value representing that the EdifPort direction is IN.
static int INOUT
          Constant value representing that the EdifPort direction is INOUT.
static int OUT
          Constant value representing that the EdifPort direction is OUT.
private  EdifSingleBitPort[] singleBitPorts
           
 
Fields inherited from class byucc.edif.NamedPropertyObject
 
Constructor Summary
EdifPort(EdifCellInterface parent, EdifNameable name, int width, int direction)
          Constructs an EdifPort according to the passed in name, width and direction.
EdifPort(EdifCellInterface parent, java.lang.String name, int width, int direction)
          Constructs an EdifPort according to the passed in name, width and direction.
 
Method Summary
 boolean busMatch(java.util.Collection ports)
           
 boolean busMatch(java.util.Collection ports, boolean ignoreBusDirection)
          This method allows busses to match.
 boolean busMatch(EdifPort port)
           
 boolean busMatch(EdifPort port, boolean ignoreBusDirection)
          This method allows busses to match.
static boolean busMatch(EdifPort bus, java.util.Collection ports)
          Overloaded method defaulting to ignoring direction of the individual ports.
private static boolean busMatch(EdifPort bus, java.util.Collection ports, boolean ignoreBusDirection)
          This method allows busses to match.
 boolean busMatchWithin(java.util.Collection ports)
           
 boolean busMatchWithin(java.util.Collection ports, boolean ignoreBusDirection)
          Returns true if this EdifPort Object contains a bus match with one of the EdifPort Objects in the passed-in Collection.
 void createCachedInnerNets()
          This method will create the array of EdifNet objects.
 boolean equals(EdifPort port)
          This method determines whether the EdifPort object passed in is the same as this EdifPort object.
private static boolean equals(EdifPort port1, EdifPort port2)
          This method determines whether the EdifPort object passed in is the same as the other passed-in EdifPort object.
private static boolean equals(EdifPort port1, EdifPort port2, boolean ignoreDirection)
          This method determines whether the EdifPort object passed in is the same as the other passed-in EdifPort object.
 java.lang.String getBaseName()
           
 int getBitPosition()
           
 EdifCellInterface getCellInterface()
          Returns the EdifCell which this EdifPort belongs to
 int getDirection()
          Returns the EdifPort's direction There are three kinds of directions in this package: IN OUT INOUT
 java.lang.String getDirectionString()
           
 EdifCell getEdifCell()
          Returns the EdifCell that contains this port.
 EdifNet getInnerNet()
          This method will return the EdifNet which connects this one bit wide EdifPort.
 EdifNet getInnerNet(int member)
          This method will return the EdifNet which connects the designated bus member of this EdifPort.
 EdifNet[] getInnerNets()
          This method will return an array of EdifNets, each EdifNet connects the corresponding bus member of this EdifPort( array index = bus member) inside the EdifCell which this EdifPort belongs to.
 int getLSB()
           
 int getMSB()
           
static EdifPort getPortAtPosition(int bitPosition, java.util.Collection ports)
          Returns the EdifPort Object from the passed-in Collection of ports that match the passed-in bitPosition.
 EdifSingleBitPort getSingleBitPort(int i)
           
 int getWidth()
          Returns the EdifPort's width
private  void init(EdifCellInterface parent, int width, int direction)
          Helper function for the constructor.
 void invalidateCachedInnerNets()
          Invalidates cached inner nets.
 boolean isBus()
          Returns true if this port is a bus-port, false otherwise.
 boolean isInOut()
          Check if this port's direction is bidirectional
 boolean isInput()
          Check if this port's direction is input, meaning IN or INOUT
 boolean isInputOnly()
          Check if this port's direction is input only, meaning IN but not INOUT
 boolean isOutput()
          Check if this port's direction is output, meaning OUT or INOUT
 boolean isOutputOnly()
          Check if this port's direction is output only, meaning OUT but not INOUT
 boolean isPartOfBus()
           
static void makeDirectionsMatch(java.util.Collection dontChange, java.util.Collection change)
          Makes the directions of the second collection match the directions in the second collection.
 boolean matchesWithin(java.util.Collection portRefs)
          Returns true if this EdifPort Object equals one of the passed-in collection of EdifPortRef Object's EdifPort.
static int oppositeDirection(int dir)
          Return the opposite direction
 void toEdif(EdifPrintWriter epw)
          Writes the EDIF representation of this EdifPort object to the EdifPrintWriter passed as a parameter.
 java.lang.String toString()
          Returns the string representation of the EdifPort
 
Methods inherited from class byucc.edif.NamedPropertyObject
addProperty, addProperty, equals, equalsProperties, getEdifNameable, getName, getProperty, getPropertyList, rename, rename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IN

public static final int IN
Constant value representing that the EdifPort direction is IN.

See Also:
Constant Field Values

OUT

public static final int OUT
Constant value representing that the EdifPort direction is OUT.

See Also:
Constant Field Values

INOUT

public static final int INOUT
Constant value representing that the EdifPort direction is INOUT.

See Also:
Constant Field Values

_direction

private int _direction
The direction of this EdifPort


singleBitPorts

private EdifSingleBitPort[] singleBitPorts

_parentInterface

private EdifCellInterface _parentInterface
The EdifCellInterface to which the EdifPort belongs


_cachedInnerNets

EdifNet[] _cachedInnerNets
Inner net: An inner net is the EdifNet array *within* the EdifCell object that are connected to this particular port. They are called inner nets because they are "inside" this edif cell (i.e. on the inside side of the port).

An array of EdifNet references, one for each bus member of this EdifPort. Each referenced EdifNet connects to the corresponding EdifPort bus member inside the EdifCell which this EdifPort belongs to.

Note that this information is cached and is a duplication of information already contained in this data structure. The "owner" of this information is the parent EdifCell. The EdifCell contains this information in the list of EdifNets that connect ports within the Cell.

Because this data structure is a duplication, it can potentially be inconsistent with "true" data structure. To account for this, this data structure is "cached" and created only when needed. Whenever the circuit changes, this cached data is invalidated.

TODO: When should this data structure be invalidated?

Who can change EdifPort?

// * @see EdifCellInstance#_cachedOuterNets

Constructor Detail

EdifPort

public EdifPort(EdifCellInterface parent,
                java.lang.String name,
                int width,
                int direction)
Constructs an EdifPort according to the passed in name, width and direction.

Parameters:
parent - The parent of this new EdifPort
name - The name of this Object
width - The width of this EdifPort
direction - The direction of this EdifPort

EdifPort

public EdifPort(EdifCellInterface parent,
                EdifNameable name,
                int width,
                int direction)
Constructs an EdifPort according to the passed in name, width and direction.

Parameters:
parent - The parent of this new EdifPort
name - The Object holding name information for this EdifPort Object
width - The width of this EdifPort
direction - The direction of this EdifPort
Method Detail

init

private void init(EdifCellInterface parent,
                  int width,
                  int direction)
Helper function for the constructor.

Parameters:
parent - The parent of this new EdifPort
width - The width of this EdifPort
direction - The direction of this EdifPort

getSingleBitPort

public EdifSingleBitPort getSingleBitPort(int i)

busMatchWithin

public boolean busMatchWithin(java.util.Collection ports,
                              boolean ignoreBusDirection)
Returns true if this EdifPort Object contains a bus match with one of the EdifPort Objects in the passed-in Collection.

Parameters:
ports - The Collection of ports to find a bus match with
Returns:
True if a bus match exists

busMatchWithin

public boolean busMatchWithin(java.util.Collection ports)

busMatch

public boolean busMatch(EdifPort port,
                        boolean ignoreBusDirection)
This method allows busses to match. Returns true if both ports match, and if one's a bus and the other isn't then all the port objects have the same basename as the bus will be fetched from the single ports parent cell for bus comparison.

Parameters:
port - The EdifPort Object to find a bus match with this one
ignoreBusDirection - If true, the direction of the individual ports will be ignored
Returns:
True if the passed-in port bus-matches with this EdifPort Object
See Also:
busMatch(EdifPort,Collection,boolean)

busMatch

public boolean busMatch(EdifPort port)

busMatch

public boolean busMatch(java.util.Collection ports,
                        boolean ignoreBusDirection)
This method allows busses to match. If this port is not a bus then it cannot be compared as a bus to a collection of ports. If it is a bus then it will be compared to the collection of ports for a match.

Parameters:
ports - A Collection of EdifPort Objects to compare for a bus-match with this EdifPort Object
ignoreBusDirection - If true, the direction of the individual ports will be ignored
Returns:
True if this EdifPort Object bus-matches with the passed-in Collection of EdifPort Objects
See Also:
busMatch(EdifPort,Collection,boolean)

busMatch

public boolean busMatch(java.util.Collection ports)

busMatch

private static boolean busMatch(EdifPort bus,
                                java.util.Collection ports,
                                boolean ignoreBusDirection)
This method allows busses to match. Returns true if the bus has the same width as the # of ports in the collection, and that a wire in the collection of port's bit position maps to each bit in the bus. Each port in the collection must also have the same basename and direction as the bus.

Parameters:
bus - The EdifPort Object to find a bus match with the collection of passed-in EdifPort Objects
ports - A Collection of EdifPort Objects to compare for a bus-match with the passed in bus parameter
ignoreBusDirection - If true, the matching algorithm will ignore the direction of the passed-in ports
Returns:
True if the passed-in bus bus-matches with the passed-in Collection of EdifPort Objects
See Also:
busMatch(EdifPort), busMatch(Collection)

busMatch

public static boolean busMatch(EdifPort bus,
                               java.util.Collection ports)
Overloaded method defaulting to ignoring direction of the individual ports.

Parameters:
bus - The EdifPort Object to find a bus match with the collection of passed-in EdifPort Objects
ports - A Collection of EdifPort Objects to compare for a bus-match with the passed in bus parameter
Returns:
True if the passed-in bus bus-matches with the passed-in Collection of EdifPort Objects
See Also:
busMatch(EdifPort,Collection,boolean)

createCachedInnerNets

public void createCachedInnerNets()
This method will create the array of EdifNet objects. Each element of the array corresponds to one bit of the EdifPort. The EdifNet associated with each port corresponds to the Net that is connected from *within* the cell.


equals

public boolean equals(EdifPort port)
This method determines whether the EdifPort object passed in is the same as this EdifPort object.

Parameters:
port - The EdifPort object to compare for equality with this EdifPort Object
Returns:
True if the passed-in EdifPort Object matches with this one
See Also:
equals(EdifPort,EdifPort)

equals

private static boolean equals(EdifPort port1,
                              EdifPort port2,
                              boolean ignoreDirection)
This method determines whether the EdifPort object passed in is the same as the other passed-in EdifPort object.

This method determines whether the two EdifPort objects are the same. The following criteria are used to make this comparison:

Parameters:
port1 - The first port used for comparison
port2 - The second port used for comparison
ignoreDirection - Specifies whether the port directions during a compare will be ignored or not
Returns:
True if the two ports match each other
See Also:
equals(EdifPort)

equals

private static boolean equals(EdifPort port1,
                              EdifPort port2)
This method determines whether the EdifPort object passed in is the same as the other passed-in EdifPort object.

This method determines whether the two EdifPort objects are the same. The following criteria are used to make this comparison:

Parameters:
port1 - The first port used for comparison
port2 - The second port used for comparison
Returns:
True if the two ports match each other
See Also:
equals(EdifPort,EdifPort,boolean), equals(EdifPort)

getCellInterface

public EdifCellInterface getCellInterface()
Returns the EdifCell which this EdifPort belongs to

Returns:
an EdifCell value representing the EdifCellInterface of this EdifPort Object

getEdifCell

public EdifCell getEdifCell()
Returns the EdifCell that contains this port.

Returns:
An EdifCell that contains this EdifPort in its EdifCellInterface

getInnerNets

public EdifNet[] getInnerNets()
This method will return an array of EdifNets, each EdifNet connects the corresponding bus member of this EdifPort( array index = bus member) inside the EdifCell which this EdifPort belongs to. If this port is a single-bit port, this method will return an array of length one.

Returns:
An array of EdifNet objects representing all the EdifNets that connect to this EdifPort Object

getInnerNet

public EdifNet getInnerNet(int member)
This method will return the EdifNet which connects the designated bus member of this EdifPort. This is offset to zero for busses that begin at values higher than zero.

Parameters:
member - an int representing the index of the EdifNet of this bus
Returns:
an EdifNet representing the EdifNet at the specified index

getInnerNet

public EdifNet getInnerNet()
This method will return the EdifNet which connects this one bit wide EdifPort.

Returns:
an EdifNet value representing the EdifNet Object that this EdifPort is connected to on the inside

getLSB

public int getLSB()
See Also:
EdifBusNameOps.getLSB(byucc.edif.EdifNameable)

getMSB

public int getMSB()
See Also:
EdifBusNameOps.getMSB(byucc.edif.EdifNameable)

getDirection

public int getDirection()
Returns the EdifPort's direction There are three kinds of directions in this package: IN OUT INOUT

Returns:
The direction of the port

getDirectionString

public java.lang.String getDirectionString()

getWidth

public int getWidth()
Returns the EdifPort's width

Returns:
an int representing the width of this EdifPort

getBaseName

public java.lang.String getBaseName()
See Also:
EdifBusNameOps.getBaseName(java.lang.String)

getBitPosition

public int getBitPosition()
See Also:
EdifBusNameOps.getBitPosition(java.lang.String)

getPortAtPosition

public static EdifPort getPortAtPosition(int bitPosition,
                                         java.util.Collection ports)
Returns the EdifPort Object from the passed-in Collection of ports that match the passed-in bitPosition. If no match exists then null is returned.

Parameters:
bitPosition - The bit position is used to find the EdifPort Object to return
ports - The Collection of EdifPort Objects to find one that matches the passed-in bit position
Returns:
An EdifPort Object that has a bit-position that matches the passed-in bitPosition parameter, or null if no match exists

invalidateCachedInnerNets

public void invalidateCachedInnerNets()
Invalidates cached inner nets.


isPartOfBus

public boolean isPartOfBus()
See Also:
EdifBusNameOps.isPartOfBus(java.lang.String)

isBus

public boolean isBus()
Returns true if this port is a bus-port, false otherwise. Equality is done by seeing if singleBitPorts.length > 1.

Returns:
True if this EdifPort Object has a width > 1, meaning that its a bus

isInOut

public boolean isInOut()
Check if this port's direction is bidirectional

Returns:
True if this EdifPort Object is InOut

isInput

public boolean isInput()
Check if this port's direction is input, meaning IN or INOUT

Returns:
True if this EdifPort Object is Input or InOut

isInputOnly

public boolean isInputOnly()
Check if this port's direction is input only, meaning IN but not INOUT

Returns:
True if this EdifPort Object is Input only

isOutput

public boolean isOutput()
Check if this port's direction is output, meaning OUT or INOUT

Returns:
True if this EdifPort Object is Output or InOut

isOutputOnly

public boolean isOutputOnly()
Check if this port's direction is output only, meaning OUT but not INOUT

Returns:
True if this EdifPort Object is Output only

matchesWithin

public boolean matchesWithin(java.util.Collection portRefs)
Returns true if this EdifPort Object equals one of the passed-in collection of EdifPortRef Object's EdifPort. Equality done by '=='.

Parameters:
portRefs - A Collection of EdifPortRef Objects that this EdifPort Object will be compared to in order to determine if a match exists between this EdifPort Object, and an EdifPortRef Object within the Collection
Returns:
True if a match exists between this EdifPort Object and an EdifPortRef Object within the passed-in Collection of EdifPortRef Objects

makeDirectionsMatch

public static void makeDirectionsMatch(java.util.Collection dontChange,
                                       java.util.Collection change)
Makes the directions of the second collection match the directions in the second collection.

Parameters:
dontChange - The Collection whose directions will be standard
change - The Collection whose directions will conform to the first

oppositeDirection

public static int oppositeDirection(int dir)
Return the opposite direction

Parameters:
dir - an int value representing the direction of the EdifPort Object
Returns:
an int value representing the opposite direction of the passed-in dir parameter

toEdif

public void toEdif(EdifPrintWriter epw)
Writes the EDIF representation of this EdifPort object to the EdifPrintWriter passed as a parameter.

Specified by:
toEdif in interface EdifOut
Parameters:
epw - an EdifPrintWriter Object where the EDIF data will be written to

toString

public java.lang.String toString()
Returns the string representation of the EdifPort

Returns:
a String value representing this Object, its direction and inner nets