File: sig_pci_bus.scxml

package info (click to toggle)
faumachine 20180503-4
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 61,272 kB
  • sloc: ansic: 272,290; makefile: 6,199; asm: 4,251; sh: 3,022; perl: 886; xml: 563; pascal: 311; lex: 214; vhdl: 204
file content (575 lines) | stat: -rw-r--r-- 16,439 bytes parent folder | download
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
<!--
<! Copyright (C) 2015 FAUmachine Team <info@faumachine.org>
<! This program is free software. You can redistribute it and/or modify it
<! under the terms of the GNU General Public License, either version 2 of
<! the License, or (at your option) any later version. See COPYING.
<!-->


<?xml version="1.0" encoding="UTF-8"?>
<scxml initial="none,arbiter:a_idle
	m1,master:m_idle
	m2,master:m_idle
	m3,master:m_idle
	t1,target:s_idle
	t2,target:s_idle
	t3,target:s_idle">
	<datamodel name="global">
		<data id="C/BE#" expr="1"/>
		<data id="AD" expr="0"/>
		<data id="DEVSEL#" expr="1"/>
		<data id="FRAME#" expr="1"/>
		<data id="IRDY#" expr="0"/>
		<data id="STOP#" expr="1"/>
		<data id="TRDY#" expr="1"/>
		<!-- DEVSELtimer -->>
		<data id="timer" expr="0"/>
		<!-- read / write counter -->
		<data id="n_trans" expr="0"/>
		<!-- current command -->
		<data id="cmd" expr="0"/>
		<!-- is someones grant set? -->
		<data id="Grant" expr="0"/>
	</datamodel>
	<datamodel name="master">
		<data id="Comp" expr="0"/>
		<data id="Dev_to" expr="0"/>
		<data id="FB2B_Ena" expr="0"/>
		<data id="L_cycle" expr="0"/>
		<data id="*AD" expr="0"/>
		<data id="&AD" expr="0"/>
		<data id="*C/BE#" expr="0"/>
		<data id="&C/BE#" expr="1"/>
		<data id="*FRAME#" expr="0"/>
		<data id="&FRAME#" expr="1"/>
		<data id="*IRDY#" expr="0"/>
		<data id="&IRDY#" expr="1"/>
		<data id="M_last_state" expr="m_idle" flags="ign"/>
		<data id="Master_abort" expr="0"/>
		<data id="Ready" expr="1"/>
		<data id="Sa" expr="0"/>
		<data id="Step" expr="0"/>
		<data id="Target_abort" expr="0"/>
		<data id="To" expr="0"/>
	</datamodel>
	<datamodel name="m1">
		<data id="Requestm1" expr="0" flags="m_idle"/>
		<data id="%REQm1" expr="1"/>
		<data id="%GNT#m1" expr="1"/>
	</datamodel>
	<datamodel name="m2">
		<data id="Requestm2" expr="0" flags="m_idle"/>
		<data id="%REQm2" expr="1"/>
		<data id="%GNT#m2" expr="1"/>
	</datamodel>
	<datamodel name="m3">
		<data id="Requestm3" expr="0" flags="m_idle"/>
		<data id="%REQm3" expr="1"/>
		<data id="%GNT#m3" expr="1"/>
	</datamodel>
	<datamodel name="target">
		<data id="D_done" expr="0"/>
		<data id="Hit" expr="0" flags="b_busy"/>
		<data id="*AD" expr="0"/>
		<data id="&AD" expr="0"/>
		<data id="*DEVSEL#" expr="0"/>
		<data id="&DEVSEL#" expr="1"/>
		<data id="*STOP#" expr="0"/>
		<data id="&STOP#" expr="1"/>
		<data id="*TRDY#" expr="0"/>
		<data id="&TRDY#" expr="1"/>
		<data id="Ready" expr="1"/>
		<data id="T_abort" expr="0"/>
		<data id="Tar_dly" expr="1"/>
		<data id="Term" expr="0"/>
	</datamodel>
	<datamodel name="arbiter">
		<!-- delay till frame has to be asserted -->
		<data id="delay" expr="0"/>

		<data id="%REQm1" expr="1"/>
		<data id="%GNT#m1" expr="1"/>
		<data id="%REQm2" expr="1"/>
		<data id="%GNT#m2" expr="1"/>
		<data id="%REQm3" expr="1"/>
		<data id="%GNT#m3" expr="1"/>
	</datamodel>

	<function name="write_1">
		<datamodel name="write model">
			<data id="param" expr="todo"/>
			<data id="retval" expr="int"/>
			<data id="IRDY#" expr="1"/>
			<data id="cmd" expr="write"/>
			<data id="n_trans" expr="2"/>
			<data id="timer" expr="3"/>
		</datamodel>
	</function>

	<function name="read_1">
		<datamodel name="read model">
			<data id="param" expr="todo"/>
			<data id="retval" expr="int"/>
			<data id="IRDY#" expr="1"/>
			<data id="cmd" expr="read"/>
			<data id="n_trans" expr="2"/>
			<data id="timer" expr="3"/>
		</datamodel>
	</function>

	<state id="a_idle">
		<onentry>
			<if cond="%REQm1==0">
				<!-- select one -->
				<assign location="Grant" expr="1"/>
				<assign location="%GNT#m1" expr="0"/>
				<assign location="delay" expr="2"/>
			</if>
			<if cond="%REQm2==0 and Grant==0">
				<!-- select one -->
				<assign location="Grant" expr="1"/>
				<assign location="%GNT#m2" expr="0"/>
				<assign location="delay" expr="2"/>
			</if>
			<if cond="%REQm3==0 and Grant==0">
				<!-- select one -->
				<assign location="Grant" expr="1"/>
				<assign location="%GNT#m3" expr="0"/>
				<assign location="delay" expr="2"/>
			</if>
		</onentry>
		<transition event="e"
			cond="Grant==0"
			target="a_idle"/>
		<transition event="e"
			cond="Grant==1"
			target="a_busy"/>
	</state>

	<state id="a_busy">
		<onentry>
			<if cond="%GNT#m1==0 and %REQm1==1
				or %GNT#m2==0 and %REQm2==1
				or %GNT#m3==0 and %REQm3==1">
				<assign location="delay" expr="0"/>
			</if>
			<if cond="delay==0">
				<if cond="FRAME#==1">
					<assign location="Grant" expr="0"/>
					<assign location="%GNT#m1" expr="1"/>
					<assign location="%GNT#m2" expr="1"/>
					<assign location="%GNT#m3" expr="1"/>
				</if>
				<else>
					<assign location="delay" expr="$delay--"/>
				</else>
			</if>
		</onentry>
		<transition event="e"
			cond="Grant==0"
			target="a_idle"/>
		<transition event="e"
			cond="Grant==1"
			target="a_busy"/>
	</state>

	<state id="s_idle">
		<assign location="&TRDY#" expr="1"/>
		<assign location="&STOP#" expr="1"/>
		<assign location="&DEVSEL#" expr="1"/>
		<assign location="D_done" expr="0"/>
		<transition event="e"
			cond="FRAME#==1"
			target="s_idle"/>
		<transition event="e"
			cond="FRAME#==0 and Hit==0"
			target="b_busy"/>
	</state>

	<state id="s_turn_ar">
		<onentry>
			<assign location="*TRDY#" expr="1"/>
			<assign location="*STOP#" expr="1"/>
			<assign location="*DEVSEL#" expr="1"/>
		</onentry>
		<assign location="&TRDY#" expr="1"/>
		<assign location="&STOP#" expr="1"/>
		<assign location="&DEVSEL#" expr="1"/>
		<assign location="Hit" expr="0"/>
		<assign location="D_done" expr="0"/>
		<transition event="e"
			cond="FRAME#==1"
			target="s_idle"/>
		<transition event="e"
			cond="FRAME#==0 and Hit==0"
			target="b_busy"/>
		<onexit>
			<assign location="*TRDY#" expr="0"/>
			<assign location="*STOP#" expr="0"/>
			<assign location="*DEVSEL#" expr="0"/>
		</onexit>
	</state>

	<state id="b_busy">
		<assign location="&TRDY#" expr="1"/>
		<assign location="&STOP#" expr="1"/>
		<assign location="&DEVSEL#" expr="1"/>

		<!-- D_done in FAUmachine is always 1, as decode doesnt take
		     time -->
		<assign location="D_done" expr="1"/>

		<transition event="e"
			cond="(FRAME#==0 or D_done==0) and Hit==0"
			target="b_busy"/>
		<transition event="e"
			cond="FRAME#==1 and D_done==1 or FRAME#==1 and D_done==0 and DEVSEL#==0"
			target="s_idle"/>
		<transition event="e"
			cond="(FRAME#==0 or IRDY#==0)
			and Hit==1
			and (Term==0 or Term==1 and Ready==1)"
			target="s_data"/>
		<transition event="e"
			cond="(FRAME#==0 and IRDY#==0) and Hit==1
			and (Term==1 and Ready==0)"
			target="backoff"/>
	</state>

	<state id="s_data">
		<onentry>
			<assign location="*TRDY#" expr="1"/>
			<assign location="*STOP#" expr="1"/>
			<assign location="*DEVSEL#" expr="1"/>
			<if cond="Tar_dly==1 and cmd==read">
				<assign location="*AD" expr="1"/>
			</if>
			<if cond="T_abort==0">
				<assign location="&DEVSEL#" expr="0"/>
				<else>
					<assign location="&DEVSEL#" expr="1"/>
				</else>
			</if>
		</onentry>
		<if cond="!((T_abort==1 or Term==1) and (cmd==write or cmd==read and Tar_dly==1))">
			<assign location="&STOP#" expr="1"/>
			<else>
				<assign location="&STOP#" expr="0"/>
			</else>
		</if>
		<if cond="!(Ready==1 and T_abort==0 and (cmd==write or cmd==read and Tar_dly==1))">
			<assign location="&TRDY#" expr="1"/>
			<else>
				<assign location="&TRDY#" expr="0"/>
			</else>
		</if>

		<method action="provide"\>

		<transition event="e"
			cond="FRAME#==0 and STOP#==0 and TRDY#==0 and IRDY#==1
			or FRAME#==0 and STOP#==1
			or FRAME#==1 and TRDY#==1 and STOP#==1"
			target="s_data"/>
		<transition event="e"
			cond="FRAME#==0 and STOP#==0 and (TRDY#==1 or IRDY#==0)"
			target="backoff"/>
		<transition event="e"
			cond="FRAME#==1 and (TRDY#==0 or STOP#==0)"
			target="s_turn_ar"/>
		<onexit>
			<assign location="*TRDY#" expr="0"/>
			<assign location="*STOP#" expr="0"/>
			<assign location="*DEVSEL#" expr="0"/>
			<assign location="*AD" expr="0"/>
		</onexit>
	</state>

	<state id="backoff">
		<onentry>
			<assign location="*TRDY#" expr="1"/>
			<assign location="*STOP#" expr="1"/>
			<assign location="*DEVSEL#" expr="1"/>
			<if cond="Tar_dly==1 and cmd==read">
				<assign location="*AD" expr="1"/>
			</if>
		</onentry>
		<assign location="&TRDY#" expr="1"/>
		<assign location="&STOP#" expr="0"/>
		<if cond="T_abort==0">
			<assign location="&DEVSEL#" expr="0"/>
			<else>
				<assign location="&DEVSEL#" expr="1"/>
			</else>
		</if>
		<if cond="Tar_dly==1 and cmd==read">
			<assign location="AD" expr="1"/>
		</if>
		<transition event="e"
			cond="FRAME#==0"
			target="backoff"/>
		<transition event="e"
			cond="FRAME#==1"
			target="s_turn_ar"/>
		<onexit>
			<assign location="*TRDY#" expr="0"/>
			<assign location="*STOP#" expr="0"/>
			<assign location="*DEVSEL#" expr="0"/>
			<assign location="*AD" expr="0"/>
		</onexit>
	</state>

	<state id="m_idle">
		<onentry>
			<if cond="M_last_state==m_data or M_last_state==addr">
				<assign location="*IRDY#" expr="1"/>
			</if>
			<assign location="&IRDY#" expr="1"/>
			<assign location="&FRAME#" expr="1"/>
			<assign location="Master_abort" expr="0"/>
			<assign location="Target_abort" expr="0"/>
			<if cond="Request'name'==1">
				<assign location="%REQ'name'" expr="0"/>
				<else>
					<assign location="%REQ'name'" expr="1"/>
				</else>
			</if>
		</onentry>
		<transition event="e"
			cond="(Request'name'==1 and Step==0) and %GNT#'name'==0 and FRAME#==1 and IRDY#==1"
			target="addr"/>
		<transition event="e"
			cond="(Request'name'==1 and Step==1 or Request'name'==0) and %GNT#'name'==0 and FRAME#==1 and IRDY#==1"
			target="dr_bus"/>
		<transition event="e"
			cond="! ((Request'name'==1 and Step==1 or Request'name'==0) and %GNT#'name'==0 and FRAME#==1 and IRDY#==1)
			and !((Request'name'==1 and Step==0) and %GNT#'name'==0 and FRAME#==1 and IRDY#==1)"
			target="m_idle"/>
		<onexit>
			<assign location="M_last_state" expr="m_idle"/>
			<assign location="*IRDY#" expr="0"/>
		</onexit>
	</state>

	<state id="addr">
		<onentry>
			<assign location="*FRAME#" expr="1"/>
			<assign location="C/BE#" expr="$cmd"/>
			<!-- TODO ad muss die adresse vom target sein -->
			<assign location="AD" expr="address"/>
			<assign location="&IRDY#" expr="1"/>
			<assign location="&FRAME#" expr="0"/>
			<if cond="M_last_state==m_data or M_last_state==addr">
				<assign location="*IRDY#" expr="1"/>
			</if>
		</onentry>
		<assign location="Master_abort" expr="0"/>
		<assign location="Target_abort" expr="0"/>
		<if cond="Request'name'==1">
			<assign location="%REQ'name'" expr="0"/>
			<else>
				<assign location="%REQ'name'" expr="1"/>
			</else>
		</if>
		<transition event="e"
			target="m_data"/>
		<onexit>
			<assign location="M_last_state" expr="addr"/>
			<assign location="*IRDY#" expr="0"/>
			<assign location="*FRAME#" expr="0"/>
		</onexit>
	</state>

	<state id="m_data">
		<onentry>
			<if cond="n_trans==1">
				<assign location="Comp" expr="1"/>
			</if>
			<if cond="M_last_state==m_data or M_last_state==addr">
				<assign location="*IRDY#" expr="1"/>
			</if>
			<if cond="!(Dev_to==0 and {[Comp==0 and (To==0 or %GNT#'name'==0) and STOP#==1] or Ready==0})">
				<assign location="&FRAME#" expr="1"/>
				<else>
					<assign location="&FRAME#" expr="0"/>
				</else>
			</if>
			<assign location="*FRAME#" expr="1"/>
			<assign location="C/BE#" expr="byte_enables"/>
			<assign location="AD" expr="data"/>
		</onentry>

		<if cond="DEVSEL#==0">
			<assign location="Dev_to" expr="0"/>
			<assign location="n_trans" expr="$n_trans--"/>
			<else>
				<if cond="timer==0">
					<assign location="Dev_to" expr="1"/>
					<else>
						<assign location="timer" expr="$timer--"/>
					</else>
				</if>
			</else>
		</if>

		<if cond="Request'name'==1">
			<assign location="%REQ'name'" expr="0"/>
			<else>
				<assign location="%REQ'name'" expr="1"/>
			</else>
		</if>
		<if cond="n_trans==0">
			<assign location="Request'name'" expr="0"/>
		</if>
		<if cond="Dev_to=1">
			<assign location="Master_abort" expr="1"/>
			<else>
				<assign location="Master_abort" expr="0"/>
			</else>
		</if>
		<if cond="STOP#==0 and DEVSEL#==1 and FRAME#==1 and IRDY#==0">
			<assign location="Target_abort" expr="1"/>
			<else>
				<assign location="Target_abort" expr="0"/>
			</else>
		</if>
		<if cond="!(Ready==1 and Dev_to==1)">
			<assign location="&IRDY#" expr="0"/>
			<else>
				<assign location="&IRDY#" expr="1"/>
			</else>
		</if>

		<method action="call"\>

		<transition event="e"
			cond="FRAME#==0 or FRAME#==1 and TRDY#==1 and STOP#==1 and Dev_to==0"
			target="m_data"/>
		<transition event="e"
			cond="(Request'name'==1 and STOP#==0) and %GNT#'name'==0 and FRAME#==1 and TRDY#==0
			and STOP#==1 and L_cycle==1 and (Sa==1 or FB2B_Ena==1)"
			target="addr"/>
		<transition event="e"
			cond="FRAME#==1 and STOP#==0 or FRAME#==1 and Dev_to==1"
			target="m_s_tar"/>
		<transition event="e"
			cond="! (FRAME#==0 or FRAME#==1 and TRDY#==1 and STOP#==1 and Dev_to==0)
			and ! ((Request'name'==1 and STOP#==0) and %GNT#'name'==0 and FRAME#==1 and TRDY#==0
			and STOP#==1 and L_cycle==1 and (Sa==1 or FB2B_Ena==1))
			and ! (FRAME#==1 and STOP#==0 or FRAME#==1 and Dev_to==1)"
			target="m_turn_ar"/>
		<onexit>
			<assign location="M_last_state" expr="m_data"/>
			<assign location="*FRAME#" expr="0"/>
			<assign location="*IRDY#" expr="0"/>
		</onexit>
	</state>

	<state id="m_turn_ar">
		<onentry>
			<if cond="M_last_state==m_data or M_last_state==addr">
				<assign location="*IRDY#" expr="1"/>
			</if>
		</onentry>
		<assign location="&IRDY#" expr="1"/>
		<assign location="&FRAME#" expr="1"/>
		<assign location="Master_abort" expr="0"/>
		<assign location="Target_abort" expr="0"/>
		<!--TODO das eher ins onexit von data?-->
		<assign location="Comp" expr="0"/>
		<assign location="Dev_to" expr="0"/>
		<if cond="Request'name'==1">
			<assign location="%REQ'name'" expr="0"/>
			<else>
				<assign location="%REQ'name'" expr="1"/>
			</else>
		</if>
		<transition event="e"
			cond="(Request'name'==1 and Step==0) and %GNT#'name'==0"
			target="addr"/>
		<transition event="e"
			cond="(Request'name'==1 and Step==1 or Request'name'==0) and %GNT#'name'==0"
			target="dr_bus"/>
		<transition event="e"
			cond="%GNT#'name'==1"
			target="m_idle"/>
		<onexit>
			<assign location="M_last_state" expr="m_turn_ar"/>
			<assign location="*IRDY#" expr="0"/>
		</onexit>
	</state>

	<state id="m_s_tar">
		<onentry>
			<if cond="M_last_state==m_s_tar">
				<assign location="Request'name'" expr="0"/>
			</if>
			<if cond="M_last_state==m_data or M_last_state==addr">
				<assign location="*IRDY#" expr="1"/>
			</if>
			<assign location="&IRDY#" expr="1"/>
			<assign location="&FRAME#" expr="1"/>
		</onentry>
		<!--cleanup-->
		<assign location="Dev_to" expr="0"/>
		<assign location="Ready" expr="0"/>
		<assign location="Comp" expr="0"/>

		<assign location="Master_abort" expr="0"/>
		<if cond="Request'name'==1">
			<assign location="%REQ'name'" expr="0"/>
			<else>
				<assign location="%REQ'name'" expr="1"/>
			</else>
		</if>
		<transition event="e"
			cond="%GNT#'name'==0"
			target="dr_bus"/>
		<transition event="e"
			cond="%GNT#'name'==1"
			target="m_idle"/>
		<onexit>
			<assign location="M_last_state" expr="m_s_tar"/>
			<assign location="*IRDY#" expr="0"/>
		</onexit>
	</state>

	<state id="dr_bus">
		<onentry>
			<if cond="M_last_state==m_data or M_last_state==addr">
				<assign location="*IRDY#" expr="1"/>
			</if>
			<if cond="Step==1 and Request'name'==1">
				<assign location="C/BE#" expr="comand"/>
				<assign location="AD" expr="address"/>
				<else>
					<assign location="C/BE#" expr="valid"/>
					<assign location="AD" expr="valid"/>
				</else>
			</if>
		</onentry>
		<assign location="&IRDY#" expr="1"/>
		<assign location="&FRAME#" expr="1"/>
		<assign location="Master_abort" expr="0"/>
		<assign location="Target_abort" expr="0"/>
		<if cond="Request'name'==1">
			<assign location="%REQ'name'" expr="0"/>
			<else>
				<assign location="%REQ'name'" expr="1"/>
			</else>
		</if>
		<transition event="e"
			cond="(Request'name'==1 and Step==1 or Request'name'==0) and %GNT#'name'==0"
			target="dr_bus"/>
		<transition event="e"
			cond=" (Request'name'==1 and Step==0) and %GNT#'name'==0"
			target="addr"/>
		<transition event="e"
			cond="%GNT#'name'==1"
			target="m_idle"/>
		<onexit>
			<assign location="M_last_state" expr="dr_bus"/>
			<assign location="*IRDY#" expr="0"/>
		</onexit>
	</state>
</scxml>