summaryrefslogtreecommitdiffstats
path: root/tests/tc300_cpu/clockmem.awl
blob: 75f4f1c3585bb996304322ae93c03bbbb625b465 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
FUNCTION "TIMEDIFF" : TIME
TITLE = Compute TIME0 minus TIME1
	VAR_INPUT
		TIME0	: TIME;
		TIME1	: TIME;
	END_VAR
BEGIN
	L	#TIME0
	L	#TIME1
	-D
	UD	DW#16#7FFFFFFF
	T	#RET_VAL
END_FUNCTION


FUNCTION "UPDATE_TIME" : VOID
BEGIN
	CALL	"TIME_TCK" (
		RET_VAL	:= "TIME",
	)
END_FUNCTION


ORGANIZATION_BLOCK OB 1
BEGIN
M001:	CALL	"UPDATE_TIME"

// Warmup time (pypy needs this)
	CALL	"TIMEDIFF" (
		TIME0	:= "TIME",
		TIME1	:= "BOOT_TIME",
		RET_VAL	:= "DIFF",
	)
	L	"DIFF"
	L	T#2s
	>=D
	S	"RUNNING"

	U	"RUNNING"
	FP	"RUNNING_EDGE"
	SPBN	M005
	CALL	"__CLKRST"
	CALL	"UPDATE_TIME"
	L	"TIME"
	T	"START_TIME"
	T	"STAMP_0.1s"
	T	"STAMP_0.2s"
	T	"STAMP_0.4s"
	T	"STAMP_0.5s"
	T	"STAMP_0.8s"
	T	"STAMP_1.0s"
	T	"STAMP_1.6s"
	T	"STAMP_2.0s"
	L	0
	T	"COUNT_0.1s"
	T	"COUNT_0.2s"
	T	"COUNT_0.4s"
	T	"COUNT_0.5s"
	T	"COUNT_0.8s"
	T	"COUNT_1.0s"
	T	"COUNT_1.6s"
	T	"COUNT_2.0s"
	CLR
	=	"CLOCK_0.1s_EDGE"
	=	"CLOCK_0.2s_EDGE"
	=	"CLOCK_0.4s_EDGE"
	=	"CLOCK_0.5s_EDGE"
	=	"CLOCK_0.8s_EDGE"
	=	"CLOCK_1.0s_EDGE"
	=	"CLOCK_1.6s_EDGE"
	=	"CLOCK_2.0s_EDGE"


// Check 0.1s trigger time
M005:	U	"CLOCK_0.1s"
	FN	"CLOCK_0.1s_EDGE"
	SPBN	M010
	CALL	"TIMEDIFF" (
		TIME0	:= "TIME",
		TIME1	:= "STAMP_0.1s",
		RET_VAL	:= "DIFF",
	)
	L		"DIFF"
	UN		"RUNNING"
	SPB		M006
	__ASSERT>=	__ACCU 1,	T#10ms
	__ASSERT<=	__ACCU 1,	T#250ms
M006:	L		"TIME"
	T		"STAMP_0.1s"
	L		"COUNT_0.1s"
	+		1
	T		"COUNT_0.1s"


// Check 0.2s trigger time
M010:	U	"CLOCK_0.2s"
	FN	"CLOCK_0.2s_EDGE"
	SPBN	M020
	CALL	"TIMEDIFF" (
		TIME0	:= "TIME",
		TIME1	:= "STAMP_0.2s",
		RET_VAL	:= "DIFF",
	)
	L		"DIFF"
	UN		"RUNNING"
	SPB		M011
	__ASSERT>=	__ACCU 1,	T#100ms
	__ASSERT<=	__ACCU 1,	T#350ms
M011:	L		"TIME"
	T		"STAMP_0.2s"
	L		"COUNT_0.2s"
	+		1
	T		"COUNT_0.2s"

// Check 0.4s trigger time
M020:	U	"CLOCK_0.4s"
	FN	"CLOCK_0.4s_EDGE"
	SPBN	M030
	CALL	"TIMEDIFF" (
		TIME0	:= "TIME",
		TIME1	:= "STAMP_0.4s",
		RET_VAL	:= "DIFF",
	)
	L		"DIFF"
	UN		"RUNNING"
	SPB		M021
	__ASSERT>=	__ACCU 1,	T#300ms
	__ASSERT<=	__ACCU 1,	T#550ms
M021:	L		"TIME"
	T		"STAMP_0.4s"
	L		"COUNT_0.4s"
	+		1
	T		"COUNT_0.4s"

// Check 0.5s trigger time
M030:	U	"CLOCK_0.5s"
	FN	"CLOCK_0.5s_EDGE"
	SPBN	M040
	CALL	"TIMEDIFF" (
		TIME0	:= "TIME",
		TIME1	:= "STAMP_0.5s",
		RET_VAL	:= "DIFF",
	)
	L		"DIFF"
	UN		"RUNNING"
	SPB		M031
	__ASSERT>=	__ACCU 1,	T#400ms
	__ASSERT<=	__ACCU 1,	T#650ms
