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

Subversion Repositories motion_estimation_processor

[/] [motion_estimation_processor/] [trunk/] [src_me/] [tb_me_top.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 eejlny
----------------------------------------------------------------------------
2
--  This file is a part of the LM VHDL IP LIBRARY
3
--  Copyright (C) 2009 Jose Nunez-Yanez
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  See the file COPYING for the full details of the license.
11
--
12
--  The license allows free and unlimited use of the library and tools for research and education purposes. 
13
--  The full LM core supports many more advanced motion estimation features and it is available under a 
14
--  low-cost commercial license. See the readme file to learn more or contact us at 
15
--  eejlny@byacom.co.uk or www.byacom.co.uk
16
--------------------------------------
17
--  entity       = tb_me_top            --
18
--  version      = 1.0              --
19
--  last update  = 20/07/06         --
20
--  author       = Jose Nunez       --
21
--------------------------------------
22
 
23
 
24
-- test bench me top of the hierarchy
25
 
26
library ieee;
27
use ieee.std_logic_1164.all;
28
use ieee.std_logic_misc.all;
29
use ieee.std_logic_textio.all;
30
use IEEE.std_logic_unsigned."+";
31
use IEEE.std_logic_unsigned."<";
32
use IEEE.std_logic_unsigned.">";
33
use IEEE.std_logic_unsigned."=";
34
use std.textio.all;
35
 
36
 
37
entity tb_me_top is
38
end tb_me_top;
39
 
40
architecture tb of tb_me_top is
41
 
42
 
43
component me_top
44
 port ( clk : in std_logic;
45
        clear : in std_logic;
46
        reset : in std_logic;
47
          register_file_address : in std_logic_vector(4 downto 0); --32
48
        register_file_write : in std_logic;
49
          register_file_data_in : in std_logic_vector(31 downto 0);
50
          register_file_data_out : out std_logic_vector(31 downto 0);
51
   done_interrupt : out std_logic; -- high when macroblock processing has completed    
52
 best_sad_debug : out std_logic_vector(15 downto 0); --debugging ports
53
             best_mv_debug : out std_logic_vector(15 downto 0);
54
             dma_rm_re_debug : in std_logic; --set to one to enable reading the reference area
55
             dma_rm_debug : out std_logic_vector(63 downto 0); -- reference area data out
56
          dma_address : in std_logic_vector(10 downto 0); -- next reference memory address or current macroblock address
57
     dma_data_in : in std_logic_vector(63 downto 0); -- pixel in from reference memory
58
     dma_rm_we : in std_logic;
59
          dma_cm_we : in std_logic;
60
   dma_pom_we : in std_logic; -- enable writing to point memory
61
           dma_prm_we : in std_logic;  -- enable writing to program memory
62
          dma_residue_out : out std_logic_vector(63 downto 0); -- get residue from winner mv
63
          dma_re_re : in std_logic -- enable reading residue
64
      );
65
end component;
66
 
67
 
68
component reference_data0
69
    port(
70
      clk : in std_logic;
71
      reset : in std_logic;
72
      clear : in std_logic;
73
      addr : in std_logic_vector (9 downto 0);
74
      data : out std_logic_vector (63 downto 0)
75
      );
76
end component;
77
 
78
 
79
component reference_data1
80
    port(
81
      clk : in std_logic;
82
      reset : in std_logic;
83
      clear : in std_logic;
84
      addr : in std_logic_vector (9 downto 0);
85
      data : out std_logic_vector (63 downto 0)
86
      );
87
end component;
88
 
89
component reference_data2
90
    port(
91
      clk : in std_logic;
92
      reset : in std_logic;
93
      clear : in std_logic;
94
      addr : in std_logic_vector (9 downto 0);
95
      data : out std_logic_vector (63 downto 0)
96
      );
97
end component;
98
 
99
 
100
component macroblock_data0
101
    port(
102
      clk : in std_logic;
103
      reset : in std_logic;
104
      clear : in std_logic;
105
      addr : in std_logic_vector (4 downto 0);
106
      data : out std_logic_vector (63 downto 0)
107
      );
108
end component;
109
 
110
component macroblock_data1
111
    port(
112
      clk : in std_logic;
113
      reset : in std_logic;
114
      clear : in std_logic;
115
      addr : in std_logic_vector (4 downto 0);
116
      data : out std_logic_vector (63 downto 0)
117
      );
118
end component;
119
 
120
component macroblock_data2
121
    port(
122
      clk : in std_logic;
123
      reset : in std_logic;
124
      clear : in std_logic;
125
      addr : in std_logic_vector (4 downto 0);
126
      data : out std_logic_vector (63 downto 0)
127
      );
128
end component;
129
 
130
component macroblock_data3
131
    port(
132
      clk : in std_logic;
133
      reset : in std_logic;
134
      clear : in std_logic;
135
      addr : in std_logic_vector (4 downto 0);
136
      data : out std_logic_vector (63 downto 0)
137
      );
138
end component;
139
 
140
component macroblock_data4
141
    port(
142
      clk : in std_logic;
143
      reset : in std_logic;
144
      clear : in std_logic;
145
      addr : in std_logic_vector (4 downto 0);
146
      data : out std_logic_vector (63 downto 0)
147
      );
148
end component;
149
 
150
component macroblock_data5
151
    port(
152
      clk : in std_logic;
153
      reset : in std_logic;
154
      clear : in std_logic;
155
      addr : in std_logic_vector (4 downto 0);
156
      data : out std_logic_vector (63 downto 0)
157
      );
158
end component;
159
 
160
component macroblock_data6
161
    port(
162
      clk : in std_logic;
163
      reset : in std_logic;
164
      clear : in std_logic;
165
      addr : in std_logic_vector (4 downto 0);
166
      data : out std_logic_vector (63 downto 0)
167
      );
168
end component;
169
 
170
component macroblock_data7
171
    port(
172
      clk : in std_logic;
173
      reset : in std_logic;
174
      clear : in std_logic;
175
      addr : in std_logic_vector (4 downto 0);
176
      data : out std_logic_vector (63 downto 0)
177
      );
178
end component;
179
 
180
 
181
--********************************************************************
182
procedure print_error(expected_data: std_logic_vector(31 downto 0);received_data: std_logic_vector(31 downto 0))  is
183
  variable tranx : line;
184
 -- variable l : line;
185
--********************************************************************  
186
begin
187
 
188
   --print to output screen
189
   write(tranx, now, justified=>right,field =>10, unit=> ns );
190
   write(tranx, string'(" Error in MV/SAD  Expected: "));
191
   hwrite(tranx,expected_data);
192
   write(tranx, string'("   Received: "));
193
   hwrite(tranx,received_data);
194
   writeline(output,tranx);
195
end print_error;
196
 
197
--********************************************************************
198
procedure print_ok(expected_data: std_logic_vector(31 downto 0);received_data: std_logic_vector(31 downto 0))  is
199
  variable tranx : line;
200
 -- variable l : line;
201
--********************************************************************  
202
begin
203
 
204
   --print to output screen
205
   write(tranx, now, justified=>right,field =>10, unit=> ns );
206
   write(tranx, string'(" MV/SAD OK  Expected: "));
207
   hwrite(tranx,expected_data);
208
   write(tranx, string'("   Received: "));
209
   hwrite(tranx,received_data);
210
   writeline(output,tranx);
211
end print_ok;
212
 
213
 
214
 
215
--  set up constants for test vector application & monitoring
216
 
217
constant clock_period: time := 100 ns;
218
constant half_period : time := clock_period / 2;
219
constant strobe_time : time := 0.9 * half_period;
220
 
221
 
222
signal clk,clear,reset,register_file_write,zero,dma_pom_we,dma_prm_we  : std_logic;
223
signal register_file_address : std_logic_vector(4 downto 0);
224
signal register_file_data_in,register_file_data_out : std_logic_vector(31 downto 0);
225
signal dma_data_in : std_logic_vector(63 downto 0);
226
signal dut_address,current_dma_address : std_logic_vector(10 downto 0);
227
signal current_external_address : std_logic_vector(9 downto 0);
228
signal macroblock_data_out1,macroblock_data_out2,macroblock_data_out3,macroblock_data_out4,macroblock_data_out5,macroblock_data_out6,macroblock_data_out7,macroblock_data_out8,macroblock_data_out,reference_data_out,reference_data_out2,reference_data_out1,reference_data_out3,dma_residue_out,reference_data_out_delay : std_logic_vector(63 downto 0);
229
signal dma_loading, dma_rm_we, dma_cm_we,dma_re_re,done_interrupt: std_logic;
230
signal best_mv_debug,best_sad_debug : std_logic_vector(15 downto 0); --debugging ports
231
signal macroblock_count : integer;
232
 
233
type results_mem is array (0 to 7) of std_logic_vector(31 downto 0);
234
signal results : results_mem := (
235
x"FF000444",
236
x"FF000669",
237
x"0000095E",
238
x"02FC03BB",
239
x"FF000869",
240
x"00000C46",
241
x"FF000CEE",
242
x"00000000"
243
);
244
 
245
 
246
 
247
begin
248
 
249
zero <= '0';
250
 
251
reference_data1i : reference_data0
252
    port map(
253
      clk =>clk,
254
      reset =>reset,
255
      clear =>clear,
256
      addr =>current_external_address,
257
      data => reference_data_out1
258
      );
259
 
260
reference_data2i : reference_data1
261
     port map(
262
      clk =>clk,
263
      reset =>reset,
264
      clear =>clear,
265
      addr =>current_external_address,
266
      data => reference_data_out2
267
      );
268
 
269
reference_data3i : reference_data2
270
     port map(
271
      clk =>clk,
272
      reset =>reset,
273
      clear =>clear,
274
      addr =>current_external_address,
275
      data => reference_data_out3
276
      );
277
 
278
 
279
macroblock_data1i : macroblock_data0
280
    port map(
281
      clk =>clk,
282
      reset =>reset,
283
      clear =>clear,
284
      addr => current_dma_address(4 downto 0),
285
      data => macroblock_data_out1
286
      );
287
 
288
 
289
macroblock_data2i : macroblock_data1
290
    port map(
291
      clk =>clk,
292
      reset =>reset,
293
      clear =>clear,
294
      addr =>current_dma_address(4 downto 0),
295
      data => macroblock_data_out2
296
      );
297
 
298
macroblock_data3i : macroblock_data2
299
    port map(
300
      clk =>clk,
301
      reset =>reset,
302
      clear =>clear,
303
      addr =>current_dma_address(4 downto 0),
304
      data => macroblock_data_out3
305
      );
306
 
307
macroblock_data4i : macroblock_data3
308
    port map(
309
      clk =>clk,
310
      reset =>reset,
311
      clear =>clear,
312
      addr =>current_dma_address(4 downto 0),
313
      data => macroblock_data_out4
314
      );
315
 
316
macroblock_data5i : macroblock_data4
317
    port map(
318
      clk =>clk,
319
      reset =>reset,
320
      clear =>clear,
321
      addr =>current_dma_address(4 downto 0),
322
      data => macroblock_data_out5
323
      );
324
 
325
macroblock_data6i : macroblock_data5
326
    port map(
327
      clk =>clk,
328
      reset =>reset,
329
      clear =>clear,
330
      addr =>current_dma_address(4 downto 0),
331
      data => macroblock_data_out6
332
      );
333
 
334
macroblock_data7i : macroblock_data6
335
    port map(
336
      clk =>clk,
337
      reset =>reset,
338
      clear =>clear,
339
      addr =>current_dma_address(4 downto 0),
340
      data => macroblock_data_out7
341
      );
342
 
343
 
344
macroblock_data8i : macroblock_data7
345
    port map(
346
      clk =>clk,
347
      reset =>reset,
348
      clear =>clear,
349
      addr =>current_dma_address(4 downto 0),
350
      data => macroblock_data_out8
351
      );
352
 
353
 
354
macroblock_data_out <= macroblock_data_out1 when macroblock_count = 1 else
355
                             macroblock_data_out2 when macroblock_count = 2 else
356
                             macroblock_data_out3 when macroblock_count = 3 else
357
                         macroblock_data_out4 when macroblock_count = 4 else
358
                         macroblock_data_out5 when macroblock_count = 5 else
359
                         macroblock_data_out6 when macroblock_count = 6 else
360
                         macroblock_data_out7 when macroblock_count = 7 else
361
                         macroblock_data_out8 when macroblock_count = 8 else
362
                             (others => '0');
363
 
364
 
365
reference_data_out <= reference_data_out1 when macroblock_count = 0 else
366
                            reference_data_out2 when (macroblock_count > 0 and macroblock_count < 6) else
367
                            reference_data_out3;
368
 
369
reference_data_out_delay <= reference_data_out after 10 ns;
370
 
371
dma_data_in <= reference_data_out_delay when dma_rm_we = '1' else
372
                  (others => '0') when dma_prm_we = '1' else
373
                   macroblock_data_out;
374
 
375
DUT : me_top
376
 port map ( clk =>clk,
377
        clear =>clear,
378
        reset =>reset,
379
             register_file_address =>register_file_address, -- 32
380
        register_file_write =>register_file_write,
381
             register_file_data_in =>register_file_data_in,
382
             register_file_data_out => register_file_data_out,
383
   done_interrupt => done_interrupt,
384
     best_sad_debug => best_sad_debug,  --debugging ports
385
             best_mv_debug => best_mv_debug,
386
             dma_rm_re_debug =>zero, -- set to one to enable reading the reference area
387
             dma_rm_debug =>open, -- reference area data out
388
             dma_address => dut_address, -- next reference memory address
389
        dma_data_in => dma_data_in, -- pixel in from reference memory           
390
        dma_rm_we => dma_rm_we,
391
             dma_cm_we => dma_cm_we,
392
          dma_pom_we => dma_pom_we, -- enable writing to point memory
393
            dma_prm_we => dma_prm_we,  -- enable writing to program memory
394
            dma_residue_out => dma_residue_out,  -- get residue from winner mv
395
            dma_re_re => dma_re_re -- enable reading residue
396
     );
397
 
398
 
399
 
400
 
401
 
402
clock_process : process
403
 
404
begin
405
 
406
        clk <= '1';
407
 
408
        wait for half_period;
409
 
410
        clk <= '0';
411
 
412
        wait for half_period;
413
 
414
end process clock_process;
415
 
416
 
417
test_vectors : process
418
 
419
 
420
begin
421
 
422
   macroblock_count <= 0;
423
   current_dma_address <= (others => '0');
424
   current_external_address <= (others => '0');
425
   dma_rm_we  <= '0';
426
   dma_cm_we <= '0';
427
   dma_re_re <= '0';
428
   dma_prm_we <= '0';  -- enable writing to program memory
429
 
430
        wait for 10 ns;
431
 
432
      register_file_address <= (others => '0');
433
 
434
        register_file_write <= '0';
435
 
436
        register_file_data_in <= (others => '0');
437
 
438
        clear <= '0';
439
 
440
        reset <= '0';
441
 
442
        wait for clock_period;
443
        wait for 1 ns;
444
 
445
        clear <= '1';
446
 
447
        reset <= '1';
448
 
449
        wait for clock_period;
450
 
451
        clear <= '0';
452
 
453
        reset <= '0';
454
 
455
        wait for clock_period;
456
 
457
        current_dma_address <= "00000000001";
458
 
459
 
460
        wait for clock_period;
461
 
462
        --dma_prm_we <= '1'; -- modify the memory contents 
463
 
464
 
465
 
466
 
467
        wait for clock_period;
468
 
469
        dma_prm_we <= '0'; -- modify the memory contents 
470
 
471
        wait for clock_period;
472
 
473
 
474
 
475
        wait for clock_period;
476
 
477
        wait for clock_period;
478
 
479
        register_file_address <= "00001"; --write frame dimensions CIF
480
 
481
        register_file_write <= '1';
482
 
483
        register_file_data_in <= x"00001612"; --352x288 22x18 in Mbs
484
 
485
 
486
        wait for clock_period;
487
 
488
      wait for clock_period;
489
 
490
        register_file_address <= "00101"; --write motion vector candidate to reg 5
491
 
492
        register_file_write <= '1';
493
 
494
        register_file_data_in <= x"00000000";
495
        wait for clock_period;
496
 
497
        register_file_write <= '0';
498
 
499
        wait for clock_period;
500
 
501
 
502
 
503
 
504
 
505
        while (current_dma_address < 1279)  loop                                -- write reference data
506
 
507
   dma_cm_we  <= '0';
508
   if (current_dma_address(3 downto 0) > 1 and current_dma_address(3 downto 0) < 12) then
509
      current_external_address <= current_external_address + "0000000001";
510
      dma_rm_we <= '1';
511
   else
512
      dma_rm_we <= '0';
513
   end if;
514
   current_dma_address <= current_dma_address + "00000000001";
515
 
516
   wait for clock_period;
517
 
518
   end loop;
519
 
520
 
521
        current_external_address <= (others => '0');
522
        current_dma_address <= (others => '0');
523
        dma_rm_we <= '0';
524
        dma_cm_we  <= '0';
525
        macroblock_count <= 1;
526
 
527
 
528
        wait for clock_period;
529
 
530
        while (current_dma_address < 1279)  loop                                -- write reference data block 6
531
 
532
   dma_cm_we  <= '0';
533
   if (current_dma_address(3 downto 0) > 11 and current_dma_address(3 downto 0) < 14) then
534
       if (current_dma_address(3 downto 0) = 13) then
535
            current_external_address <= current_external_address + "0000001001"; -- one full row displacement 
536
      else
537
            current_external_address <= current_external_address + "0000000001";
538
      end if;
539
      dma_rm_we <= '1';
540
   else
541
      dma_rm_we <= '0';
542
   end if;
543
   current_dma_address <= current_dma_address + "00000000001";
544
 
545
   wait for clock_period;
546
 
547
   end loop;
548
 
549
 
550
        current_external_address <= (others => '0');
551
        current_dma_address <= (others => '0');
552
        dma_rm_we <= '0';
553
   dma_cm_we  <= '0';
554
 
555
   wait for clock_period;
556
 
557
        while (current_dma_address < x"020")  loop                              -- write macroblock data
558
 
559
   dma_rm_we <= '0';
560
   dma_cm_we  <= '1';
561
   current_dma_address <= current_dma_address + "0000000001";
562
 
563
   wait for clock_period;
564
 
565
   end loop;
566
 
567
   current_dma_address <= (others => '0');
568
        dma_rm_we <= '0';
569
   dma_cm_we  <= '0';
570
 
571
  wait for 15000 ns;
572
 
573
   wait for clock_period;
574
 
575
   ----------------------------------------------------------
576
   -- First macroblock processing
577
   ----------------------------------------------------------
578
 
579
 
580
        register_file_address <= "00000"; -- start processing
581
 
582
        register_file_write <= '1';
583
 
584
        register_file_data_in <= x"80000000"; -- for 16x16
585
 
586
 
587
 
588
        wait for clock_period;
589
 
590
   register_file_address <= (others => '0');
591
 
592
        register_file_write <= '0';
593
 
594
        register_file_data_in <= (others => '0');
595
 
596
        wait for clock_period;
597
 
598
   --write the next reference column in parallel with processing
599
 
600
   current_dma_address <= (others => '0');
601
   current_external_address <= "0000000010";
602
 
603
        wait for clock_period;
604
 
605
        while (current_dma_address < x"317")  loop                              -- write reference data 1 column out of 5
606
 
607
   current_external_address <= current_external_address + "0000000001";
608
   dma_rm_we <= '1';
609
   dma_cm_we  <= '0';
610
   current_dma_address <= current_dma_address + "0000000001"; -- address for second 8 bytes
611
 
612
   wait for clock_period;
613
 
614
   if (current_dma_address < x"317") then
615
 
616
      current_external_address <= current_external_address + "0000001001"; -- one full row displacement 
617
      current_dma_address <= current_dma_address + "0000001111"; -- one full row displacement 
618
 
619
   end if;
620
 
621
   wait for clock_period;
622
 
623
   end loop;
624
 
625
  --write the next macroblock in parallel with processing
626
 
627
  macroblock_count <= 2;
628
 
629
  current_dma_address <= (others => '0');
630
        dma_rm_we <= '0';
631
   dma_cm_we  <= '0';
632
 
633
    wait for clock_period;
634
 
635
        while (current_dma_address < x"020")  loop                              -- write new macroblock data
636
 
637
   dma_rm_we <= '0';
638
   dma_cm_we  <= '1';
639
   current_dma_address <= current_dma_address + "0000000001";
640
 
641
   wait for clock_period;
642
 
643
   end loop;
644
 
645
 
646
-------------------------------------------------------------------------------------------------------------------
647
while (done_interrupt /= '1') loop
648
 
649
        wait for clock_period;
650
end loop;
651
 
652
 
653
 
654
  ---  check results
655
 
656
 
657
        wait for clock_period;
658
 
659
        register_file_address <= "01110"; -- register 14
660
 
661
        register_file_write <= '0';
662
 
663
        wait for clock_period;
664
 
665
 
666
        --vregister_file_data_out := register_file_data_out;
667
 
668
        if (register_file_data_out = results(0)) then
669
                print_ok(results(0),register_file_data_out);
670
        else
671
                print_error(results(0),register_file_data_out);
672
        end if;
673
 
674
 
675
 
676
 
677
   ----------------------------------------------------------
678
   -- Second macroblock processing
679
   ----------------------------------------------------------
680
 
681
 
682
        wait for clock_period;
683
 
684
        register_file_address <= "00000"; -- start processing
685
 
686
        register_file_write <= '1';
687
 
688
        register_file_data_in <= x"80000100"; -- 
689
 
690
 
691
        wait for clock_period;
692
 
693
   register_file_address <= (others => '0');
694
 
695
        register_file_write <= '0';
696
 
697
        register_file_data_in <= (others => '0');
698
 
699
        wait for clock_period;
700
 
701
 
702
 
703
-------------------------------------------------------------------------------------------------------------------
704
   -- macroblock 3
705
   --write the next reference column in parallel with processing
706
 
707
   current_dma_address <= (others => '0');
708
   current_external_address <= "0000000100";
709
 
710
        wait for clock_period;
711
 
712
        while (current_dma_address < x"317")  loop                              -- write reference data 1 column out of 5
713
 
714
   current_external_address <= current_external_address + "0000000001";
715
   dma_rm_we <= '1';
716
   dma_cm_we  <= '0';
717
   current_dma_address <= current_dma_address + "0000000001"; -- address for second 8 bytes
718
 
719
   wait for clock_period;
720
 
721
   if (current_dma_address < x"317") then
722
 
723
      current_external_address <= current_external_address + "0000001001"; -- one full row displacement 
724
      current_dma_address <= current_dma_address + "0000001111"; -- one full row displacement 
725
 
726
   end if;
727
 
728
   wait for clock_period;
729
 
730
   end loop;
731
 
732
  --write the next macroblock in parallel with processing
733
 
734
  macroblock_count <= 3;
735
 
736
  current_dma_address <= (others => '0');
737
        dma_rm_we <= '0';
738
   dma_cm_we  <= '0';
739
 
740
    wait for clock_period;
741
 
742
        while (current_dma_address < x"020")  loop                              -- write new macroblock data
743
 
744
   dma_rm_we <= '0';
745
   dma_cm_we  <= '1';
746
   current_dma_address <= current_dma_address + "0000000001";
747
 
748
   wait for clock_period;
749
 
750
   end loop;
751
 
752
      current_dma_address <= (others => '0');
753
        dma_rm_we <= '0';
754
   dma_cm_we  <= '0';
755
 
756
 
757
 
758
-------------------------------------------------------------------------------------------------------------------
759
 
760
 
761
-------------------------------------------------------------------------------------------------------------------
762
while (done_interrupt /= '1') loop
763
 
764
        wait for clock_period;
765
end loop;
766
 
767
 
768
        wait for clock_period;
769
 
770
 ---  check results
771
 
772
 
773
        wait for clock_period;
774
 
775
        register_file_address <= "01110"; -- register 14
776
 
777
        register_file_write <= '0';
778
 
779
        wait for clock_period;
780
 
781
 
782
        --vregister_file_data_out := register_file_data_out;
783
 
784
        if (register_file_data_out = results(1)) then
785
                print_ok(results(1),register_file_data_out);
786
        else
787
                print_error(results(1),register_file_data_out);
788
        end if;
789
 
790
        wait for clock_period;
791
 
792
        register_file_address <= "00000"; -- start processing
793
 
794
        register_file_write <= '1';
795
 
796
        register_file_data_in <= x"80000200";
797
 
798
        wait for clock_period;
799
 
800
   register_file_address <= (others => '0');
801
 
802
        register_file_write <= '0';
803
 
804
        register_file_data_in <= (others => '0');
805
 
806
        wait for clock_period;
807
 
808
 
809
 
810
-------------------------------------------------------------------------------------------------------------------
811
   -- macroblock 4
812
   --write the next reference column in parallel with processing
813
 
814
   current_dma_address <= (others => '0');
815
   current_external_address <= "0000000110";
816
 
817
        wait for clock_period;
818
 
819
        while (current_dma_address < x"317")  loop                              -- write reference data 1 column out of 5
820
 
821
   current_external_address <= current_external_address + "0000000001";
822
   dma_rm_we <= '1';
823
   dma_cm_we  <= '0';
824
   current_dma_address <= current_dma_address + "0000000001"; -- address for second 8 bytes
825
 
826
   wait for clock_period;
827
 
828
   if (current_dma_address < x"317") then
829
 
830
      current_external_address <= current_external_address + "0000001001"; -- one full row displacement 
831
      current_dma_address <= current_dma_address + "0000001111"; -- one full row displacement 
832
 
833
   end if;
834
 
835
   wait for clock_period;
836
 
837
   end loop;
838
 
839
  --write the next macroblock in parallel with processing
840
 
841
  macroblock_count <= 4;
842
 
843
  current_dma_address <= (others => '0');
844
        dma_rm_we <= '0';
845
   dma_cm_we  <= '0';
846
 
847
    wait for clock_period;
848
 
849
        while (current_dma_address < x"020")  loop                              -- write new macroblock data
850
 
851
   dma_rm_we <= '0';
852
   dma_cm_we  <= '1';
853
   current_dma_address <= current_dma_address + "0000000001";
854
 
855
   wait for clock_period;
856
 
857
   end loop;
858
 
859
      current_dma_address <= (others => '0');
860
        dma_rm_we <= '0';
861
   dma_cm_we  <= '0';
862
 
863
 
864
 
865
-------------------------------------------------------------------------------------------------------------------
866
 
867
-------------------------------------------------------------------------------------------------------------------
868
while (done_interrupt /= '1') loop
869
 
870
        wait for clock_period;
871
end loop;
872
 
873
 ---  check results
874
 
875
 
876
        wait for clock_period;
877
 
878
        register_file_address <= "01110"; -- register 14
879
 
880
        register_file_write <= '0';
881
 
882
        wait for clock_period;
883
 
884
 
885
        --vregister_file_data_out := register_file_data_out;
886
 
887
        if (register_file_data_out = results(2)) then
888
                print_ok(results(2),register_file_data_out);
889
        else
890
                print_error(results(2),register_file_data_out);
891
        end if;
892
 
893
        wait for clock_period;
894
 
895
 
896
        register_file_address <= "00101"; -- mv candidate
897
 
898
        register_file_write <= '1';
899
 
900
        register_file_data_in <= x"00000000";
901
 
902
        wait for clock_period;
903
 
904
        wait for clock_period;
905
 
906
        register_file_address <= "00000"; -- start processing
907
 
908
        register_file_write <= '1';
909
 
910
        register_file_data_in <= x"80000300";
911
 
912
        wait for clock_period;
913
 
914
   register_file_address <= (others => '0');
915
 
916
        register_file_write <= '0';
917
 
918
        register_file_data_in <= (others => '0');
919
 
920
        wait for clock_period;
921
 
922
 
923
 
924
-------------------------------------------------------------------------------------------------------------------
925
   -- macroblock 5
926
   --write the next reference column in parallel with processing
927
 
928
   current_dma_address <= (others => '0');
929
   current_external_address <= "0000001000";
930
 
931
        wait for clock_period;
932
 
933
        while (current_dma_address < x"317")  loop                              -- write reference data 1 column out of 5
934
 
935
   current_external_address <= current_external_address + "0000000001";
936
   dma_rm_we <= '1';
937
   dma_cm_we  <= '0';
938
   current_dma_address <= current_dma_address + "0000000001"; -- address for second 8 bytes
939
 
940
   wait for clock_period;
941
 
942
   if (current_dma_address < x"317") then
943
 
944
      current_external_address <= current_external_address + "0000001001"; -- one full row displacement 
945
      current_dma_address <= current_dma_address + "0000001111"; -- one full row displacement 
946
 
947
   end if;
948
 
949
   wait for clock_period;
950
 
951
   end loop;
952
 
953
  --write the next macroblock in parallel with processing
954
 
955
  macroblock_count <= 5;
956
 
957
  current_dma_address <= (others => '0');
958
        dma_rm_we <= '0';
959
   dma_cm_we  <= '0';
960
 
961
    wait for clock_period;
962
 
963
        while (current_dma_address < x"020")  loop                              -- write new macroblock data
964
 
965
   dma_rm_we <= '0';
966
   dma_cm_we  <= '1';
967
   current_dma_address <= current_dma_address + "0000000001";
968
 
969
   wait for clock_period;
970
 
971
   end loop;
972
 
973
      current_dma_address <= (others => '0');
974
        dma_rm_we <= '0';
975
   dma_cm_we  <= '0';
976
 
977
 
978
 
979
-------------------------------------------------------------------------------------------------------------------
980
 
981
-------------------------------------------------------------------------------------------------------------------
982
while (done_interrupt /= '1') loop
983
 
984
        wait for clock_period;
985
end loop;
986
 
987
 
988
 ---  check results
989
 
990
 
991
        wait for clock_period;
992
 
993
        register_file_address <= "01110"; -- register 14
994
 
995
        register_file_write <= '0';
996
 
997
        wait for clock_period;
998
 
999
 
1000
        --vregister_file_data_out := register_file_data_out;
1001
 
1002
        if (register_file_data_out = results(3)) then
1003
                print_ok( results(3),register_file_data_out);
1004
        else
1005
                print_error(results(3),register_file_data_out);
1006
        end if;
1007
 
1008
        wait for clock_period;
1009
 
1010
        register_file_address <= "00101"; -- mv candidate
1011
 
1012
        register_file_write <= '1';
1013
 
1014
        register_file_data_in <= x"00000000";
1015
 
1016
        wait for clock_period;
1017
 
1018
        register_file_address <= "00000"; -- start processing
1019
 
1020
        register_file_write <= '1';
1021
 
1022
        register_file_data_in <= x"80000400";
1023
 
1024
        wait for clock_period;
1025
 
1026
   register_file_address <= (others => '0');
1027
 
1028
        register_file_write <= '0';
1029
 
1030
        register_file_data_in <= (others => '0');
1031
 
1032
        wait for clock_period;
1033
 
1034
 
1035
 
1036
-------------------------------------------------------------------------------------------------------------------
1037
   -- macroblock 6
1038
   --write the next reference column in parallel with processing
1039
 
1040
   current_dma_address <= (others => '0');
1041
   current_external_address <= "0000000000";
1042
 
1043
        wait for clock_period;
1044
 
1045
        while (current_dma_address < x"317")  loop                              -- write reference data 1 column out of 5
1046
 
1047
   current_external_address <= current_external_address + "0000000001";
1048
   dma_rm_we <= '1';
1049
   dma_cm_we  <= '0';
1050
   current_dma_address <= current_dma_address + "0000000001"; -- address for second 8 bytes
1051
 
1052
   wait for clock_period;
1053
 
1054
   if (current_dma_address < x"317") then
1055
 
1056
      current_external_address <= current_external_address + "0000001001"; -- one full row displacement 
1057
      current_dma_address <= current_dma_address + "0000001111"; -- one full row displacement 
1058
 
1059
   end if;
1060
 
1061
   wait for clock_period;
1062
 
1063
   end loop;
1064
 
1065
  --write the next macroblock in parallel with processing
1066
 
1067
  macroblock_count <= 6;
1068
 
1069
  current_dma_address <= (others => '0');
1070
        dma_rm_we <= '0';
1071
   dma_cm_we  <= '0';
1072
 
1073
    wait for clock_period;
1074
 
1075
        while (current_dma_address < x"020")  loop                              -- write new macroblock data
1076
 
1077
   dma_rm_we <= '0';
1078
   dma_cm_we  <= '1';
1079
   current_dma_address <= current_dma_address + "0000000001";
1080
 
1081
   wait for clock_period;
1082
 
1083
   end loop;
1084
 
1085
      current_dma_address <= (others => '0');
1086
        dma_rm_we <= '0';
1087
   dma_cm_we  <= '0';
1088
 
1089
 
1090
 
1091
-------------------------------------------------------------------------------------------------------------------
1092
 
1093
-------------------------------------------------------------------------------------------------------------------
1094
while (done_interrupt /= '1') loop
1095
 
1096
        wait for clock_period;
1097
end loop;
1098
 
1099
 ---  check results
1100
 
1101
 
1102
        wait for clock_period;
1103
 
1104
        register_file_address <= "01110"; -- register 14
1105
 
1106
        register_file_write <= '0';
1107
 
1108
        wait for clock_period;
1109
 
1110
 
1111
        --vregister_file_data_out := register_file_data_out;
1112
 
1113
        if (register_file_data_out = results(4)) then
1114
                print_ok(results(4),register_file_data_out);
1115
        else
1116
                print_error(results(4),register_file_data_out);
1117
        end if;
1118
 
1119
        wait for clock_period;
1120
 
1121
        register_file_address <= "00101"; -- mv candidate
1122
 
1123
        register_file_write <= '1';
1124
 
1125
        register_file_data_in <= x"00000000";
1126
 
1127
        wait for clock_period;
1128
 
1129
 
1130
        register_file_address <= "00000"; -- start processing
1131
 
1132
        register_file_write <= '1';
1133
 
1134
        register_file_data_in <= x"80000302";
1135
 
1136
        wait for clock_period;
1137
 
1138
   register_file_address <= (others => '0');
1139
 
1140
        register_file_write <= '0';
1141
 
1142
        register_file_data_in <= (others => '0');
1143
 
1144
        wait for clock_period;
1145
 
1146
 
1147
 
1148
-------------------------------------------------------------------------------------------------------------------
1149
   -- macroblock 7
1150
   --write the next reference column in parallel with processing
1151
 
1152
   current_dma_address <= (others => '0');
1153
   current_external_address <= "0000000010";
1154
 
1155
        wait for clock_period;
1156
 
1157
        while (current_dma_address < x"317")  loop                              -- write reference data 1 column out of 5
1158
 
1159
   current_external_address <= current_external_address + "0000000001";
1160
   dma_rm_we <= '1';
1161
   dma_cm_we  <= '0';
1162
   current_dma_address <= current_dma_address + "0000000001"; -- address for second 8 bytes
1163
 
1164
   wait for clock_period;
1165
 
1166
   if (current_dma_address < x"317") then
1167
 
1168
      current_external_address <= current_external_address + "0000001001"; -- one full row displacement 
1169
      current_dma_address <= current_dma_address + "0000001111"; -- one full row displacement 
1170
 
1171
   end if;
1172
 
1173
   wait for clock_period;
1174
 
1175
   end loop;
1176
 
1177
  --write the next macroblock in parallel with processing
1178
 
1179
  macroblock_count <= 7;
1180
 
1181
  current_dma_address <= (others => '0');
1182
        dma_rm_we <= '0';
1183
   dma_cm_we  <= '0';
1184
 
1185
    wait for clock_period;
1186
 
1187
        while (current_dma_address < x"020")  loop                              -- write new macroblock data
1188
 
1189
   dma_rm_we <= '0';
1190
   dma_cm_we  <= '1';
1191
   current_dma_address <= current_dma_address + "0000000001";
1192
 
1193
   wait for clock_period;
1194
 
1195
   end loop;
1196
 
1197
      current_dma_address <= (others => '0');
1198
        dma_rm_we <= '0';
1199
   dma_cm_we  <= '0';
1200
 
1201
 
1202
 
1203
-------------------------------------------------------------------------------------------------------------------
1204
 
1205
-------------------------------------------------------------------------------------------------------------------
1206
-------------------------------------------------------------------------------------------------------------------
1207
 
1208
-------------------------------------------------------------------------------------------------------------------
1209
while (done_interrupt /= '1') loop
1210
 
1211
        wait for clock_period;
1212
end loop;
1213
 
1214
 
1215
 ---  check results
1216
 
1217
 
1218
        wait for clock_period;
1219
 
1220
        register_file_address <= "01110"; -- register 14
1221
 
1222
        register_file_write <= '0';
1223
 
1224
        wait for clock_period;
1225
 
1226
 
1227
        --vregister_file_data_out := register_file_data_out;
1228
 
1229
        if (register_file_data_out = results(5)) then
1230
                print_ok(results(5),register_file_data_out);
1231
        else
1232
                print_error(results(5),register_file_data_out);
1233
        end if;
1234
 
1235
        wait for clock_period;
1236
 
1237
        register_file_address <= "00101"; -- mv candidate
1238
 
1239
        register_file_write <= '1';
1240
 
1241
        register_file_data_in <= x"00000000";
1242
 
1243
        wait for clock_period;
1244
 
1245
        wait for clock_period;
1246
 
1247
        register_file_address <= "00000"; -- start processing
1248
 
1249
        register_file_write <= '1';
1250
 
1251
        register_file_data_in <= x"80000302";
1252
 
1253
        wait for clock_period;
1254
 
1255
   register_file_address <= (others => '0');
1256
 
1257
        register_file_write <= '0';
1258
 
1259
        register_file_data_in <= (others => '0');
1260
 
1261
        wait for clock_period;
1262
 
1263
 
1264
 
1265
-------------------------------------------------------------------------------------------------------------------
1266
   -- macroblock 8
1267
   --write the next reference column in parallel with processing
1268
 
1269
   current_dma_address <= (others => '0');
1270
   current_external_address <= "0000001000";
1271
 
1272
        wait for clock_period;
1273
 
1274
        while (current_dma_address < x"317")  loop                              -- write reference data 1 column out of 5
1275
 
1276
   current_external_address <= current_external_address + "0000000001";
1277
   dma_rm_we <= '1';
1278
   dma_cm_we  <= '0';
1279
   current_dma_address <= current_dma_address + "0000000001"; -- address for second 8 bytes
1280
 
1281
   wait for clock_period;
1282
 
1283
   if (current_dma_address < x"317") then
1284
 
1285
      current_external_address <= current_external_address + "0000001001"; -- one full row displacement 
1286
      current_dma_address <= current_dma_address + "0000001111"; -- one full row displacement 
1287
 
1288
   end if;
1289
 
1290
   wait for clock_period;
1291
 
1292
   end loop;
1293
 
1294
  --write the next macroblock in parallel with processing
1295
 
1296
  macroblock_count <= 8;
1297
 
1298
  current_dma_address <= (others => '0');
1299
        dma_rm_we <= '0';
1300
   dma_cm_we  <= '0';
1301
 
1302
    wait for clock_period;
1303
 
1304
        while (current_dma_address < x"020")  loop                              -- write new macroblock data
1305
 
1306
   dma_rm_we <= '0';
1307
   dma_cm_we  <= '1';
1308
   current_dma_address <= current_dma_address + "0000000001";
1309
 
1310
   wait for clock_period;
1311
 
1312
   end loop;
1313
 
1314
      current_dma_address <= (others => '0');
1315
        dma_rm_we <= '0';
1316
   dma_cm_we  <= '0';
1317
 
1318
 
1319
 
1320
-------------------------------------------------------------------------------------------------------------------
1321
 
1322
-------------------------------------------------------------------------------------------------------------------
1323
 
1324
-------------------------------------------------------------------------------------------------------------------
1325
 
1326
-------------------------------------------------------------------------------------------------------------------
1327
while (done_interrupt /= '1') loop
1328
 
1329
        wait for clock_period;
1330
end loop;
1331
 
1332
 
1333
 ---  check results
1334
 
1335
 
1336
        wait for clock_period;
1337
 
1338
        register_file_address <= "01110"; -- register 14
1339
 
1340
        register_file_write <= '0';
1341
 
1342
        wait for clock_period;
1343
 
1344
 
1345
        --vregister_file_data_out := register_file_data_out;
1346
 
1347
        if (register_file_data_out = results(6)) then
1348
                print_ok(results(6),register_file_data_out);
1349
        else
1350
                print_error(results(6),register_file_data_out);
1351
        end if;
1352
 
1353
        wait for clock_period;
1354
 
1355
 
1356
        register_file_address <= "00101"; -- mv candidate
1357
 
1358
        register_file_write <= '1';
1359
 
1360
        register_file_data_in <= x"00000000";
1361
 
1362
        wait for clock_period;
1363
 
1364
        register_file_address <= "00000"; -- start processing
1365
 
1366
        register_file_write <= '1';
1367
 
1368
        register_file_data_in <= x"80000302";
1369
 
1370
        wait for clock_period;
1371
 
1372
   register_file_address <= (others => '0');
1373
 
1374
        register_file_write <= '0';
1375
 
1376
        register_file_data_in <= (others => '0');
1377
 
1378
        wait for clock_period;
1379
 
1380
while (done_interrupt /= '1') loop
1381
 
1382
        wait for clock_period;
1383
end loop;
1384
 
1385
 
1386
end process test_vectors;
1387
 
1388
 
1389
 
1390
regs : process(clk,clear)
1391
 
1392
begin
1393
 
1394
 if (clear = '1') then
1395
    dut_address <= (others => '0');
1396
 elsif rising_edge(clk) then
1397
                dut_address <= current_dma_address after 10 ns;
1398
 end if;
1399
 
1400
end process regs;
1401
 
1402
dma_pom_we <= '0'; -- enable writing to point memo
1403
 
1404
 
1405
 
1406
 
1407
end tb; --end of architecture
1408
 
1409
 
1410
 
1411
 
1412
 
1413
 
1414
 
1415
 
1416
 
1417
 
1418
 
1419
 
1420
 
1421
 

powered by: WebSVN 2.1.0

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