/// <summary> /// Returns the clock signal in an edge condition. /// If the expression is no edge condition <code>null</code> is returned. /// <p>Recognized expressions: /// <code><ul> /// <li>clock'event and clock = '0' /// <li>clock'event and clock = '1' /// <li>clock = '0' and clock'event /// <li>clock = '1' and clock'event /// <li>not clock'stable and clock = '0' /// <li>not clock'stable and clock = '1' /// <li>clock = '0' and not clock'stable /// <li>clock = '1' and not clock'stable /// <li>falling_edge(clock) /// <li>rising_edge(clock) /// </ul></code> /// </summary> /// <param name="expression">the expression</param> /// <returns>the clock signal or <code>null</code></returns> public static Signal getEdgeConditionClock(Expression expression) { if (expression is BinaryExpression) { BinaryExpression binExpr = toBinaryExpression(expression, ExpressionKind.AND); if (binExpr == null) { return(null); } Signal clock = clockLevelToSignal(binExpr.Left); if (clock != null) { return(isEventExpression(binExpr.Right, clock) ? clock : null); } clock = clockLevelToSignal(binExpr.Right); if (clock != null) { return(isEventExpression(binExpr.Left, clock) ? clock : null); } } else if (expression is FunctionCall) { FunctionCall call = (FunctionCall)expression; if (call.Function.Equals(StdLogic1164.FALLING_EDGE) || call.Function.Equals(StdLogic1164.RISING_EDGE)) { if (call.Parameters.Count == 1) { AssociationElement ae = call.Parameters[0]; if (ae.Actual is Name) { var obj = (ae.Actual as Name).Referenced; if (obj is Signal) { return(obj as Signal); } } } } } else if (expression is Parentheses) { Parentheses p = (Parentheses)expression; return(getEdgeConditionClock(p.Expression)); } else if (expression is Aggregate) { Aggregate a = (Aggregate)expression; if (a.Associations.Count != 1) { return(null); } ElementAssociation association = a.Associations[0]; if (association.Choices.Count == 0) { return(getEdgeConditionClock(association.Expression)); } } return(null); }
/// <summary> /// Visits a function call. /// </summary> /// <param name="expression">the function call</param> protected internal virtual void visitFunctionCall(FunctionCall expression) { }
public virtual VHDL.expression.FunctionCall ResolveFunctionCall(List <AssociationElement> arguments, VHDL.type.ISubtypeIndication currentAssignTarget, List <VHDL.declaration.IFunction> candidates) { VHDL.declaration.IFunction declaration = VHDL.parser.typeinfer.TypeInference.ResolveOverloadFunction(currentScore, candidates, arguments, currentAssignTarget); VHDL.expression.FunctionCall call = new VHDL.expression.FunctionCall(declaration, arguments); return(call); }