mapss.dif.csdf
Class CSDFGraph

java.lang.Object
  extended by mocgraph.Graph
      extended by mocgraph.DirectedGraph
          extended by mapss.dif.DIFGraph
              extended by mapss.dif.csdf.CSDFGraph
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BCSDFGraph, SDFGraph

public class CSDFGraph
extends DIFGraph

Information associated with an CSDF graph. This class caches frequently-used data associated with CSDF graphs. It is also useful for intermediate CSDF graph representations that do not correspond to Ptolemy II models, and performing graph transformations (e.g. convertion to and manipulation of single-rate graphs). It is intended for use with analysis/synthesis algorithms that operate on generic graph representations of CSDF models.

CSDFGraph nodes and edges have weights of type CSDFNodeWeight and \ CSDFEdgeWeight, respectively.

The repetition vector computed in this class is the minimal integer solution of the topology matrix. Which is different from the repetition vector defined in the "Cyclo-static Dataflow" paper by G. Bilsen, M. Engels, R. Lauwereins, and J. Peperstraete. The repetition vector defined in that paper is the "phase" repetition vector.

Version:
$Id: CSDFGraph.java 406 2007-05-10 14:27:07Z plishker $
Author:
Chia-Jui Hsu, Michael Rinehart, Ming-Yung Ko, Shuvra S. Bhattacharyya
See Also:
CSDFEdgeWeight, CSDFNodeWeight

Constructor Summary
CSDFGraph()
          Construct an empty CSDF graph.
CSDFGraph(int nodeCount)
          Construct an empty CSDF graph with enough storage allocated for the specified number of nodes.
CSDFGraph(int nodeCount, int edgeCount)
          Construct an empty CSDF graph with enough storage allocated for the specified number of edges, and number of nodes.
 
Method Summary
protected  java.util.HashMap _checkPeriods()
          Computes and checks periods of nodes.
protected  int _getPeriod(mocgraph.Node node)
          Get the period of a CSDF node.
protected  java.util.HashMap _getRepetitionsMap(ptolemy.actor.CompositeActor compositeActor)
          Compute the repetitions vector assuming that this CSDF graph has been converted from a Ptolemy II SDF model.
 boolean checkRepetitions(mocgraph.Node node)
          Check node's repetitions.
 java.util.HashMap computeRepetitions()
          Compute repetitions vector for a given CSDF graph.
 int getRepetitions(mocgraph.Node node)
          Get the repetition count of a given CSDF node in this graph.
 boolean removeNode(mocgraph.Node node)
          Remove a node from the CSDF graph.
 void setRepetitions(mocgraph.Node node, int count)
          Set repetition counts for a node.
 boolean validEdgeWeight(java.lang.Object weight)
          Verify edge weight for CSDF graph.
 boolean validNodeWeight(java.lang.Object weight)
          Verify node weight for CSDF graph.
 
Methods inherited from class mapss.dif.DIFGraph
_getAttributeContainer, _registerEdge, _registerNode, _removeAttributeContainer, _removeReferenceFromAttributes, _setAttributeContainer, addEdge, addEdge, equals, getAttribute, getAttribute, getAttributeByContent, getAttributeByContent, getAttributeDescriptions, getAttributeDescriptions, getAttributeNames, getAttributeNames, getAttributes, getAttributes, getAttributesByContent, getAttributesByContent, getEdge, getName, getName, getNode, getObject, getParameter, getParameterNames, getParameters, hashCode, hideEdge, mergeGraph, mirror, mirror, removeAllAttributes, removeAllAttributes, removeAttribute, removeAttribute, removeAttribute, removeAttribute, removeEdge, removeParameter, restoreEdge, setAttribute, setAttribute, setName, setName, setParameter, subgraph, subgraph
 
Methods inherited from class mocgraph.DirectedGraph
_connect, _connectedSubGraph, _disconnect, _initializeAnalyses, backwardReachableNodes, backwardReachableNodes, backwardReachableNodes, backwardReachableNodes, cycleNodeCollection, cycleNodes, edgeExists, edgeExists, inputEdgeCount, inputEdges, isAcyclic, outputEdgeCount, outputEdges, predecessorEdges, predecessors, reachableNodes, reachableNodes, reachableNodes, reachableNodes, sccDecomposition, selfLoopEdgeCount, sinkNodeCount, sinkNodes, sourceNodeCount, sourceNodes, subgraphs, successorEdges, successors, toDirectedAcyclicGraph, topologicalSort, topologicalSort, transitiveClosure
 
