Ejemplo n.º 1
0
        /// <summary>
        /// Just testing to see how things work.
        /// TODO We need a facade to manage the simulation.
        /// </summary>
        private void btnStart_Click(object sender, EventArgs e)
        {
            MSstate state = MSstate.Get_MSstate();

#if false
            // Show the initial state
            tbOut.Text += state.ToString() + Environment.NewLine + Environment.NewLine;
#endif
            // Make a few state changes
            state.RegisterContent[MSstate.RegSet.MARlo] = 0x11;
            state.RegisterContent[MSstate.RegSet.MARhi] = 0x22;
            state.RegisterContent[MSstate.RegSet.AClo]  = 0x50;
            state.RegisterContent[MSstate.RegSet.AChi]  = 0x42;
            state.RegisterContent[MSstate.RegSet.SPhi]  = 0x50;

            // Show the results
            tbOut.Text += state.ToString() + Environment.NewLine + Environment.NewLine;

            // Execute some microcode
            MS_ALU alu = MS_ALU.Get_MS_ALU();
            alu.PerformOneMicroStatement(new MSmicrocodeStatement("", 13, 9, 0, 0, 0)); // ALUin := SPhi
            tbOut.Text += state.ToString() + Environment.NewLine + Environment.NewLine;

            alu.PerformOneMicroStatement(new MSmicrocodeStatement("", 5, 2, 0, 0, 0));  // BRhi := AClo
            alu.PerformOneMicroStatement(new MSmicrocodeStatement("", 14, 0, 0, 0, 0)); // Inc MAR&PC // TODO not working
            alu.PerformOneMicroStatement(new MSmicrocodeStatement("", 8, 9, 7, 0, 0));  // SPlo := SPhi+ALUin 50+50=A0

            // Show the results
            tbOut.Text += state.ToString() + Environment.NewLine + Environment.NewLine;
        }
Ejemplo n.º 2
0
        private void LoadInitStates()
        {
            // allocate memory; it is automatically set to zeros
            MicroRegisterContent = new byte[iRegCount];

            state        = MSstate.Get_MSstate();
            alu          = MS_ALU.Get_MS_ALU();
            ControlTable = new MScontrolTable();
        }
Ejemplo n.º 3
0
        public override string ToString()
        {
            string ret = "";

            // ToString("X") alternatively prints the integer address as hexadecimal; this should also print the *contents* at the current MAR address TODO
            ret += string.Format("MAR:  {0,2} {1,2:}", RegisterContent[RegSet.MARhi].ToString("X"), RegisterContent[RegSet.MARlo].ToString("X"));
            ret += System.Environment.NewLine;

            // Print the remaining register contents
            foreach (RegSet rs in aRegisters)
            {
                ret += string.Format("{0}:{1,2}  ", rs.ToString(), RegisterContent[rs].ToString("X"));
            }

            // Add the state of the microsequencer
            ret += System.Environment.NewLine;
            ret += MSmicrosequencer.Get_MSmicrosequencer().ToString();

            // Add the status word from the ALU
            ret += MS_ALU.Get_MS_ALU().ToString();
            ret += System.Environment.NewLine;

            return(ret);
        }