예제 #1
0
        private void dataMemory(string _addr, string write_data, bool MemWrite, bool MemRead, int datawidth,            // datawidth = 8/16/32
                                out string read_data)
        {
            read_data = string.Empty;
            if (!MemRead && !MemRead)
            {
                return;
            }
            UInt32  addr      = Convert.ToUInt32(_addr, 2);
            DataSeg targetSeg = new DataSeg(0xFFFFFFFF);

            foreach (var dataseg in dataSegs)
            {
                if (addr >= dataseg.addr && addr < (dataseg.addr + dataseg.size))
                {
                    targetSeg = dataseg;
                }
            }
            if (addr >= stackSeg.addr && addr < stackSeg.addr + defStackSize)
            {
                targetSeg = stackSeg;
            }

            if (targetSeg.addr == 0xFFFFFFFF)
            {
                throw new Exception("Data Segment Not Found");
            }

            if (MemRead)
            {
                for (int i = 0; i < datawidth / 8; i++)
                {
                    read_data += Convert.ToString(targetSeg.data[(int)(addr - targetSeg.addr + i)], 2);
                }
                Console.WriteLine("read_data at 0x" + Convert.ToString(addr, 16) + " = " + read_data);
            }
            if (MemWrite)
            {
                for (int i = 0; i < datawidth / 8; i++)
                {
                    targetSeg.data[(int)(addr - targetSeg.addr + i)] = Convert.ToByte(write_data.Substring(i * 8, 8), 2);
                }
                Console.WriteLine("Data at 0x" + Convert.ToString(addr, 16) + " = " + write_data);
            }
            return;
        }
예제 #2
0
        public void Init(List <string> _lines)
        {
            executeLines = new List <string>( );

            originLines = new List <string>( );                        // Original lines displayed in the SourceCode view

            isBreakPoint = new Dictionary <UInt32, bool>( );

            constants = new Dictionary <string, UInt32>( );

            segAddr = new Dictionary <string, UInt32>( )
            {
                //{"main", CodeSegStart },
            };

            dataSegs = new List <DataSeg>( );

            stackSeg = new DataSeg(StackSegEnd - defStackSize);

            //ctrlSignal.init( );
            PreCompile(_lines);

            ReInit( );
        }