byucc.jhdl.synth
Class DFSubGraph

java.lang.Object
  extended bybyucc.jhdl.synth.DFSubGraph

public class DFSubGraph
extends java.lang.Object

An object used to represent a subset of a DataFlowGraph. DFSubGraph will maintain the following data:

DFSubGraph also provides the primary mechanisms for adding and getting constants, signals, decisions, and edges to/from the graph. These operations should go through the subGraph as much as possible rather than directly through the DataFlowGraph. However, at least for now, all remove operations should still go through the actual DataFlowGraph.


Constructor Summary
DFSubGraph(DataFlowGraph parent, java.lang.String name)
          Create a new DFSubGraph under the given DataFlowGraph and with the given name.
 
Method Summary
 DFVertex addAnnotation(java.lang.String name)
          Add a new annotation to this DFSubGraph.
 DFVertex addConstant(int width, int value)
          Add a new constant to the subGraph with the given value, or return a previously existing.
 DFEdge addDFEdge(Vertex tail, java.lang.String tailPort, Vertex head)
          Add a new DFEdge with the given tail port name to the subGraph.
 DFEdge addDFEdge(Vertex tail, java.lang.String tailPort, Vertex head, java.lang.String headPort)
          Add a new DFEdge with the given port names to the subGraph.
 DFEdge addDFEdge(Vertex tail, Vertex head)
          Add a new DFEdge to the subGraph.
 DFEdge addDFEdge(Vertex tail, Vertex head, java.lang.String headPort)
          Add a new DFEdge with the given head port name to the subGraph.
 DFVertex addDFVertex(java.lang.String name)
          Add a new DFVertex to the graph.
 Edge addEdge(Vertex tail, Vertex head)
          Add a new Edge to the subGraph.
 DFVertex addOperator(java.lang.String operation)
          Add a new operator to this DFSubGraph.
 DFVertex addSignal(int width, java.lang.String name)
          Add a new signal to the subGraph with the given name, or return a previously existing one.
 DFVertex addUnsharedConstant(int width, int value)
          Add a new unshared constant to this DFSubGraph.
 DFVertex addUnsharedSignal(int width, java.lang.String name)
          Add a new unshared signal to this DFSubGraph.
 Vertex addVertex(java.lang.String name)
          Add a new Vertex to the graph.
 void connectSourceAndSink()
          Connect the source and sink vertices to all dangling vertices.
 DFVertex findDecisionSignal()
          Find a signal in this subGraph that is named DataFlowGraph.DECISION_VERTEX_NAME.
 DFVertex getConstant(int width, int value)
          Get a constant from the subGraph that has the given value, (null if none exists)
 GenericIterator getInputSignals()
          Get a GenericIterator of all input signals in the subgraph.
 java.lang.String getName()
          Get the name of this subGraph.
 GenericIterator getOutputSignals()
          Get a GenericIterator of all output signals in the subgraph.
 DataFlowGraph getParent()
          Get the parent graph of this subGraph.
 DFVertex getSignal(java.lang.String name)
          Get a signal from the subGraph that has the given name, (null if none exists)
 GenericIterator getSignals()
          Get a GenericIterator of all signals in the subgraph.
 DFVertex getSink()
          Get the sink vertex for this DFSubGraph.
 DFVertex getSource()
          Get the source vertex for this DFSubGraph.
 boolean hasConstant(int width, int value)
          Does this subGraph have a constant with the given width and value.
 boolean hasSignal(java.lang.String name)
          Does this subGraph have a signal with the given name.
 void resolveInputSignalsAndConstants()
          Resolve the state of this subGraph in terms of input signals and constants.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DFSubGraph

public DFSubGraph(DataFlowGraph parent,
                  java.lang.String name)
Create a new DFSubGraph under the given DataFlowGraph and with the given name.

Parameters:
parent - the DataFlowGraph to which this DFSubGraph belongs.
name - the name for the new subGraph.
Method Detail

getParent

public DataFlowGraph getParent()
Get the parent graph of this subGraph.

Returns:
the DataFlowGraph to which this subGraph belongs.

getName

public java.lang.String getName()
Get the name of this subGraph.

