semana 1 - procesador.pdf

26
P1 .1 PROCESADOR: ESPECIFICACIONES Lluís Terés Instituto de Microelectrónica de Barcelona, IMB-CNM (CSIC) Universitat Autònoma de Barcelona (UAB)

Upload: jesus-o

Post on 22-Dec-2015

244 views

Category:

Documents


0 download

TRANSCRIPT

P1.1 PROCESADOR: ESPECIFICACIONES

Lluís TerésInstituto de Microelectrónica de Barcelona, IMB-CNM (CSIC)Universitat Autònoma de Barcelona (UAB)

CONTROL DE TEMPERATURA (lección 1.1):

loopif temp < pos – half_degree then onoff := on;elsif temp > pos + half_degree then onoff := off;end if;wait for 10 s;

end loop;

1. Especificación de dos sistemas digitalesP1.1

2

CRONÓMETRO (lección 1.1)

loopif reset = ON then time := 0;elsif start = ON then

while stop = OFF loopif ref_positive_edge = TRUE then time := update(time); end if;

end loop;end if;

end loop;

P1.1

3

P1.1A cada uno de ellos => SISTEMA DIGITAL (lección 1.1):

Controlador de temperatura:

Cronómetro:

4

P1.1

OPCIÓN 1: Asociar a cada algoritmo un sistema completamente nuevo que ejecuteexclusivamente dicho algoritmo, y no pueda por tanto ejecutar ningún otroalgoritmo.

SIN EMBARGO …

Ambos algoritmos tienen algunas características comunes. 

2. Estrategias de diseño

5

P1.1

1. Las instrucciones se ejecutan secuencialmente

∙∙∙∙∙∙∙∙∙∙∙∙∙

n: if temp < pos – half_degree then onoff := on;elsif temp > pos + half_degree then onoff := off;end if;

n+1: wait for 10 s;

n+2: if temp < pos – half_degree then onoff := on;elsif temp > pos + half_degree then onoff := off;end if;

n+3: wait for 10 s;

∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙

loopif temp < pos – half_degree then onoff := on;elsif temp > pos + half_degree then onoff := off;end if;wait for 10 s;

end loop;

loopif reset = ON then time := 0;elsif start = ON then

while stop = OFF loopif ref_positive_edge = TRUE then time := update(time); end if;

end loop;end if;

end loop;6

P1.1

2. Ambos algoritmos contienen bifurcacionescondicionales y saltos: 

if temp < pos – half_degree then onoff := on;elsif temp > pos + half_degree then onoff := off;

while stop = OFF loopif ref_positive_edge = TRUE then time := update(time); end if;

end loop;

loopif temp < pos – half_degree then onoff := on;elsif temp > pos + half_degree then onoff := off;end if;wait for 10 s;

end loop;

loopif reset = ON then time := 0;elsif start = ON then

while stop = OFF loopif ref_positive_edge = TRUE then time := update(time); end if;

end loop;end if;

end loop;7

P1.1

3. Algunas instrucciones leen valores de entrada o  escriben valores de salida. 

if temp < pos – half_degree (read temp and pos);

onoff := on (write onoff);

while stop = OFF (read stop);

time := update(time) (write time);

loopif temp < pos – half_degree then onoff := on;elsif temp > pos + half_degree then onoff := off;end if;wait for 10 s;

end loop;

loopif reset = ON then time := 0;elsif start = ON then

while stop = OFF loopif ref_positive_edge = TRUE then time := update(time); end if;

end loop;end if;

end loop;8

P1.1

4. Existen instrucciones que ejecutan cálculos.

temp – (pos – half_degree);

update(time);

loopif temp < pos – half_degree then onoff := on;elsif temp > pos + half_degree then onoff := off;end if;wait for 10 s;

end loop;

loopif reset = ON then time := 0;elsif start = ON then

while stop = OFF loopif ref_positive_edge = TRUE then time := update(time); end if;

end loop;end if;

end loop;9

Conclusión (otra idea …) 

Opción 2: Diseñar un nuevo (meta)sistema genérico que incluya …

Puertos de entrada (IN0, IN1, IN2, ∙∙∙ ), Puertos de salida, OUT1, OUT2, ∙∙∙),  Elementos de memoria capaces de almacenar datos (X0, X1, X2, ∙∙∙), Recursos de cómputo que permitan realizar cálculos (+, ‐, ∙∙∙),

Y que sea capaz de interpretar instruciones como …

Xi := A (A constante); Xi := INj; OUTi := Xj; OUTi := A (A constante); Xi := f(Xj, Xk) (f => un recurso de cómputo); goto n, donde n es un número de instrucción; if condicion goto n, donde n es un número de instrucción.

P1.1

10

P1.1

Sistema genérico: 

Capaz de implementar cualquieralgoritmo

Lista de instrucciones (programa): Dependiendo del algoritmo particular que se desee implementar

RESUMEN

11

P1.1

12

P1.2 EJEMPLOS DE PROGRAMAS

P1.2

