OpenCores
URL https://opencores.org/ocsvn/xucpu/xucpu/trunk

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [datapath/] [dp_000.vhdl] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 lcdsgmtr
-- Copyright 2015, Jürgen Defurne
2
--
3
-- This file is part of the Experimental Unstable CPU System.
4
--
5
-- The Experimental Unstable CPU System Is free software: you can redistribute
6
-- it and/or modify it under the terms of the GNU Lesser General Public License
7
-- as published by the Free Software Foundation, either version 3 of the
8
-- License, or (at your option) any later version.
9
--
10
-- The Experimental Unstable CPU System is distributed in the hope that it will
11
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
13
-- General Public License for more details.
14
--
15
-- You should have received a copy of the GNU Lesser General Public License
16
-- along with Experimental Unstable CPU System. If not, see
17
-- http://www.gnu.org/licenses/lgpl.txt.
18
 
19
 
20
LIBRARY ieee;
21
USE ieee.std_logic_1164.ALL;
22
USE ieee.numeric_std.ALL;
23
 
24
ENTITY dp_000 IS
25
END dp_000;
26
 
27
ARCHITECTURE behavior OF dp_000 IS
28
 
29
  -- Component Declaration for the Unit Under Test (UUT)
30
 
31
  COMPONENT dp
32
    PORT(
33
      reset     : IN  STD_LOGIC;
34
      clock     : IN  STD_LOGIC;
35
      reg_a     : IN  STD_LOGIC_VECTOR(4 DOWNTO 0);
36
      reg_b     : IN  STD_LOGIC_VECTOR(4 DOWNTO 0);
37
      reg_input : IN  STD_LOGIC_VECTOR(1 DOWNTO 0);
38
      op_sel    : IN  STD_LOGIC_VECTOR(3 DOWNTO 0);
39
      we        : IN  STD_LOGIC;
40
      pc_input  : IN  STD_LOGIC_VECTOR(1 DOWNTO 0);
41
      pc_load   : IN  STD_LOGIC;
42
      dr_load   : IN  STD_LOGIC;
43
      ar_load   : IN  STD_LOGIC;
44
      aa_load   : IN  STD_LOGIC;
45
      ab_load   : IN  STD_LOGIC;
46
      addr_sel  : IN  STD_LOGIC;
47
      zero      : OUT STD_LOGIC;
48
      n_zero    : OUT STD_LOGIC;
49
      data_in   : IN  STD_LOGIC_VECTOR(15 DOWNTO 0);
50
      data_out  : OUT STD_LOGIC_VECTOR(15 DOWNTO 0);
51
      addr_out  : OUT STD_LOGIC_VECTOR(14 DOWNTO 0)
52
      );
53
  END COMPONENT;
54
 
55
  -- purpose: Convert a register number into a STD_LOGIC_VECTOR
56
  FUNCTION reg (reg_nr, len : NATURAL)
57
    RETURN STD_LOGIC_VECTOR IS
58
  BEGIN  -- reg
59
    RETURN STD_LOGIC_VECTOR(to_unsigned(reg_nr, len));
60
  END reg;
61
 
62
 
63
  --Inputs
64
  -- These two are master signals
65
  -- There should also be a reset generated by the test code FOR
66
  -- resetting the data path.
67
  SIGNAL reset : STD_LOGIC := '0';
68
  SIGNAL clock : STD_LOGIC := '0';
69
 
70
  SIGNAL dp_rst    : STD_LOGIC                     := '0';
71
  SIGNAL reg_a     : STD_LOGIC_VECTOR(4 DOWNTO 0)  := (OTHERS => '0');
72
  SIGNAL reg_b     : STD_LOGIC_VECTOR(4 DOWNTO 0)  := (OTHERS => '0');
73
  SIGNAL reg_input : STD_LOGIC_VECTOR(1 DOWNTO 0)  := (OTHERS => '0');
74
  SIGNAL op_sel    : STD_LOGIC_VECTOR(3 DOWNTO 0)  := (OTHERS => '0');
75
  SIGNAL we        : STD_LOGIC                     := '0';
76
  SIGNAL pc_input  : STD_LOGIC_VECTOR(1 DOWNTO 0)  := (OTHERS => '0');
77
  SIGNAL pc_load   : STD_LOGIC                     := '0';
78
  SIGNAL dr_load   : STD_LOGIC                     := '0';
79
  SIGNAL ar_load   : STD_LOGIC                     := '0';
