예제 #1
0
파일: UFix.cs 프로젝트: cephdon/systemsharp
 public override object CreateInstance(ETypeCreationOptions options, object template)
 {
     if (options.HasFlag(ETypeCreationOptions.MultiplicativeNeutral))
     {
         if (template == null)
         {
             return(UFix.One);
         }
         else
         {
             var ufix = (UFix)template;
             return(UFix.FromDouble(1.0, ufix.Format.IntWidth, ufix.Format.FracWidth));
         }
     }
     else if (options.HasFlag(ETypeCreationOptions.NonZero))
     {
         if (template == null)
         {
             return(UFix.One);
         }
         else
         {
             var ufix = (UFix)template;
             return(UFix.FromUnsigned(Unsigned.FromUInt(1, ufix.Format.TotalWidth), ufix.Format.FracWidth));
         }
     }
     else
     {
         if (template == null)
         {
             return(UFix.Zero);
         }
         else
         {
             var ufix = (UFix)template;
             return(UFix.FromDouble(0.0, ufix.Format.IntWidth, ufix.Format.FracWidth));
         }
     }
 }
예제 #2
0
파일: UFix.cs 프로젝트: cephdon/systemsharp
        public object Deserialize(StdLogicVector slv, TypeDescriptor targetType)
        {
            var fmt = UFix.GetFormat(targetType);

            return(UFix.FromUnsigned(slv.UnsignedValue, fmt.FracWidth));
        }