public override object CreateInstance(ETypeCreationOptions options, object template) { if (options.HasFlag(ETypeCreationOptions.MultiplicativeNeutral) || options.HasFlag(ETypeCreationOptions.NonZero)) { if (template == null) { return(Unsigned.One); } else { var unsigned = (Unsigned)template; return(Unsigned.FromUInt(1, unsigned.Size)); } } else { if (template == null) { return(Unsigned.Zero); } else { var unsigned = (Unsigned)template; return(Unsigned.FromUInt(0, unsigned.Size)); } } }
public override TypeDescriptor MakeHardwareType(TypeDescriptor ctype) { if (_isSigned) { return(TypeDescriptor.GetTypeOf(Signed.FromInt(0, _size))); } else { return(TypeDescriptor.GetTypeOf(Unsigned.FromUInt(0, _size))); } }
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)); } } }