80
  SIGNAL aa_load   : STD_LOGIC                     := '0';
81
  SIGNAL ab_load   : STD_LOGIC                     := '0';
82
  SIGNAL addr_sel  : STD_LOGIC                     := '0';
83
  SIGNAL data_in   : STD_LOGIC_VECTOR(15 DOWNTO 0) := (OTHERS => '0');
84
 
85
  SIGNAL l_dp_rst    : STD_LOGIC                     := '0';
86
  SIGNAL l_reg_a     : STD_LOGIC_VECTOR(4 DOWNTO 0)  := (OTHERS => '0');
87
  SIGNAL l_reg_b     : STD_LOGIC_VECTOR(4 DOWNTO 0)  := (OTHERS => '0');
88
  SIGNAL l_reg_input : STD_LOGIC_VECTOR(1 DOWNTO 0)  := (OTHERS => '0');
89
  SIGNAL l_op_sel    : STD_LOGIC_VECTOR(3 DOWNTO 0)  := (OTHERS => '0');
90
  SIGNAL l_we        : STD_LOGIC                     := '0';
91
  SIGNAL l_pc_input  : STD_LOGIC_VECTOR(1 DOWNTO 0)  := (OTHERS => '0');
92
  SIGNAL l_pc_load   : STD_LOGIC                     := '0';
93
  SIGNAL l_dr_load   : STD_LOGIC                     := '0';
94
  SIGNAL l_ar_load   : STD_LOGIC                     := '0';
95
  SIGNAL l_aa_load   : STD_LOGIC                     := '0';
96
  SIGNAL l_ab_load   : STD_LOGIC                     := '0';
97
  SIGNAL l_addr_sel  : STD_LOGIC                     := '0';
98
  SIGNAL l_data_in   : STD_LOGIC_VECTOR(15 DOWNTO 0) := (OTHERS => '0');
99
 
100
  --Outputs
101
  SIGNAL zero     : STD_LOGIC;
102
  SIGNAL n_zero   : STD_LOGIC;
103
  SIGNAL data_out : STD_LOGIC_VECTOR(15 DOWNTO 0);
104
  SIGNAL addr_out : STD_LOGIC_VECTOR(14 DOWNTO 0);
105
 
106
  -- Clock period definitions
107
  CONSTANT clock_period : TIME := 10 ns;
108
 
109
  SUBTYPE state_range IS NATURAL RANGE 0 TO 104;
110
 
111
  -- State machine definitions
112
  SIGNAL current : state_range := 0;
113
  SIGNAL next_s  : state_range := 0;
114
 
115
BEGIN
116
 
117
  -- Instantiate the Unit Under Test (UUT)
118
  uut : dp PORT MAP (
119
    reset     => dp_rst,
120
    clock     => clock,
121
    reg_a     => reg_a,
122
    reg_b     => reg_b,
123
    reg_input => reg_input,
124
    op_sel    => op_sel,
125
    we        => we,
126
    pc_input  => pc_input,
127
    pc_load   => pc_load,
128
    dr_load   => dr_load,
129
    ar_load   => ar_load,
130
    aa_load   => aa_load,
131
    ab_load   => ab_load,
132
    addr_sel  => addr_sel,
133
    zero      => zero,
134
    n_zero    => n_zero,
135
    data_in   => data_in,
136
    data_out  => data_out,
137
    addr_out  => addr_out
138
    );
139
 
140
  -- Clock process definitions
141
  clock_process : PROCESS
142
  BEGIN
143
    clock <= '0';
144
    WAIT FOR clock_period/2;
145
    clock <= '1';
146
    WAIT FOR clock_period/2;
147
  END PROCESS;
148
 
149
 
150
  -- Stimulus process
151
  stim_proc : PROCESS
152
  BEGIN
153
    -- hold reset state for 100 ns.
154
    WAIT FOR 100 ns;
155
    reset <= '1';
156
    WAIT FOR clock_period*10;
157
 
158
    -- insert stimulus here 
159
 
160
    IF current = 11 AND next_s = 11 THEN
161
      WAIT;
162
    END IF;
163
  END PROCESS;
164
 
165
  -- purpose: This is the microcontroller pipeline register
166
  -- type   : sequential
167
  -- inputs : clock, reset
168
  -- outputs: reg_a,reg_b,reg_input,op_sel
169
  pipeline_reg : PROCESS (clock, reset)
170
  BEGIN  -- PROCESS controller
171
    IF reset = '0' THEN                 -- asynchronous reset (active low)
