Example #1
0
 /// <summary>
 /// Private constructor creating an instance of memory map for specified PIC.
 /// </summary>
 /// <param name="thePIC">the PIC descriptor.</param>
 protected PIC18MemoryMap(IPICDescriptor thePIC) : base(thePIC)
 {
     AccessRAM    = null !;
     AccessSFR    = null !;
     ExtendedGPRE = null !;
     SetMaps();
 }
Example #2
0
            /// <summary>
            /// Creates a new <see cref="IPICMemoryMap"/> interface for PIC16.
            /// </summary>
            /// <param name="pic">the PIC descriptor.</param>
            /// <returns>
            /// A <see cref="IPICMemoryMap"/> interface instance.
            /// </returns>
            /// <exception cref="ArgumentNullException">Thrown if <paramref name="pic"/> is null.</exception>
            /// <exception cref="ArgumentOutOfRangeException">Thrown if the PIC definition contains an invalid
            ///                                               data memory size (less than 12 bytes).</exception>
            /// <exception cref="InvalidOperationException">Thrown if the PIC definition does not permit to construct the memory map.</exception>
            public static IPICMemoryMap Create(IPICDescriptor pic)
            {
                if (pic is null)
                {
                    throw new ArgumentNullException(nameof(pic));
                }
                uint datasize = pic.DataSpaceSize;

                if (datasize < MinDataMemorySize)
                {
                    throw new ArgumentOutOfRangeException($"Too low data memory size (less than {MinDataMemorySize} bytes). Check PIC definition.");
                }

                switch (pic.GetInstructionSetID)
                {
                case InstructionSetID.PIC16:
                case InstructionSetID.PIC16_ENHANCED:
                case InstructionSetID.PIC16_FULLFEATURED:
                    var map = new PIC16MemoryMap(pic);
                    if (!map.IsValid)
                    {
                        throw new InvalidOperationException($"Mapper cannot be constructed for '{pic.PICName}' device.");
                    }
                    return(map);

                default:
                    throw new InvalidOperationException($"Invalid PIC16 family: '{pic.PICName}'.");
                }
            }
Example #3
0
 /// <summary>
 /// Creates the Enhanced PIC16 registers.
 /// </summary>
 /// <param name="pic">The PIC definition.</param>
 /// <exception cref="ArgumentNullException">Parameter <paramref name="pic"/> is null.</exception>
 public static void Create(IPICDescriptor pic)
 {
     LoadRegisters(pic ?? throw new ArgumentNullException(nameof(pic)));
     var regs = new PIC16EnhancedRegisters();
     regs.SetCoreRegisters();
     regs.SetRegistersValuesAtPOR();
 }
Example #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="pic">The PIC architecture main definitions.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="pic"/> is null.</exception>
 public MemTraits(IPICDescriptor pic)
 {
     if (pic == null)
     {
         throw new ArgumentNullException(nameof(pic));
     }
     maptraits.Clear();
     foreach (var trait in pic.PICMemoryTraits)
     {
         if (trait.Domain != PICMemoryDomain.Data)
         {
             var key = new MemoryDomainKey(trait.Domain, trait.SubDomain);
             if (!maptraits.ContainsKey(key))
             {
                 maptraits.Add(key, trait);
             }
         }
         else
         {
             maptraits.Add(new MemoryDomainKey(PICMemoryDomain.Data, PICMemorySubDomain.DPR), trait);
             maptraits.Add(new MemoryDomainKey(PICMemoryDomain.Data, PICMemorySubDomain.GPR), trait);
             maptraits.Add(new MemoryDomainKey(PICMemoryDomain.Data, PICMemorySubDomain.SFR), trait);
             maptraits.Add(new MemoryDomainKey(PICMemoryDomain.Data, PICMemorySubDomain.Emulator), trait);
             maptraits.Add(new MemoryDomainKey(PICMemoryDomain.Data, PICMemorySubDomain.Linear), trait);
         }
     }
 }
Example #5
0
        public static IPICDeviceConfigDefs Create(IPICDescriptor pic)
        {
            if (pic == null)
            {
                throw new ArgumentNullException(nameof(pic));
            }
            var dcrconf = new PICDeviceConfigDefs(pic);

            if (dcrconf.dcregisters.Count < 0)
            {
                throw new InvalidOperationException($"Can't create PIC Device Configuration definitions.");
            }
            return(dcrconf);
        }
Example #6
0
        /// <summary>
        /// Loads the PIC registers, as found in the PIC definition, into the registers symbol table.
        /// </summary>
        /// <param name="registersSymTable">The registers symbol table interface.</param>
        /// <param name="pic">the PIC definition.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="registersSymTable"/> is
        ///                                         null.</exception>
        protected void LoadRegistersInTable(IPICRegisterSymTable registersSymTable, IPICDescriptor pic)
        {
            if (pic == null)
            {
                throw new ArgumentNullException(nameof(pic));
            }
            symTable  = registersSymTable ?? throw new ArgumentNullException(nameof(registersSymTable));
            regNumber = 0;

            foreach (var sfr in pic.SFRs)
            {
                var reg = AddSFRRegister(sfr, regNumber);
                regNumber++;
                symTable.AddRegister(reg);
            }
            foreach (var jsfr in pic.JoinedRegisters)
            {
                var subregs = new List <PICRegisterStorage>();
                bitRegAddr = 0;
                foreach (var sfr in jsfr.ChildSFRs)
                {
                    if (!PICRegisters.TryGetRegister(sfr.Name, out var creg))
                    {
                        creg = AddSFRRegister(sfr, regNumber++);
                    }
                    creg.BitAddress = bitRegAddr;
                    subregs.Add(creg);
                    bitRegAddr += 8;
                }
                if (subregs.Count > 0)
                {
                    var sfr = new PICRegisterStorage(jsfr, regNumber, subregs);
                    if (symTable.AddRegister(sfr))
                    {
                        regNumber++;
                    }
                }
            }
        }
Example #7
0
        private PICDeviceConfigDefs(IPICDescriptor thePIC)
        {
            dcregisters = new SortedList <Address, PICDevConfigRegister>();
            foreach (var fuse in thePIC.ConfigurationFuses)
            {
                var dcreg = new PICDevConfigRegister(fuse);

                foreach (var dcilg in fuse.IllegalSettings)
                {
                    dcreg.AddIllegal(new DevConfigIllegal(dcilg));
                }
                foreach (var dcfld in fuse.ConfigFields.Where(f => !(f.IsHidden || f.IsLangHidden)))
                {
                    var dcrfdef = new DevConfigField(dcfld, dcreg.Address);
                    foreach (var dcsem in dcfld.Semantics)
                    {
                        dcrfdef.AddSemantic(new DevConfigSemantic(dcsem));
                    }
                    dcreg.AddField(dcrfdef);
                }
                dcregisters.Add(dcreg.Address, dcreg);
            }
        }
Example #8
0
 /// <summary>
 /// Creates a new instance of PIC16 memory map for specified PIC.
 /// </summary>
 /// <param name="pic">the PIC descriptor.</param>
 protected PIC16MemoryMap(IPICDescriptor pic) : base(pic)
 {
 }
Example #9
0
 /// <summary>
 /// Private constructor creating an instance of memory map for specified PIC.
 /// </summary>
 /// <param name="thePIC">the PIC descriptor.</param>
 protected PIC18MemoryMap(IPICDescriptor thePIC) : base(thePIC)
 {
     SetMaps();
 }