Пример #1
0
        private static Expression clockEdge(Signal clock, bool rising, bool useFunction)
        {
            if (useFunction)
            {
                FunctionCall call;
                if (rising)
                {
                    call = new FunctionCall(StdLogic1164.RISING_EDGE);
                }
                else
                {
                    call = new FunctionCall(StdLogic1164.FALLING_EDGE);
                }
                call.Parameters.Add(new AssociationElement(Name.reference(clock)));
                return(call);
            }
            else
            {
                Expression condition1 = new AttributeName(Name.reference(clock), SignalAttributes.EVENT);
                Expression state      = rising ? StdLogic1164.STD_LOGIC_1 : StdLogic1164.STD_LOGIC_0;
                Expression condition2 = new Equals(Name.reference(clock), state);

                return(new And(condition1, condition2));
            }
        }
Пример #2
0
        private static bool isEventExpression(Expression expression, Signal clock)
        {
            if (expression is AttributeName)
            {
                AttributeName ae = (AttributeName)expression;
                if (!ae.Attribute.Identifier.EqualsIdentifier("event"))
                {
                    return(false);
                }

                return(ae.Prefix.Equals(clock));
            }
            else if (expression is Not)
            {
                Not not = (Not)expression;
                if (not.Expression is AttributeName)
                {
                    AttributeName ae = (AttributeName)not.Expression;
                    if (!ae.Attribute.Identifier.EqualsIdentifier("stable"))
                    {
                        return(false);
                    }

                    return(ae.Prefix.Equals(clock));
                }
            }

            return(false);
        }
Пример #3
0
 public Signal(ModellingType type, VHDL.Object.Signal parsedVariable)
 {
     this.parsedVariable = parsedVariable;
     this.name           = parsedVariable.Identifier;
     this.type           = type;
     dump = new SimpleSignalDump(parsedVariable.Identifier, type);
     InitChildrens();
     InitValue();
 }
Пример #4
0
 public Signal GetSignal(VHDL.Object.Signal signal)
 {
     foreach (Signal s in signalScope)
     {
         if (s.DefaultVhdlObject == signal)
         {
             return(s);
         }
     }
     return(null);
 }
Пример #5
0
 public Signal(ModellingType type, VHDL.Object.Signal parsedVariable, List <AbstractSignalDump> dumps)
 {
     this.parsedVariable = parsedVariable;
     this.name           = parsedVariable.Identifier;
     this.type           = type;
     if ((type.Type is VHDL.type.RecordType) || (type.Type is VHDL.type.ArrayType))
     {
         dump = new SignalScopeDump(parsedVariable.Identifier, type, dumps);
     }
     InitChildrens();
     InitValue();
 }
Пример #6
0
 public virtual VHDL.Object.Signal GetSignal()
 {
     VHDL.Object.Signal signal = resolve <VHDL.Object.Signal>(currentScore);
     if (signal != null)
     {
         return(signal);
     }
     else
     {
         throw new VHDL.ParseError.vhdlUnknownSignalException(context, visitor.FileName, Identifier);
     }
 }
Пример #7
0
 public static Signal CreateSignal(VHDL.Object.Signal s)
 {
     return(new Signal(TypeCreator.CreateType(s.Type), s));
 }
Пример #8
0
 /// <summary>
 /// Creates a falling edge clock condition.
 /// Generated VHDL: <code>clock'event and clock = '0'</code>
 /// </summary>
 /// <param name="clock">the clock signal</param>
 /// <returns>the risign edge clock condition</returns>
 public static Expression fallingEdge(Signal clock)
 {
     return(clockEdge(clock, false, false));
 }
Пример #9
0
 /// <summary>
 /// Creates a rising edge clock condition with or without using a function call.
 /// Generated VHDL: <code>clock'event and clock = '1'</code> or <code>rising_edge(clock)</code>
 /// </summary>
 /// <param name="clock">the clock signal</param>
 /// <param name="useFunction"><code>true</code>, if the <code>rising_edge</code> should be used</param>
 /// <returns>the risign edge clock condition</returns>
 public static Expression risingEdge(Signal clock, bool useFunction)
 {
     return(clockEdge(clock, true, useFunction));
 }
Пример #10
0
 /// <summary>
 /// Creates a rising edge clock condition.
 /// Generated VHDL: clock'event and clock = '1'
 /// </summary>
 /// <param name="clock">the clock signal</param>
 /// <returns>the risign edge clock condition</returns>
 public static Expression risingEdge(Signal clock)
 {
     return(clockEdge(clock, true, false));
 }
Пример #11
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);
        }
Пример #12
0
 /// <summary>
 /// Creates a falling edge clock condition with or without using a function call.
 /// Generated VHDL: <code>clock'event and clock = '0'</code> or <code>falling_edge(clock)</code>
 /// </summary>
 /// <param name="clock">the clock signal</param>
 /// <param name="useFunction"><code>true</code>, if the <code>falling_edge</code> should be used</param>
 /// <returns>the risign edge clock condition</returns>
 public static Expression fallingEdge(Signal clock, bool useFunction)
 {
     return(clockEdge(clock, false, useFunction));
 }
 public SignalDeclarationObserver(VHDL.Object.Signal mSignal, Logger logger)
 {
     this.logger  = logger;
     this.mSignal = mSignal;
 }