172
      dp_rst    <= '0';
173
      reg_a     <= (OTHERS => '0');
174
      reg_b     <= (OTHERS => '0');
175
      reg_input <= (OTHERS => '0');
176
      op_sel    <= (OTHERS => '0');
177
      we        <= '0';
178
      pc_input  <= (OTHERS => '0');
179
      pc_load   <= '0';
180
      dr_load   <= '0';
181
      ar_load   <= '0';
182
      aa_load   <= '0';
183
      ab_load   <= '0';
184
      addr_sel  <= '0';
185
      data_in   <= (OTHERS => '0');
186
      current   <= 0;
187
    ELSIF rising_edge(clock) THEN       -- rising clock edge
188
      dp_rst    <= l_dp_rst;
189
      reg_a     <= l_reg_a;
190
      reg_b     <= l_reg_b;
191
      reg_input <= l_reg_input;
192
      op_sel    <= l_op_sel;
193
      we        <= l_we;
194
      pc_input  <= l_pc_input;
195
      pc_load   <= l_pc_load;
196
      dr_load   <= l_dr_load;
197
      ar_load   <= l_ar_load;
198
      aa_load   <= l_aa_load;
199
      ab_load   <= l_ab_load;
200
      addr_sel  <= l_addr_sel;
201
      data_in   <= l_data_in;
202
      current   <= next_s;
203
    END IF;
204
  END PROCESS pipeline_reg;
205
 
206
  -- purpose: Compute the next state based upon the current state and result zero state
207
  -- type   : combinational
208
  -- inputs : current, zero, n_zero
209
  -- outputs: l_*
210
  next_state_logic : PROCESS (current, zero, n_zero)
211
  BEGIN  -- PROCESS next_state_logic
212
 
213
    next_s      <= 0;
214
    l_dp_rst    <= '1';
215
    l_reg_a     <= (OTHERS => '0');
216
    l_reg_b     <= (OTHERS => '0');
217
    l_reg_input <= (OTHERS => '0');
218
    l_op_sel    <= (OTHERS => '0');
219
    l_we        <= '0';
220
    l_pc_input  <= (OTHERS => '0');
221
    l_pc_load   <= '0';
222
    l_dr_load   <= '0';
223
    l_ar_load   <= '0';
224
    l_aa_load   <= '0';
225
    l_ab_load   <= '0';
226
    l_addr_sel  <= '0';
227
    l_data_in   <= (OTHERS => '0');
228
 
229
    CASE current IS
230
 
231
      WHEN 0 =>
232
        next_s   <= 1;
233
        l_dp_rst <= '0';
234
 
235
      WHEN 1 =>
236
        next_s      <= 2;
237
        l_dp_rst    <= '1';
238
        l_reg_a     <= "00001";
239
        l_reg_input <= "00";
240
        l_we        <= '1';
241
        l_data_in   <= X"F0F0";
242
 
243
      WHEN 2 =>
244
        next_s     <= 3;
245
        l_reg_a    <= "00001";
246
        l_reg_b    <= "00001";
247
        l_pc_input <= "10";
248
        l_pc_load  <= '1';
249
        l_dr_load  <= '1';
250
        l_ar_load  <= '1';
251
        l_aa_load  <= '1';
252
        l_ab_load  <= '1';
253
        l_addr_sel <= '1';
254
 
255
      WHEN 3 =>
256
        next_s     <= 4;
257
        l_addr_sel <= '1';
258
 
259
      WHEN 4 =>
260
        next_s   <= 5;
261
        l_dp_rst <= '0';
262
 
263
      WHEN 5 =>
264
        next_s     <= 6;
265
        l_data_in  <= X"A1B2";
266
        l_pc_input <= "01";
267
        l_pc_load  <= '1';
268
        l_addr_sel <= '0';
269
 
270
      WHEN 6 =>
271
        next_s <= 7;
272
 
273
      WHEN 7 =>
274
        next_s   <= 8;
275
        l_dp_rst <= '0';
276
 
277
      WHEN 8 =>                         -- Reset state
278
        next_s      <= 9;
279
        l_data_in   <= X"DEAD";
280
        l_reg_input <= "00";
281
        l_reg_a     <= "00000";
282
        l_we        <= '1';
283
 
284
      WHEN 9 =>                         -- Present value to register file
285
        next_s     <= 10;
286
        l_reg_a    <= "00000";
287
        l_pc_input <= "10";
288
        l_pc_load  <= '1';
