Exemplo 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;
        }
Exemplo 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();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the only instance of the PO_NameFixer class that may exist.  If a single
        /// instance of PO_NameFixer has not yet been created, one is created.
        ///
        /// PRE:    None.
        /// POST:   An MSstate (reference) has been returned, or created and returned.
        /// </summary>
        /// <returns>Returns a reference to the only existing instance of MSstate.</returns>
        public static MS_ALU Get_MS_ALU()
        {
            lock (c_aluLock)
            {
                // if this is the first request, initialize the one instance
                if (c_alu == null)
                {
                    c_alu = new MS_ALU();
                    c_alu.Init();
                }

                // whether new or old, return a reference to the only instance
                return(c_alu);
            } // lock
        }
Exemplo n.º 4
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);
        }