de.upb.hni.vmagic.statement
Class CaseStatement

java.lang.Object
  extended by de.upb.hni.vmagic.VhdlElement
      extended by de.upb.hni.vmagic.LabeledElement
          extended by de.upb.hni.vmagic.statement.SequentialStatement
              extended by de.upb.hni.vmagic.statement.CaseStatement

public class CaseStatement
extends SequentialStatement

Case statement.

Example:
vMAGIC code:
EnumerationType stateType = new EnumerationType("STATE_TYPE", "IDLE", "RUN");
Signal state = new Signal("STATE", stateType);
CaseStatement statement = new CaseStatement(state);
statement.createAlternative(stateType.getLiterals().get(0)).
    getStatements().add(new ReportStatement("state is idle"));
statement.createAlternative(Choices.OTHERS).
    getStatements().add(new ReportStatement("state is not idle"));
VHDL output:
case STATE is
    when IDLE =>
        report "state is idle";

    when others =>
        report "state is not idle";
end case;

Nested Class Summary
 class CaseStatement.Alternative
          Case statement alternative.
 
Constructor Summary
CaseStatement(Expression expression)
          Creates a case statement.
 
Method Summary
 CaseStatement.Alternative createAlternative(Choice... choices)
          Creates a new alternative and adds it to this case statement.
 CaseStatement.Alternative createAlternative(java.util.List<Choice> choices)
          Creates a new alternative and adds it to this case statement.
 java.util.List<CaseStatement.Alternative> getAlternatives()
          Returns the alternatives.
 Expression getExpression()
          Returns the expression.
 void setExpression(Expression expression)
          Sets the expression.
 
Methods inherited from class de.upb.hni.vmagic.statement.SequentialStatement
getLabel, setLabel
 
Methods inherited from class de.upb.hni.vmagic.VhdlElement
getParent, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CaseStatement

public CaseStatement(Expression expression)
Creates a case statement.

Parameters:
expression - the expression
Method Detail

getExpression

public Expression getExpression()
Returns the expression.

Returns:
the epxression

setExpression

public void setExpression(Expression expression)
Sets the expression.

Parameters:
expression - the expression

createAlternative

public CaseStatement.Alternative createAlternative(Choice... choices)
Creates a new alternative and adds it to this case statement.

Parameters:
choices - one or more choices that select this alternative
Returns:
the created alternative

createAlternative

public CaseStatement.Alternative createAlternative(java.util.List<Choice> choices)
Creates a new alternative and adds it to this case statement.

Parameters:
choices - a list of choices that select this alternative
Returns:
the created alternative

getAlternatives

public java.util.List<CaseStatement.Alternative> getAlternatives()
Returns the alternatives.

Returns:
a modifiable list of case alternatives