289
 
290
      WHEN 10 =>  -- Read value from register file into PC
291
        next_s <= 11;
292
 
293
      WHEN 11 =>
294
        next_s   <= 12;
295
        l_dp_rst <= '0';
296
 
297
      WHEN 12 =>                        -- Reset state
298
        next_s      <= 13;
299
        l_data_in   <= X"BEEF";
300
        l_reg_input <= "00";
301
        l_reg_a     <= "00010";
302
        l_we        <= '1';
303
 
304
      WHEN 13 =>                        -- Load into register 2
305
        next_s    <= 14;
306
        l_reg_a   <= "00010";
307
        l_dr_load <= '1';
308
 
309
      WHEN 14 =>                        -- Load from register into data out
310
        next_s <= 15;
311
 
312
      WHEN 15 =>
313
        next_s   <= 16;
314
        l_dp_rst <= '0';
315
 
316
      WHEN 16 =>
317
        next_s      <= 17;
318
        l_data_in   <= X"FEED";
319
        l_reg_input <= "00";
320
        l_reg_a     <= "00011";
321
        l_we        <= '1';
322
 
323
      WHEN 17 =>
324
        next_s      <= 18;
325
        l_reg_input <= "11";
326
        l_reg_a     <= "01111";
327
        l_reg_b     <= "00011";
328
        l_we        <= '1';
329
 
330
      WHEN 18 =>
331
        next_s    <= 19;
332
        l_reg_a   <= "01111";
333
        l_dr_load <= '1';
334
 
335
      WHEN 19 =>
336
        next_s <= 20;
337
 
338
      WHEN 20 =>                        -- Start AND cycle
339
        next_s   <= 21;
340
        l_dp_rst <= '0';
341
 
342
      WHEN 21 =>                        -- Reset cycle
343
        next_s      <= 22;
344
        l_data_in   <= X"0FA6";
345
        l_reg_input <= "00";
346
        l_reg_a     <= "00100";
347
        l_we        <= '1';
348
 
349
      WHEN 22 =>                        -- Present 0FA6 to register 00100
350
        next_s      <= 23;
351
        l_data_in   <= X"FA84";
352
        l_reg_input <= "00";
353
        l_reg_a     <= "00101";
354
        l_we        <= '1';
355
 
356
      WHEN 23 =>                        -- Present FA84 to register 00101
357
        next_s    <= 24;
358
        l_reg_a   <= "00100";
359
        l_reg_b   <= "00101";
360
        l_aa_load <= '1';
361
        l_ab_load <= '1';
362
 
363
      WHEN 24 =>                        -- Read reg a and b into A and B
364
        next_s      <= 25;
365
        l_reg_input <= "10";
366
        l_reg_a     <= "00110";
367
        l_we        <= '1';
368
        l_op_sel    <= "1010";
369
 
370
      WHEN 25 =>                        -- Perform AND operation, write result
371
                                        -- into reg 00110
372
        next_s    <= 26;
373
        l_reg_a   <= reg(6, 5);
374
        l_dr_load <= '1';
375
 
376
      WHEN 26 =>                        -- Load reg a into data out register
377
        next_s <= 27;
378
 
379
      WHEN 27 =>
380
        next_s   <= 28;
381
        l_dp_rst <= '0';
382
 
383
      WHEN 28 =>                        -- Reset cycle
384
        next_s      <= 29;
385
        l_data_in   <= X"0111";
386
        l_reg_input <= "00";
387
        l_reg_a     <= reg(7, 5);
388
        l_we        <= '1';
389
 
390
      WHEN 29 =>                        -- Present 0111 to register 00111
391
        next_s      <= 30;
392
        l_data_in   <= X"0F21";
393
        l_reg_input <= "00";
394
        l_reg_a     <= reg(8, 5);
395
        l_we        <= '1';
396
 
397
      WHEN 30 =>                        -- Present 0F21 to register 01000
398
        next_s    <= 31;
399
        l_reg_a   <= reg(7, 5);
400
        l_reg_b   <= reg(8, 5);
401
        l_aa_load <= '1';
402
        l_ab_load <= '1';
403
 
404
      WHEN 31 =>                        -- Read reg a and b into A and B
405
        next_s      <= 32;
406
        l_reg_input <= "10";
407
        l_reg_a     <= reg(9, 5);
408
        l_we        <= '1';
409
        l_op_sel    <= "0111";
410
 
411
      WHEN 32 =>                        -- Perform ADD operation, write result