Lluís TerésInstituto de Microelectrónica de Barcelona, IMB-CNM (CSIC)Universitat Autònoma de Barcelona (UAB)

1. Controlador de temperaturaP1.2

loopif temp < pos then onoff := on;elsif temp > pos then onoff := off;end if;wait for 10 s;

end loop;

14

Tipos de instrucción:

Xi := A; Xi := INj; OUTi := Xj; OUTi := A; Xi := Xj + Xk; Xi := Xj ‐ Xk; goto n; if Xi < 0 goto n; if Xi > 0 goto n;

P1.2

15

Seis elementos de memoria para almacenar los datos:

X0: temp (leído por IN0)X1: pos (leído por IN1)X2: time (leído por IN2)X3: initial time (leído por IN2)X4: computation result (generado interamente)X5: constant 10 (generado interamente)

P1.2

16

P1.2loop

if temp < pos then onoff := on;elsif temp > pos then onoff := off;end if;wait for 10 s;

end loop;

X0: temp (leído por IN0)X1: pos (leído por IN1)X2: time (leído por IN2)X3: initial time (leído por IN2)X4: computation result (generado interamente)X5: constant 10 (generado interamente)

17

P1.2loop

if temp < pos then onoff := on;elsif temp > pos then onoff := off;end if;wait for 10 s;

end loop;

X0: temp (leído por IN0)X1: pos (leído por IN1)X2: time (leído por IN2)X3: initial time (leído por IN2)X4: computation result (generado interamente)X5: constant 10 (generado interamente)

18

0:  X5 := 10;1:  X0 := IN0;2:  X1 := IN1;3:  X4 := X0 ‐ X1;4:  if X4 < 0 then go to 7;5:  if X4 > 0 then go to 9;6:  go to 10;7:  OUT0 := 1;8:  go to 10;9:  OUT0 := 0;10: X3 := IN2;11: X2 := IN2;12: X4 := X2 ‐ X3;13: X4 := X4 ‐ X5;14: if X4 < 0 then go to 11;15: go to 1;

P1.2

19

2. CronómetroP1.2

loopif reset = ON then time := 0;elsif start = ON then

while stop = OFF loopif ref_positive_edge = TRUE then time := update(time); end if;

end loop;end if;

end loop;

20

Cuatro elementos de memoria para almecenar los datos:

X0: reset, start, stop, ref o computation result (leído por IN0, IN1, IN2, IN3 o generado internamente)

X1: initial ref (leído por IN3)X2: time (generado internamente)X3: constant 1 (generado internamente)

P1.2

21

Tiempo de ejecución de cadainstrucción<< Tref = 0.1 s

P1.2loop

if reset = ON then time := 0;elsif start = ON then

while stop = OFF loopif ref_positive_edge = TRUE then time := update(time); end if;

end loop;end if;

end loop;

X0: reset, start, stop, ref o computation result (leído por IN0, IN1, IN2, IN3 o generado internamente)

X1: initial ref (leído por IN3)X2: time (generado internamente)X3: constant 1 (generado internamente)

22

Tiempo de ejecución de cadainstrucción<< Tref = 0.1 s

P1.2loop

if reset = ON then time := 0;elsif start = ON then

while stop = OFF loopif ref_positive_edge = TRUE then time := update(time); end if;

end loop;end if;

end loop;

X0: reset, start, stop, ref o computation result (leído por IN0, IN1, IN2, IN3 o generado internamente)

X1: initial ref (leído por IN3)X2: time (generado internamente)X3: constant 1 (generado internamente)

23

(Ejercicio)Construir el programa correspondiente a diagrama de fujo anterior. Para ello debéis asignarnúmeros a las instrucciones tal como aparecen en los cuadros siguientes:

i: instrucción;i+1: instrución siguiente;

i: if a_condition goto j;i+1: an_instruction;···········j: another_instruction;

P1.2

Tipos de instrucción Xi := A; Xi := INj; OUTi := Xj; OUTi := A; Xi := Xj + Xk; Xi := Xj ‐ Xk; goto n; if Xi < 0 goto n; if Xi > 0 goto n;

cc

i-1: an instructioni: go to j;···········j: another_instruction;

24

0:  X3 := 1:1:  X0 := IN0;2:  if X0 > 0 then go to 6 ;3:  X0 := IN1;4: if X0 > 0 then go to 9 ;5: go to 1;6: X2 := 0;7: OUT0 := X2;8: go to 1;9: X0 ;= IN2; 10: if X0 > 0 then go to 1 ;11: X1 := IN3;12: X0 := IN3;13: X0 := X0 ‐ X1;14: if X0 > 0 then go to 16;15: go to 9;16: X2 := X2 + X3;17: OUT0 := X2;18: go to 9;

P1.2(Solución)

25

RESUMENP1.2

Hemos definido (parcialmente) un sistema genérico al que hemos dado el nombre de PROCESADOR. 

Dicho sistema permite implementar algoritmos muy distintos entre sí. 

Hemos visto dos ejemplos sencillos de cómo utilizarlo. 

26