Пример #1
0
 public override object CreateInstance(ETypeCreationOptions options, object template)
 {
     if (options.HasFlag(ETypeCreationOptions.MultiplicativeNeutral))
     {
         if (template == null)
         {
             return(SFix.One);
         }
         else
         {
             var sfix = (SFix)template;
             return(SFix.FromDouble(1.0, sfix.Format.IntWidth, sfix.Format.FracWidth));
         }
     }
     else if (options.HasFlag(ETypeCreationOptions.NonZero))
     {
         if (template == null)
         {
             return(SFix.One);
         }
         else
         {
             var sfix = (SFix)template;
             return(SFix.FromSigned(Signed.FromInt(1, sfix.Format.TotalWidth), sfix.Format.FracWidth));
         }
     }
     else
     {
         if (template == null)
         {
             return(SFix.Zero);
         }
         else
         {
             var sfix = (SFix)template;
             return(SFix.FromDouble(0.0, sfix.Format.IntWidth, sfix.Format.FracWidth));
         }
     }
 }
Пример #2
0
        public object Deserialize(StdLogicVector slv, TypeDescriptor targetType)
        {
            var fmt = SFix.GetFormat(targetType);

            return(SFix.FromSigned(slv.SignedValue, fmt.FracWidth));
        }