Example #1
0
        public static object DefaultEval(ArrayRef arrayRef, IEvaluator eval)
        {
            Array array = (Array)arrayRef.ArrayExpr.Eval(eval);

            long[] indices = arrayRef.Indices.Select(i =>
                                                     TypeConversions.ToLong(i.Eval(eval))).ToArray();
            return(array.GetValue(indices));
        }
Example #2
0
        public override bool Equals(object obj)
        {
            ArrayRef aref = obj as ArrayRef;

            if (aref == null)
            {
                return(false);
            }

            return
                (object.Equals(ArrayExpr, aref.ArrayExpr) &&
                 Enumerable.SequenceEqual(Indices, aref.Indices));
        }
Example #3
0
                protected override void DeclareAlgorithm()
                {
                    var srClk = SignalRef.Create(_taSite._clk, SignalRef.EReferencedProperty.RisingEdge);
                    var lrClk = new LiteralReference(srClk);
                    var srWrEn = _taSite.NeedWriteAccess ? SignalRef.Create(_taSite._wrEn, SignalRef.EReferencedProperty.Cur) : null;
                    var lrWrEn = _taSite.NeedWriteAccess ? new LiteralReference(srWrEn) : null;
                    var srAddr = SignalRef.Create(_taSite._addr, SignalRef.EReferencedProperty.Cur);
                    var lrAddr = new LiteralReference(srAddr);
                    var srDataIn = _taSite.NeedWriteAccess ? SignalRef.Create(_taSite._dataIn, SignalRef.EReferencedProperty.Cur) : null;
                    var lrDataIn = _taSite.NeedWriteAccess ? new LiteralReference(srDataIn) : null;
                    var srDataOut = SignalRef.Create(_taSite._dataOut, SignalRef.EReferencedProperty.Next);
                    var hi = LiteralReference.CreateConstant(StdLogic._1);
                    var addrUType = TypeDescriptor.GetTypeOf(((StdLogicVector)_taSite._addr.InitialValue).UnsignedValue);
                    var uAddr = IntrinsicFunctions.Cast(lrAddr, typeof(StdLogicVector), addrUType);
                    var iAddr = IntrinsicFunctions.Cast(uAddr, addrUType.CILType, typeof(int));
                    var array = _taSite._array;
                    var lrArray = new LiteralReference(array.ArrayLit);
                    var elemType = array.ElementType;
                    var aref = new ArrayRef(lrArray, elemType, iAddr);
                    var convDataIn = _taSite.NeedWriteAccess ? IntrinsicFunctions.Cast(lrDataIn, typeof(StdLogicVector), elemType) : null;
                    var convAref = IntrinsicFunctions.Cast(aref, elemType.CILType, _taSite._dataOut.ElementType);

                    If(lrClk);
                    {
                        Store(srDataOut, convAref);
                        if (_taSite.NeedWriteAccess)
                        {
                            If(Expression.Equal(lrWrEn, hi));
                            {
                                Store(aref, convDataIn);
                            }
                            EndIf();
                        }
                    }
                    EndIf();
                }
Example #4
0
 public static object DefaultEval(ArrayRef arrayRef, IEvaluator eval)
 {
     Array array = (Array)arrayRef.ArrayExpr.Eval(eval);
     long[] indices = arrayRef.Indices.Select(i => 
         TypeConversions.ToLong(i.Eval(eval))).ToArray();
     return array.GetValue(indices);
 }
Example #5
0
 public void VisitArrayRef(ArrayRef arrayRef)
 {
     Result = false;
 }
Example #6
0
 public void VisitArrayRef(ArrayRef arrayRef)
 {
     OnVisitArrayRef(arrayRef);
 }
Example #7
0
 public void VisitArrayRef(ArrayRef arrayRef)
 {
     Result = false;
 }
Example #8
0
 public void VisitArrayRef(ArrayRef arrayRef)
 {
     OnVisitArrayRef(arrayRef);
 }
 public object EvalArrayRef(ArrayRef arrayRef)
 {
     return DoEvalArrayRef(arrayRef);
 }
 public object DefaultEvalArrayRef(ArrayRef arrayRef)
 {
     return ArrayRef.DefaultEval(arrayRef, this);
 }
 public void VisitArrayRef(ArrayRef arrayRef)
 {
     Resolve(arrayRef.ArrayExpr);
     foreach (var idx in arrayRef.Indices)
         Resolve(idx);
     _result = arrayRef;
 }
Example #12
0
 public void VisitArrayRef(ArrayRef arrayRef)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append(arrayRef.ArrayExpr.ToString(_vhdg));
     var indices = arrayRef.Indices.Select(idx => idx.ToString(_vhdg));
     sb.Append("(");
     sb.Append(string.Join(", ", indices));
     sb.Append(")");
     Result = sb.ToString();
 }