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

java.lang.Object
  extended by de.cau.cs.kieler.krep.compiler.ceq.Equation

public class Equation
extends Object

A clocked equation, consisting of a name, a initial expression, a runtime expression, and a clock.

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

Constructor Summary
Equation(String id, Expression expr)
          generate Equation without initializer which runs on the base clock.
Equation(String id, Expression i, Expression e, String clk)
          Construct a new clocked equation.
 
Method Summary
 LinkedList<Equation> flatten(HashMap<String,Variable> vars)
          Replace complex expressions in the init expression and introduce auxiliary equations if necessary.
 String getClock()
           
 List<Variable> getDeps()
          compute List of all variables, on which current value the expression depends.
 Expression getExpr()
           
 Expression getInit()
           
 String getName()
           
 List<String> getPDeps()
           
 int getPrio()
           
 Type getType()
           
 boolean hasClock()
           
 boolean isClock()
           
 ConstExpression propagateConst(HashMap<String,ConstExpression> con)
           
 boolean replace(Equation eq)
           
 void replaceVar(HashMap<String,Variable> equiv)
           
 void setClock(String clk)
           
 void setExpr(Expression expr)
           
 void setInit(Expression init)
           
 void setName(String n)
           
 void setPrio(int pr)
           
 void staticEval()
          static evaluation.
 LinkedList<AbstractInstruction> toKlp(boolean useClocks, String scope, HashMap<String,Variable> vars)
          generate KLP code to compute this equation.
 String toString()
          Show the equation in Lustre format: v=init -> current(e when c).
 int wcrt()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Equation

public Equation(String id,
                Expression i,
                Expression e,
                String clk)
Construct a new clocked equation.

Parameters:
id - name of the value that is computed
i - expression to compute the initial value
e - expression to compute the value during runtim
clk - the clock on which the equation is evaluated

Equation

public Equation(String id,
                Expression expr)
generate Equation without initializer which runs on the base clock.

Parameters:
id - name of the equation
expr - expres * @kieler.rating 2010-02-05 yellow review by cmot, msp, tamsion to compute the equation.
Method Detail

toString

public String toString()
Show the equation in Lustre format: v=init -> current(e when c).

Overrides:
toString in class Object
Returns:
Lustre equation for the clocked equation.

isClock

public boolean isClock()
Returns:
true if this expression computes a clock, ie, a boolean stream

getDeps

public List<Variable> getDeps()
compute List of all variables, on which current value the expression depends. This is the same as getVars without the variables which pre value is used.

Returns:
list of variables this expression depends on

getName

public String getName()
Returns:
name of the value that is computed

getInit

public Expression getInit()
Returns:
expression to initialize the equation

setName

public void setName(String n)
Parameters:
n - name of the variable that is computed by this equation

getClock

public String getClock()
Returns:
clock on which this equation runs

hasClock

public boolean hasClock()
Returns:
true if the equation has a clock

flatten

public LinkedList<Equation> flatten(HashMap<String,Variable> vars)
Replace complex expressions in the init expression and introduce auxiliary equations if necessary.

Parameters:
vars - list of new introduced variables
Returns:
List of new introduced equations, the first element in the list is the original equation (this).

toKlp

public LinkedList<AbstractInstruction> toKlp(boolean useClocks,
                                             String scope,
                                             HashMap<String,Variable> vars)
generate KLP code to compute this equation.

Parameters:
useClocks - true if hardware clocks of the klp are used
scope - scope of the equation
vars - list of all used variables
Returns:
list ofKLP instructions to compute the value

getType

public Type getType()
Returns:
type of these equation

propagateConst

public ConstExpression propagateConst(HashMap<String,ConstExpression> con)
Parameters:
con - constant values.
Returns:
propagate constant values

setExpr

public void setExpr(Expression expr)
Parameters:
expr - expression to compute this equation

setInit

public void setInit(Expression init)
Parameters:
init - expression to initialize this equation

setClock

public void setClock(String clk)
Parameters:
clk - new clock on which this equation runs

getExpr

public Expression getExpr()
Returns:
expression that computes this equation

staticEval

public void staticEval()
static evaluation.


replaceVar

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

wcrt

public int wcrt()
Returns:
estimated wcrt for the equation.

getPrio

public int getPrio()
Returns:
priotrity for the equation.

setPrio

public void setPrio(int pr)
Parameters:
pr - priority

getPDeps

public List<String> getPDeps()
Returns:
all dependencies of the equation.

replace

public boolean replace(Equation eq)
Parameters:
eq - equation to replace.
Returns:
true if the replacement was successful.