/// <summary>
 /// Visits a parentheses expression.
 /// </summary>
 /// <param name="expression">the parentheses expression</param>
 protected internal virtual void visitParentheses(Parentheses expression)
 {
     visit(expression.Expression);
 }
Beispiel #2
0
        /// <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);
        }