Methods inherited from class mocgraph.Graph
_addEdge, _connectEdge, _disconnectEdge, _emptyGraph, _registerChange, addAnalysis, addEdge, addEdge, addEdge, addEdges, addGraph, addNode, addNode, addNodes, addNodeWeight, addNodeWeights, changeCount, clone, cloneAs, connectedComponents, containsEdge, containsEdgeWeight, containsNode, containsNodeWeight, edge, edge, edgeCount, edgeLabel, edgeLabel, edges, edges, edges, edgeWeight, hidden, hiddenEdgeCount, hiddenEdges, incidentEdgeCount, incidentEdges, neighborEdges, neighbors, node, node, nodeCount, nodeLabel, nodeLabel, nodes, nodes, nodes, nodeWeight, selfLoopEdgeCount, selfLoopEdges, selfLoopEdges, toString, validateWeight, validateWeight, validateWeight, validateWeight, weightArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CSDFGraph

public CSDFGraph()
Construct an empty CSDF graph.


CSDFGraph

public CSDFGraph(int nodeCount)
Construct an empty CSDF graph with enough storage allocated for the specified number of nodes.

Parameters:
nodeCount - The number of nodes.

CSDFGraph

public CSDFGraph(int nodeCount,
                 int edgeCount)
Construct an empty CSDF graph with enough storage allocated for the specified number of edges, and number of nodes.

Parameters:
nodeCount - The integer specifying the number of nodes
edgeCount - The integer specifying the number of edges
Method Detail

checkRepetitions

public boolean checkRepetitions(mocgraph.Node node)
Check node's repetitions. Return true if the repetitions have been evaluated, otherwise false. This method is created to cooperate new node addition.

Parameters:
node - The given node
Returns:
true if repetitions evaluated, false otherwise

computeRepetitions

public java.util.HashMap computeRepetitions()
Compute repetitions vector for a given CSDF graph. The repetitions will be returned as a HashMap, with Node as the key(s) and Integer as the repetition value(s).

Returns:
A HashMap (node - repetition)

getRepetitions

public int getRepetitions(mocgraph.Node node)
Get the repetition count of a given CSDF node in this graph. If the repetitions value has not yet been computed, then first compute the repetitions vector for the entire graph.

Parameters:
node - The CSDF node.
Returns:
The repetition count.

removeNode

public boolean removeNode(mocgraph.Node node)
Remove a node from the CSDF graph. This method overrides removeNode() in Graph. Besides removing node from graph, it removes the entry of repetitions map.

Overrides:
removeNode in class DIFGraph
Parameters:
node - The node to remove
Returns:
True if the node was removed.

setRepetitions

public void setRepetitions(mocgraph.Node node,
                           int count)
Set repetition counts for a node. Sample rate consistency will be checked. Therefore, proper sample rates should be assigned before calling this method.

Parameters:
node - The given node
count - The given repetition counts
Throws:
java.lang.IllegalArgumentException - If the node is not contained in the graph.
java.lang.RuntimeException - Graph not connected
java.lang.RuntimeException - Inconsistent sample rates

validEdgeWeight

public boolean validEdgeWeight(java.lang.Object weight)
Verify edge weight for CSDF graph.

Overrides:
validEdgeWeight in class DIFGraph
Parameters:
weight - The edge weight to verify.
Returns:
True if the given edge weight is valid for CSDF graph.

validNodeWeight

public boolean validNodeWeight(java.lang.Object weight)
Verify node weight for CSDF graph.

Overrides:
validNodeWeight in class DIFGraph
Parameters:
weight - The node weight to verify.
Returns:
True if the given node weight is valid for CSDF graph.

_checkPeriods

protected java.util.HashMap _checkPeriods()
Computes and checks periods of nodes. If the edges connected to a node with different periods, this function throws an exception.

Returns:
A HashMap (node - period)

_getPeriod

protected int _getPeriod(mocgraph.Node node)
Get the period of a CSDF node.


_getRepetitionsMap

protected java.util.HashMap _getRepetitionsMap(ptolemy.actor.CompositeActor compositeActor)
Compute the repetitions vector assuming that this CSDF graph has been converted from a Ptolemy II SDF model. The repetitions vector is returned in the form of a HashMap. The keys in the map are Nodes of the CSDFGraph, and the values are Integer representations of the associated repetitions vector values.

Parameters:
compositeActor - The Ptolemy II representation of the CSDF graph.
Returns:
The repetitions vector in the form of a HashMap.