412
                                        -- into reg 01001
413
        next_s    <= 33;
414
        l_reg_a   <= reg(9, 5);
415
        l_dr_load <= '1';
416
 
417
      WHEN 33 =>                        -- Load reg a into data out register
418
        next_s <= 34;
419
 
420
      WHEN 34 =>
421
        next_s   <= 35;
422
        l_dp_rst <= '0';
423
 
424
      WHEN 35 =>                        -- Reset cycle (1)
425
        next_s      <= 36;
426
        l_data_in   <= X"7321";
427
        l_reg_input <= "00";
428
        l_reg_a     <= reg(10, 5);
429
        l_we        <= '1';
430
 
431
      WHEN 36 =>                        -- Present X"7321" to register 10 (2)
432
        next_s      <= 37;
433
        l_data_in   <= X"6421";
434
        l_reg_input <= "00";
435
        l_reg_a     <= reg(11, 5);
436
        l_we        <= '1';
437
 
438
      WHEN 37 =>                        -- Present X"6421" to register 11 (3)
439
        next_s    <= 38;
440
        l_reg_a   <= reg(10, 5);
441
        l_reg_b   <= reg(11, 5);
442
        l_aa_load <= '1';
443
        l_ab_load <= '1';
444
 
445
      WHEN 38 =>                        -- Read reg a and b into A and B (4)
446
        next_s      <= 39;
447
        l_reg_input <= "10";
448
        l_reg_a     <= reg(12, 5);
449
        l_we        <= '1';
450
        l_op_sel    <= "1000";
451
 
452
      WHEN 39 =>                        -- Perform ADD operation, write result
453
                                        -- into reg 12 (5)
454
        next_s    <= 40;
455
        l_reg_a   <= reg(12, 5);
456
        l_dr_load <= '1';
457
 
458
      WHEN 40 =>  -- Load reg a into data out register (6)
459
        next_s <= 41;
460
 
461
      WHEN 41 =>
462
        next_s   <= 42;
463
        l_dp_rst <= '0';
464
 
465
      WHEN 42 =>                        -- Reset cycle (1)
466
        next_s      <= 43;
467
        l_data_in   <= X"0101";
468
        l_reg_input <= "00";
469
        l_reg_a     <= reg(13, 5);
470
        l_we        <= '1';
471
 
472
      WHEN 43 =>                        -- Present X"0101" to register 13 (2)
473
        next_s      <= 44;
474
        l_data_in   <= X"0011";
475
        l_reg_input <= "00";
476
        l_reg_a     <= reg(14, 5);
477
        l_we        <= '1';
478
 
479
      WHEN 44 =>                        -- Present X"0011" to register 14 (3)
480
        next_s    <= 45;
481
        l_reg_a   <= reg(13, 5);
482
        l_reg_b   <= reg(14, 5);
483
        l_aa_load <= '1';
484
        l_ab_load <= '1';
485
 
486
      WHEN 45 =>                        -- Read reg a and b into A and B (4)
487
        next_s      <= 46;
488
        l_reg_input <= "10";
489
        l_reg_a     <= reg(15, 5);
490
        l_we        <= '1';
491
        l_op_sel    <= "1011";
492
 
493
      WHEN 46 =>                        -- Perform OR operation, write result
494
                                        -- into reg 15 (5)
495
        next_s    <= 47;
496
        l_reg_a   <= reg(15, 5);
497
        l_dr_load <= '1';
498
 
499
      WHEN 47 =>  -- Load reg a into data out register (6)
500
        next_s <= 48;
501
 
502
      WHEN 48 =>
503
        next_s   <= 49;
504
        l_dp_rst <= '0';
505
 
506
      WHEN 49 =>                        -- Reset cycle (1)
507
        next_s      <= 50;
508
        l_data_in   <= X"0101";
509
        l_reg_input <= "00";
510
        l_reg_a     <= reg(0, 5);
511
        l_we        <= '1';
512
 
513
      WHEN 50 =>                        -- Present X"0101" to register 0 (2)
514
        next_s      <= 51;
515
        l_data_in   <= X"0011";
516
        l_reg_input <= "00";
517
        l_reg_a     <= reg(1, 5);
518
        l_we        <= '1';
519
 
520
      WHEN 51 =>                        -- Present X"0011" to register 1 (3)
521
        next_s    <= 52;
522
        l_reg_a   <= reg(0, 5);
523
        l_reg_b   <= reg(1, 5);
524
        l_aa_load <= '1';
