de.cau.cs.kieler.krep.compiler.ceq
Class Program

java.lang.Object
  extended by de.cau.cs.kieler.krep.compiler.ceq.Program
Direct Known Subclasses:
KlpProgram, ScadeProgram

public class Program
extends Object

CEQ program, eg, a set of CEQ equation and Safe State Machines plus information on inputs and outputs.

Rating yellow
(2010-02-05) review by cmot, msp, tam

Constructor Summary
Program(String n)
          generate empty program.
Program(String n, Program p)
          generate program from an existing one.
 
Method Summary
 void addEq(Equation eq)
           
 void addInput(Variable v)
           
 void addLocal(Variable v)
           
 void addOutput(Variable v)
           
 void addVar(String n, Variable variable)
          Add additional variable to the program.
 void addVar(Variable v)
           
 void destroyTemp(String prefix)
          Remove temporary variables.
 void flatten()
          replace complex expression by temporary computations.
protected  DepGraph getDepGraph()
           
protected  LinkedList<Equation> getEqs()
           
 LinkedList<Variable> getInputs()
           
 String getLabel()
          Generate a unique label.
protected  LinkedList<Variable> getLocals()
           
 int getMax()
           
 String getName()
           
 LinkedList<Variable> getOutputs()
           
protected  LinkedList<Automaton> getSsms()
           
 Variable getTemp(String prefix, Type type)
           
 Variable getVar(String n)
          Generate new variable.
 Variable getVar(String n, Variable.Kind kind, Type type)
          Generate new, unique variable.
protected  HashMap<String,Variable> getVars()
           
 void init()
          initialize program.
 void propagateConst()
          propagate constant values.
 void removeEquiv()
          remove equivalent equations.
 void replace(HashMap<String,Variable> equiv)
           
protected  void setDepGraph(DepGraph dG)
           
protected  void setEqs(LinkedList<Equation> equations)
           
protected  void setInputs(LinkedList<Variable> i)
           
protected  void setLocals(LinkedList<Variable> loc)
           
 void setName(String n)
           
protected  void setOutputs(LinkedList<Variable> outs)
           
protected  void setSsms(LinkedList<Automaton> s)
           
protected  void setVars(HashMap<String,Variable> v)
           
 void simplify()
          simplify all equations by replacing variables that are only read once.
 void staticEval()
          perform static evaluation.
 String toLustre()
           
 String toString()
           
 int wcrt()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Program

public Program(String n)
generate empty program.

Parameters:
n - of the main node

Program

public Program(String n,
               Program p)
generate program from an existing one.

Parameters:
n - name of the new program
p - program to copy.
Method Detail

init

public void init()
initialize program.


flatten

public void flatten()
replace complex expression by temporary computations.


toString

public String toString()
Overrides:
toString in class Object

toLustre

public String toLustre()
Returns:
Lustre code for the program

setName

public void setName(String n)
Parameters:
n - of the program

propagateConst

public void propagateConst()
propagate constant values.


staticEval

public void staticEval()
perform static evaluation.


getName

public String getName()
Returns:
name of the main node

getOutputs

public LinkedList<Variable> getOutputs()
Returns:
outputs of the program

getInputs

public LinkedList<Variable> getInputs()
Returns:
inputs of the program

addVar

public void addVar(Variable v)
Parameters:
v - additional variable

addEq

public void addEq(Equation eq)
Parameters:
eq - additional equation

removeEquiv

public void removeEquiv()
remove equivalent equations.


replace

public void replace(HashMap<String,Variable> equiv)
Parameters:
equiv - list of quivalent variables.

wcrt

public int wcrt()
Returns:
estimated wcrt for this program.

addLocal

public void addLocal(Variable v)
Parameters:
v - new local variable

addOutput

public void addOutput(Variable v)
Parameters:
v - new output variable

addInput

public void addInput(Variable v)
Parameters:
v - new input variable

simplify

public void simplify()
simplify all equations by replacing variables that are only read once. This is in partcular necessary for code that is generated from graphical dataflow models.


setDepGraph

protected void setDepGraph(DepGraph dG)
Parameters:
dG - the dependency graph

getDepGraph

protected DepGraph getDepGraph()
Returns:
the dependency graph

setSsms

protected void setSsms(LinkedList<Automaton> s)
Parameters:
s - the Safe State Machines

getSsms

protected LinkedList<Automaton> getSsms()
Returns:
the Safe State Machines

setEqs

protected void setEqs(LinkedList<Equation> equations)
Parameters:
equations - the CEQ equations

getEqs

protected LinkedList<Equation> getEqs()
Returns:
the CEQ equations

setLocals

protected void setLocals(LinkedList<Variable> loc)
Parameters:
loc - the new local variables

getLocals

protected LinkedList<Variable> getLocals()
Returns:
the local variables

setOutputs

protected void setOutputs(LinkedList<Variable> outs)
Parameters:
outs - the outputs to set

setInputs

protected void setInputs(LinkedList<Variable> i)
Parameters:
i - the inputs to set

setVars

protected void setVars(HashMap<String,Variable> v)
Parameters:
v - the new variables of the program

getVars

protected HashMap<String,Variable> getVars()
Returns:
the variables of the program

getVar

public Variable getVar(String n)
Generate new variable. Implements singleton pattern.

Parameters:
n - name of the variable
Returns:
variable with same name if it exists, new temp variable otherwise

getVar

public Variable getVar(String n,
                       Variable.Kind kind,
                       Type type)
Generate new, unique variable.

Parameters:
n - name of the variable
kind - io kind of the variable
type - type of the variable
Returns:
variable with same name if it exists, new temp variable otherwise

getTemp

public Variable getTemp(String prefix,
                        Type type)
Parameters:
prefix - of the temporary variable
type - of the new variable
Returns:
new temporary variable

destroyTemp

public void destroyTemp(String prefix)
Remove temporary variables.

Parameters:
prefix - prefix of the variables to reset

getMax

public int getMax()
Returns:
number of defined variables

addVar

public void addVar(String n,
                   Variable variable)
Add additional variable to the program.

Parameters:
n - name of the variable
variable - the additional variable.

getLabel

public String getLabel()
Generate a unique label.

Returns:
a unique name for a label