Пример #1
0
        private static string MemoryAccess(string control, string result) //add pc so i can jump and link
        {
            Datamem.writeEHB = control.Substring(14, 5).Replace("_", ""); //Write enable, half and byte
            Datamem.DataIn(result, Register.data2);                       //perform operation

            string data = Extender.Extend(Datamem.DataOut(result).Substring(16, 16), control.Substring(20, 3));

            m4to1 = new Mux(new String[] { Datamem.DataOut(result), data, result })
            {
                select = control.Substring(26, 2)
            };
            return(m4to1.Selected());
        }
Пример #2
0
        static void MIPS()
        {
            Register.FillRegesters(); //Fill Registers with Random data
            Datamem.FillDatamem();    //Fill Data memory with Random data

            int pc = 0;

            //Instruction Decode and Register Fetch
            InstructionDecodeAndRegisterFetch(pc, out string instruction, out string control, out string selected);
            //Execute Address Calc.
            string result = AddressCalc(instruction, control);
            //Memory Access
            string data = MemoryAccess(control, result);

            //Write Back: Write to memory and Registers

            Register.WriteRegister(selected, control.Substring(3, 1), data);
        }