|
|
| version 1.1, 2006/01/19 17:16:29 | version 1.2, 2006/02/15 13:00:30 |
|---|---|
| Line 31 | Line 31 |
| /********************************************************************/ | /********************************************************************/ |
| /******************************************************************************/ | /******************************************************************************/ |
| /** MÓDULO: AnalizadorDependencias.c */ | /* MÓDULO: AnalizadorDependencias.c */ |
| /** */ | /* */ |
| /** Este módulo contiene las funciones que permiten analizar dependencias */ | /* Este módulo contiene las funciones que permiten analizar dependencias */ |
| /** de datos entre instrucciones. */ | /* de datos entre instrucciones. */ |
| /******************************************************************************/ | /******************************************************************************/ |
| /** Fecha: 23 de septiembre de 2005 */ | /* Fecha: 23 de septiembre de 2005 */ |
| /******************************************************************************/ | /******************************************************************************/ |
| /**@file AnalizadosDependencias.c | |
| Este módulo contiene las funciones que permiten analizar dependencias | |
| de datos entre instrucciones | |
| */ | |
| /**@author Sergio Alvarez Moreno | |
| */ | |
| #include <stdio.h> | #include <stdio.h> |
| #include <stdlib.h> | #include <stdlib.h> |
| #include <string.h> | #include <string.h> |
| Line 80 extern struct punterosD matriz; | Line 70 extern struct punterosD matriz; |
| /** ver relación de ContarUbicaciones y CrearListadoUbicaciones con NormalizarUbicacion | /* ver relación de ContarUbicaciones y CrearListadoUbicaciones con NormalizarUbicacion */ |
| /* cuento el número de posibles ubicaciones que cumplen con lo exigido en la */ | |
| @brief Cuento el número de posibles ubicaciones que cumplen con lo exigido en la | /* configuración (tipos admitidos) */ |
| configuración (tipos admitidos) | |
| @return r como el valor de ubicaciones encontradas | |
| */ | |
| int ContarUbicaciones() | int ContarUbicaciones() |
| { | { |
| unsigned int i; /* los registros de las bases de datos comienzan en el índice 0 */ | unsigned int i; /* los registros de las bases de datos comienzan en el índice 0 */ |
| unsigned int r = 0; /* recuento de ubicaciones */ | unsigned int r = 0; /* recuento de ubicaciones */ |
| char listado[MAX_LISTA]; | char listado[MAX_LISTA]; |
| char *elemento; /* es un puntero a char para la función strtok */ | char *elemento; /* es un puntero a char para la función strtok */ |
| char tipo; | char tipo; |
| strcpy(listado, configuracion.listaubis); | strcpy(listado, configuracion.listaubis); |
| elemento = strtok(listado, ":"); /* el separador de elementos de la lista es ':' */ | elemento = strtok(listado, ":"); /* el separador de elementos de la lista es ':' */ |
| while(elemento != NULL) | while(elemento != NULL) |
| { | { |
| tipo = atoi(elemento); | tipo = atoi(elemento); |
| i = 0; | i = 0; |
| while(i<num_simbolos) | while(i<num_simbolos) |
| { | { |
| if (simbolos[i].tipo == tipo) r++; | if (simbolos[i].tipo == tipo) r++; |
| i++; | i++; |
| } | } |
| /* capturo el siguiente campo */ | /* capturo el siguiente campo */ |
| elemento = strtok(NULL, ":"); | elemento = strtok(NULL, ":"); |
| } | } |
| return r; | return r; |
| } | } |
| /** | /* construyo el listado de posibles ubicaciones sobre una tabla nueva */ |
| @brief Construyo el listado de posibles ubicaciones sobre una tabla nueva | |
| */ | |
| void CrearListadoUbicaciones() | void CrearListadoUbicaciones() |
| { | { |
| unsigned int i, r; | unsigned int i, r; |
| char mensaje[MAX_LINE]; | char mensaje[MAX_LINE]; |
| char listado[MAX_LISTA]; | char listado[MAX_LISTA]; |
| char *elemento; /* es un puntero a char para la función strtok */ | char *elemento; /* es un puntero a char para la función strtok */ |
| char tipo; | char tipo; |
| /* doy valor a la variable global número total de ubicaciones */ | /* doy valor a la variable global número total de ubicaciones */ |
| num_ubicaciones = ContarUbicaciones(); | num_ubicaciones = ContarUbicaciones(); |
| /* creo un listado de posibles ubicaciones */ | /* creo un listado de posibles ubicaciones */ |
| datos = calloc(num_ubicaciones, sizeof (ubicacion)); | datos = calloc(num_ubicaciones, sizeof (ubicacion)); |
| if (datos == NULL) | if (datos == NULL) |
| { | { |
| sprintf(mensaje, "Memoria insuficiente"); | sprintf(mensaje, "Memoria insuficiente"); |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | Notificar(mensaje, ERROR_SALIR, ECO_NO); |
| /* el programa finaliza si no hay memoria suficiente */ | /* el programa finaliza si no hay memoria suficiente */ |
| } | } |
| strcpy(listado, configuracion.listaubis); | strcpy(listado, configuracion.listaubis); |
| r = 0; | r = 0; |
| elemento = strtok(listado, ":"); /* el separador de elementos de la lista es ':' */ | elemento = strtok(listado, ":"); /* el separador de elementos de la lista es ':' */ |
| while(elemento != NULL) | while(elemento != NULL) |
| { | { |
| tipo = atoi(elemento); | tipo = atoi(elemento); |
| i = 0; | i = 0; |
| while(i<num_simbolos) | while(i<num_simbolos) |
| { | { |
| if (simbolos[i].tipo == tipo) | if (simbolos[i].tipo == tipo) |
| { | { |
| strcpy(datos[r].nombre, simbolos[i].simbolo); | strcpy(datos[r].nombre, simbolos[i].simbolo); |
| r++; | r++; |
| } | } |
| i++; | i++; |
| } | } |
| /* capturo el siguiente campo */ | /* capturo el siguiente campo */ |
| elemento = strtok(NULL, ":"); | elemento = strtok(NULL, ":"); |
| } | } |
| /* for(i=0; i<num_ubicaciones; i++) printf("%d\t%s\n", i, datos[i].nombre); */ | /* for(i=0; i<num_ubicaciones; i++) printf("%d\t%s\n", i, datos[i].nombre); */ |
| } | } |
| /** | /* libera la memoria reservada para el listado de ubicaciones */ |
| @brief Libera la memoria reservada para el listado de ubicaciones | |
| */ | |
| void LiberarMemoriaListadoUbicaciones() | void LiberarMemoriaListadoUbicaciones() |
| { | { |
| free(datos); | free(datos); |
| } | } |
| /* busca una determinada ubicación de entre las que se dan en el listado de tipos */ | |
| /* si no se encuentra devuelve el número total de posibles ubicaciones */ | |
| /* BDBuscarUbicacion(char *cadena) NO IMPLEMENTADA */ | |
| /*@brief Busca una determinada ubicación de entre las que se dan en el listado de tipos | |
| si no se encuentra devuelve el número total de posibles ubicaciones | |
| BDBuscarUbicacion(char *cadena) NO IMPLEMENTADA | /* para buscar una determinada ubicación en el listado de posibles ubicaciones */ |
| /* utilizo la función int BDBuscarCadena(int idtabla, int idcampo, char *cadena) */ | |
| /* con idtabla = TABLA_UBICACIONES e idcampo = CAMPO_NOMBRE */ | |
| para buscar una determinada ubicación en el listado de posibles ubicaciones | |
| utilizo la función int BDBuscarCadena(int idtabla, int idcampo, char *cadena) | |
| con idtabla = TABLA_UBICACIONES e idcampo = CAMPO_NOMBRE */ | |
| /* crear la pizarra de escrituras */ | |
| /** | |
| @brief Crear la pizarra de escrituras | |
| */ | |
| void CrearPizarraEscrituras() | void CrearPizarraEscrituras() |
| { | { |
| char mensaje[MAX_LINE]; | char mensaje[MAX_LINE]; |
| pizarra_escrituras = calloc(num_ubicaciones, sizeof (int)); | pizarra_escrituras = calloc(num_ubicaciones, sizeof (int)); |
| if (pizarra_escrituras == NULL) | if (pizarra_escrituras == NULL) |
| { | { |
| sprintf(mensaje, "[CrearPizarraEscrituras] Memoria insuficiente"); | sprintf(mensaje, "[CrearPizarraEscrituras] Memoria insuficiente"); |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | Notificar(mensaje, ERROR_SALIR, ECO_NO); |
| /* el programa finaliza si no hay memoria suficiente */ | /* el programa finaliza si no hay memoria suficiente */ |
| } | } |
| } | } |
| /** | /* iniciar la pizarra de escrituras */ |
| @brief Iniciar la pizarra de escrituras | |
| */ | |
| void IniciarPizarraEscrituras() | void IniciarPizarraEscrituras() |
| { | { |
| unsigned int i; | unsigned int i; |
| /* relleno con FFFF...FFF (-1) */ | /* relleno con FFFF...FFF (-1) */ |
| for(i=0; i<num_ubicaciones; i++) pizarra_escrituras[i] = -1; | for(i=0; i<num_ubicaciones; i++) pizarra_escrituras[i] = -1; |
| /*for(i=0; i<num_ubicaciones; i++) printf("%6s", datos[i].nombre); printf("\n"); | /*for(i=0; i<num_ubicaciones; i++) printf("%6s", datos[i].nombre); printf("\n"); |
| for(i=0; i<num_ubicaciones; i++) printf("%6d", pizarra_escrituras[i]);*/ | for(i=0; i<num_ubicaciones; i++) printf("%6d", pizarra_escrituras[i]);*/ |
| } | } |
| /** | /* crear la pizarra de lecturas */ |
| @brief Crear la pizarra de lecturas | |
| */ | |
| void CrearPizarraLecturas() | void CrearPizarraLecturas() |
| { | { |
| char mensaje[MAX_LINE]; | char mensaje[MAX_LINE]; |
| unsigned int i; | unsigned int i; |
| /* 1º un puntero a entero por cada ubicación */ | /* 1º un puntero a entero por cada ubicación */ |
| pizarra_lecturas = calloc(num_ubicaciones, sizeof(int *)); | pizarra_lecturas = calloc(num_ubicaciones, sizeof(int *)); |
| if (pizarra_lecturas == NULL) | if (pizarra_lecturas == NULL) |
| { | { |
| sprintf(mensaje, "[CrearPizarraLecturas] Memoria insuficiente"); | sprintf(mensaje, "[CrearPizarraLecturas] Memoria insuficiente"); |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | Notificar(mensaje, ERROR_SALIR, ECO_NO); |
| /* el programa finaliza si no hay memoria suficiente */ | /* el programa finaliza si no hay memoria suficiente */ |
| } | } |
| /* 2º un entero por cada instrucción en la ventana de instrucciones */ | /* 2º un entero por cada instrucción en la ventana de instrucciones */ |
| for(i=0; i<num_ubicaciones; i++) | for(i=0; i<num_ubicaciones; i++) |
| { | { |
| pizarra_lecturas[i] = calloc(configuracion.ventana, sizeof(int)); | pizarra_lecturas[i] = calloc(configuracion.ventana, sizeof(int)); |
| if (pizarra_lecturas[i] == NULL) | if (pizarra_lecturas[i] == NULL) |
| { | { |
| sprintf(mensaje, "[CrearPizarraLecturas] Memoria insuficiente"); | sprintf(mensaje, "[CrearPizarraLecturas] Memoria insuficiente"); |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | Notificar(mensaje, ERROR_SALIR, ECO_NO); |
| /* el programa finaliza si no hay memoria suficiente */ | /* el programa finaliza si no hay memoria suficiente */ |
| } | } |
| } | } |
| } | } |
| /** | /* iniciar la pizarra de lecturas */ |
| @brief Iniciar la pizarra de lecturas | |
| */ | |
| void IniciarPizarraLecturas() | void IniciarPizarraLecturas() |
| { | { |
| unsigned int i, j; | unsigned int i, j; |
| /* relleno con FFFF...FFF (-1) */ | /* relleno con FFFF...FFF (-1) */ |
| for(i=0; i<num_ubicaciones; i++) | for(i=0; i<num_ubicaciones; i++) |
| { | { |
| for(j=0; j<configuracion.ventana; j++) pizarra_lecturas[i][j] = -1; | for(j=0; j<configuracion.ventana; j++) pizarra_lecturas[i][j] = -1; |
| } | } |
| /*for(i=0; i<num_ubicaciones; i++) | /*for(i=0; i<num_ubicaciones; i++) |
| { | { |
| printf("%s\t", datos[i].nombre); | printf("%s\t", datos[i].nombre); |
| for(j=0; j<configuracion.ventana; j++) printf("%d ", pizarra_lecturas[i][j]); | for(j=0; j<configuracion.ventana; j++) printf("%d ", pizarra_lecturas[i][j]); |
| printf("\n"); | printf("\n"); |
| }*/ | }*/ |
| } | } |
| /** | /* crea las pizarras en las que se anotan las dependencias de datos de cada ventana */ |
| @brief Crea las pizarras en las que se anotan las dependencias de datos de cada ventana | |
| */ | |
| void CrearPizarras() | void CrearPizarras() |
| { | { |
| /* las pizarras se crean de acuerdo a un listado de ubicaciones */ | /* las pizarras se crean de acuerdo a un listado de ubicaciones */ |
| CrearListadoUbicaciones(); | CrearListadoUbicaciones(); |
| CrearPizarraEscrituras(); | CrearPizarraEscrituras(); |
| CrearPizarraLecturas(); | CrearPizarraLecturas(); |
| } | } |
| /** | /* inicia las pizarras */ |
| @brief Inicia las pizarras | |
| */ | |
| void IniciarPizarras() | void IniciarPizarras() |
| { | { |
| IniciarPizarraEscrituras(); | IniciarPizarraEscrituras(); |
| IniciarPizarraLecturas(); | IniciarPizarraLecturas(); |
| } | } |
| /** | /* libera la memoria reservada para las pizarras */ |
| @brief Libera la memoria reservada para las pizarras | |
| */ | |
| void LiberarMemoriaPizarras() | void LiberarMemoriaPizarras() |
| { | { |
| unsigned int i; | unsigned int i; |
| /* libero el listado de ubicaciones con el que se han construido las pizarras */ | /* libero el listado de ubicaciones con el que se han construido las pizarras */ |
| LiberarMemoriaListadoUbicaciones(); | LiberarMemoriaListadoUbicaciones(); |
| free(pizarra_escrituras); | free(pizarra_escrituras); |
| for (i=0; i<num_ubicaciones; i++) free(pizarra_lecturas[i]); | for (i=0; i<num_ubicaciones; i++) free(pizarra_lecturas[i]); |
| free(pizarra_lecturas); | free(pizarra_lecturas); |
| } | } |
| /** | /* crear el vector de dependencias */ |
| @brief Crear el vector de dependencias | |
| */ | |
| void CrearVectorDependencias() | void CrearVectorDependencias() |
| { | { |
| char mensaje[MAX_LINE]; | char mensaje[MAX_LINE]; |
| vector = calloc(configuracion.ventana, sizeof (unsigned char)); | vector = calloc(configuracion.ventana, sizeof (unsigned char)); |
| if (vector == NULL) | if (vector == NULL) |
| { | { |
| sprintf(mensaje, "[CrearVectorDependencias] Memoria insuficiente"); | sprintf(mensaje, "[CrearVectorDependencias] Memoria insuficiente"); |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | Notificar(mensaje, ERROR_SALIR, ECO_NO); |
| /* el programa finaliza si no hay memoria suficiente */ | /* el programa finaliza si no hay memoria suficiente */ |
| } | } |
| } | } |
| /** | /* limpiar vector de dependencias */ |
| @brief Limpiar vector de dependencias | |
| */ | |
| void IniciarVectorDependencias() | void IniciarVectorDependencias() |
| { | { |
| unsigned int i; | unsigned int i; |
| for(i=0; i<configuracion.ventana; i++) vector[i] = 0; | for(i=0; i<configuracion.ventana; i++) vector[i] = 0; |
| } | } |
| /** | /* liberar memoria del vector de dependencias */ |
| @brief Liberar memoria del vector de dependencias | |
| */ | |
| void LiberarMemoriaVectorDependencias() | void LiberarMemoriaVectorDependencias() |
| { | { |
| free(vector); | free(vector); |
| } | } |
| /** | /* genera un vector de dependencias para un tipo de dependencia y tipo de datos */ |
| @brief Genera un vector de dependencias para un tipo de dependencia y tipo de datos | /* el resultado representa la SUMA con los valores previos del vector */ |
| el resultado representa la SUMA con los valores previos del vector | |
| @param *tarjetaoperandos: Puntero a una estructura del tipo fichainstruccion | |
| @param iddepen: Cadena de caracteres que indica el identificador del tipo de dependencia que se quiere generar el vector (WW, WR. RW) | |
| @param idfuente: Cadena de caracteres que indica el identificador del fuente del cual se quiere generar el vector (DATOSEXP,DATOSIMP,DIREXP,DIRIMP,PILAEXP,PILAIMP,CCEXP) | |
| */ | |
| void GenerarVector(fichainstruccion *tarjetaoperandos, char iddepen, char idfuente) | void GenerarVector(fichainstruccion *tarjetaoperandos, char iddepen, char idfuente) |
| { | { |
| char mensaje[MAX_LINE]; | char mensaje[MAX_LINE]; |
| char listado[MAX_LISTA]; | char listado[MAX_LISTA]; |
| char *elemento; | char *elemento; |
| int indice_ubi; | int indice_ubi; |
| unsigned int j; | unsigned int j; |
| switch(idfuente) | |
| { | |
| case DATOSEXP: /* datos explícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoexpldatos); | |
| else strcpy(listado, tarjetaoperandos->escritoexpldatos); | |
| break; | |
| case DATOSIMP: /* datos implícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoimpldatos); | |
| else strcpy(listado, tarjetaoperandos->escritoimpldatos); | |
| break; | |
| case DIREXP: /* direcciones explícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoexpldir); | |
| else strcpy(listado, tarjetaoperandos->escritoexpldir); | |
| break; | |
| case DIRIMP: /* direcciones implícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoimpldir); | |
| else strcpy(listado, tarjetaoperandos->escritoimpldir); | |
| break; | |
| case PILAEXP: /* pila explícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoexplpila); | |
| else strcpy(listado, tarjetaoperandos->escritoexplpila); | |
| break; | |
| case PILAIMP: /* pila implícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoimplpila); | |
| else strcpy(listado, tarjetaoperandos->escritoimplpila); | |
| break; | |
| case CCEXP: /* códigos de condición explícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoexplestado); | |
| else strcpy(listado, tarjetaoperandos->escritoexplestado); | |
| break; | |
| case CCIMP: /* códigos de condición implícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoimplestado); | |
| else strcpy(listado, tarjetaoperandos->escritoimplestado); | |
| break; | |
| } | |
| elemento = strtok(listado, ":"); /* el separador de elementos de la lista es ':' */ | switch(idfuente) |
| { | |
| case DATOSEXP: /* datos explícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoexpldatos); | |
| else strcpy(listado, tarjetaoperandos->escritoexpldatos); | |
| break; | |
| case DATOSIMP: /* datos implícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoimpldatos); | |
| else strcpy(listado, tarjetaoperandos->escritoimpldatos); | |
| break; | |
| case DIREXP: /* direcciones explícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoexpldir); | |
| else strcpy(listado, tarjetaoperandos->escritoexpldir); | |
| break; | |
| case DIRIMP: /* direcciones implícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoimpldir); | |
| else strcpy(listado, tarjetaoperandos->escritoimpldir); | |
| break; | |
| case PILAEXP: /* pila explícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoexplpila); | |
| else strcpy(listado, tarjetaoperandos->escritoexplpila); | |
| break; | |
| case PILAIMP: /* pila implícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoimplpila); | |
| else strcpy(listado, tarjetaoperandos->escritoimplpila); | |
| break; | |
| case CCEXP: /* códigos de condición explícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoexplestado); | |
| else strcpy(listado, tarjetaoperandos->escritoexplestado); | |
| break; | |
| case CCIMP: /* códigos de condición implícitos */ | |
| if (iddepen == RW) strcpy(listado, tarjetaoperandos->leidoimplestado); | |
| else strcpy(listado, tarjetaoperandos->escritoimplestado); | |
| break; | |
| } | |
| elemento = strtok(listado, ":"); /* el separador de elementos de la lista es ':' */ | |
| while(elemento != NULL) | while(elemento != NULL) |
| { | { |
| indice_ubi = BDBuscarCadena(TABLA_UBICACIONES, CAMPO_NOMBRE, elemento); | indice_ubi = BDBuscarCadena(TABLA_UBICACIONES, CAMPO_NOMBRE, elemento); |
| if(indice_ubi == -1) | if(indice_ubi == -1) |
| { | { |
| /* emito un error al fichero de log */ | /* emito un error al fichero de log */ |
| sprintf(mensaje, "[GenerarVector] La cadena '%s' no se ha encontrado en Tabla Ubicaciones", elemento); | sprintf(mensaje, "[GenerarVector] La cadena '%s' no se ha encontrado en Tabla Ubicaciones", elemento); |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | Notificar(mensaje, ERROR_SALIR, ECO_NO); |
| } | } |
| switch(iddepen) | switch(iddepen) |
| { | { |
| case RW: /* verdadera o lectura después de escritura */ | case RW: /* verdadera o lectura después de escritura */ |
| if(pizarra_escrituras[indice_ubi] != -1) | if(pizarra_escrituras[indice_ubi] != -1) |
| { | { |
| vector[pizarra_escrituras[indice_ubi]] += 1; | vector[pizarra_escrituras[indice_ubi]] += 1; |
| if(vector[pizarra_escrituras[indice_ubi]] == 0) | if(vector[pizarra_escrituras[indice_ubi]] == 0) |
| { | { |
| sprintf(mensaje, "[GenerarVector] La componente del vector de dependencias ha excedido el valor 255"); | sprintf(mensaje, "[GenerarVector] La componente del vector de dependencias ha excedido el valor 255"); |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | Notificar(mensaje, ERROR_SALIR, ECO_NO); |
| } | } |
| } | } |
| break; | break; |
| case WR: /* antidependencia o escritura después de lectura */ | case WR: /* antidependencia o escritura después de lectura */ |
| /* pizarra_lecturas[i][j] -> i: ubicaciones; j: instrucciones */ | /* pizarra_lecturas[i][j] -> i: ubicaciones; j: instrucciones */ |
| for(j=0; j<configuracion.ventana; j++) | for(j=0; j<configuracion.ventana; j++) |
| { | { |
| if(pizarra_lecturas[indice_ubi][j] == 1) | if(pizarra_lecturas[indice_ubi][j] == 1) |
| { | { |
| vector[j] += 1; | vector[j] += 1; |
| if(vector[j] == 0) | if(vector[j] == 0) |
| { | { |
| sprintf(mensaje, "[GenerarVector] La componente del vector de dependencias ha excedido el valor 255"); | sprintf(mensaje, "[GenerarVector] La componente del vector de dependencias ha excedido el valor 255"); |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | Notificar(mensaje, ERROR_SALIR, ECO_NO); |
| } | } |
| } | } |
| } | } |
| break; | break; |
| case WW: /* salida o escritura después de escritura */ | case WW: /* salida o escritura después de escritura */ |
| if(pizarra_escrituras[indice_ubi] != -1) | if(pizarra_escrituras[indice_ubi] != -1) |
| { | { |
| vector[pizarra_escrituras[indice_ubi]] += 1; | vector[pizarra_escrituras[indice_ubi]] += 1; |
| if(vector[pizarra_escrituras[indice_ubi]] == 0) | if(vector[pizarra_escrituras[indice_ubi]] == 0) |
| { | { |
| sprintf(mensaje, "[GenerarVector] La componente del vector de dependencias ha excedido el valor 255"); | sprintf(mensaje, "[GenerarVector] La componente del vector de dependencias ha excedido el valor 255"); |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | Notificar(mensaje, ERROR_SALIR, ECO_NO); |
| } | } |
| } | } |
| break; | break; |
| } | } |
| /* capturo el siguiente campo */ | /* capturo el siguiente campo */ |
| elemento = strtok(NULL, ":"); | elemento = strtok(NULL, ":"); |
| } | } |
| } | } |
| /** | /* traslada un vector de dependencias a la matriz indicada como parámetro */ |
| @brief Traslada un vector de dependencias a la matriz indicada como parámetro | /* en la posición indicada por el número de instrucción (índice) en la ventana */ |
| en la posición indicada por el número de instrucción (índice) en la ventana | |
| @param **matriz: Matriz a la cual se le va a trasladar el vector | |
| @param indice: Posición dentro de la matriz en la cual se va a trasladar el vector | |
| */ | |
| void Vector2Matriz(unsigned char **matriz, unsigned int indice) | void Vector2Matriz(unsigned char **matriz, unsigned int indice) |
| { | { |
| char mensaje[MAX_LINE]; | char mensaje[MAX_LINE]; |
| unsigned int i; | unsigned int i; |
| if(matriz == NULL) | if(matriz == NULL) |
| { | { |
| sprintf(mensaje, "[Vector2Matriz] La matriz indicada no existe"); | sprintf(mensaje, "[Vector2Matriz] La matriz indicada no existe"); |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | Notificar(mensaje, ERROR_SALIR, ECO_NO); |
| } | } |
| for(i=0; i<configuracion.ventana; i++) matriz[indice][i] = vector[i]; | for(i=0; i<configuracion.ventana; i++) matriz[indice][i] = vector[i]; |
| } | } |
| /** | /* analiza todas las posibles dependencias de datos generando su vector */ |
| @brief Analiza todas las posibles dependencias de datos generando su vector | /* de dependencias y almacenándolo en la matriz adecuada */ |
| de dependencias y almacenándolo en la matriz adecuada | |
| @param *tarjetaoperandos: Puntero a una estructura del tipo fichainstruccion | |
| @param indice: posición de la matriz en la cual se va a analizar la dependencia | |
| */ | |
| void AnalizarDependencias(fichainstruccion *tarjetaoperandos, unsigned int indice) | void AnalizarDependencias(fichainstruccion *tarjetaoperandos, unsigned int indice) |
| { | { |
| /* evalúo las dependencias en el siguiente orden: verdaderas, anti y salida */ | /* evalúo las dependencias en el siguiente orden: verdaderas, anti y salida */ |
| /* dentro de cada fuente: explícitas y luego implícitas */ | /* dentro de cada fuente: explícitas y luego implícitas */ |
| /* dentro de cada origen por tipos: datos, direcciones, pila y estado */ | /* dentro de cada origen por tipos: datos, direcciones, pila y estado */ |
| /* si no limpio el vector de dependencias éste lleva la SUMA de los precedentes */ | /* si no limpio el vector de dependencias éste lleva la SUMA de los precedentes */ |
| /* mapa de posibles matrices */ | /* mapa de posibles matrices */ |
| /* fuente origen tipo */ | /* tipo origen fuente */ |
| /* SI SI SI */ | /* SI SI SI */ |
| /* SI SI NO */ | /* SI SI NO */ |
| /* SI NO NO */ | /* SI NO NO */ |
| /* NO NO NO */ | /* NO NO NO */ /* -> por defecto no se desacopla nada */ |
| /* VERDADERAS */ | /* VERDADERAS */ |
| if(configuracion.verdaderas == SI) | if(configuracion.verdaderas == SI) |
| { | { |
| if(configuracion.explicitos == SI) | if(configuracion.explicitos == SI) |
| { | { |
| if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, RW, DATOSEXP); | if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, RW, DATOSEXP); |
| /* for(i=0; i<configuracion.ventana; i++) printf("%d ", vector[i]); printf("\n"); */ | /* for(i=0; i<configuracion.ventana; i++) printf("%d ", vector[i]); printf("\n"); */ |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.datos == SI) |
| { | { |
| Vector2Matriz(matriz.Ddatoexp, indice); | Vector2Matriz(matriz.Ddatoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, RW, DIREXP); | if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, RW, DIREXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.direcciones == SI) |
| { | { |
| Vector2Matriz(matriz.Ddir_exp, indice); | Vector2Matriz(matriz.Ddir_exp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, RW, PILAEXP); | if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, RW, PILAEXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.pila == SI) |
| { | { |
| Vector2Matriz(matriz.Dpilaexp, indice); | Vector2Matriz(matriz.Dpilaexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, RW, CCEXP); | if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, RW, CCEXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.cc == SI) |
| { | { |
| Vector2Matriz(matriz.Destadoexp, indice); | Vector2Matriz(matriz.Destadoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| } | } |
| if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) | if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) |
| { | { |
| Vector2Matriz(matriz.Ddatoexp, indice); | Vector2Matriz(matriz.Ddatoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.implicitos == SI) | if(configuracion.implicitos == SI) |
| { | { |
| if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, RW, DATOSIMP); | if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, RW, DATOSIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.datos == SI) |
| { | { |
| Vector2Matriz(matriz.Ddatoimp, indice); | Vector2Matriz(matriz.Ddatoimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, RW, DIRIMP); | if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, RW, DIRIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.direcciones == SI) |
| { | { |
| Vector2Matriz(matriz.Ddir_imp, indice); | Vector2Matriz(matriz.Ddir_imp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, RW, PILAIMP); | if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, RW, PILAIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.pila == SI) |
| { | { |
| Vector2Matriz(matriz.Dpilaimp, indice); | Vector2Matriz(matriz.Dpilaimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, RW, CCIMP); | if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, RW, CCIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.cc == SI) |
| { | { |
| Vector2Matriz(matriz.Destadoimp, indice); | Vector2Matriz(matriz.Destadoimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| } | } |
| if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) | if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) |
| { | { |
| Vector2Matriz(matriz.Ddatoimp, indice); | Vector2Matriz(matriz.Ddatoimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| } | } |
| if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == NO && configuracion.desacoplarfuentes == SI) | if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == NO && configuracion.desacoplarfuentes == SI) |
| { | { |
| Vector2Matriz(matriz.Ddatoexp, indice); | Vector2Matriz(matriz.Ddatoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| /* ANTIDEPENDENCIAS */ | /* ANTIDEPENDENCIAS */ |
| if(configuracion.antidependencias == SI) | if(configuracion.antidependencias == SI) |
| { | { |
| if(configuracion.explicitos == SI) | if(configuracion.explicitos == SI) |
| { | { |
| if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, WR, DATOSEXP); | if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, WR, DATOSEXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.datos == SI) |
| { | { |
| Vector2Matriz(matriz.ADdatoexp, indice); | Vector2Matriz(matriz.ADdatoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, WR, DIREXP); | if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, WR, DIREXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.direcciones == SI) |
| { | { |
| Vector2Matriz(matriz.ADdir_exp, indice); | Vector2Matriz(matriz.ADdir_exp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, WR, PILAEXP); | if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, WR, PILAEXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.pila == SI) |
| { | { |
| Vector2Matriz(matriz.ADpilaexp, indice); | Vector2Matriz(matriz.ADpilaexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, WR, CCEXP); | if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, WR, CCEXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.cc == SI) |
| { | { |
| Vector2Matriz(matriz.ADestadoexp, indice); | Vector2Matriz(matriz.ADestadoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| } | } |
| if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) | if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) |
| { | { |
| Vector2Matriz(matriz.ADdatoexp, indice); | Vector2Matriz(matriz.ADdatoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.implicitos == SI) | if(configuracion.implicitos == SI) |
| { | { |
| if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, WR, DATOSIMP); | if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, WR, DATOSIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.datos == SI) |
| { | { |
| Vector2Matriz(matriz.ADdatoimp, indice); | Vector2Matriz(matriz.ADdatoimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, WR, DIRIMP); | if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, WR, DIRIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.direcciones == SI) |
| { | { |
| Vector2Matriz(matriz.ADdir_imp, indice); | Vector2Matriz(matriz.ADdir_imp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, WR, PILAIMP); | if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, WR, PILAIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.pila == SI) |
| { | { |
| Vector2Matriz(matriz.ADpilaimp, indice); | Vector2Matriz(matriz.ADpilaimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, WR, CCIMP); | if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, WR, CCIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.cc == SI) |
| { | { |
| Vector2Matriz(matriz.ADestadoimp, indice); | Vector2Matriz(matriz.ADestadoimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| } | } |
| if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) | if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) |
| { | { |
| Vector2Matriz(matriz.ADdatoimp, indice); | Vector2Matriz(matriz.ADdatoimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| } | } |
| if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == NO && configuracion.desacoplarfuentes == SI) | if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == NO && configuracion.desacoplarfuentes == SI) |
| { | { |
| Vector2Matriz(matriz.ADdatoexp, indice); | Vector2Matriz(matriz.ADdatoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| /* SALIDA */ | /* SALIDA */ |
| if(configuracion.salida == SI) | if(configuracion.salida == SI) |
| { | { |
| if(configuracion.explicitos == SI) | if(configuracion.explicitos == SI) |
| { | { |
| if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, WW, DATOSEXP); | if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, WW, DATOSEXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.datos == SI) |
| { | { |
| Vector2Matriz(matriz.Sdatoexp, indice); | Vector2Matriz(matriz.Sdatoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, WW, DIREXP); | if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, WW, DIREXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.direcciones == SI) |
| { | { |
| Vector2Matriz(matriz.Sdir_exp, indice); | Vector2Matriz(matriz.Sdir_exp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, WW, PILAEXP); | if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, WW, PILAEXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.pila == SI) |
| { | { |
| Vector2Matriz(matriz.Spilaexp, indice); | Vector2Matriz(matriz.Spilaexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, WW, CCEXP); | if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, WW, CCEXP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.cc == SI) |
| { | { |
| Vector2Matriz(matriz.Sestadoexp, indice); | Vector2Matriz(matriz.Sestadoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| } | } |
| if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) | if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) |
| { | { |
| Vector2Matriz(matriz.Sdatoexp, indice); | Vector2Matriz(matriz.Sdatoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.implicitos == SI) | if(configuracion.implicitos == SI) |
| { | { |
| if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, WW, DATOSIMP); | if(configuracion.datos == SI) GenerarVector(tarjetaoperandos, WW, DATOSIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.datos == SI) |
| { | { |
| Vector2Matriz(matriz.Sdatoimp, indice); | Vector2Matriz(matriz.Sdatoimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, WW, DIRIMP); | if(configuracion.direcciones == SI) GenerarVector(tarjetaoperandos, WW, DIRIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.direcciones == SI) |
| { | { |
| Vector2Matriz(matriz.Sdir_imp, indice); | Vector2Matriz(matriz.Sdir_imp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, WW, PILAIMP); | if(configuracion.pila == SI) GenerarVector(tarjetaoperandos, WW, PILAIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.pila == SI) |
| { | { |
| Vector2Matriz(matriz.Spilaimp, indice); | Vector2Matriz(matriz.Spilaimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, WW, CCIMP); | if(configuracion.cc == SI) GenerarVector(tarjetaoperandos, WW, CCIMP); |
| if(configuracion.desacoplartipos == SI) | if(configuracion.desacoplartipos == SI && configuracion.cc == SI) |
| { | { |
| Vector2Matriz(matriz.Sestadoimp, indice); | Vector2Matriz(matriz.Sestadoimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| } | } |
| if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) | if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == SI) |
| { | { |
| Vector2Matriz(matriz.Sdatoimp, indice); | Vector2Matriz(matriz.Sdatoimp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| } | } |
| if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == NO && configuracion.desacoplarfuentes == SI) | if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == NO && configuracion.desacoplarfuentes == SI) |
| { | { |
| Vector2Matriz(matriz.Sdatoexp, indice); | Vector2Matriz(matriz.Sdatoexp, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| /* si no desacoplo por ningún concepto todo va a la matriz D */ | /* si no desacoplo por ningún concepto todo va a la matriz D */ |
| if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == NO && configuracion.desacoplarfuentes == NO) | if(configuracion.desacoplartipos == NO && configuracion.desacoplarorigen == NO && configuracion.desacoplarfuentes == NO) |
| { | { |
| Vector2Matriz(matriz.D, indice); | Vector2Matriz(matriz.D, indice); |
| IniciarVectorDependencias(); | IniciarVectorDependencias(); |
| } | } |
| } | } |
| /** | /* genera la matriz D a partir de las desacopladas */ |
| @brief Genera la matriz D a partir de las desacopladas | |
| */ | |
| void GenerarMatrizD() | void GenerarMatrizD() |
| { | { |
| unsigned int i, j, dim; | unsigned int i, j, dim; |
| unsigned char suma; | unsigned char suma; |
| dim = configuracion.ventana; | |
| dim = configuracion.ventana; | /* si no desacoplo por ningún concepto ya tengo la matriz D */ |
| /* en caso de que haya desacoplos debo SUMAR las matrices parciales para generar D */ | |
| if(configuracion.desacoplartipos != NO || configuracion.desacoplarorigen != NO || configuracion.desacoplarfuentes != NO) | |
| { | |
| for(i=0; i<dim; i++) | |
| { | |
| for(j=0; j<dim; j++) | |
| { | |
| suma = 0; | |
| if(matriz.Ddatoexp != NULL) suma = suma + matriz.Ddatoexp[i][j]; | |
| if(matriz.Ddir_exp != NULL) suma = suma + matriz.Ddir_exp[i][j]; | |
| if(matriz.Dpilaexp != NULL) suma = suma + matriz.Dpilaexp[i][j]; | |
| if(matriz.Destadoexp != NULL) suma = suma + matriz.Destadoexp[i][j]; | |
| if(matriz.Ddatoimp != NULL) suma = suma + matriz.Ddatoimp[i][j]; | |
| if(matriz.Ddir_imp != NULL) suma = suma + matriz.Ddir_imp[i][j]; | |
| if(matriz.Dpilaimp != NULL) suma = suma + matriz.Dpilaimp[i][j]; | |
| if(matriz.Destadoimp != NULL) suma = suma + matriz.Destadoimp[i][j]; | |
| if(matriz.ADdatoexp != NULL) suma = suma + matriz.ADdatoexp[i][j]; | |
| if(matriz.ADdir_exp != NULL) suma = suma + matriz.ADdir_exp[i][j]; | |
| if(matriz.ADpilaexp != NULL) suma = suma + matriz.ADpilaexp[i][j]; | |
| if(matriz.ADestadoexp != NULL) suma = suma + matriz.ADestadoexp[i][j]; | |
| if(matriz.ADdatoimp != NULL) suma = suma + matriz.ADdatoimp[i][j]; | |
| if(matriz.ADdir_imp != NULL) suma = suma + matriz.ADdir_imp[i][j]; | |
| if(matriz.ADpilaimp != NULL) suma = suma + matriz.ADpilaimp[i][j]; | |
| if(matriz.ADestadoimp != NULL) suma = suma + matriz.ADestadoimp[i][j]; | |
| if(matriz.Sdatoexp != NULL) suma = suma + matriz.Sdatoexp[i][j]; | |
| if(matriz.Sdir_exp != NULL) suma = suma + matriz.Sdir_exp[i][j]; | |
| if(matriz.Spilaexp != NULL) suma = suma + matriz.Spilaexp[i][j]; | |
| if(matriz.Sestadoexp != NULL) suma = suma + matriz.Sestadoexp[i][j]; | |
| if(matriz.Sdatoimp != NULL) suma = suma + matriz.Sdatoimp[i][j]; | |
| if(matriz.Sdir_imp != NULL) suma = suma + matriz.Sdir_imp[i][j]; | |
| if(matriz.Spilaimp != NULL) suma = suma + matriz.Spilaimp[i][j]; | |
| if(matriz.Sestadoimp != NULL) suma = suma + matriz.Sestadoimp[i][j]; | |
| /* si no desacoplo por ningún concepto ya tengo la matriz D */ | matriz.D[i][j] = suma; |
| /* en caso de que haya desacoplos debo SUMAR las matrices parciales para generar D */ | } |
| if(configuracion.desacoplartipos != NO || configuracion.desacoplarorigen != NO || configuracion.desacoplarfuentes != NO) | } |
| { | } |
| for(i=0; i<dim; i++) | |
| { | |
| for(j=0; j<dim; j++) | |
| { | |
| suma = 0; | |
| if(matriz.Ddatoexp != NULL) suma = suma + matriz.Ddatoexp[i][j]; | |
| if(matriz.Ddir_exp != NULL) suma = suma + matriz.Ddir_exp[i][j]; | |
| if(matriz.Dpilaexp != NULL) suma = suma + matriz.Dpilaexp[i][j]; | |
| if(matriz.Destadoexp != NULL) suma = suma + matriz.Destadoexp[i][j]; | |
| if(matriz.Ddatoimp != NULL) suma = suma + matriz.Ddatoimp[i][j]; | |
| if(matriz.Ddir_imp != NULL) suma = suma + matriz.Ddir_imp[i][j]; | |
| if(matriz.Dpilaimp != NULL) suma = suma + matriz.Dpilaimp[i][j]; | |
| if(matriz.Destadoimp != NULL) suma = suma + matriz.Destadoimp[i][j]; | |
| if(matriz.ADdatoexp != NULL) suma = suma + matriz.ADdatoexp[i][j]; | |
| if(matriz.ADdir_exp != NULL) suma = suma + matriz.ADdir_exp[i][j]; | |
| if(matriz.ADpilaexp != NULL) suma = suma + matriz.ADpilaexp[i][j]; | |
| if(matriz.ADestadoexp != NULL) suma = suma + matriz.ADestadoexp[i][j]; | |
| if(matriz.ADdatoimp != NULL) suma = suma + matriz.ADdatoimp[i][j]; | |
| if(matriz.ADdir_imp != NULL) suma = suma + matriz.ADdir_imp[i][j]; | |
| if(matriz.ADpilaimp != NULL) suma = suma + matriz.ADpilaimp[i][j]; | |
| if(matriz.ADestadoimp != NULL) suma = suma + matriz.ADestadoimp[i][j]; | |
| if(matriz.Sdatoexp != NULL) suma = suma + matriz.Sdatoexp[i][j]; | |
| if(matriz.Sdir_exp != NULL) suma = suma + matriz.Sdir_exp[i][j]; | |
| if(matriz.Spilaexp != NULL) suma = suma + matriz.Spilaexp[i][j]; | |
| if(matriz.Sestadoexp != NULL) suma = suma + matriz.Sestadoexp[i][j]; | |
| if(matriz.Sdatoimp != NULL) suma = suma + matriz.Sdatoimp[i][j]; | |
| if(matriz.Sdir_imp != NULL) suma = suma + matriz.Sdir_imp[i][j]; | |
| if(matriz.Spilaimp != NULL) suma = suma + matriz.Spilaimp[i][j]; | |
| if(matriz.Sestadoimp != NULL) suma = suma + matriz.Sestadoimp[i][j]; | |
| matriz.D[i][j] = suma; | |
| } | |
| } | |
| } | |
| } | } |
| /** | /* anota en la pizarra de escrituras las que realiza una instrucción */ |
| @brief Anota en la pizarra de escrituras las que realiza una instrucción | /* en una lista de ubicaciones */ |
| en una lista de ubicaciones | |
| @param *listado: Cadena de caracteres que indican las operaciones que hace la instruccion | |
| @param indice: Posición dentro de la matriz que ocupa dicha operaciones con su dependencia correspondiente | |
| */ | |
| void AnotarListaEscrituras(char *listado, unsigned int indice) | void AnotarListaEscrituras(char *listado, unsigned int indice) |
| { | { |
| char mensaje[MAX_LINE]; | char mensaje[MAX_LINE]; |
| char *elemento; | char *elemento; |
| int indice_ubi; | int indice_ubi; |
| elemento = strtok(listado, ":"); /* el separador de elementos de la lista es ':' */ | elemento = strtok(listado, ":"); /* el separador de elementos de la lista es ':' */ |
| while(elemento != NULL) | while(elemento != NULL) |
| { | { |
| indice_ubi = BDBuscarCadena(TABLA_UBICACIONES, CAMPO_NOMBRE, elemento); | indice_ubi = BDBuscarCadena(TABLA_UBICACIONES, CAMPO_NOMBRE, elemento); |
| if(indice_ubi == -1) | |
| { | |
| /* emito un error al fichero de log */ | |
| sprintf(mensaje, "[AnotarListaEscrituras] La cadena '%s' no se ha encontrado en Tabla Ubicaciones", elemento); | |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | |
| } | |
| if(indice_ubi == -1) | pizarra_escrituras[indice_ubi] = indice; |
| { | |
| /* emito un error al fichero de log */ | /* capturo el siguiente campo */ |
| sprintf(mensaje, "[AnotarListaEscrituras] La cadena '%s' no se ha encontrado en Tabla Ubicaciones", elemento); | |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | |
| } | |
| pizarra_escrituras[indice_ubi] = indice; | |
| /* capturo el siguiente campo */ | |
| elemento = strtok(NULL, ":"); | elemento = strtok(NULL, ":"); |
| } | } |
| } | } |
| /** | /* anota en la pizarra de escrituras aquellas que realiza */ |
| @brief Anota en la pizarra de escrituras aquellas que realiza | /* la instrucción, de todos los tipos y de todos los orígenes */ |
| la instrucción, de todos los tipos y de todos los orígenes | |
| @param *tarjetaoperandos: Puntero a una estructura del tipo fichainstruccion | |
| @param indice: Posición dentro de la matriz | |
| */ | |
| void AnotarEscrituras(fichainstruccion *tarjetaoperandos, unsigned int indice) | void AnotarEscrituras(fichainstruccion *tarjetaoperandos, unsigned int indice) |
| { | { |
| char listado[MAX_LISTA]; | char listado[MAX_LISTA]; |
| strcpy(listado, tarjetaoperandos->escritoexpldatos); | strcpy(listado, tarjetaoperandos->escritoexpldatos); |
| AnotarListaEscrituras(listado, indice); | AnotarListaEscrituras(listado, indice); |
| strcpy(listado, tarjetaoperandos->escritoimpldatos); | strcpy(listado, tarjetaoperandos->escritoimpldatos); |
| AnotarListaEscrituras(listado, indice); | AnotarListaEscrituras(listado, indice); |
| strcpy(listado, tarjetaoperandos->escritoexpldir); | strcpy(listado, tarjetaoperandos->escritoexpldir); |
| AnotarListaEscrituras(listado, indice); | AnotarListaEscrituras(listado, indice); |
| strcpy(listado, tarjetaoperandos->escritoimpldir); | strcpy(listado, tarjetaoperandos->escritoimpldir); |
| AnotarListaEscrituras(listado, indice); | AnotarListaEscrituras(listado, indice); |
| strcpy(listado, tarjetaoperandos->escritoexplpila); | strcpy(listado, tarjetaoperandos->escritoexplpila); |
| AnotarListaEscrituras(listado, indice); | AnotarListaEscrituras(listado, indice); |
| strcpy(listado, tarjetaoperandos->escritoimplpila); | strcpy(listado, tarjetaoperandos->escritoimplpila); |
| AnotarListaEscrituras(listado, indice); | AnotarListaEscrituras(listado, indice); |
| strcpy(listado, tarjetaoperandos->escritoexplestado); | strcpy(listado, tarjetaoperandos->escritoexplestado); |
| AnotarListaEscrituras(listado, indice); | AnotarListaEscrituras(listado, indice); |
| strcpy(listado, tarjetaoperandos->escritoimplestado); | strcpy(listado, tarjetaoperandos->escritoimplestado); |
| AnotarListaEscrituras(listado, indice); | AnotarListaEscrituras(listado, indice); |
| } | } |
| /** | /* anota en la pizarra de lecturas las que realiza una instrucción */ |
| @brief Anota en la pizarra de lecturas las que realiza una instrucción | /* en una lista de ubicaciones */ |
| en una lista de ubicaciones | |
| @param *listado: Cadena de caracteres que indican las operaciones que hace la instruccion | |
| @param indice: Posición dentro de la matriz que ocupa dicha operaciones con su dependencia correspondiente | |
| */ | |
| void AnotarListaLecturas(char *listado, unsigned int indice) | void AnotarListaLecturas(char *listado, unsigned int indice) |
| { | { |
| char mensaje[MAX_LINE]; | char mensaje[MAX_LINE]; |
| char *elemento; | char *elemento; |
| int indice_ubi; | int indice_ubi; |
| elemento = strtok(listado, ":"); /* el separador de elementos de la lista es ':' */ | elemento = strtok(listado, ":"); /* el separador de elementos de la lista es ':' */ |
| while(elemento != NULL) | while(elemento != NULL) |
| { | { |
| indice_ubi = BDBuscarCadena(TABLA_UBICACIONES, CAMPO_NOMBRE, elemento); | indice_ubi = BDBuscarCadena(TABLA_UBICACIONES, CAMPO_NOMBRE, elemento); |
| if(indice_ubi == -1) | |
| { | |
| /* emito un error al fichero de log */ | |
| sprintf(mensaje, "[AnotarListaLecturas] La cadena '%s' no se ha encontrado en Tabla Ubicaciones", elemento); | |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | |
| } | |
| if(indice_ubi == -1) | pizarra_lecturas[indice_ubi][indice] = 1; |
| { | |
| /* emito un error al fichero de log */ | /* capturo el siguiente campo */ |
| sprintf(mensaje, "[AnotarListaLecturas] La cadena '%s' no se ha encontrado en Tabla Ubicaciones", elemento); | |
| Notificar(mensaje, ERROR_SALIR, ECO_NO); | |
| } | |
| pizarra_lecturas[indice_ubi][indice] = 1; | |
| /* capturo el siguiente campo */ | |
| elemento = strtok(NULL, ":"); | elemento = strtok(NULL, ":"); |
| } | } |
| } | } |
| /** | /* anota en la pizarra de lecturas aquellas que realiza */ |
| @brief Anota en la pizarra de lecturas aquellas que realiza | /* la instrucción, de todos los tipos y de todos los orígenes */ |
| la instrucción, de todos los tipos y de todos los orígenes | |
| @param *tarjetaoperandos: Puntero a una estructura del tipo fichainstruccion | |
| @param indice: Posición dentro de la matriz | |
| */ | |
| void AnotarLecturas(fichainstruccion *tarjetaoperandos, unsigned int indice) | void AnotarLecturas(fichainstruccion *tarjetaoperandos, unsigned int indice) |
| { | { |
| char listado[MAX_LISTA]; | char listado[MAX_LISTA]; |
| strcpy(listado, tarjetaoperandos->leidoexpldatos); | strcpy(listado, tarjetaoperandos->leidoexpldatos); |
| AnotarListaLecturas(listado, indice); | AnotarListaLecturas(listado, indice); |
| strcpy(listado, tarjetaoperandos->leidoimpldatos); | strcpy(listado, tarjetaoperandos->leidoimpldatos); |
| AnotarListaLecturas(listado, indice); | AnotarListaLecturas(listado, indice); |
| strcpy(listado, tarjetaoperandos->leidoexpldir); | strcpy(listado, tarjetaoperandos->leidoexpldir); |
| AnotarListaLecturas(listado, indice); | AnotarListaLecturas(listado, indice); |
| strcpy(listado, tarjetaoperandos->leidoimpldir); | strcpy(listado, tarjetaoperandos->leidoimpldir); |
| AnotarListaLecturas(listado, indice); | AnotarListaLecturas(listado, indice); |
| strcpy(listado, tarjetaoperandos->leidoexplpila); | strcpy(listado, tarjetaoperandos->leidoexplpila); |
| AnotarListaLecturas(listado, indice); | AnotarListaLecturas(listado, indice); |
| strcpy(listado, tarjetaoperandos->leidoimplpila); | strcpy(listado, tarjetaoperandos->leidoimplpila); |
| AnotarListaLecturas(listado, indice); | AnotarListaLecturas(listado, indice); |
| strcpy(listado, tarjetaoperandos->leidoexplestado); | strcpy(listado, tarjetaoperandos->leidoexplestado); |
| AnotarListaLecturas(listado, indice); | AnotarListaLecturas(listado, indice); |
| strcpy(listado, tarjetaoperandos->leidoimplestado); | strcpy(listado, tarjetaoperandos->leidoimplestado); |
| AnotarListaLecturas(listado, indice); | AnotarListaLecturas(listado, indice); |
| } | } |