This repository was archived by the owner on Apr 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab10.abl
More file actions
61 lines (54 loc) · 1.53 KB
/
Lab10.abl
File metadata and controls
61 lines (54 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
TITLE 'Programmable Combination Lock'
[C0..C5] pin; "programmed bit sequence
!X0, !X0_N, !X1, !X1_N pin; "combination data input"
R pin; "relock input"
RESET pin; "asynchronous reset"
CLOCK pin;
Q2, Q1, Q0 pin istype 'reg';
!LOCKED pin istype 'com'; "LOCKED indicator"
!UNLOCKED pin istype 'com'; "UNLOCKED indicator"
!ALARM pin istype 'com'; "ALARM indicator"
BSQ0, BSQ1, M pin istype 'com'; "bounceless switch
QALL = [Q2,Q1,Q0];
A0 = [ 0, 0, 0];
A1 = [ 0, 0, 1];
A2 = [ 0, 1, 0];
A3 = [ 0, 1, 1];
A4 = [ 1, 0, 0];
A5 = [ 1, 0, 1];
A6 = [ 1, 1, 0];
A7 = [ 1, 1, 1];
STATE_DIAGRAM QALL
state A0: if (R==1) then A0
else if (R==0)&(M==!C0) then A7
else if (R==0)&(M==C0) then A1;
state A1: if (R==1) then A0
else if (R==0)&(M==C1) then A2
else if (R==0)&(M==!C1) then A7;
state A2: if (R==1) then A0
else if (R==0)&(M==!C2) then A7
else if (R==0)&(M==C2) then A3;
state A3: if (R==1) then A0
else if (R==0)&(M==!C3) then A7
else if (R==0)&(M==C3) then A4;
state A4: if (R==1) then A0
else if (R==0)&(M==!C4) then A7
else if (R==0)&(M==C4) then A5;
state A5: if (R==1) then A0
else if (R==0)&(M==C5) then A6
else if (R==0)&(M==!C5) then A7;
state A6: if (R==1) then A0
else if (R==0) then A6;
state A7: goto A7;
EQUATIONS
QALL.CLK = CLOCK;
QALL.AR = RESET;
LOCKED = !Q2&!Q1&!Q0;
UNLOCKED = Q2&Q1&!Q0;
ALARM = Q2&Q1&Q0;
BSQ0 = X0 # !X0_N & BSQ0;
BSQ1 = X1 # !X1_N & BSQ1;
TRUTH_TABLE([BSQ0,BSQ1]->[M])
[0,1]->[1];
[1,0]->[0];
END