Returns:
the name of the subGraph.

getSource

public DFVertex getSource()
Get the source vertex for this DFSubGraph.

Returns:
The Vertex that is the source, (ie. all vertices in the subGraph are reachable from the source).

getSink

public DFVertex getSink()
Get the sink vertex for this DFSubGraph.

Returns:
The Vertex that is the sink, (ie. the source vertex is a vertex that is reachable by all other vertices in the subGraph).

addVertex

public Vertex addVertex(java.lang.String name)
Add a new Vertex to the graph. This method will perform the call to parent.addVertex.

Parameters:
name - The name for the new vertex.
Returns:
a new Vertex added to this DFSubGraph.

addDFVertex

public DFVertex addDFVertex(java.lang.String name)
Add a new DFVertex to the graph. This method will perform the call to parent.addVertex.

Parameters:
name - The name for the new vertex.
Returns:
a new DFVertex added to this DFSubGraph.

addEdge

public Edge addEdge(Vertex tail,
                    Vertex head)
Add a new Edge to the subGraph. This method will perform the call to parent.addEdge.

Parameters:
tail - the tail vertex for the new edge.
head - the head vertex for the new edge.
Returns:
a new Edge in this graph pointing from tail to head.

addDFEdge

public DFEdge addDFEdge(Vertex tail,
                        Vertex head)
Add a new DFEdge to the subGraph. This method will perform the call to parent.addEdge.

Parameters:
tail - the tail vertex for the new edge.
head - the head vertex for the new edge.
Returns:
a new DFEdge in this graph pointing from tail to head.

addDFEdge

public DFEdge addDFEdge(Vertex tail,
                        java.lang.String tailPort,
                        Vertex head)
Add a new DFEdge with the given tail port name to the subGraph.

Parameters:
tail - the tail vertex for the new edge.
tailPort - the name for the port at the tail of the edge.
head - the head vertex for the new edge.
Returns:
a new DFEdge in this graph pointing from tail to head.

addDFEdge

public DFEdge addDFEdge(Vertex tail,
                        Vertex head,
                        java.lang.String headPort)
Add a new DFEdge with the given head port name to the subGraph.

Parameters:
tail - the tail vertex for the new edge.
head - the head vertex for the new edge.
headPort - the name for the port at the head of the edge.
Returns:
a new DFEdge in this graph pointing from tail to head.

addDFEdge

public DFEdge addDFEdge(Vertex tail,
                        java.lang.String tailPort,
                        Vertex head,
                        java.lang.String headPort)
Add a new DFEdge with the given port names to the subGraph.

Parameters:
tail - the tail vertex for the new edge.
tailPort - the name for the port at the tail of the edge.
head - the head vertex for the new edge.
headPort - the name for the port at the head of the edge.
Returns:
a new DFEdge in this graph pointing from tail to head.

hasSignal

public boolean hasSignal(java.lang.String name)
Does this subGraph have a signal with the given name.

Parameters:
name - The name of a signal to look up in the subGraph.
Returns:
true if there exists a signal in the subGraph named name, false otherwise.
See Also:
getSignal(java.lang.String)

hasConstant

public boolean hasConstant(int width,
                           int value)
Does this subGraph have a constant with the given width and value.

Parameters:
width - The width of a constant to look up in the subGraph.
Returns:
true if there exists a constant in the subGraph with value, false otherwise.

getSignal

public DFVertex getSignal(java.lang.String name)
Get a signal from the subGraph that has the given name, (null if none exists)

Parameters:
name - the name of the signal of interest.
Returns:
If there is a signal in the subGraph with the given name, return it. If there is no signal with that name, return null.
See Also:
hasSignal(java.lang.String), addSignal(int, java.lang.String)

getSignals

public GenericIterator getSignals()
Get a GenericIterator of all signals in the subgraph.

Returns:
a GenericIterator containing all signals in the subgraph.

getInputSignals

public GenericIterator getInputSignals()
Get a GenericIterator of all input signals in the subgraph.

Returns:
a GenericIterator containing all input signals in the subgraph.

getOutputSignals

public GenericIterator getOutputSignals()
Get a GenericIterator of all output signals in the subgraph.

