Пример #1
0
                public void VisitSignalRef(SignalRef signalRef)
                {
                    ISignalOrPortDescriptor desc = signalRef.Desc;
                    SignalRef remappedRef = signalRef.AssimilateIndices();
                    if (_vhdg._curComponent != null && 
                        !(signalRef.Desc is SignalArgumentDescriptor))
                    {
                        remappedRef = signalRef.RelateToComponent(_vhdg._curComponent);
                        if (remappedRef == null)
                            throw new InvalidOperationException("Referenced signal unknown to declaring component");
                    }
                    string name = remappedRef.Name;
                    StringBuilder sb = new StringBuilder();
                    var udesc = desc.GetUnindexedContainer();
                    sb.Append(_vhdg.MakeIDName(name, udesc.GetBoundSignal()));
                    if (!remappedRef.IsStaticIndex ||
                        !remappedRef.IndexSample.Equals(udesc.ElementType.Index))
                    {
                        foreach (Expression[] indexSpec in remappedRef.GetFullIndices())
                        {
                            if (indexSpec.Length == 0)
                                continue;

                            sb.Append("(");
                            bool first = true;
                            foreach (Expression index in indexSpec.Reverse())
                            {
                                if (first)
                                    first = false;
                                else
                                    sb.Append(", ");
                                sb.Append(index.ToString(_vhdg));
                            }
                            sb.Append(")");
                        }
                    }
                    switch (signalRef.Prop)
                    {
                        case SignalRef.EReferencedProperty.ChangedEvent:
                            Result = "-- changed event not supported";
                            break;

                        case SignalRef.EReferencedProperty.Cur:
                        case SignalRef.EReferencedProperty.Instance:
                        case SignalRef.EReferencedProperty.Next:
                            Result = sb.ToString();
                            break;

                        case SignalRef.EReferencedProperty.Pre:
                            sb.Append("'pre");
                            Result = sb.ToString();
                            break;

                        case SignalRef.EReferencedProperty.RisingEdge:
                            Result = "rising_edge(" + sb.ToString() + ")";
                            break;

                        case SignalRef.EReferencedProperty.FallingEdge:
                            Result = "falling_edge(" + sb.ToString() + ")";
                            break;

                        default:
                            throw new NotImplementedException();
                    }
                }
Пример #2
0
            public void VisitSignalRef(SignalRef signalRef)
            {
                ISignalOrPortDescriptor desc = signalRef.Desc;
                SignalRef remappedRef = signalRef;
                if (_SysCg._curComponent != null &&
                    !(signalRef.Desc is SignalArgumentDescriptor))
                {
                    /*
                    desc = _SysCg._curComponent.FindSignalOrPort(signalRef.Desc);
                    if (desc == null)
                        throw new InvalidOperationException("Referenced signal unknown to declaring component");
                     * */
                    remappedRef = signalRef.RelateToComponent(_SysCg._curComponent);
                    if (remappedRef == null)
                        throw new InvalidOperationException("Referenced signal unknown to declaring component");
                }
                string name = remappedRef.Name;

                string[] aux;
                StringBuilder sb = new StringBuilder();
                StringBuilder sb1 = new StringBuilder();
                var udesc = desc.GetUnindexedContainer();
                sb.Append(_SysCg.MakeIDName(name, desc.GetUnindexedContainer().GetBoundSignal()));
                if (!remappedRef.IsStaticIndex ||
                        !remappedRef.IndexSample.Equals(udesc.ElementType.Index))
                {
                    foreach (Expression[] indexSpec in remappedRef.GetFullIndices())
                    {
                        if (indexSpec.Length == 0)
                            continue;

                        bool first = true;
                        foreach (Expression index in indexSpec)
                        {
                            if (first)
                                first = false;
                            else
                                sb.Append(", ");
                            //sb.Append(index.ToString(_SysCg));
                            aux = index.ToString(_SysCg).Split(' ');
                            if (aux.Length == 3)
                                sb1.Append("(" + aux[0] + ", " + aux[2] + ")");
                            else
                            if (aux.Length == 1)
                                sb1.Append("[" + aux[0] + "]");
                            //else
                            //    sb.Append("Erro na geracao de incdices!");
                        }
                    }
                }
                //sb.Append(")");
                switch (signalRef.Prop)
                {
                    case SignalRef.EReferencedProperty.ChangedEvent:
                        sb.Append(".event()");
                        Result = sb.ToString();
                        break;

                    case SignalRef.EReferencedProperty.Cur:
                        if (desc.ElementType.CILType.IsArray)
                        {
                            if (sb1.Length > 0)
                                sb.Append(sb1);
                            sb.Append(".read()");
                        }
                        else
                        {
                            sb.Append(".read()");
                            if (sb1.Length > 0)
                                sb.Append(sb1);
                        }                       
                        Result = sb.ToString();
                        break;
                    case SignalRef.EReferencedProperty.Instance:
                    case SignalRef.EReferencedProperty.Next:
                        sb.Append(sb1);
                        Result = sb.ToString();
                        break;

                    case SignalRef.EReferencedProperty.Pre:
                    //sb.Append("'pre");
                    //Result = sb.ToString();
                    //break;

                    case SignalRef.EReferencedProperty.RisingEdge:
                        Result = sb.ToString() + ".posedge()";
                        break;

                    case SignalRef.EReferencedProperty.FallingEdge:
                        Result = sb.ToString() + ".negedge()";
                        break;

                    default:
                        throw new NotImplementedException();
                }
            }