edu.byu.ece.edif.core
Class EdifPort

java.lang.Object
  extended by edu.byu.ece.edif.core.NamedPropertyObject
      extended by edu.byu.ece.edif.core.EdifPort
All Implemented Interfaces:
EdifOut, Properties, java.io.Serializable

public class EdifPort
extends NamedPropertyObject
implements EdifOut

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 hierarchy.

Because ports in EDIF can represent both single and multiple bits, this class represents the port as a collection of EdifSingleBitPort objects. A distinct object is created for each bit of the port.

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))
  )
  )
  )
 

Version:
$Id:EdifPort.java 198 2008-04-16 21:14:21Z jamesfcarroll $
See Also:
Serialized Form

Field Summary
private  int _direction
          The direction of this EdifPort
private  EdifCellInterface _parentInterface
          The EdifCellInterface to which the EdifPort belongs
private  EdifSingleBitPort[] _singleBitPorts
          The array of single bit ports that make up this port object.
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.
 
Constructor Summary
EdifPort(EdifCellInterface parent, EdifNameable name, int width, int direction)
          Construct an EdifPort according to the passed in name, width and direction.
EdifPort(EdifCellInterface parent, java.lang.String name, int width, int direction)
          Construct an EdifPort according to the passed in name, width and direction.
 
Method Summary
private  void _init(EdifCellInterface parent, int width, int direction)
          Helper function for the constructor.
(package private)  int compareTo(EdifPort port)
          This method is needed to use a TreeSet of EdifPort 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.
 EdifCellInterface getCellInterface()
          Return the EdifCell which this EdifPort belongs to.
 int getDirection()
          Return the EdifPort's direction There are three kinds of directions in this package: IN OUT INOUT
 java.lang.String getDirectionString()
           
 EdifCell getEdifCell()
          Return the EdifCell that contains this port.
 EdifSingleBitPort getSingleBitPort(int i)
          Returns the EdifSingleBitPort object associated with bit i of this port.
 java.util.List<EdifSingleBitPort> getSingleBitPortList()
           
 int getWidth()
          Return the width of this EdifPort.
 boolean isBus()
          Return 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 isInput(boolean tristate)
          Determine whether this port is an input.
 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 isOutput(boolean tristate)
          Determine whether this port is an output.
 boolean isOutputOnly()
          Check if this port's direction is output only, meaning OUT but not INOUT
 void toEdif(EdifPrintWriter epw)
          Write the EDIF representation of this EdifPort object to the EdifPrintWriter passed as a parameter.
 java.lang.String toString()
          Return the string representation of the EdifPort
 
Methods inherited from class edu.byu.ece.edif.core.NamedPropertyObject
addProperty, addProperty, addPropertyList, copyProperties, equals, equalsProperties, getEdifNameable, getName, getOldName, getProperty, getPropertyList, rename, 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


_parentInterface

private EdifCellInterface _parentInterface
The EdifCellInterface to which the EdifPort belongs


_singleBitPorts

private EdifSingleBitPort[] _singleBitPorts
The array of single bit ports that make up this port object.

Constructor Detail

EdifPort

public EdifPort(EdifCellInterface parent,
                java.lang.String name,
                int width,
                int direction)
         throws InvalidEdifNameException
Construct 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
Throws:
InvalidEdifNameException

EdifPort

public EdifPort(EdifCellInterface parent,
                EdifNameable name,
                int width,
                int direction)
Construct 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

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

getCellInterface

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

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

getDirection

public int getDirection()
Return 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()

getEdifCell

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

Returns:
An EdifCell that contains this EdifPort in its EdifCellInterface

getSingleBitPort

public EdifSingleBitPort getSingleBitPort(int i)
Returns the EdifSingleBitPort object associated with bit i of this port. If i < 0 or greater than the maximum number of ports, this method will return null.

Parameters:
i - Bit index of port.
Returns:
The EdifSingleBitPort object associated with bit i of this port.

getSingleBitPortList

public java.util.List<EdifSingleBitPort> getSingleBitPortList()
Returns:
A List of all the EdifSingleBitPort objects associated with this EdifPort.

getWidth

public int getWidth()
Return the width of this EdifPort.

Returns:
an int representing the width of this EdifPort

isBus

public boolean isBus()
Return 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

isInput

public boolean isInput(boolean tristate)
Determine whether this port is an input. This method uses a tristate flag to indicate how to handle the tristate or INOUT condition.

Parameters:
tristate - Indicates that a tri-state port (INOUT) should be considered as an input. If false, this method will return false for ports that are tri-state (INOUT).
Returns:
true if the port is considered an input

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

isOutput

public boolean isOutput(boolean tristate)
Determine whether this port is an output. This method uses a tristate flag to indicate how to handle the tristate or INOUT condition.

Parameters:
tristate - Indicates that a tri-state port (INOUT) should be considered as an output. If false, this method will return false for ports that are tri-state (INOUT).
Returns:
true if the above

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

toEdif

public void toEdif(EdifPrintWriter epw)
Write 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()
Return the string representation of the EdifPort

Overrides:
toString in class java.lang.Object
Returns:
a String value representing this Object, its direction and inner nets

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)

_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

compareTo

int compareTo(EdifPort port)
This method is needed to use a TreeSet of EdifPort objects. In order to use a TreeSet, the Object must be "consistent with equals" meaning ... a class C is said to be "consistent with equals" if and only if (e1.compareTo((Object)e2) == 0) has the same boolean value as e1.equals((Object)e2) for every e1 and e2 of class C The comparison, or sorting for this object for now is going to just be based on the string representation of its name. To enforce "consistent with equals", the method will return 0 if the two objects are equal according to the equals method.

Parameters:
port -
Returns:
the output generated by compareTo(String)