Returns:
a GenericIterator containing all output signals in the subgraph.

getConstant

public DFVertex getConstant(int width,
                            int value)
Get a constant from the subGraph that has the given value, (null if none exists)

Parameters:
width - the width of the constant of interest.
value - the value of the constant of interest.
Returns:
If there is a constant in the subGraph with the given value, return it. If there is no constant with that value, return null.
See Also:
hasConstant(int, int), addConstant(int, int)

addSignal

public DFVertex addSignal(int width,
                          java.lang.String name)
Add a new signal to the subGraph with the given name, or return a previously existing one.

Parameters:
width - the width of the signal.
name - the name for the signal.
Returns:
a signal vertex in the subGraph of the given name. This method will find and return a previously existing vertex with the given signal name if one exists. If no vertex named name currently exists, then a new one will be created and returned.
See Also:
DFSubGraph#hasSignal,, addUnsharedSignal(int, java.lang.String)

addConstant

public DFVertex addConstant(int width,
                            int value)
Add a new constant to the subGraph with the given value, or return a previously existing.

Parameters:
width - the width of the constant.
value - the value for the constant.
Returns:
a constant vertex in the subGraph with the given value. This method will find and return a previously existing vertex with the given constant value if one exists. If no vertex with this value currently exists, then a new one will be created and returned.
See Also:
hasConstant(int, int), addUnsharedConstant(int, int)

addUnsharedSignal

public DFVertex addUnsharedSignal(int width,
                                  java.lang.String name)
Add a new unshared signal to this DFSubGraph.

This method creates a new signal DFVertex named name. The behavior of this method is different from addSignal in that addUnsharedSignal will always make a new vertex named name, even if there is already a vertex in the graph with the same name. If you would like to share signal vertices with the same name, use addSignal rather than addUnsharedSignal.

Parameters:
width - the width of the new signal.
name - the name for the new signal.
Returns:
a new signal in the subGraph with the given name, this vertex is guaranteed to be unique from all existing vertices.
See Also:
addSignal(int, java.lang.String)

addUnsharedConstant

public DFVertex addUnsharedConstant(int width,
                                    int value)
Add a new unshared constant to this DFSubGraph.

This method creates a new constant DFVertex with value set to value. The behavior of this method is different from addConstant in that addUnsharedConstant will always make a new vertex with value value, even if there is already a vertex in the graph with the same value. If you would like to share constant vertices with the same value, use addConstant rather than addUnsharedConstant.

Parameters:
width - the width for the new constant.
value - the value for the new constant.
Returns:
a new constant in the subGraph with the given value, this vertex is guaranteed to be unique from all existing vertices.
See Also:
addConstant(int, int)

addOperator

public DFVertex addOperator(java.lang.String operation)
Add a new operator to this DFSubGraph. This method creates a new DFVertex named name and makes it an operator.

Parameters:
operation - the operation performed by the new operator.
Returns:
a new operator in the subGraph named operation.

addAnnotation

public DFVertex addAnnotation(java.lang.String name)
Add a new annotation to this DFSubGraph. This method creates a new DFVertex named name and makes it an annotation.

Parameters:
name - the name for this annotation.
Returns:
a new annotation in the subGraph named name.

connectSourceAndSink

public void connectSourceAndSink()
Connect the source and sink vertices to all dangling vertices. This method will create an edge from source to any vertex in parent that has no input edges. It will also create an edge from every vertex in parent without an ouput edge to sink. Also, delete any vertex that has no input edges and no output edges.


resolveInputSignalsAndConstants

public void resolveInputSignalsAndConstants()
Resolve the state of this subGraph in terms of input signals and constants. This method will find any input signal or constant, (ie. a signal or constant adjacent to source), which is not listed in signalHash or constantHash and will add it to the appropriate hash. Also, any duplicated input signals or constants will be merged.


findDecisionSignal

public DFVertex findDecisionSignal()
Find a signal in this subGraph that is named DataFlowGraph.DECISION_VERTEX_NAME.

Returns:
the decision signal in this subGraph, or null if no signal is named DataFlowGraph.DECISON_VERTEX_NAME


Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.