Exemplo n.º 1
0
        protected SimCPU(SimCPU simCPU)
        {
            // Create CPU clone with the assumption that NO new instructions or symbols are added.

            MemoryBlocks = new uint[simCPU.MemoryBlocks.Length][];
            InstructionCache = simCPU.InstructionCache;
            SourceInformation = simCPU.SourceInformation;
            SimDevices = new List<BaseSimDevice>();
            SimMemoryDevices = simCPU.SimMemoryDevices;
            PortDevices = new BaseSimDevice[65536];
            Symbols = simCPU.Symbols;
            Monitor = new SimMonitor(this);
            AcceleratorAddresses = new List<ulong>();
            AcceleratorEnabled = simCPU.AcceleratorEnabled;
            AccelerationMethods = new Dictionary<ulong, AccelerationMethod>();
            MemoryRegions = simCPU.MemoryRegions;
            Tick = simCPU.Tick;
            IsLittleEndian = simCPU.IsLittleEndian;

            CurrentProgramCounter = simCPU.CurrentProgramCounter;
            LastProgramCounter = simCPU.LastProgramCounter;
            LastInstruction = simCPU.LastInstruction;
            StackPointer = simCPU.StackPointer;
            FramePointer = simCPU.FramePointer;
            LastException = simCPU.LastException;

            foreach (var device in simCPU.SimDevices)
            {
                var clone = device.Clone(this);

                if (clone == null)
                    throw new InvalidProgramException("Unable to clone sim device");

                SimDevices.Add(clone);

                var ports = clone.GetPortList();

                if (ports != null)
                {
                    foreach (var port in ports)
                    {
                        PortDevices[port] = clone;
                    }
                }
            }

            for (int i = 0; i < MemoryBlocks.Length; i++)
            {
                if (simCPU.MemoryBlocks[i] == null)
                    continue;

                MemoryBlocks[i] = new uint[BlockSize];

                simCPU.MemoryBlocks[i].CopyTo(MemoryBlocks[i], 0);
            }

            RegisterAccelerationFunctions();
        }
Exemplo n.º 2
0
        public SimCPU()
        {
            MemoryBlocks = new byte[MaxMemory / BlockSize][];
            InstructionCache = new Dictionary<ulong, SimInstruction>();
            SimDevices = new List<BaseSimDevice>();
            PortDevices = new BaseSimDevice[65536];
            Symbols = new Dictionary<string, SimSymbol>();
            Monitor = new SimMonitor(this);
            MemoryRegions = new List<MemoryRegion>();
            //MemoryDelta = new Dictionary<ulong, KeyValuePair<byte, byte>>();

            Tick = 0;
            IsLittleEndian = true;
        }
Exemplo n.º 3
0
        public SimCPU()
        {
            MemoryBlocks = new uint[MaxMemory / BlockSize][];
            InstructionCache = new Dictionary<ulong, SimInstruction>();
            SourceInformation = new Dictionary<ulong, string>();
            SimDevices = new List<BaseSimDevice>();
            SimMemoryDevices = new List<BaseSimDevice>();
            PortDevices = new BaseSimDevice[65536];
            Symbols = new Dictionary<string, SimSymbol>();
            Monitor = new SimMonitor(this);
            MemoryRegions = new List<MemoryRegion>();

            Tick = 0;
            IsLittleEndian = true;
        }
Exemplo n.º 4
0
        internal static ulong MaxMemory = 1024L * 1024L * 1024L * 4L; // 4 GB

        public SimCPU()
        {
            MemoryBlocks      = new uint[MaxMemory / BlockSize][];
            InstructionCache  = new Dictionary <ulong, SimInstruction>();
            SourceInformation = new Dictionary <ulong, string>();
            SimDevices        = new List <BaseSimDevice>();
            SimMemoryDevices  = new List <BaseSimDevice>();
            PortDevices       = new BaseSimDevice[65536];
            Symbols           = new Dictionary <string, SimSymbol>();
            Monitor           = new SimMonitor(this);
            MemoryRegions     = new List <MemoryRegion>();

            Tick           = 0;
            IsLittleEndian = true;
        }
Exemplo n.º 5
0
        protected SimCPU(SimCPU simCPU)
        {
            // Create CPU clone with the assumption that NO new instructions or symbols are added.

            MemoryBlocks         = new uint[simCPU.MemoryBlocks.Length][];
            InstructionCache     = simCPU.InstructionCache;
            SourceInformation    = simCPU.SourceInformation;
            SimDevices           = new List <BaseSimDevice>();
            SimMemoryDevices     = simCPU.SimMemoryDevices;
            PortDevices          = new BaseSimDevice[65536];
            Symbols              = simCPU.Symbols;
            Monitor              = new SimMonitor(this);
            AcceleratorAddresses = new List <ulong>();
            AcceleratorEnabled   = simCPU.AcceleratorEnabled;
            AccelerationMethods  = new Dictionary <ulong, AccelerationMethod>();
            MemoryRegions        = simCPU.MemoryRegions;
            Tick           = simCPU.Tick;
            IsLittleEndian = simCPU.IsLittleEndian;

            CurrentProgramCounter = simCPU.CurrentProgramCounter;
            LastProgramCounter    = simCPU.LastProgramCounter;
            LastInstruction       = simCPU.LastInstruction;
            StackPointer          = simCPU.StackPointer;
            FramePointer          = simCPU.FramePointer;
            LastException         = simCPU.LastException;

            foreach (var device in simCPU.SimDevices)
            {
                var clone = device.Clone(this);

                if (clone == null)
                {
                    throw new InvalidProgramException("Unable to clone sim device");
                }

                SimDevices.Add(clone);

                var ports = clone.GetPortList();

                if (ports != null)
                {
                    foreach (var port in ports)
                    {
                        PortDevices[port] = clone;
                    }
                }
            }

            for (int i = 0; i < MemoryBlocks.Length; i++)
            {
                if (simCPU.MemoryBlocks[i] == null)
                {
                    continue;
                }

                MemoryBlocks[i] = new uint[BlockSize];

                simCPU.MemoryBlocks[i].CopyTo(MemoryBlocks[i], 0);
            }

            RegisterAccelerationFunctions();
        }