コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            funcoes teste = new funcoes();

            if (openFileDialog1.FileName != "openFileDialog1")
            {
                if (checkBox1.Checked == false)
                {
                    richTextBox1.Text = DateTime.Now.ToString();
                    defineTipoMapeamento();
                    dataGridView1.Enabled = false;
                    dataGridView2.Enabled = false;
                    if (cmbTipoMapeamento.SelectedIndex == 0) //mapeamento direto
                    {
                        Thread mpDireto = new Thread(() => teste.mapeamentoDireto(openFileDialog1.FileName, teste.potencia2(Convert.ToInt32(tamCache) / bloco), 32 - (teste.potencia2(Convert.ToInt32(tamCache) / bloco)) - word, word, 0));
                        mpDireto.Start();
                        Thread.Sleep(30);
                    }

                    if (cmbTipoMapeamento.SelectedIndex >= 1) //mapeamento associativo 2-way
                    {
                        if (cmbPolSubstituicao.SelectedIndex == 0)
                        {
                            Thread mpAssociativoLRU = new Thread(() => teste.mapeamentoAssociativo(openFileDialog1.FileName, 32 - (teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet)) - word, teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet), tamSet, true, false, word, 0, 0));
                            mpAssociativoLRU.Start();
                            Thread.Sleep(90);
                        }

                        if (cmbPolSubstituicao.SelectedIndex == 1)
                        {
                            Thread mpAssociativoFIFO = new Thread(() => teste.mapeamentoAssociativo(openFileDialog1.FileName, 32 - (teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet)) - word, teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet), tamSet, false, true, word, 0, 0));
                            mpAssociativoFIFO.Start();
                            Thread.Sleep(40);
                        }
                    }
                }
                else
                {
                    tamCache = 1024;
                    int a = 0;
                    while (a < 5)
                    {
                        line = Convert.ToInt32(tamCache) / bloco;
                        line = teste.potencia2(line);

                        //direto

                        //teste.mapeamentoDireto(openFileDialog1.FileName, teste.potencia2(Convert.ToInt32(tamCache) / bloco), 32 - (teste.potencia2(Convert.ToInt32(tamCache) / bloco)) - word, word, a);

                        Thread mpDireto = new Thread(() => teste.mapeamentoDireto(openFileDialog1.FileName, teste.potencia2(Convert.ToInt32(tamCache) / bloco), 32 - (teste.potencia2(Convert.ToInt32(tamCache) / bloco)) - word, word, a));
                        mpDireto.Start();
                        Thread.Sleep(300);

                        //associativo
                        tamSet = 2;
                        for (int p = 1; p < 4; p++)
                        {
                            //teste.mapeamentoAssociativo(openFileDialog1.FileName, 32 - (teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet)) - word, teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet), tamSet, true, false, word, p, a);

                            Thread mpAssociativoLRU = new Thread(() => teste.mapeamentoAssociativo(openFileDialog1.FileName, 32 - (teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet)) - word, teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet), tamSet, true, false, word, p, a));
                            mpAssociativoLRU.Start();
                            Thread.Sleep(300);

                            //teste.mapeamentoAssociativo(openFileDialog1.FileName, 32 - (teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet)) - word, teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet), tamSet, false, true, word, p, a);

                            Thread mpAssociativoFIFO = new Thread(() => teste.mapeamentoAssociativo(openFileDialog1.FileName, 32 - (teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet)) - word, teste.potencia2(Convert.ToInt32(Math.Pow(2, line)) / tamSet), tamSet, false, true, word, p, a));
                            mpAssociativoFIFO.Start();
                            Thread.Sleep(300);
                            tamSet = tamSet * 2;
                        }
                        tamCache = tamCache * 2;
                        a++;
                    }
                }
            }
            else
            {
                MessageBox.Show("Selecione um arquivo.");
            }
        }
コード例 #2
0
        public void defineTipoMapeamento()
        {
            if (deixaFuncionar == true)
            {
                funcoes teste = new funcoes();
                line     = Convert.ToInt32(cmbTamCache.Text) / bloco;
                line     = teste.potencia2(line);
                tamCache = Convert.ToInt32(cmbTamCache.Text);

                if (cmbTipoMapeamento.SelectedIndex == 0) //mapeamento direto
                {
                    tag = 32 - line - word;

                    label5.Visible   = true;
                    labelSet.Visible = false;
                    labLine.Text     = line.ToString();
                    labTag.Text      = tag.ToString();
                    labWord.Text     = word.ToString();
                }

                if (cmbTipoMapeamento.SelectedIndex == 1) //mapeamento associativo 2-way
                {
                    tamSet = 2;                           //pois é 2 way
                    set    = Convert.ToInt32(Math.Pow(2, line)) / tamSet;
                    set    = teste.potencia2(set);
                    tag    = 32 - set - word;

                    label5.Visible   = false;
                    labelSet.Visible = true;

                    labLine.Text = set.ToString();
                    labTag.Text  = tag.ToString();
                    labWord.Text = word.ToString();
                }

                if (cmbTipoMapeamento.SelectedIndex == 2) //mapeamento associativo 4-way
                {
                    tamSet = 4;                           //pois é 4 way
                    set    = Convert.ToInt32(Math.Pow(2, line)) / tamSet;
                    set    = teste.potencia2(set);
                    tag    = 32 - set - word;

                    label5.Visible   = false;
                    labelSet.Visible = true;

                    labLine.Text = set.ToString();
                    labTag.Text  = tag.ToString();
                    labWord.Text = word.ToString();
                }

                if (cmbTipoMapeamento.SelectedIndex == 3) //mapeamento associativo 8-way
                {
                    tamSet = 8;                           //pois é 8 way
                    set    = Convert.ToInt32(Math.Pow(2, line)) / tamSet;
                    set    = teste.potencia2(set);
                    tag    = 32 - set - word;

                    label5.Visible   = false;
                    labelSet.Visible = true;

                    labLine.Text = set.ToString();
                    labTag.Text  = tag.ToString();
                    labWord.Text = word.ToString();
                }
            }
        }