1
|
library ieee;
|
2
|
use ieee.std_logic_1164.all;
|
3
|
|
4
|
library ieee;
|
5
|
use ieee.numeric_std.all;
|
6
|
|
7
|
entity fsm_15 is
|
8
|
port (
|
9
|
clock : in std_logic;
|
10
|
reset : in std_logic;
|
11
|
out3 : out std_logic;
|
12
|
out157 : out std_logic;
|
13
|
out159 : out std_logic;
|
14
|
out160 : out std_logic;
|
15
|
out171 : out std_logic;
|
16
|
out172 : out std_logic;
|
17
|
out173 : out std_logic;
|
18
|
out175 : out std_logic;
|
19
|
out178 : out std_logic;
|
20
|
in0 : in std_logic;
|
21
|
out0 : out std_logic;
|
22
|
in5 : in std_logic;
|
23
|
in6 : in std_logic;
|
24
|
in7 : in std_logic;
|
25
|
out35 : out std_logic;
|
26
|
out39 : out std_logic;
|
27
|
out40 : out std_logic;
|
28
|
out41 : out std_logic;
|
29
|
out44 : out std_logic;
|
30
|
out46 : out std_logic;
|
31
|
out140 : out std_logic;
|
32
|
in8 : in std_logic;
|
33
|
in9 : in std_logic;
|
34
|
in10 : in std_logic;
|
35
|
in11 : in std_logic;
|
36
|
in12 : in std_logic;
|
37
|
in13 : in std_logic;
|
38
|
in14 : in std_logic;
|
39
|
out65 : out std_logic;
|
40
|
in1 : in std_logic;
|
41
|
in2 : in std_logic;
|
42
|
in3 : in std_logic;
|
43
|
in4 : in std_logic;
|
44
|
out225 : out std_logic;
|
45
|
out227 : out std_logic;
|
46
|
out231 : out std_logic;
|
47
|
out235 : out std_logic;
|
48
|
out236 : out std_logic;
|
49
|
out237 : out std_logic;
|
50
|
out238 : out std_logic;
|
51
|
out97 : out std_logic;
|
52
|
out98 : out std_logic;
|
53
|
out101 : out std_logic;
|
54
|
out102 : out std_logic;
|
55
|
out124 : out std_logic;
|
56
|
out125 : out std_logic;
|
57
|
out80 : out std_logic;
|
58
|
out81 : out std_logic;
|
59
|
out84 : out std_logic;
|
60
|
out86 : out std_logic;
|
61
|
out88 : out std_logic;
|
62
|
out93 : out std_logic;
|
63
|
out94 : out std_logic
|
64
|
);
|
65
|
end fsm_15;
|
66
|
|
67
|
architecture augh of fsm_15 is
|
68
|
|
69
|
signal state_cur : std_logic_vector(0 to 21) := (19 => '1', others => '0');
|
70
|
signal state_next : std_logic_vector(0 to 21) := (19 => '1', others => '0');
|
71
|
|
72
|
-- Buffers for outputs
|
73
|
signal out0_buf : std_logic := '0';
|
74
|
signal out0_bufn : std_logic;
|
75
|
signal out40_buf : std_logic := '0';
|
76
|
signal out40_bufn : std_logic;
|
77
|
signal out101_buf : std_logic := '0';
|
78
|
signal out101_bufn : std_logic;
|
79
|
signal out172_buf : std_logic := '0';
|
80
|
signal out172_bufn : std_logic;
|
81
|
|
82
|
-- Function calls: return IDs
|
83
|
signal funccall0 : unsigned(0 downto 0) := (others => '0');
|
84
|
signal funccall0_next : unsigned(0 downto 0) := (others => '0');
|
85
|
|
86
|
begin
|
87
|
|
88
|
-- Sequential process
|
89
|
-- Set the current state
|
90
|
|
91
|
process (clock)
|
92
|
begin
|
93
|
if rising_edge(clock) then
|
94
|
|
95
|
-- Next state
|
96
|
state_cur <= state_next;
|
97
|
-- Buffers for outputs
|
98
|
out0_buf <= out0_bufn;
|
99
|
out40_buf <= out40_bufn;
|
100
|
out101_buf <= out101_bufn;
|
101
|
out172_buf <= out172_bufn;
|
102
|
-- Function calls: return IDs
|
103
|
funccall0 <= funccall0_next;
|
104
|
|
105
|
end if;
|
106
|
end process;
|
107
|
|
108
|
-- Combinatorial process
|
109
|
-- Compute the next state
|
110
|
-- Compute the outputs
|
111
|
|
112
|
process (
|
113
|
-- Inputs of the FSM
|
114
|
reset, in0, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in1, in2, in3, in4,
|
115
|
-- Function calls: return IDs
|
116
|
funccall0,
|
117
|
-- Current state
|
118
|
state_cur
|
119
|
)
|
120
|
begin
|
121
|
|
122
|
-- Reset the next state value
|
123
|
|
124
|
state_next <= (others => '0');
|
125
|
|
126
|
-- Default value to the outputs or output buffers
|
127
|
|
128
|
out46 <= '0';
|
129
|
out35 <= '0';
|
130
|
out65 <= '0';
|
131
|
out39 <= '0';
|
132
|
out3 <= '0';
|
133
|
out44 <= '0';
|
134
|
out0_bufn <= '0';
|
135
|
out41 <= '0';
|
136
|
out40_bufn <= '0';
|
137
|
out80 <= '0';
|
138
|
out81 <= '0';
|
139
|
out84 <= '0';
|
140
|
out86 <= '0';
|
141
|
out88 <= '0';
|
142
|
out93 <= '0';
|
143
|
out94 <= '0';
|
144
|
out97 <= '0';
|
145
|
out98 <= '0';
|
146
|
out101_bufn <= '0';
|
147
|
out102 <= '0';
|
148
|
out124 <= '0';
|
149
|
out125 <= '0';
|
150
|
out140 <= '0';
|
151
|
out157 <= '0';
|
152
|
out159 <= '0';
|
153
|
out160 <= '0';
|
154
|
out171 <= '0';
|
155
|
out172_bufn <= '0';
|
156
|
out173 <= '0';
|
157
|
out175 <= '0';
|
158
|
out178 <= '0';
|
159
|
out225 <= '0';
|
160
|
out227 <= '0';
|
161
|
out231 <= '0';
|
162
|
out235 <= '0';
|
163
|
out236 <= '0';
|
164
|
out237 <= '0';
|
165
|
out238 <= '0';
|
166
|
|
167
|
-- Function calls: default values (no change)
|
168
|
funccall0_next <= funccall0;
|
169
|
|
170
|
-- For all states, compute the next state bits
|
171
|
-- And the outputs, and the next value for buffered outputs
|
172
|
|
173
|
if state_cur(0) = '1' then
|
174
|
-- Next state
|
175
|
if ((in4) or (in3) or (in2)) = '1' then
|
176
|
state_next(17) <= '1';
|
177
|
-- Next values for buffered outputs
|
178
|
else
|
179
|
if (in1) = '1' then
|
180
|
-- Function call: memextrct_0
|
181
|
-- Save the origin of the call
|
182
|
funccall0_next <= to_unsigned(0, 1);
|
183
|
-- This is where the function call leads
|
184
|
state_next(4) <= '1';
|
185
|
-- Next values for buffered outputs
|
186
|
out0_bufn <= '1';
|
187
|
else
|
188
|
if (in0) = '1' then
|
189
|
-- Function call: memextrct_1
|
190
|
state_next(2) <= '1';
|
191
|
-- Next values for buffered outputs
|
192
|
out0_bufn <= '1';
|
193
|
else
|
194
|
state_next(17) <= '1';
|
195
|
-- Next values for buffered outputs
|
196
|
end if;
|
197
|
end if;
|
198
|
end if;
|
199
|
-- Assignment of non-buffered outputs
|
200
|
out3 <= '1';
|
201
|
end if;
|
202
|
|
203
|
if state_cur(1) = '1' then
|
204
|
-- Next state
|
205
|
if (in5) = '1' then
|
206
|
state_next(1) <= '1';
|
207
|
-- Next values for buffered outputs
|
208
|
out40_bufn <= '1';
|
209
|
else
|
210
|
-- Return from function: memextrct_1
|
211
|
-- Function call: memextrct_0
|
212
|
-- Save the origin of the call
|
213
|
funccall0_next <= to_unsigned(1, 1);
|
214
|
-- This is where the function call leads
|
215
|
state_next(4) <= '1';
|
216
|
-- Next values for buffered outputs
|
217
|
out0_bufn <= '1';
|
218
|
end if;
|
219
|
-- Assignment of non-buffered outputs
|
220
|
out41 <= '1';
|
221
|
out39 <= '1';
|
222
|
out35 <= '1';
|
223
|
end if;
|
224
|
|
225
|
if state_cur(2) = '1' then
|
226
|
-- Next state
|
227
|
state_next(1) <= '1';
|
228
|
-- Next values for buffered outputs
|
229
|
out40_bufn <= '1';
|
230
|
-- Assignment of non-buffered outputs
|
231
|
out44 <= '1';
|
232
|
end if;
|
233
|
|
234
|
if state_cur(3) = '1' then
|
235
|
-- Next state
|
236
|
if (in6) = '1' then
|
237
|
state_next(3) <= '1';
|
238
|
-- Next values for buffered outputs
|
239
|
out40_bufn <= '1';
|
240
|
else
|
241
|
-- Return from function: memextrct_0
|
242
|
if funccall0 = 1 then
|
243
|
state_next(17) <= '1';
|
244
|
-- Next values for buffered outputs
|
245
|
end if;
|
246
|
-- Return from function: memextrct_0
|
247
|
if funccall0 = 0 then
|
248
|
state_next(17) <= '1';
|
249
|
-- Next values for buffered outputs
|
250
|
end if;
|
251
|
end if;
|
252
|
-- Assignment of non-buffered outputs
|
253
|
out41 <= '1';
|
254
|
out65 <= '1';
|
255
|
out46 <= '1';
|
256
|
end if;
|
257
|
|
258
|
if state_cur(4) = '1' then
|
259
|
-- Next state
|
260
|
state_next(3) <= '1';
|
261
|
-- Next values for buffered outputs
|
262
|
out40_bufn <= '1';
|
263
|
-- Assignment of non-buffered outputs
|
264
|
out44 <= '1';
|
265
|
end if;
|
266
|
|
267
|
if state_cur(5) = '1' then
|
268
|
-- Next state
|
269
|
if (in8) = '1' then
|
270
|
state_next(20) <= '1';
|
271
|
-- Next values for buffered outputs
|
272
|
else
|
273
|
if (not (in7)) = '1' then
|
274
|
state_next(5) <= '1';
|
275
|
-- Next values for buffered outputs
|
276
|
else
|
277
|
state_next(6) <= '1';
|
278
|
-- Next values for buffered outputs
|
279
|
end if;
|
280
|
end if;
|
281
|
-- Assignment of non-buffered outputs
|
282
|
out84 <= '1';
|
283
|
out81 <= '1';
|
284
|
out80 <= '1';
|
285
|
end if;
|
286
|
|
287
|
if state_cur(6) = '1' then
|
288
|
-- Next state
|
289
|
if (in8) = '1' then
|
290
|
state_next(20) <= '1';
|
291
|
-- Next values for buffered outputs
|
292
|
else
|
293
|
if (not (in9)) = '1' then
|
294
|
state_next(6) <= '1';
|
295
|
-- Next values for buffered outputs
|
296
|
else
|
297
|
state_next(7) <= '1';
|
298
|
-- Next values for buffered outputs
|
299
|
end if;
|
300
|
end if;
|
301
|
-- Assignment of non-buffered outputs
|
302
|
out88 <= '1';
|
303
|
out86 <= '1';
|
304
|
out81 <= '1';
|
305
|
end if;
|
306
|
|
307
|
if state_cur(7) = '1' then
|
308
|
-- Next state
|
309
|
if (in8) = '1' then
|
310
|
state_next(20) <= '1';
|
311
|
-- Next values for buffered outputs
|
312
|
else
|
313
|
if (not (in9)) = '1' then
|
314
|
state_next(7) <= '1';
|
315
|
-- Next values for buffered outputs
|
316
|
else
|
317
|
state_next(16) <= '1';
|
318
|
-- Next values for buffered outputs
|
319
|
end if;
|
320
|
end if;
|
321
|
-- Assignment of non-buffered outputs
|
322
|
out94 <= '1';
|
323
|
out93 <= '1';
|
324
|
out81 <= '1';
|
325
|
end if;
|
326
|
|
327
|
if state_cur(8) = '1' then
|
328
|
-- Next state
|
329
|
state_next(14) <= '1';
|
330
|
-- Next values for buffered outputs
|
331
|
-- Assignment of non-buffered outputs
|
332
|
out98 <= '1';
|
333
|
out97 <= '1';
|
334
|
end if;
|
335
|
|
336
|
if state_cur(9) = '1' then
|
337
|
-- Next state
|
338
|
if (in10) = '1' then
|
339
|
state_next(10) <= '1';
|
340
|
-- Next values for buffered outputs
|
341
|
out101_bufn <= '1';
|
342
|
else
|
343
|
state_next(5) <= '1';
|
344
|
-- Next values for buffered outputs
|
345
|
end if;
|
346
|
-- Assignment of non-buffered outputs
|
347
|
end if;
|
348
|
|
349
|
if state_cur(10) = '1' then
|
350
|
-- Next state
|
351
|
state_next(11) <= '1';
|
352
|
-- Next values for buffered outputs
|
353
|
-- Assignment of non-buffered outputs
|
354
|
out102 <= '1';
|
355
|
end if;
|
356
|
|
357
|
if state_cur(11) = '1' then
|
358
|
-- Next state
|
359
|
state_next(13) <= '1';
|
360
|
-- Next values for buffered outputs
|
361
|
out172_bufn <= '1';
|
362
|
-- Assignment of non-buffered outputs
|
363
|
out125 <= '1';
|
364
|
out124 <= '1';
|
365
|
end if;
|
366
|
|
367
|
if state_cur(12) = '1' then
|
368
|
-- Next state
|
369
|
state_next(9) <= '1';
|
370
|
-- Next values for buffered outputs
|
371
|
-- Assignment of non-buffered outputs
|
372
|
out159 <= '1';
|
373
|
out157 <= '1';
|
374
|
out140 <= '1';
|
375
|
end if;
|
376
|
|
377
|
if state_cur(13) = '1' then
|
378
|
-- Next state
|
379
|
if (in8) = '1' then
|
380
|
state_next(20) <= '1';
|
381
|
-- Next values for buffered outputs
|
382
|
else
|
383
|
state_next(9) <= '1';
|
384
|
-- Next values for buffered outputs
|
385
|
end if;
|
386
|
-- Assignment of non-buffered outputs
|
387
|
out173 <= '1';
|
388
|
out171 <= '1';
|
389
|
out160 <= '1';
|
390
|
out81 <= '1';
|
391
|
end if;
|
392
|
|
393
|
if state_cur(14) = '1' then
|
394
|
-- Next state
|
395
|
if (in11) = '1' then
|
396
|
state_next(15) <= '1';
|
397
|
-- Next values for buffered outputs
|
398
|
out172_bufn <= '1';
|
399
|
out101_bufn <= '1';
|
400
|
else
|
401
|
state_next(12) <= '1';
|
402
|
-- Next values for buffered outputs
|
403
|
end if;
|
404
|
-- Assignment of non-buffered outputs
|
405
|
end if;
|
406
|
|
407
|
if state_cur(15) = '1' then
|
408
|
-- Next state
|
409
|
if (in8) = '1' then
|
410
|
state_next(20) <= '1';
|
411
|
-- Next values for buffered outputs
|
412
|
else
|
413
|
state_next(14) <= '1';
|
414
|
-- Next values for buffered outputs
|
415
|
end if;
|
416
|
-- Assignment of non-buffered outputs
|
417
|
out173 <= '1';
|
418
|
out178 <= '1';
|
419
|
out175 <= '1';
|
420
|
out81 <= '1';
|
421
|
end if;
|
422
|
|
423
|
if state_cur(16) = '1' then
|
424
|
-- Next state
|
425
|
state_next(8) <= '1';
|
426
|
-- Next values for buffered outputs
|
427
|
-- Assignment of non-buffered outputs
|
428
|
out159 <= '1';
|
429
|
out227 <= '1';
|
430
|
out225 <= '1';
|
431
|
end if;
|
432
|
|
433
|
if state_cur(17) = '1' then
|
434
|
-- Next state
|
435
|
if (in12) = '1' then
|
436
|
if (in4) = '1' then
|
437
|
state_next(5) <= '1';
|
438
|
-- Next values for buffered outputs
|
439
|
else
|
440
|
if (in3) = '1' then
|
441
|
state_next(6) <= '1';
|
442
|
-- Next values for buffered outputs
|
443
|
else
|
444
|
if (in2) = '1' then
|
445
|
state_next(7) <= '1';
|
446
|
-- Next values for buffered outputs
|
447
|
else
|
448
|
if (in1) = '1' then
|
449
|
state_next(13) <= '1';
|
450
|
-- Next values for buffered outputs
|
451
|
out172_bufn <= '1';
|
452
|
else
|
453
|
state_next(15) <= '1';
|
454
|
-- Next values for buffered outputs
|
455
|
out172_bufn <= '1';
|
456
|
out101_bufn <= '1';
|
457
|
end if;
|
458
|
end if;
|
459
|
end if;
|
460
|
end if;
|
461
|
else
|
462
|
state_next(18) <= '1';
|
463
|
-- Next values for buffered outputs
|
464
|
end if;
|
465
|
-- Assignment of non-buffered outputs
|
466
|
out231 <= '1';
|
467
|
end if;
|
468
|
|
469
|
if state_cur(18) = '1' then
|
470
|
-- Next state
|
471
|
state_next(18) <= '1';
|
472
|
-- Next values for buffered outputs
|
473
|
-- Assignment of non-buffered outputs
|
474
|
end if;
|
475
|
|
476
|
-- Info: This is the init/reset state
|
477
|
if state_cur(19) = '1' then
|
478
|
-- Next state
|
479
|
if (not (in13)) = '1' then
|
480
|
state_next(19) <= '1';
|
481
|
-- Next values for buffered outputs
|
482
|
else
|
483
|
if (in12) = '1' then
|
484
|
state_next(20) <= '1';
|
485
|
-- Next values for buffered outputs
|
486
|
else
|
487
|
state_next(6) <= '1';
|
488
|
-- Next values for buffered outputs
|
489
|
end if;
|
490
|
end if;
|
491
|
-- Assignment of non-buffered outputs
|
492
|
out236 <= '1';
|
493
|
out235 <= '1';
|
494
|
end if;
|
495
|
|
496
|
if state_cur(20) = '1' then
|
497
|
-- Next state
|
498
|
state_next(21) <= '1';
|
499
|
-- Next values for buffered outputs
|
500
|
-- Assignment of non-buffered outputs
|
501
|
out44 <= '1';
|
502
|
end if;
|
503
|
|
504
|
if state_cur(21) = '1' then
|
505
|
-- Next state
|
506
|
if (in14) = '1' then
|
507
|
state_next(21) <= '1';
|
508
|
-- Next values for buffered outputs
|
509
|
else
|
510
|
state_next(0) <= '1';
|
511
|
-- Next values for buffered outputs
|
512
|
out0_bufn <= '1';
|
513
|
end if;
|
514
|
-- Assignment of non-buffered outputs
|
515
|
out41 <= '1';
|
516
|
out238 <= '1';
|
517
|
out237 <= '1';
|
518
|
end if;
|
519
|
|
520
|
-- Reset input
|
521
|
if reset = '1' then
|
522
|
-- Set the reset state
|
523
|
state_next <= (19 => '1', others => '0');
|
524
|
-- Note: Resetting all buffers for outputs here is not necessary.
|
525
|
-- It would cost hardware. They will be reset at the next clock front.
|
526
|
-- Reset state: set the buffered outputs
|
527
|
end if;
|
528
|
|
529
|
end process;
|
530
|
|
531
|
-- Assignment of buffered outputs
|
532
|
|
533
|
out0 <= out0_buf;
|
534
|
out40 <= out40_buf;
|
535
|
out101 <= out101_buf;
|
536
|
out172 <= out172_buf;
|
537
|
|
538
|
end architecture;
|
539
|
|