525
        l_ab_load <= '1';
526
 
527
      WHEN 52 =>                        -- Read reg a and b into A and B (4)
528
        next_s      <= 53;
529
        l_reg_input <= "10";
530
        l_reg_a     <= reg(2, 5);
531
        l_we        <= '1';
532
        l_op_sel    <= "1100";
533
 
534
      WHEN 53 =>                        -- Perform XOR operation, write result
535
                                        -- into reg 2 (5)
536
        next_s    <= 54;
537
        l_reg_a   <= reg(2, 5);
538
        l_dr_load <= '1';
539
 
540
      WHEN 54 =>  -- Load reg a into data out register (6)
541
        next_s <= 55;
542
 
543
      WHEN 55 =>
544
        next_s   <= 56;
545
        l_dp_rst <= '0';
546
 
547
      WHEN 56 =>                        -- Reset cycle (1)
548
        next_s      <= 57;
549
        l_data_in   <= X"0A0C";
550
        l_reg_input <= "00";
551
        l_reg_a     <= reg(2, 5);
552
        l_we        <= '1';
553
 
554
      WHEN 57 =>                        -- Present X"0A0C" to register 2 (2)
555
        next_s    <= 58;
556
        l_reg_a   <= reg(2, 5);
557
        l_aa_load <= '1';
558
 
559
      WHEN 58 =>                        -- Read reg a into A (3)
560
        next_s      <= 59;
561
        l_reg_input <= "10";
562
        l_reg_a     <= reg(3, 5);
563
        l_we        <= '1';
564
        l_op_sel    <= "1101";
565
 
566
      WHEN 59 =>                        -- Perform NOT operation, write result
567
                                        -- into reg 3 (4)
568
        next_s    <= 60;
569
        l_reg_a   <= reg(3, 5);
570
        l_dr_load <= '1';
571
 
572
      WHEN 60 =>  -- Load reg a into data out register (5)
573
        next_s <= 61;
574
 
575
      WHEN 61 =>
576
        next_s   <= 62;
577
        l_dp_rst <= '0';
578
 
579
      WHEN 62 =>                        -- Reset cycle (1)
580
        next_s      <= 63;
581
        l_data_in   <= X"7310";
582
        l_reg_input <= "00";
583
        l_reg_a     <= reg(4, 5);
584
        l_we        <= '1';
585
 
586
      WHEN 63 =>                        -- Present X"7310" to register 4 (2)
587
        next_s    <= 64;
588
        l_reg_a   <= reg(4, 5);
589
        l_aa_load <= '1';
590
 
591
      WHEN 64 =>                        -- Read reg a into A (3)
592
        next_s      <= 65;
593
        l_reg_input <= "10";
594
        l_reg_a     <= reg(5, 5);
595
        l_we        <= '1';
596
        l_op_sel    <= "1110";
597
 
598
      WHEN 65 =>                        -- Perform SLL operation, write result
599
                                        -- into reg 5 (4)
600
        next_s    <= 66;
601
        l_reg_a   <= reg(5, 5);
602
        l_dr_load <= '1';
603
 
604
      WHEN 66 =>  -- Load reg a into data out register (5)
605
        next_s <= 67;
606
 
607
      WHEN 67 =>
608
        next_s   <= 68;
609
        l_dp_rst <= '0';
610
 
611
      WHEN 68 =>                        -- Reset cycle (1)
612
        next_s      <= 69;
613
        l_data_in   <= X"C426";
614
        l_reg_input <= "00";
615
        l_reg_a     <= reg(6, 5);
616
        l_we        <= '1';
617
 
618
      WHEN 69 =>                        -- Present X"C426" to register 6 (2)
619
        next_s    <= 70;
620
        l_reg_a   <= reg(6, 5);
621
        l_aa_load <= '1';
622
 
623
      WHEN 70 =>                        -- Read reg a into A (3)
624
        next_s      <= 71;
625
        l_reg_input <= "10";
626
        l_reg_a     <= reg(7, 5);
627
        l_we        <= '1';
628
        l_op_sel    <= "1111";
629
 
630
      WHEN 71 =>                        -- Perform SLL operation, write result
631
                                        -- into reg 5 (4)
632
        next_s    <= 72;
633
        l_reg_a   <= reg(7, 5);
634
        l_dr_load <= '1';
635
 
636
      WHEN 72 =>  -- Load reg a into data out register (5)
637
        next_s <= 73;
638
 
639
      WHEN 73 =>
