Esempio n. 1
0
 /// <summary>
 /// Constructor of a named joined PIC register.
 /// </summary>
 /// <param name="jsfr">The joined SFR definition.</param>
 /// <param name="number">The Reko index number of this register.</param>
 /// <param name="subregs">The sub-registers of the joint.</param>
 public PICRegisterStorage(IJoinedRegister jsfr, int number, IList <PICRegisterStorage> subregs)
     : base(jsfr.Name, number, 0, PrimitiveType.CreateWord(jsfr.BitWidth))
 {
     Traits       = new PICRegisterTraits(jsfr, subregs);
     AttachedRegs = subregs.ToList();
     AttachedRegs.ForEach(r => r.ParentRegister = this);
     ParentRegister = null;
     BitFields      = new SortedList <PICRegisterBitFieldSortKey, PICRegisterBitFieldStorage>();
 }
Esempio n. 2
0
 public PICRegisterContent(PICRegisterTraits traits)
 {
     this.traits = traits ?? throw new ArgumentNullException(nameof(traits));
 }
Esempio n. 3
0
 /// <summary>
 /// Constructor of a named PIC register.
 /// </summary>
 /// <param name="regName">Name of the PIC register.</param>
 /// <param name="regNumber">The Reko index number of this register.</param>
 /// <param name="bitAddress">The lowest bit address of this register.</param>
 /// <param name="dt">The register word type.</param>
 /// <param name="traits">The traits of the PIC register.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="traits"/> is null.</exception>
 public PICRegisterStorage(string regName, int regNumber, uint bitAddress, PrimitiveType dt, PICRegisterTraits traits)
     : base(regName, regNumber, bitAddress, dt)
 {
     Traits       = traits ?? throw new ArgumentNullException(nameof(traits));
     AttachedRegs = new List <PICRegisterStorage>();
     BitFields    = new SortedList <PICRegisterBitFieldSortKey, PICRegisterBitFieldStorage>();
 }
Esempio n. 4
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public PICRegisterStorage() : base("None", -1, 0, PrimitiveType.Byte)
 {
     Traits       = new PICRegisterTraits();
     AttachedRegs = null;
     BitFields    = null;
 }
Esempio n. 5
0
        private PICRegisterAccessMasks(PICRegisterTraits traits)
        {
            string sPOR    = traits?.POR ?? new string('0', traits.BitWidth);
            string sAccess = traits?.Access ?? new string('n', traits.BitWidth);

            ResetValue = 0;
            foreach (var c in sPOR)
            {
                ResetValue <<= 1;
                ResetValue  |= (c == '1' ? 1U : 0U);
            }

            ulong fullimpl = ((1UL << traits.BitWidth) - 1UL) & traits.Impl;

            ReadOrMask   = 0;
            ReadAndMask  = (uint)fullimpl;
            WriteOrMask  = 0;
            WriteAndMask = (uint)fullimpl;

            int bitno = traits.BitWidth - 1;

            foreach (char a in sAccess)
            {
                uint orMask  = 1U << bitno;
                uint andMask = ~orMask;
                switch (a)
                {
                case '0':     // Bit is always 0.
                    ReadAndMask  &= andMask;
                    WriteAndMask &= andMask;
                    break;

                case '1':     // Bit is always 1.
                    ReadOrMask  |= orMask;
                    WriteOrMask |= orMask;
                    break;

                case '-':     // Bit is not implemented. Read as 0.
                    ReadAndMask &= andMask;
                    fullimpl    &= andMask;
                    break;

                case 'r':     // Bit is readonly. Write as 0.
                    WriteAndMask &= andMask;
                    break;

                case 'w':     // Bit is write-only. Read as 0.
                    ReadAndMask &= andMask;
                    break;

                case 'x':     // Bit is read-write
                case 'X':
                case 'n':
                case 'c':     // Bit is clearable-only
                case 's':     // Bit is setable-only
                    break;
                }
                bitno--;
            }

            ImplementedMask = (uint)fullimpl;
            ResetValue     &= ImplementedMask;
        }
Esempio n. 6
0
 public static PICRegisterAccessMasks Create(PICRegisterTraits traits)
 {
     return(new PICRegisterAccessMasks(traits ?? throw new ArgumentNullException(nameof(traits))));
 }