public static void DisplayInstr( MainForm mainForm )
        {
            Debug.WriteLine( "display instr" );

            for ( var addr = 0; addr < InstrFileLen; )
            {
                var icode = (byte) ( Memory[ addr ] / 16 );
                var ifun = (byte) ( Memory[ addr ] % 16 );

                var instr = GetString.Instr( icode, ifun );
                var operand = GetString.InstrOperand( icode, addr );

                var len = GetLength.Instr( icode );
                var bina = "";
                for ( var i = 0; i < len; i++ )
                {
                    bina += new string( PipeConvert.Byte2C_Array( Memory[ addr + i ] ) );
                }
                var data = new[ ] { "", "", PipeConvert.BigEnd2S( addr ), bina, instr + " " + operand };
                mainForm.InsertListViewCode( data );

                foreach ( var s in data )
                {
                    Debug.Write( s );
                }
                Debug.WriteLine( "" );
                addr += bina.Length / 2;
            }
            var blank = new[ ] { "", "", "", "", "" };
            for ( var i = 0; i < 10; i++ )
            {
                mainForm.InsertListViewCode( blank );
            }
        }
Ejemplo n.º 2
0
 private static void Main( )
 {
     Application.EnableVisualStyles( );
     Application.SetCompatibleTextRenderingDefault( false );
     var mainForm = new MainForm( );
     Application.Run( mainForm );
 }
        public static void StepBreakPoint( MainForm mainform )
        {
            WriteBack( );
            MemoryVisit( );
            Execute( );
            Decode( );
            Fetch( );
            Bubble( );

            Debug.WriteLine( " In stepBreakPoint breakpoints: " );
            foreach ( var breakaddr in Breakpoints )
            {
                Debug.WriteLine( breakaddr + " " );
            }
            Debug.WriteLine( f_pc );
            Debug.WriteLine( "" );
            if ( Breakpoints.Contains( f_pc ) )
            {
                //mainform.timer2.Stop( );
                mainform.timer2.Enabled = false;
                mainform.ButtonDisplaySwitch( );

                MessageBox.Show( @"Breakpoint." );
                return;
            }

            UpdateRegisters( );
            Cycle++;

            mainform.ProcessDisplay( );
            mainform.MemoryDisplay( );

            FileHandler.WrtiePipeInfo( Cycle );

            if ( w_stat == Stats.SAOK && W_icode == Instrs.IHALT )
            {
                //mainform.timer2.Stop( );
                mainform.timer2.Enabled = false;
                mainform.ButtonDisplaySwitch( );

                StopRunning( );

                MessageBox.Show( @"Done. Pipeling info saved as out.txt." );
            }
            else if ( W_code == "address error" )
            {
                //mainform.timer2.Stop( );
                mainform.timer2.Enabled = false;
                mainform.ButtonDisplaySwitch( );
                StopRunning( );

                MessageBox.Show( @"Address error. Pipeling info saved as out.txt." );
            }
        }
        public static void Step( MainForm mainform )
        {
            Step( );

            mainform.ProcessDisplay( );
            mainform.MemoryDisplay( );

            if ( w_stat == Stats.SAOK && W_icode == Instrs.IHALT )
            {
                //mainform.timer1.Stop( );
                mainform.timer1.Enabled = false;
                mainform.ButtonDisplaySwitch( );

                StopRunning( );

                MessageBox.Show( @"Done. Pipeling info saved as out.txt." );
            }
            else if ( W_code == "address error" )
            {
                //mainform.timer1.Stop( );
                mainform.timer1.Enabled = false;
                mainform.ButtonDisplaySwitch( );
                StopRunning( );

                MessageBox.Show( @"Address error. Pipeling info saved as out.txt." );
            }
        }
        public static void DisplyMemory( MainForm mainForm )
        {
            var idx = 0;
            for ( var addr = 0; addr + 3 < 2049; addr += 4, idx++ )
            {
                var addr_ = PipeConvert.BigEnd2S( addr );
                var mem0 = new string( PipeConvert.Byte2C_Array( Memory[ addr ] ) );
                var mem1 = new string( PipeConvert.Byte2C_Array( Memory[ addr + 1 ] ) );
                var mem2 = new string( PipeConvert.Byte2C_Array( Memory[ addr + 2 ] ) );
                var mem3 = new string( PipeConvert.Byte2C_Array( Memory[ addr + 3 ] ) );
                var mem = mem0 + " " + mem1 + " " + mem2 + " " + mem3;

                string[ ] data = { addr_, mem };
                mainForm.EditListViewMemory( data , idx );
                //mainForm.lvMemory.Items[ idx ].SubItems[ 0 ].Text = addr_;
                //mainForm.lvMemory.Items[ idx ].SubItems[ 1 ].Text = mem;
            }
        }
        public static void DisplayProcess( MainForm mainForm )
        {
            //图表刷新

            mainForm.fpredPC.Text = "predpc    " + PipeConvert.LitEnd2S( F_predPC );
            mainForm.fcircle.Text = "cycle    " + Convert.ToString( Cycle );

            mainForm.dinstr.Text = "" + Convert.ToString( D_code );
            mainForm.dstat.Text = "state    " + Convert.ToString( D_stat );
            mainForm.dicode.Text = "icode    " + PipeConvert.Byte2S( (byte) ( D_icode ) );
            mainForm.difun.Text = "ifun    " + PipeConvert.Byte2S( (byte) ( D_ifun ) );
            mainForm.dra.Text = "ra    " + PipeConvert.Byte2S( (byte) ( D_rA ) );
            mainForm.drb.Text = "rb    " + PipeConvert.Byte2S( (byte) ( D_rB ) );
            mainForm.dvalc.Text = "valc    " + PipeConvert.LitEnd2S( D_valC );
            mainForm.dvalp.Text = "valp    " + PipeConvert.LitEnd2S( D_valP );

            mainForm.einstr.Text = "" + Convert.ToString( E_code );
            mainForm.estat.Text = "stat    " + Convert.ToString( E_stat );
            mainForm.eicode.Text = "icode    " + PipeConvert.Byte2S( (byte) ( E_icode ) );
            mainForm.eifun.Text = "ifun    " + PipeConvert.Byte2S( (byte) ( E_ifun ) );

            mainForm.evalc.Text = "valc    " + PipeConvert.LitEnd2S( E_valC );
            mainForm.evala.Text = "vala    " + PipeConvert.LitEnd2S( E_valA );
            mainForm.evalb.Text = "valb    " + PipeConvert.LitEnd2S( E_valB );
            mainForm.edste.Text = "dste    " + PipeConvert.Byte2S( (byte) ( E_dstE ) );
            mainForm.edstm.Text = "dstm    " + PipeConvert.Byte2S( (byte) ( E_dstM ) );
            mainForm.esrca.Text = "srca    " + PipeConvert.Byte2S( (byte) ( E_srcA ) );
            mainForm.esrcb.Text = "srcb    " + PipeConvert.Byte2S( (byte) ( E_srcB ) );

            mainForm.minstr.Text = "" + Convert.ToString( M_code );

            mainForm.mstat.Text = "state    " + Convert.ToString( M_stat );
            mainForm.mifun.Text = "cnd    " + Convert.ToString( M_Cnd );
            mainForm.micode.Text = "icode    " + PipeConvert.Byte2S( (byte) ( M_icode ) );
            mainForm.mvale.Text = "valE    " + PipeConvert.LitEnd2S( M_valE );
            mainForm.mvala.Text = "valM    " + PipeConvert.LitEnd2S( M_valA );
            mainForm.mdste.Text = "dstE    " + PipeConvert.Byte2S( (byte) ( M_dstE ) );
            mainForm.mdstm.Text = "dstM    " + PipeConvert.Byte2S( (byte) ( M_dstM ) );

            mainForm.mcc.Text = "ZF  " + PipeConvert.Byte2C( (byte) ( zf ) ) + "    SF  " +
                                PipeConvert.Byte2C( (byte) ( sf ) ) + "    OF  " + PipeConvert.Byte2C( (byte) ( of ) );

            mainForm.winstr.Text = "" + Convert.ToString( W_code );
            mainForm.wstat.Text = "state    " + Convert.ToString( W_stat );
            mainForm.wicode.Text = "icode    " + PipeConvert.Byte2S( (byte) ( W_icode ) );
            mainForm.wvale.Text = "valE    " + PipeConvert.LitEnd2S( W_valE );
            mainForm.wvalm.Text = "valM    " + PipeConvert.LitEnd2S( W_valM );
            mainForm.wdste.Text = "dstE    " + PipeConvert.Byte2S( (byte) ( W_dstE ) );
            mainForm.wdstm.Text = "dstM    " + PipeConvert.Byte2S( (byte) ( W_dstM ) );

            if(mainForm.eax.Text != "eax    " + PipeConvert.LitEnd2S( Registers[ 0 ] ))
            {
                mainForm.eax.Text = "eax    " + PipeConvert.LitEnd2S( Registers[ 0 ] );
                mainForm.eax.Focus( );
            }
            if ( mainForm.ecx.Text != "ecx    " + PipeConvert.LitEnd2S( Registers[ 1 ] ) )
            {
                mainForm.ecx.Text = "ecx    " + PipeConvert.LitEnd2S( Registers[ 1 ] );
                mainForm.ecx.Focus( );
            }
            if ( mainForm.edx.Text != "edx    " + PipeConvert.LitEnd2S( Registers[ 2 ] ) )
            {
                mainForm.edx.Text = "edx    " + PipeConvert.LitEnd2S( Registers[ 2 ] );
                mainForm.edx.Focus( );
            }
            if ( mainForm.ebx.Text != "ebx    " + PipeConvert.LitEnd2S( Registers[ 3 ] ) )
            {
                mainForm.ebx.Text = "ebx    " + PipeConvert.LitEnd2S( Registers[ 3 ] );
                mainForm.ebx.Focus( );
            }
            if ( mainForm.esp.Text != "esp    " + PipeConvert.LitEnd2S( Registers[ 4 ] ) )
            {
                mainForm.esp.Text = "esp    " + PipeConvert.LitEnd2S( Registers[ 4 ] );
                mainForm.esp.Focus( );
                Debug.WriteLine( "esp changed" );
            }
            if ( mainForm.ebp.Text != "ebp    " + PipeConvert.LitEnd2S( Registers[ 5 ] ) )
            {
                mainForm.ebp.Text = "ebp    " + PipeConvert.LitEnd2S( Registers[ 5 ] );
                mainForm.ebp.Focus( );
            }
            if ( mainForm.esi.Text != "esi     " + PipeConvert.LitEnd2S( Registers[ 6 ] ) )
            {
                mainForm.esi.Text = "esi     " + PipeConvert.LitEnd2S( Registers[ 6 ] );
                mainForm.esi.Focus( );
            }
            if ( mainForm.edi.Text != "edi     " + PipeConvert.LitEnd2S( Registers[ 7 ] ) )
            {
                mainForm.edi.Text = "edi     " + PipeConvert.LitEnd2S( Registers[ 7 ] );
                mainForm.edi.Focus( );
            }
            /*
            mainForm.eax.Text = "eax    " + PipeConvert.LitEnd2S( Registers[ 0 ] );
            mainForm.ecx.Text = "ecx    " + PipeConvert.LitEnd2S( Registers[ 1 ] );
            mainForm.edx.Text = "edx    " + PipeConvert.LitEnd2S( Registers[ 2 ] );
            mainForm.ebx.Text = "ebx    " + PipeConvert.LitEnd2S( Registers[ 3 ] );
            mainForm.esp.Text = "esp    " + PipeConvert.LitEnd2S( Registers[ 4 ] );
            mainForm.ebp.Text = "ebp    " + PipeConvert.LitEnd2S( Registers[ 5 ] );
            mainForm.esi.Text = "esi     " + PipeConvert.LitEnd2S( Registers[ 6 ] );
            mainForm.edi.Text = "edi     " + PipeConvert.LitEnd2S( Registers[ 7 ] );
            */
            mainForm.fstall.Text = "";
            mainForm.dstall.Text = "";
            mainForm.estall.Text = "";
            mainForm.mstall.Text = "";
            mainForm.wstall.Text = "";

            mainForm.fstall.Hide( );
            mainForm.dstall.Hide( );
            mainForm.estall.Hide( );
            mainForm.mstall.Hide( );
            mainForm.wstall.Hide( );

            if ( F_stall == 1 )
            {
                mainForm.fstall.Text = "stall";
                mainForm.fstall.Show( );
            }
            if ( D_stall == 1 )
            {
                mainForm.dstall.Text = "stall";
                mainForm.dstall.Show( );
            }
            else if ( D_bubble == 1 )
            {
                mainForm.dstall.Text = "bubble";
                mainForm.dstall.Show( );
            }
            if ( E_bubble == 1 )
            {
                mainForm.estall.Text = "bubble";
                mainForm.estall.Show( );
            }
            if ( M_bubble == 1 )
            {
                mainForm.mstall.Text = "bubble";
                mainForm.mstall.Show( );
            }
            if ( W_stall == 1 )
            {
                mainForm.wstall.Text = "stall";
                mainForm.wstall.Show( );
            }
        }