Exemplo n.º 1
0
    public void UpdateInstructionCacheUI()
    {
        if (instructionCache == null)
        {
            GetInstructionCache();
        }

        for (int i = 0; i < CacheConstants.Blocks; i++)
        {
            blocks[i].w0.text = instructionCache.GetInstruction(i, 0).Code.ToString();
            blocks[i].w1.text = instructionCache.GetInstruction(i, 1).Code.ToString();

            blocks[i].tag.text = TBL.InstIndexToDir(instructionCache.GetTag(i)).ToString();
        }
    }
Exemplo n.º 2
0
    // Cargar programas a memoria
    // esta funcionalidad podria ser traspasada a otra clase
    void LoadPrograms(string[] programNames)
    {
        int i      = 0;
        int thread = 0;

        foreach (string program in programNames)
        {
            bool firstLine = true;

            if (!System.IO.File.Exists(program)) // si el archivo no existe
            {
                continue;                        // continuar con el siguiente
            }
            string[] lines = System.IO.File.ReadAllLines(program);
            foreach (string line in lines)
            {
                string[]    args            = line.Split(' ');
                int         instructionCode = int.Parse(args[0]);
                int         r1          = int.Parse(args[1]);
                int         r2          = int.Parse(args[2]);
                int         imm         = int.Parse(args[3]);
                Instruction instruction = new Instruction(instructionCode, r1, r2, imm);
                memory.WriteInstruction(i, instruction);

                if (firstLine)                           // guardar el inicio de ejecucion de cada hilo
                {
                    int instDir = TBL.InstIndexToDir(i); // direccion de la instruccion
                    contextMemory.SetPC(thread, instDir);
                    firstLine = false;
                    //Debug.Log("Hilo " + threads + " PC Inicial: " + instDir);
                }

                i++;
            }
            thread++;
        }
    }