byucc.jhdl.synth
Class GraphStack

java.lang.Object
  extended bybyucc.jhdl.synth.GraphStack
All Implemented Interfaces:
VirtualMachine

public class GraphStack
extends java.lang.Object
implements VirtualMachine


Constructor Summary
GraphStack(Cell cell)
          Constructs a new GraphStack that will be used to synthesize the given cell
 
Method Summary
 void addBranches(WeightedOpCode[] targets)
          Add branches to the CFGraph for the given WeightedOpCodes.
 DFVertex addConstant(int width, int value)
           
 CFEdge addEdge(CFVertex tail, CFVertex head)
          Add an edge in the control flow graph.
 CFEdge addEdge(CFVertex tail, CFVertex head, java.lang.String weight)
          Add a weighted edge in the control flow graph.
 DFEdge addEdge(DFVertex tail, DFVertex head)
          Add an edge in the dataflow graph.
 DFEdge addEdge(DFVertex tail, DFVertex head, java.lang.String headPort)
          Add an edge in the dataflow graph with the given head port name.
 DFEdge addEdge(DFVertex tail, java.lang.String tailPort, DFVertex head)
          Add an edge in the dataflow graph with the given tail port name.
 DFEdge addEdge(DFVertex tail, java.lang.String tailPort, DFVertex head, java.lang.String headPort)
          Add an edge in the dataflow graph with the given port names.
 DFVertex addOperator(java.lang.String name)
           
 DFVertex addSignal(int width, java.lang.String name)
           
 void createCFAndDFGraphs(MethodInfo method)
          Create the ControlFlowGraph and the DataFlowGraph corresponding to the given method.
 void execute(MethodInfo method)
           
 java.lang.Object getCellFieldValue(java.lang.String name)
          Get the value of a specific field from the current cell being synthesized.
 ControlFlowGraph getCFGraph()
           
 DFVertex getConstant(int width, int value)
           
 MethodInfo getCurrentMethod()
           
 DataFlowGraph getDFGraph()
           
 DFVertex getExistingSignal(java.lang.String name)
          Find a vertex that already exists in the dataflow graph with the given signal name and return it.
 java.lang.Object getLocalVariable(int pc, int i)
           
 DFVertex getSignal(int width, java.lang.String name)
          If a Vertex already exists in the dataflow graph with the given signal name, return it.
 DFVertex getSignal(java.lang.String name, Wire wire)
          If a Vertex already exists in the dataflow graph with the given name and associated with the given Wire, return it.
 void jumpAbsolute(int pc)
           
 void mergeCombinationalBranches()
          For all conditional branches, (if and switch), which don't have sequential statements in their blocks, merge the controlFlow blocks of each branch.
 BasicBlock newBasicBlock(AttributeCode parent, int number)
           
 java.lang.Object peek()
           
 java.lang.Object pop()
           
 java.lang.Object push(java.lang.Object o)
           
 boolean registerWireAssignments()
          Should wire assignments be registered or not.
 void registerWireAssignments(boolean flag)
          Should wire assignments be registered or not.
 void setLocalVariable(java.lang.Object o, int i)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphStack

public GraphStack(Cell cell)
Constructs a new GraphStack that will be used to synthesize the given cell

Parameters:
cell - A cell object which is being synthesized. This cell will be used with the reflection interface to fetch fields whenever getField is called etc. These fields will be used to determine wire widths, etc.
See Also:
getCellFieldValue
Method Detail

getCFGraph

public ControlFlowGraph getCFGraph()

getDFGraph

public DataFlowGraph getDFGraph()

getCellFieldValue

public java.lang.Object getCellFieldValue(java.lang.String name)
Get the value of a specific field from the current cell being synthesized.

Parameters:
name - The name of the field to be retrieved from the current cell being synthesized.

addEdge

public CFEdge addEdge(CFVertex tail,
                      CFVertex head)
Add an edge in the control flow graph.

Parameters:
tail - the tail vertex of the new edge to create, (tail should exist within the control flow graph)
head - the head vertex of the new edge to create (head should exist within the control flow graph)
Returns:
A new edge created in the control flow graph, (from tail to head).

addEdge

public CFEdge addEdge(CFVertex tail,
                      CFVertex head,
                      java.lang.String weight)
Add a weighted edge in the control flow graph.

Parameters:
tail - the tail vertex of the new edge to create, (tail should exist within the control flow graph)
head - the head vertex of the new edge to create (head should exist within the control flow graph)
weight - the weight for the new edge
Returns:
A new edge created in the control flow graph, (from tail to head).

addEdge

public DFEdge addEdge(DFVertex tail,
                      DFVertex head)
Add an edge in the dataflow graph.

Parameters:
tail - the tail vertex of the new edge to create, (tail should exist within the dataflow graph)
head - the head vertex of the new edge to create (head should exist within the dataflow graph)
Returns:
A new edge created in the dataflow graph, (from tail to head).

addEdge

public DFEdge addEdge(DFVertex tail,
                      java.lang.String tailPort,
                      DFVertex head)
Add an edge in the dataflow graph with the given tail port name.

Parameters:
tail - the tail vertex of the new edge to create, (tail should exist within the dataflow graph)
tailPort - the name for the tail port of this edge
head - the head vertex of the new edge to create (head should exist within the dataflow graph)
Returns:
A new edge created in the dataflow graph, (from tail to head).

addEdge

public DFEdge addEdge(DFVertex tail,
                      DFVertex head,
                      java.lang.String headPort)
Add an edge in the dataflow graph with the given head port name.

