public PICRegisterTraits() { RegAddress = new PICRegisterSizedUniqueAddress(PICDataAddress.Invalid, 8); Name = "None"; Desc = ""; Impl = 0xFF; Access = new string('n', 8); POR = MCLR = new string('u', 8); IsVolatile = false; IsIndirect = false; }
/// <summary> /// Construct the PIC register's traits based on the given <see cref="IJoinedRegister"/> descriptor /// and its children PIC registers' traits. /// </summary> /// <remarks> /// The construction of the joined register's traits assumes that the enumeration of attached registers/traits /// is enuerable in increasing registers' order (LSB, MSB, little-endian). /// </remarks> /// <param name="joinedSFR">The joined PIC register descriptor.</param> /// <param name="attachedRegsTraits">The joined registers' traits.</param> /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception> public PICRegisterTraits(IJoinedRegister joinedSFR, IEnumerable <PICRegisterTraits> attachedRegsTraits) { if (joinedSFR is null) { throw new ArgumentNullException(nameof(joinedSFR)); } if (attachedRegsTraits is null) { throw new ArgumentNullException(nameof(attachedRegsTraits)); } Name = joinedSFR.Name; Desc = joinedSFR.Description; RegAddress = new PICRegisterSizedUniqueAddress(PICDataAddress.Ptr(joinedSFR.Addr), (int)joinedSFR.BitWidth); var rev = attachedRegsTraits.Reverse(); Access = AdjustString(String.Join("", rev.Select(e => e.Access)), '-'); MCLR = AdjustString(String.Join("", rev.Select(e => e.MCLR)), 'u'); POR = AdjustString(String.Join("", rev.Select(e => e.POR)), '0'); Impl = rev.Aggregate(0UL, (total, reg) => total = (total << 8) + reg.Impl); IsVolatile = attachedRegsTraits.Any(e => e.IsVolatile == true); IsIndirect = attachedRegsTraits.Any(e => e.IsIndirect == true); }
/// <summary> /// Construct the PIC register's traits based on the given <see cref="SFRDef"/> descriptor. /// </summary> /// <param name="sfr">The PIC register descriptor.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="sfr"/> is null.</exception> public PICRegisterTraits(ISFRRegister sfr) { if (sfr is null) { throw new ArgumentNullException(nameof(sfr)); } if (string.IsNullOrEmpty(sfr.NMMRID)) { RegAddress = new PICRegisterSizedUniqueAddress(PICDataAddress.Ptr(sfr.Addr), (int)sfr.BitWidth); } else { RegAddress = new PICRegisterSizedUniqueAddress(sfr.NMMRID, (int)sfr.BitWidth); } Name = sfr.Name; Desc = sfr.Description; Impl = sfr.ImplMask; Access = AdjustString(sfr.AccessBits, '-'); MCLR = AdjustString(sfr.MCLR, 'u'); POR = AdjustString(sfr.POR, '0'); IsVolatile = sfr.IsVolatile; IsIndirect = sfr.IsIndirect; }