640
        next_s   <= 74;
641
        l_dp_rst <= '0';
642
 
643
      WHEN 74 =>                        -- Reset cycle (1)
644
        next_s      <= 75;
645
        l_data_in   <= X"001F";
646
        l_reg_input <= "00";
647
        l_reg_a     <= reg(8, 5);
648
        l_we        <= '1';
649
 
650
      WHEN 75 =>                        -- Present X"C426" to register 6 (2)
651
        next_s    <= 76;
652
        l_reg_a   <= reg(8, 5);
653
        l_aa_load <= '1';
654
 
655
      WHEN 76 =>                        -- Read reg a into A (3)
656
        next_s      <= 77;
657
        l_reg_input <= "10";
658
        l_reg_a     <= reg(9, 5);
659
        l_we        <= '1';
660
        l_op_sel    <= "0000";
661
 
662
      WHEN 77 =>                        -- Perform INC operation, write result
663
                                        -- into reg 5 (4)
664
        next_s    <= 78;
665
        l_reg_a   <= reg(9, 5);
666
        l_dr_load <= '1';
667
 
668
      WHEN 78 =>  -- Load reg a into data out register (5)
669
        next_s <= 79;
670
 
671
      WHEN 79 =>
672
        next_s   <= 80;
673
        l_dp_rst <= '0';
674
 
675
      WHEN 80 =>                        -- Reset cycle (1)
676
        next_s      <= 81;
677
        l_data_in   <= X"1000";
678
        l_reg_input <= "00";
679
        l_reg_a     <= reg(9, 5);
680
        l_we        <= '1';
681
 
682
      WHEN 81 =>                        -- Present X"1000" to register 9 (2)
683
        next_s    <= 82;
684
        l_reg_a   <= reg(9, 5);
685
        l_aa_load <= '1';
686
 
687
      WHEN 82 =>                        -- Read reg a into A (3)
688
        next_s      <= 83;
689
        l_reg_input <= "10";
690
        l_reg_a     <= reg(10, 5);
691
        l_we        <= '1';
692
        l_op_sel    <= "0001";
693
 
694
      WHEN 83 =>                        -- Perform DEC operation, write result
695
                                        -- into reg 10 (4)
696
        next_s    <= 84;
697
        l_reg_a   <= reg(10, 5);
698
        l_dr_load <= '1';
699
 
700
      WHEN 84 =>  -- Load reg a into data out register (5)
701
        next_s <= 85;
702
 
703
      WHEN 85 =>
704
        next_s   <= 86;
705
        l_dp_rst <= '0';
706
 
707
      WHEN 86 =>                        -- Reset cycle (1)
708
        next_s     <= 87;
709
        l_data_in  <= X"1000";
710
        l_pc_input <= "01";
711
        l_pc_load  <= '1';
712
 
713
      WHEN 87 =>                        -- Present X"1000" to the program
714
                                        -- counter (2)
715
        next_s     <= 88;
716
        l_pc_input <= "00";
717
        l_pc_load  <= '1';
718
 
719
      WHEN 88 =>                        -- Reload the program counter
720
        next_s <= 89;
721
 
722
      WHEN 89 =>
723
        next_s   <= 90;
724
        l_dp_rst <= '0';
725
 
726
      WHEN 90 =>                        -- Reset cycle (1)
727
        next_s     <= 91;
728
        l_data_in  <= X"2000";
729
        l_pc_input <= "01";
730
        l_pc_load  <= '1';
731
 
732
      WHEN 91 =>                        -- Present X"2000" to the program
733
                                        -- counter (2)
734
        next_s      <= 92;
735
        l_reg_input <= "01";
736
        l_reg_a     <= reg(11, 5);
737
        l_we        <= '1';
738
 
739
      WHEN 92 =>                        -- Store PC in register 11
740
        next_s    <= 93;
741
        l_reg_a   <= reg(11, 5);
742
        l_dr_load <= '1';
743
 
744
      WHEN 93 =>                        -- Store reg 11 into data register
745
        next_s <= 94;
746
 
747
      WHEN 94 =>
748
        next_s   <= 95;
749
        l_dp_rst <= '0';
750
 
751
      WHEN 95 =>
752
        next_s      <= 96;
753
        l_data_in   <= X"0000";
754
        l_reg_input <= "00";
755
        l_reg_a     <= reg(12, 5);
756
        l_we        <= '1';
757
 
758
      WHEN 96 =>
759
        next_s  <= 97;
