0% found this document useful (0 votes)
27 views

Week 1 Processor

Here is a possible program for the chronometer algorithm using the generic instruction types: 0: X3 := 1 1: X0 := IN0 2: if X0 = 1 then goto 5 3: X0 := IN1 4: if X0 = 1 then goto 8 5: X2 := 0 6: goto 11 7: X2 := X2 + X3 8: X1 := IN3 9: if X1 = 1 then goto 7 10: goto 8 11: X0 := IN2 12: if X0 = 0 then goto 9 13: goto 1 This program uses memory elements X0-X3 and the

Uploaded by

Juliene Argana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Week 1 Processor

Here is a possible program for the chronometer algorithm using the generic instruction types: 0: X3 := 1 1: X0 := IN0 2: if X0 = 1 then goto 5 3: X0 := IN1 4: if X0 = 1 then goto 8 5: X2 := 0 6: goto 11 7: X2 := X2 + X3 8: X1 := IN3 9: if X1 = 1 then goto 7 10: goto 8 11: X0 := IN2 12: if X0 = 0 then goto 9 13: goto 1 This program uses memory elements X0-X3 and the

Uploaded by

Juliene Argana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

P1.

1 PROCESSOR: SPECIFICATION
Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
1 SPECIFICATION OF TWO DIGITAL SYSTEMS P1 .1

 Temperature controller (lesson 1.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

 Chronometer (lesson 1.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

Both algorithms have some common characteristics.

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:

if temp < pos – half_degree then onoff := on;


loop elsif temp > pos + half_degree then onoff := off;
if reset = ON then time := 0;
elsif start = ON then while stop = OFF loop
while stop = OFF loop if ref_positive_edge = TRUE then
if ref_positive_edge = TRUE then time := update(time);
time := update(time); end if;
end if; end loop;
end loop;
end if;
end loop; 7
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;
 some instructions read input values or write
output values:
loop
if reset = ON then time := 0; if temp < pos – half_degree (read temp and pos);
elsif start = ON then
while stop = OFF loop onoff := on (write onoff);
if ref_positive_edge = TRUE then
time := update(time); while stop = OFF (read stop);
end if;
end loop; time := update(time) (write time);
end if;
end loop; 8
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;
 some instructions execute computations:
loop temp – pos;
if reset = ON then time := 0;
elsif start = ON then update(time);
while stop = OFF loop
if ref_positive_edge = TRUE then
time := update(time);
end if;
end loop;
end if;
end loop; 9
Conclusion (another idea) P1 .1
Option 2: define a generic (meta)system that includes

 input ports (IN0, IN1, IN2, ··· ),


 output ports (OUT0, OUT1, OUT2, ···),
 memory elements able to store data (X0, X1, X2, ···),
 processing resources that can execute computations (+, -, ···), generic (meta)system
able to interpret instructions such as

 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

Generic system: able to implement


any algorithm

List of instructions (program): depends on


the particular algorithm to be implemented

11
P1 .1

12
P1 .2

P1.2 EXAMPLES OF PROGRAMS


Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
1 TEMPERATURE CONTROLLER P1 .2
loop
if temp < pos then onoff := on;
elsif temp > pos then onoff := off;
end if;
wait for 10 s;
end loop;

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;

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)

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:

X0: reset, start or stop (read from IN0, IN1 or IN2)


X1: ref (read from IN3)
X2: time (internally generated)
X3: constant 1 (internally generated)

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

 A generic system, called PROCESSOR, has been partially defined.


 It allows implementing many different algorithms.
 Two simple examples have been described.

24

You might also like