Parameters:
tail - the tail vertex of the new edge to create, (tail should exist within the dataflow graph)
head - the head vertex of the new edge to create (head should exist within the dataflow graph)
headPort - the name for the head port of this graph
Returns:
A new edge created in the dataflow graph, (from tail to head).

addEdge

public DFEdge addEdge(DFVertex tail,
                      java.lang.String tailPort,
                      DFVertex head,
                      java.lang.String headPort)
Add an edge in the dataflow graph with the given port names.

Parameters:
tail - the tail vertex of the new edge to create, (tail should exist within the dataflow graph)
tailPort - the name for the tail port of this edge
head - the head vertex of the new edge to create (head should exist within the dataflow graph)
headPort - the name for the head port of this graph
Returns:
A new edge created in the dataflow graph, (from tail to head).

addSignal

public DFVertex addSignal(int width,
                          java.lang.String name)

addConstant

public DFVertex addConstant(int width,
                            int value)

addOperator

public DFVertex addOperator(java.lang.String name)

addBranches

public void addBranches(WeightedOpCode[] targets)
Add branches to the CFGraph for the given WeightedOpCodes. This method will insert a decision vertex from the current CFVertex block with weighted edges to the blocks corresponding to the OpCodes within the given WeightedOpCode array.

Parameters:
targets - an array of WeightedOpCodes specifying the possible branch paths, each weighted by the value of the decision signal that would choose that path.

getExistingSignal

public DFVertex getExistingSignal(java.lang.String name)
Find a vertex that already exists in the dataflow graph with the given signal name and return it. Otherwise, we will print a warning message, create a new signal with width 0 and the given signal name and add it to the dataflow graph.

Parameters:
name - the name of the desired signal
Returns:
a pre-existing Vertex in the dataflow graph with the given name, or a new Vertex with the given name.

getSignal

public DFVertex getSignal(java.lang.String name,
                          Wire wire)
If a Vertex already exists in the dataflow graph with the given name and associated with the given Wire, return it. If there is a vertex with the right name but a mismatch of the width or the wire then an exception is thrown. Otherwise, create a new Vertex with that signal name and associate the given wire with it.

Parameters:
name - The name for a signal to lookup in the graph.
wire - A wire to be associated with the named signal. If there is already a signal named name it must be associated with this Wire; if not an exception will be thrown. If there is no existing signal then a new one will be created and will be associated with this wire.
Returns:
a pre-existing Vertex in the dataflow graph associated with the given wire, or a new vertex associated with the given wire.

getSignal

public DFVertex getSignal(int width,
                          java.lang.String name)
If a Vertex already exists in the dataflow graph with the given signal name, return it. Otherwise, create a new Vertex with that signal name and add it to the dataflow graph.

Parameters:
width - the width of the desired signal
name - the name of the desired signal
Returns:
a pre-existing Vertex in the dataflow graph with the given name, or a new Vertex with the given name.

getConstant

public DFVertex getConstant(int width,
                            int value)

pop

public java.lang.Object pop()
Specified by:
pop in interface VirtualMachine

push

public java.lang.Object push(java.lang.Object o)
Specified by:
push in interface VirtualMachine

getLocalVariable

public java.lang.Object getLocalVariable(int pc,
                                         int i)
Specified by:
getLocalVariable in interface VirtualMachine

setLocalVariable

public void setLocalVariable(java.lang.Object o,
                             int i)
Specified by:
setLocalVariable in interface VirtualMachine

getCurrentMethod

public MethodInfo getCurrentMethod()
Specified by:
getCurrentMethod in interface VirtualMachine

newBasicBlock

public BasicBlock newBasicBlock(AttributeCode parent,
                                int number)
Specified by:
newBasicBlock in interface VirtualMachine

jumpAbsolute

public void jumpAbsolute(int pc)
Specified by:
jumpAbsolute in interface VirtualMachine

execute

public void execute(MethodInfo method)
Specified by:
execute in interface VirtualMachine

createCFAndDFGraphs

public void createCFAndDFGraphs(MethodInfo method)
Create the ControlFlowGraph and the DataFlowGraph corresponding to the given method. After this method is complete, you can use GraphStack.getCFGraph or GraphStack.getDFGraph to get the graphs.

Parameters:
method - The method to be analyzed for controlflow and dataflow.

mergeCombinationalBranches

public void mergeCombinationalBranches()
For all conditional branches, (if and switch), which don't have sequential statements in their blocks, merge the controlFlow blocks of each branch. Also, merge the corresponding portions of the DataFlowGraph. In order to merge the DataFlow portions we must insert mux vertices controlled by the decision vertex which is controlling the branch.


peek

public java.lang.Object peek()

registerWireAssignments

public void registerWireAssignments(boolean flag)
Should wire assignments be registered or not. Depending on the semantics of the method being synthesized, (ie clock vs. propagate), assignments to Wire objects may or may not imply the creation of a register. This method should be called to set the current state of affairs.

Parameters:
flag - true if Wire assignments should result in registers, (ala clock), false if no registers should be inferred, (ala propagate).

registerWireAssignments

public boolean registerWireAssignments()
Should wire assignments be registered or not. Depending on the semantics of the method being synthesized, (ie clock vs. propagate), assignments to Wire objects may or may not imply the creation of a register. This method should be called to set the current state of affairs.

Returns:
the current state of affairs as last set by the version of registerWireAssignments that accepts one arguments. The return value is true if Wire assignments should result in register creation, false otherwise.

toString

public java.lang.String toString()


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