Esempio n. 1
0
        private void ImplementLdConst(object value)
        {
            var      mms         = GetDataLayout(value);
            Unsigned addr        = mms.BaseAddress;
            var      addrType    = TypeDescriptor.GetTypeOf(addr);
            int      addrSize    = addr.Size;
            var      rawWordType = Mapper.MarshalInfo.GetRawWordType();
            var      stackTypes  = new TypeDescriptor[mms.Size + 1];

            for (ulong k = 0; k < mms.Size; k++)
            {
                Emit(_iset.RdMemFix(Mapper.DefaultRegion, addr).CreateStk(0, rawWordType));
                addr          = (addr + Unsigned.FromULong(1, 1)).Resize(addrSize);
                stackTypes[k] = rawWordType;
            }
            uint concatSize = (uint)(mms.Size * Mapper.MarshalInfo.WordSize);
            var  concatType = TypeDescriptor.GetTypeOf(StdLogicVector._0s(concatSize));

            if (mms.Size > 1)
            {
                stackTypes[mms.Size] = concatType;
                Emit(_iset.Concat().CreateStk(stackTypes.Length, stackTypes));
            }
            var valueType    = TypeDescriptor.GetTypeOf(value);
            var slvValue     = StdLogicVector.Serialize(value);
            var rawValueType = TypeDescriptor.GetTypeOf(slvValue);

            if (!rawValueType.Equals(concatType))
            {
                Emit(_iset.Convert().CreateStk(1, concatType, rawValueType));
            }
            if (!rawValueType.Equals(valueType))
            {
                Emit(_iset.Convert().CreateStk(1, rawValueType, valueType));
            }
        }