Week 1 Processor
Week 1 Processor
1 PROCESSOR: SPECIFICATION
Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
1 SPECIFICATION OF TWO DIGITAL SYSTEMS P1 .1
loop
if temp < pos – half_degree then onoff := on;
elsif temp > pos + half_degree then onoff := off;
end if;
wait for 10 s;
end loop;
2
P1 .1
loop
if reset = ON then time := 0;
elsif start = ON then
while stop = OFF loop
if ref_positive_edge = TRUE then time := update(time);
end if;
end loop;
end if;
end loop;
3
P1 .1
To each of them => digital system (lesson 1.1):
Temperature controller:
Chronometer:
4
2 DESIGN STRATEGIES P1 .1
Option 1: associate to each algorithm a completely new system that executes the
corresponding algorithm, and could not execute any other algorithm.
NEVERTHELESS
5
P1 .1
loop
if temp < pos – half_degree then onoff := on; sequentially executed instructions
elsif temp > pos + half_degree then onoff := off;
end if; ·············
wait for 10 s;
end loop; n: if temp < pos – half_degree then onoff := on;
elsif temp > pos + half_degree then onoff := off;
end if;
loop
if reset = ON then time := 0; n+1: wait for 10 s;
elsif start = ON then
while stop = OFF loop n+2: if temp < pos – half_degree then onoff := on;
if ref_positive_edge = TRUE then elsif temp > pos + half_degree then onoff := off;
time := update(time); end if;
end if;
end loop; n+3: wait for 10 s;
end if;
end loop; ··················· 6
P1 .1
loop
if temp < pos – half_degree then onoff := on;
elsif temp > pos + half_degree then onoff := off;
end if;
wait for 10 s;
end loop; conditional branches and jumps:
Xi := A (A constant);
Xi := INj;
OUTi := Xj;
OUTi := A (A constant);
Xi := f(Xj, Xk) (f => a processing resources);
goto n, where n is an instruction number;
if some_condition goto n, where n is an instruction number.
10
SUMMARY P1 .1
11
P1 .1
12
P1 .2
wait for 10 s;
14
Instruction types: P1 .2
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;
15
Six memory elements used to store algorithm data:
P1 .2
X0: temp (read from IN0)
X1: pos (read from IN1)
X2: time (read from IN2)
X3: initial time (read from IN2)
X4: computation result (internally generated)
X5: constant 10 (internally generated)
16
loop P1 .2
if temp < pos then onoff := on;
elsif temp > pos then onoff := off;
end if;
wait for 10 s;
end loop;
17
P1 .2
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; 18
2 CHRONOMETER P1 .2
loop
if reset = ON then time := 0;
elsif start = ON then
while stop = OFF loop
if ref_positive_edge = TRUE then
time := update(time);
end if;
end loop;
end if;
end loop;
19
P1 .2
Four memory elements used to store algorithm data:
20
loop P1 .2
if reset = ON then time := 0;
elsif start = ON then
while stop = OFF loop
if ref_positive_edge = TRUE then
time := update(time);
end if;
end loop;
end if;
end loop;
instruction
execution time
X0: reset, start or stop (read from IN0, IN1 or IN2) << Tref = 0.1 s
X1: ref (read from IN3)
X2: time (internally generated)
X3: constant 1 (internally generated)
21
(Exercise) Instruction types: P1 .2
Xi := A;
Xi := INj;
Generate a program corresponding to the previous OUTi := Xj;
diagram. For that: assign numbers to the instructions. OUTi := A;
Xi := Xj + Xk;
Xi := Xj - Xk;
goto n;
if Xi < 0 goto n;
if Xi > 0 goto n;
i: an_instruction; i: if a_condition go to j; i: go to j;
i+1: another_instruction; i+1: an_instruction; ···········
··········· J: an_instruction;
J: another_instruction; 22
(Solution) P1 .2
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: if X1 > 0 then go to 11 ;
13: X1 := IN3;
14: if X1 > 0 then go to 16;
15: go to 13;
16: X2 := X2 + X3;
17: OUT0 := X2;
18: go to 9;
23
SUMMARY P1 .2
24