Hardware Design: SIE
Sign in or create your account | Project List | Help
Hardware Design: SIE Git Source Tree
Root/
| 1 | |
| 2 | /** Genetic definitions **/ |
| 3 | #define HW_ENABLE 1 //cambiar en sintesishw_server.h habilitar hw, 0 se hace por SW |
| 4 | #define PAR_ONLYFIT 0 //paralelizacion, 0 ALGORITMO ENTERO, 1 SOLO FITNESS |
| 5 | |
| 6 | #define FUNCIONES 4 |
| 7 | #define COMBS (int) pow(2,vars) |
| 8 | #define FUNCOMBS (int) pow(FUNCIONES + 1, 3) |
| 9 | #define FUN_NOT 0 |
| 10 | #define FUN_AND 1 |
| 11 | #define FUN_XOR 2 |
| 12 | #define FUN_OR 3 |
| 13 | #define YES FUNCIONES |
| 14 | #define NOVAR vars |
| 15 | #define PESO_SALIDA 100 |
| 16 | #define PESO_PUERTAS 5 |
| 17 | #define PESO_NIVELES 0 |
| 18 | |
| 19 | #define RESULTADOS 2 |
| 20 | |
| 21 | /* Numero de generaciones en el que se amplia la logitud del cromosoma*/ |
| 22 | #define UMBRAL_GENERACION (int) pow(3, pentarboles) * 33 |
| 23 | #define MAX_PENTARBOLES 16 |
| 24 | |
| 25 | #define ARBOLES 5 |
| 26 | #define LONG_ARBOL 8 |
| 27 | |
| 28 | int nivel2[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; |
| 29 | int nivel3[]={0,0,1,1,1,2,2,2,2,3,3, 3, 3, 4, 4, 4}; |
| 30 | int nivel4[]={0,0,0,0,0,1,1,1,1,1,1, 1, 1, 1, 1, 1}; |
| 31 | int nivel5[]={0,0,0,0,0,0,0,0,0,0,0, 0, 0, 0, 0, 0}; |
| 32 | |
| 33 | #define nivel1 pentarboles * 4 |
| 34 | #define ARBOLES_INDIV (int)(nivel1 + *(nivel2+pentarboles) + *(nivel3+pentarboles) + *(nivel4+pentarboles) + *(nivel5+pentarboles)) |
| 35 | #define LONG_INDIV (int)(ARBOLES_INDIV * LONG_ARBOL) |
| 36 | |
| 37 | #define INDICE_PADRE1 ((*ordenpoblacion) * LONG_INDIV) |
| 38 | #define INDICE_PADRE2 ((*(ordenpoblacion+1)) * LONG_INDIV) |
| 39 | |
| 40 | #define INDICE_TARA1 ((*(ordenpoblacion+poblacion-1)) * LONG_INDIV) |
| 41 | #define INDICE_TARA2 ((*(ordenpoblacion+poblacion-2)) * LONG_INDIV) |
| 42 | #define INDICE_TARA3 ((*(ordenpoblacion+poblacion-3)) * LONG_INDIV) |
| 43 | #define INDICE_TARA4 ((*(ordenpoblacion+poblacion-4)) * LONG_INDIV) |
| 44 | |
| 45 | |
| 46 | /************************** peripheral Definitions ***************************/ |
| 47 | |
| 48 | #define CONFIG_REGS_BASE 0x13010000 |
| 49 | #define SMCR2_OFFSET 0x18 |
| 50 | #define SACR2_OFFSET 0x38 |
| 51 | |
| 52 | #define EVALFIT_PHYSBASE1 0x14000000 |
| 53 | #define MAP_SIZE 0x4000Ul |
| 54 | #define MAP_MASK (MAP_SIZE - 1) |
| 55 | |
| 56 | #define DONE_MASK 0x8000 |
| 57 | #define ERRORS_MASK 0xFFFF |
| 58 | |
| 59 | /** CONTROL REGISTERS **/ |
| 60 | #define EVALFIT_REGBASE_OFFSET 0x1000 |
| 61 | |
| 62 | #define EVALFIT_CONTROL_OFFSET EVALFIT_REGBASE_OFFSET + 0x1D |
| 63 | #define CONTROL_RESET_MASK 0x80 |
| 64 | #define CONTROL_START_MASK 0x40 |
| 65 | |
| 66 | #define EVALFIT_REG_OFFSET EVALFIT_REGBASE_OFFSET + 0 |
| 67 | |
| 68 | /** WRITE REGISTERS **/ |
| 69 | |
| 70 | #define EVALFIT_MAX_COMBS EVALFIT_REGBASE_OFFSET + 0x1E |
| 71 | #define EVALFIT_MAX_LEVEL EVALFIT_REGBASE_OFFSET + 0x1C |
| 72 | |
| 73 | |
| 74 | #define EVALFIT_WREG4 (EVALFIT_REGBASE_OFFSET + (4*4)) |
| 75 | #define EVALFIT_WREG5 (EVALFIT_REGBASE_OFFSET + (4*5)) |
| 76 | #define EVALFIT_wREG6 (EVALFIT_REGBASE_OFFSET + (4*6)) |
| 77 | #define EVALFIT_wREG7 (EVALFIT_REGBASE_OFFSET + (4*7)) |
| 78 | #define EVALFIT_wREG8 (EVALFIT_REGBASE_OFFSET + (4*8)) |
| 79 | |
| 80 | /** READ REGISTERS **/ |
| 81 | #define EVALFIT_ERRORS EVALFIT_REGBASE_OFFSET + 0x14 |
| 82 | #define EVALFIT_RANDOM EVALFIT_REGBASE_OFFSET + 0x18 |
| 83 | #define EVALFIT_STATUS EVALFIT_REGBASE_OFFSET + 0x16 |
| 84 | |
| 85 | |
| 86 | #define EVALFIT_RDREG0 (EVALFIT_REGBASE_OFFSET) |
| 87 | #define EVALFIT_RDREG1 (EVALFIT_REGBASE_OFFSET + (4*1)) |
| 88 | #define EVALFIT_RDREG2 (EVALFIT_REGBASE_OFFSET + (4*2)) |
| 89 | #define EVALFIT_RDREG3 (EVALFIT_REGBASE_OFFSET + (4*3)) |
| 90 | #define EVALFIT_RDREG4 (EVALFIT_REGBASE_OFFSET + (4*4)) |
| 91 | #define EVALFIT_RDREG5 (EVALFIT_REGBASE_OFFSET + (4*5)) |
| 92 | #define EVALFIT_RDREG6 (EVALFIT_REGBASE_OFFSET + (4*6)) |
| 93 | #define EVALFIT_RDREG7 (EVALFIT_REGBASE_OFFSET + (4*7)) |
| 94 | #define EVALFIT_RDREG8 (EVALFIT_REGBASE_OFFSET + (4*8)) |
| 95 | /** MEMORY **/ |
| 96 | #define EVALFIT_MEMOFFSET 0x0 |
| 97 | #define EVALFIT_OBJOFFSET EVALFIT_MEMOFFSET + (0x40 * 8) |
| 98 | |
| 99 | /* Variables globales */ |
| 100 | char *funlut_ap, *puertas_ap; |
| 101 | void *evalfit_ptr1, *evalfit_ptr4, *evalfit_ptr3, *evalfit_ptr2; |
| 102 | int maxgeneraciones, poblacion; |
| 103 | |
| 104 | |
| 105 | typedef long long timestamp_t; |
| 106 | static timestamp_t |
| 107 | get_timestamp () |
| 108 | { |
| 109 | struct timeval now; |
| 110 | gettimeofday (&now, NULL); |
| 111 | return now.tv_usec + (timestamp_t)now.tv_sec *1000000 ; |
| 112 | } |
| 113 | |
| 114 | struct gen_datos_tipo |
| 115 | { |
| 116 | int *objetivo; |
| 117 | int tamaobj; |
| 118 | int pentarboles; |
| 119 | int vars; |
| 120 | int tamacrom; |
| 121 | int maxgen; |
| 122 | char *cromo_sal; |
| 123 | int *fitness; |
| 124 | char *cromo_entrada; |
| 125 | int fitness_entrada; |
| 126 | int nivel_max; |
| 127 | int en_cromo_entrada; |
| 128 | int *generacion; |
| 129 | int *tiempo; |
| 130 | int aux; |
| 131 | int *aux_sal; |
| 132 | }; |
| 133 | |
| 134 |
Branches:
master
