Esempio n. 1
0
        public static void RunTests(StreamWriter log)
        {
            log.WriteLine("Test: Starting RAM unit tests");
            ramSim tram = new ramSim(32768);

            log.WriteLine("Test: Read/Write Byte");
            byte byteRes = tram.ReadByte(0);
            Debug.Assert(byteRes == 0);
            tram.WriteByte(0, 0xee);
            byteRes = tram.ReadByte(0);
            Debug.Assert(byteRes == 0xee);

            tram.CLEAR();

            log.WriteLine("Test: Read/Write HalfWord");
            short shortRes = tram.ReadHalfWord(0);
            Debug.Assert(shortRes == 0);
            tram.WriteHalfWord(0, 0xeef);
            shortRes = tram.ReadHalfWord(0);
            Debug.Assert(shortRes == 0xeef);

            tram.CLEAR();

            log.WriteLine("Test: Read/Write Word");
            int intRes = tram.ReadWord(0);
            Debug.Assert(intRes == 0);
            tram.WriteWord(0, 0xabcdef);
            intRes = tram.ReadWord(0);
            Debug.Assert(intRes == 0xabcdef);

            tram.CLEAR();

            log.WriteLine("Test: Set/Test Flag");
            bool flagRes = tram.TestFlag(0, 4);
            Debug.Assert(flagRes == false);
            tram.SetFlag(0, 4, true);
            flagRes = tram.TestFlag(0, 4);
            Debug.Assert(flagRes == true);
            flagRes = tram.TestFlag(0, 3);
            Debug.Assert(flagRes == false);


            log.WriteLine("Test: All Ram Tests passed\n");
            tram.CLEAR();

        }
Esempio n. 2
0
        public static void writeElfToRam(ELFReader e, byte[] elfArray, ref ramSim ram)
        {

            log.WriteLine("RAM: Size {0}", ram.getSize());


            for (int prog = 0; prog < e.elfHeader.e_phnum; prog++)
            {
                int ramAddress = e.elfphs[prog].p_vaddr;
                log.WriteLine("RAM: Writing to {0} ", ramAddress);

                int elfOffSet = (int)e.elfphs[prog].p_offset;
                log.WriteLine("ELF: Reading from {0}", e.elfphs[prog].p_offset);

                log.WriteLine("ELF: Size of Segment {0}", e.elfphs[prog].p_filesz);
                int ii = ramAddress;
                int j = elfOffSet;
                for (; j < elfArray.Length && ii < e.elfphs[prog].p_filesz + ramAddress; ii++, j++)
                {
                    ram.WriteByte(ii, elfArray[j]);
                }


            }

        }