760
        l_reg_a <= reg(12, 5);
761
 
762
      WHEN 97 =>
763
        next_s <= 98;
764
 
765
      WHEN 98 =>
766
        next_s <= 99;
767
 
768
      WHEN 99 =>
769
        next_s <= 100;
770
        l_dp_rst <= '0';
771
 
772
      WHEN 100 =>
773
        next_s      <= 101;
774
        l_data_in   <= X"0001";
775
        l_reg_input <= "00";
776
        l_reg_a     <= reg(13, 5);
777
        l_we        <= '1';
778
 
779
      WHEN 101 =>
780
        next_s  <= 102;
781
        l_reg_a <= reg(13, 5);
782
 
783
      WHEN 102 =>
784
        next_s <= 103;
785
 
786
      WHEN 103 =>
787
        next_s <= 104;
788
 
789
      WHEN 104 =>
790
        next_s <= 104;
791
 
792
    END CASE;
793
 
794
  END PROCESS next_state_logic;
795
 
796
  -- purpose: This process checks the values of the data path for every state
797
  -- type   : sequential
798
  -- inputs : clock, reset
799
  -- outputs: 
800
  assert_tests : PROCESS (clock)
801
  BEGIN  -- PROCESS assert_tests
802
    IF rising_edge(clock) THEN          -- rising clock edge
803
      CASE current IS
804
        WHEN 1 =>
805
          ASSERT data_out = X"0000" REPORT "data out register not zero" SEVERITY failure;
806
          ASSERT addr_out = "111" & X"FF" & X"E" REPORT "address out register not zero" SEVERITY failure;
807
        WHEN 4 =>
808
          ASSERT data_out = X"F0F0" REPORT "data out register not F0F0" SEVERITY failure;
809
          ASSERT addr_out = "111" & X"0F" & X"0" REPORT "address out register not 70F0" SEVERITY failure;
810
        WHEN 7 =>
811
          ASSERT addr_out = "010" & X"1B" & X"2" REPORT "address out register not 21B2" SEVERITY failure;
812
        WHEN 11 =>
813
          ASSERT addr_out = "101" & X"EA" & X"D" REPORT "address out register not 5EAD" SEVERITY failure;
814
        WHEN 15 =>
815
          ASSERT data_out = X"BEEF" REPORT "data out register not BEEF" SEVERITY failure;
816
        WHEN 20 =>
817
          ASSERT data_out = X"FEED" REPORT "data out register not FEED" SEVERITY failure;
818
        WHEN 27 =>
819
          ASSERT data_out = X"0A84" REPORT "data out register not 0A84" SEVERITY failure;
820
        WHEN 34 =>
821
          ASSERT data_out = X"1032" REPORT "data out register not 1032" SEVERITY failure;
822
        WHEN 41 =>
823
          ASSERT data_out = X"0F00" REPORT "data out register not 0F00" SEVERITY failure;
824
        WHEN 48 =>
825
          ASSERT data_out = X"0111" REPORT "data out register not 0111" SEVERITY failure;
826
        WHEN 55 =>
827
          ASSERT data_out = X"0110" REPORT "XOR: data out register not 0110" SEVERITY failure;
828
        WHEN 61 =>
829
          ASSERT data_out = X"F5F3" REPORT "NOT: data out register not F5F3" SEVERITY failure;
830
        WHEN 67 =>
831
          ASSERT data_out = X"E620" REPORT "SLL: data out register not E620" SEVERITY failure;
832
        WHEN 73 =>
833
          ASSERT data_out = X"6213" REPORT "SLR: data out register not 6213" SEVERITY failure;
834
        WHEN 79 =>
835
          ASSERT data_out = X"0020" REPORT "INC: data out register not 0020" SEVERITY failure;
836
        WHEN 85 =>
837
          ASSERT data_out = X"0FFF" REPORT "DEC: data out register not 0FFF" SEVERITY failure;
838
        WHEN 89 =>
839
          ASSERT addr_out = "001000000000001" REPORT "PC-I: address out not 1001" SEVERITY failure;
840
        WHEN 94 =>
841
          ASSERT data_out = X"2000" REPORT "PC-II: data out register not 2000" SEVERITY failure;
842
        WHEN 98 =>
843
          ASSERT zero = '1' REPORT "TEST-I: zero result not correct" SEVERITY failure;
844
        WHEN OTHERS => NULL;
845
      END CASE;
846
    END IF;
847
  END PROCESS assert_tests;
848
END;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.