The pseudocode shown in figure 1 functionally describes the chronometer introduced in lesson 1.1. The update
procedure updates the values of h, m, s and t whenever a clock pulse arrives (ref_positive edge signal).
Does the pseudocode shown in figure 2 correctly implement the update procedure?
Figure 1
1
2
3
4
5
6
7
8
9
loop
if reset=ON then h <= 0; m <= 0; s <= 0; t <= 0;
else if start=ON then
while stop=OFF loop
if ref_positive_edge=TRUE then update(h,m,s,t);
end if;
end loop;
end if;
end loop;
Figure 2: update procedure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
if t = 9 then t <= 0; add_one_second <= 1;
else t <= t+1; add_one_second <= 0;
end if;
s <= s + add_one_second;
if s = 60 then s <= 0; add_one_minute <= 1;
else add_one_minute <=
end if;
m <= m + add_one_minute;
if m = 60 then m <= 0; add_one_hour <= 1;
else add_one_hour <= 0;
end if;
h <= h + add_one_hour;
if h = 24 then h <= 0;
end if:
Answers
Answered by
1
Answer:
so long ajhahabsnsjsks.. okay bro
Similar questions