summaryrefslogtreecommitdiffstats
path: root/Bachelor/Digitaltechnik 2/SS07/P6/abel_samples.zip_FILES/count4b2.abl
blob: 545d92b78ecafc7dd1e2e269224d9faf79e5cf5b (plain)
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
62
63
64
65
66
67
68
69
70
71
MODULE Counter_4_bit
TITLE '0 ... 9, version with state diagram'
DEClARATIONS
	clk pin 15;  " I/O 0, Eingang f�r den Takt
	rst pin 16;  " I/O 1, Eingang f�r das Reset Signal
	ce  pin 17;  " I/O 2, Eingang f�r das Enable Signal
	q3,q2,q1,q0 pin 29,30,31,32 istype 'reg'; " I/O 12, 13, 14, 15, Ausgang: Bits des Z�hlers, 15: 2^0
	carry pin 44 istype 'reg'; // I/O 23, Ausgang f�r Carry

" bus definition, vector, register
	counter = [q3,q2,q1,q0];

EQUATIONS
	counter.clk = clk;
	carry.clk   = clk;

STATE_DIAGRAM counter;
	State 0:
		if(!rst & ce) then 1; " Bei Erf�llung der Bedingung erfolgt ein �bergang in State 1
		else 0;
	State 1:
		if (rst) then 0;
		else if (ce) then 2;
		else 1;
	State 2:
		if (rst) then 0;
		else if (ce) then 3;
		else 2;
	State 3:
		if (rst) then 0;
		else if (ce) then 4;
		else 3;
	State 4:
		if (rst) then 0;
		else if (ce) then 5;
		else 4;
	State 5:
		if (rst) then 0;
		else if (ce) then 6;
		else 5;
	State 6:
		if (rst) then 0;
		else if (ce) then 7;
		else 6;
	State 7:
		if (rst) then 0;
		else if (ce) then 8;
		else 7;
	State 8:
		if (rst) then 0;
		else if (ce) then 9;
		else 8;
	State 9:
		carry := 1;
		if (rst) then 0;
		else if (ce) then 0;
		else 9;
	State 10:
		goto 0;  " es erfolgt ein bedingungsloser �bergang in State 0
	State 11:
		goto 0;
	State 12:
		goto 0;
	State 13:
		goto 0;
	State 14:
		goto 0;
	State 15:
		goto 0;
END