M031:	L		"TIME"
	T		"STAMP_0.5s"
	L		"COUNT_0.5s"
	+		1
	T		"COUNT_0.5s"

// Check 0.8s trigger time
M040:	U	"CLOCK_0.8s"
	FN	"CLOCK_0.8s_EDGE"
	SPBN	M050
	CALL	"TIMEDIFF" (
		TIME0	:= "TIME",
		TIME1	:= "STAMP_0.8s",
		RET_VAL	:= "DIFF",
	)
	L		"DIFF"
	UN		"RUNNING"
	SPB		M041
	__ASSERT>=	__ACCU 1,	T#700ms
	__ASSERT<=	__ACCU 1,	T#950ms
M041:	L		"TIME"
	T		"STAMP_0.8s"
	L		"COUNT_0.8s"
	+		1
	T		"COUNT_0.8s"

// Check 1.0s trigger time
M050:	U	"CLOCK_1.0s"
	FN	"CLOCK_1.0s_EDGE"
	SPBN	M060
	CALL	"TIMEDIFF" (
		TIME0	:= "TIME",
		TIME1	:= "STAMP_1.0s",
		RET_VAL	:= "DIFF",
	)
	L		"DIFF"
	UN		"RUNNING"
	SPB		M051
	__ASSERT>=	__ACCU 1,	T#900ms
	__ASSERT<=	__ACCU 1,	T#1s150ms
M051:	L		"TIME"
	T		"STAMP_1.0s"
	L		"COUNT_1.0s"
	+		1
	T		"COUNT_1.0s"

// Check 1.6s trigger time
M060:	U	"CLOCK_1.6s"
	FN	"CLOCK_1.6s_EDGE"
	SPBN	M070
	CALL	"TIMEDIFF" (
		TIME0	:= "TIME",
		TIME1	:= "STAMP_1.6s",
		RET_VAL	:= "DIFF",
	)
	L		"DIFF"
	UN		"RUNNING"
	SPB		M061
	__ASSERT>=	__ACCU 1,	T#1s500ms
	__ASSERT<=	__ACCU 1,	T#1s750ms
M061:	L		"TIME"
	T		"STAMP_1.6s"
	L		"COUNT_1.6s"
	+		1
	T		"COUNT_1.6s"

// Check 2.0s trigger time
M070:	U	"CLOCK_2.0s"
	FN	"CLOCK_2.0s_EDGE"
	SPBN	M080
	CALL	"TIMEDIFF" (
		TIME0	:= "TIME",
		TIME1	:= "STAMP_2.0s",
		RET_VAL	:= "DIFF",
	)
	L		"DIFF"
	UN		"RUNNING"
	SPB		M071
	__ASSERT>=	__ACCU 1,	T#1s900ms
	__ASSERT<=	__ACCU 1,	T#2s150ms
M071:	L		"TIME"
	T		"STAMP_2.0s"
	L		"COUNT_2.0s"
	+		1
	T		"COUNT_2.0s"

// Stop test, if test time complete
M080:	CALL	"TIMEDIFF" (
		TIME0	:= "TIME",
		TIME1	:= "START_TIME",
		RET_VAL	:= "DIFF",
	)
	UN		"RUNNING"
	BEB
	L		"DIFF"
	L		T#4s50ms
	<D
	BEB // Not completed, yet

	// Completed. Check trigger counts.
	L		"COUNT_0.1s"
	__ASSERT>=	__ACCU 1,	39
	__ASSERT<=	__ACCU 1,	41
	L		"COUNT_0.2s"
	__ASSERT==	__ACCU 1,	20
	L		"COUNT_0.4s"
	__ASSERT==	__ACCU 1,	10
	L		"COUNT_0.5s"
	__ASSERT==	__ACCU 1,	8
	L		"COUNT_0.8s"
	__ASSERT==	__ACCU 1,	5
	L		"COUNT_1.0s"
	__ASSERT==	__ACCU 1,	4
	L		"COUNT_1.6s"
	__ASSERT==	__ACCU 1,	2
	L		"COUNT_2.0s"
	__ASSERT==	__ACCU 1,	2
	// Everything is ok. Abort the test.
	CALL	"STP" // Stop CPU

END_ORGANIZATION_BLOCK


ORGANIZATION_BLOCK OB 100
BEGIN
	CALL	"UPDATE_TIME"
	L	"TIME"
	T	"BOOT_TIME"
	CLR
	=	"RUNNING"
	=	"RUNNING_EDGE"
END_ORGANIZATION_BLOCK
bues.ch cgit interface