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

Subversion Repositories mdct

[/] [mdct/] [trunk/] [source/] [testbench/] [INPIMAGE.VHD] - Diff between revs 13 and 15

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 13 Rev 15
Line 27... Line 27...
  use STD.TEXTIO.all;
  use STD.TEXTIO.all;
 
 
library WORK;
library WORK;
  use WORK.MDCT_PKG.all;
  use WORK.MDCT_PKG.all;
  use WORK.MDCTTB_PKG.all;
  use WORK.MDCTTB_PKG.all;
 
  use WORK.RNG.all;
 
 
entity INPIMAGE is
entity INPIMAGE is
  port (
  port (
        clk               : in STD_LOGIC;
        clk               : in STD_LOGIC;
        ready             : in STD_LOGIC;
        ready             : in STD_LOGIC;
Line 52... Line 53...
 
 
  constant PERIOD             : TIME := 1 us /(CLK_FREQ_C);
  constant PERIOD             : TIME := 1 us /(CLK_FREQ_C);
 
 
  signal rst_s                : STD_LOGIC;
  signal rst_s                : STD_LOGIC;
  signal test_inp             : INTEGER;
  signal test_inp             : INTEGER;
 
  signal test_stim            : INTEGER;
  signal test_out             : INTEGER;
  signal test_out             : INTEGER;
  signal xcon_s               : INTEGER;
  signal xcon_s               : INTEGER;
  signal ycon_s               : INTEGER;
  signal ycon_s               : INTEGER;
  signal error_dct_matrix_s   : I_MATRIX_TYPE;
  signal error_dct_matrix_s   : I_MATRIX_TYPE;
  signal error_dcto1_matrix_s : I_MATRIX_TYPE;
  signal error_dcto1_matrix_s : I_MATRIX_TYPE;
Line 69... Line 71...
 --------------------------
 --------------------------
 INPIMAGE_PROC: process
 INPIMAGE_PROC: process
   variable i : INTEGER := 0;
   variable i : INTEGER := 0;
   variable j : INTEGER := 0;
   variable j : INTEGER := 0;
   variable INSERT_DELAYS : BOOLEAN := FALSE;
   variable INSERT_DELAYS : BOOLEAN := FALSE;
 
   variable unf:        Uniform  := InitUniform(7, 0.0, 2.0);
 
        variable rnd:   real     := 0.0;
 
        variable xi            : INTEGER := 0;
 
 
  -------------------------------------
  -------------------------------------
  -- wait for defined number of clock cycles
  -- wait for defined number of clock cycles
  -------------------------------------
  -------------------------------------
  procedure waitposedge(clocks : in INTEGER) is
  procedure waitposedge(clocks : in INTEGER) is
Line 157... Line 162...
            imageo  <= STD_LOGIC_VECTOR(
            imageo  <= STD_LOGIC_VECTOR(
                         TO_UNSIGNED(INTEGER(matrix(i,j)),IP_W));
                         TO_UNSIGNED(INTEGER(matrix(i,j)),IP_W));
            xcon_s <= x_blk_cnt*N+j;
            xcon_s <= x_blk_cnt*N+j;
            ycon_s <= y_blk_cnt*N+i;
            ycon_s <= y_blk_cnt*N+i;
            waitposedge;
            waitposedge;
            while(ready = '0') loop
 
              waitposedge;
 
            end loop;
 
            if INSERT_DELAYS = TRUE then
            if INSERT_DELAYS = TRUE then
              dv    <= '0';
              dv    <= '0';
              waitposedge(40);
              waitposedge(40);
            end if;
            end if;
          end loop;
          end loop;
Line 177... Line 179...
 
 
   ---------------------------
   ---------------------------
   -- process begin
   -- process begin
   ---------------------------
   ---------------------------
   begin
   begin
 
     test_stim <= 0;
     dv      <= '0';
     dv      <= '0';
     imageo  <= (others => '0');
     imageo  <= (others => '0');
     rst_s <= '1';
     rst_s <= '1';
     waitposedge(2);
     waitposedge(2);
     rst_s <= '0';
     rst_s <= '0';
 
 
     -------------------------
     -------------------------
     -- test 1
     -- test 1
     -------------------------
     -------------------------
 
     test_stim <= 1;
     for i in 0 to 7 loop
     for i in 0 to 7 loop
       for j in 0 to 7 loop
       for j in 0 to 7 loop
         dv      <= '1';
         dv      <= '1';
         imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data0(i,j)),IP_W));
         imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data0(i,j)),IP_W));
         waitposedge;
         waitposedge;
         while(ready = '0') loop
 
           waitposedge;
 
         end loop;
 
       end loop;
       end loop;
 
 
     end loop;
     end loop;
 
 
     dv <= '0';
     dv <= '0';
Line 205... Line 206...
     -------------------------
     -------------------------
 
 
     -------------------------
     -------------------------
     -- test 2
     -- test 2
     -------------------------
     -------------------------
 
     test_stim <= 2;
     for i in 0 to 7 loop
     for i in 0 to 7 loop
       for j in 0 to 7 loop
       for j in 0 to 7 loop
         dv      <= '1';
         dv      <= '1';
         imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data1(i,j)),IP_W));
         imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data1(i,j)),IP_W));
         waitposedge;
         waitposedge;
         while(ready = '0') loop
 
           waitposedge;
 
         end loop;
 
       end loop;
       end loop;
 
 
     end loop;
     end loop;
 
 
     dv <= '0';
     dv <= '0';
Line 224... Line 223...
     ------------------------
     ------------------------
 
 
     -------------------------
     -------------------------
     -- test 3
     -- test 3
     -------------------------
     -------------------------
 
     test_stim <= 3;
     for i in 0 to 7 loop
     for i in 0 to 7 loop
       for j in 0 to 7 loop
       for j in 0 to 7 loop
         dv      <= '1';
         dv      <= '1';
         imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data2(i,j)),IP_W));
         imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data2(i,j)),IP_W));
         waitposedge;
         waitposedge;
         while(ready = '0') loop
 
           waitposedge;
 
         end loop;
 
       end loop;
       end loop;
 
 
     end loop;
     end loop;
 
 
     dv <= '0';
     dv <= '0';
Line 243... Line 240...
     ------------------------
     ------------------------
 
 
     -------------------------
     -------------------------
     -- test 4
     -- test 4
     -------------------------
     -------------------------
 
     test_stim <= 4;
     for i in 0 to 7 loop
     for i in 0 to 7 loop
       for j in 0 to 7 loop
       for j in 0 to 7 loop
         dv      <= '1';
         dv      <= '1';
         imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data1(i,j)),IP_W));
         imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data0(i,j)),IP_W));
         waitposedge;
 
         while(ready = '0') loop
 
           waitposedge;
           waitposedge;
         end loop;
 
         dv      <= '0';
         dv      <= '0';
         waitposedge;
         waitposedge;
       end loop;
       end loop;
 
 
     end loop;
     end loop;
Line 264... Line 259...
     ------------------------
     ------------------------
 
 
     -------------------------
     -------------------------
     -- test 5
     -- test 5
     -------------------------
     -------------------------
 
     test_stim <= 5;
     for i in 0 to 7 loop
     for i in 0 to 7 loop
       for j in 0 to 7 loop
       for j in 0 to 7 loop
         dv      <= '1';
         dv      <= '1';
         imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data1(i,j)),IP_W));
         imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data1(i,j)),IP_W));
         waitposedge;
         waitposedge;
         while(ready = '0') loop
 
           waitposedge;
 
         end loop;
 
         dv      <= '0';
         dv      <= '0';
         waitposedge(25);
         waitposedge(25);
       end loop;
       end loop;
 
 
     end loop;
     end loop;
Line 283... Line 276...
     dv <= '0';
     dv <= '0';
     waitposedge;
     waitposedge;
     ------------------------
     ------------------------
 
 
     -------------------------
     -------------------------
 
     -- test 6-16
 
     -------------------------
 
 
 
     for x in 0 to 10 loop
 
       test_stim <= test_stim+1;
 
       for i in 0 to 7 loop
 
         for j in 0 to 7 loop
 
           dv      <= '1';
 
           if x rem 2 = 0 then
 
             imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data0(i,j)),IP_W));
 
           else
 
             imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data3(i,j)),IP_W));
 
           end if;
 
           waitposedge;
 
         end loop;
 
       end loop;
 
     end loop;
 
 
 
     dv <= '0';
 
     waitposedge;
 
     ------------------------
 
 
 
     -------------------------
 
     -- test 17-33
 
     -------------------------
 
 
 
     for x in 0 to 48 loop
 
       test_stim <= test_stim+1;
 
       if xi < 4 then
 
         xi := xi + 1;
 
       else
 
         xi := 0;
 
       end if;
 
       for i in 0 to 7 loop
 
         for j in 0 to 7 loop
 
           dv      <= '1';
 
 
 
           case xi is
 
             when 0 =>
 
               imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data1(i,j)),IP_W));
 
             when 1 =>
 
               imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data0(i,j)),IP_W));
 
             when 2 =>
 
               imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data3(i,j)),IP_W));
 
             when 3 =>
 
               imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data4(i,j)),IP_W));
 
             when others =>
 
               imageo  <= STD_LOGIC_VECTOR(TO_UNSIGNED(INTEGER(input_data0(i,j)),IP_W));
 
           end case;
 
           waitposedge;
 
           dv      <= '0';
 
           GenRnd(unf);
 
                rnd := unf.rnd;
 
                waitposedge(INTEGER(rnd));
 
         end loop;
 
       end loop;
 
     end loop;
 
 
 
     dv <= '0';
 
     waitposedge;
 
     ------------------------
 
 
 
     -------------------------
     -- test 6
     -- test 6
     -------------------------
     -------------------------
 
     if RUN_FULL_IMAGE = TRUE then
     read_image;
     read_image;
 
     end if;
 
 
     -------------------------
     -------------------------
     -- test 7
     -- test 7
     -------------------------
     -------------------------
     --INSERT_DELAYS := TRUE;
     --INSERT_DELAYS := TRUE;
Line 311... Line 369...
   variable error_matrix : I_MATRIX_TYPE;
   variable error_matrix : I_MATRIX_TYPE;
   variable error_cnt    : INTEGER := 0;
   variable error_cnt    : INTEGER := 0;
   variable raport_str   : STRING(1 to 255);
   variable raport_str   : STRING(1 to 255);
   variable ref_matrix   : I_MATRIX_TYPE;
   variable ref_matrix   : I_MATRIX_TYPE;
   variable dcto_matrix  : I_MATRIX_TYPE;
   variable dcto_matrix  : I_MATRIX_TYPE;
 
   variable xi           : INTEGER := 0;
  -------------------------------------
  -------------------------------------
  -- wait for defined number of clock cycles
  -- wait for defined number of clock cycles
  -------------------------------------
  -------------------------------------
  procedure waitposedge(clocks : in INTEGER) is
  procedure waitposedge(clocks : in INTEGER) is
  begin
  begin
Line 446... Line 505...
         end if;
         end if;
 
 
       end loop;
       end loop;
     end loop;
     end loop;
 
 
     waitposedge;
 
 
 
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
     -------------------------
     -------------------------
 
 
     -------------------------
     -------------------------
     -- test 2
     -- test 2
Line 475... Line 532...
         end if;
         end if;
 
 
       end loop;
       end loop;
     end loop;
     end loop;
 
 
     waitposedge;
 
 
 
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
     -------------------------
     -------------------------
 
 
     -------------------------
     -------------------------
     -- test 3
     -- test 3
Line 504... Line 559...
         end if;
         end if;
 
 
       end loop;
       end loop;
     end loop;
     end loop;
 
 
     waitposedge;
 
 
 
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
     -------------------------
     -------------------------
 
 
     -------------------------
     -------------------------
     -- test 4
     -- test 4
     -------------------------
     -------------------------
     test_inp <= 4;
     test_inp <= 4;
     -- compute reference coefficients
     -- compute reference coefficients
     ref_matrix := COMPUTE_REF_DCT1D(input_data1,TRUE);
     ref_matrix := COMPUTE_REF_DCT1D(input_data0,TRUE);
 
 
     for i in 0 to N-1 loop
     for i in 0 to N-1 loop
       j := 0;
       j := 0;
       while(true) loop
       while(true) loop
 
 
Line 533... Line 586...
         end if;
         end if;
 
 
       end loop;
       end loop;
     end loop;
     end loop;
 
 
     waitposedge;
 
 
 
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
     -------------------------
     -------------------------
 
 
     -------------------------
     -------------------------
     -- test 5
     -- test 5
Line 562... Line 613...
         end if;
         end if;
 
 
       end loop;
       end loop;
     end loop;
     end loop;
 
 
 
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
 
     -------------------------
 
 
 
     -------------------------
 
     -- test 6-16
 
     -------------------------
 
     for x in 0 to 10 loop
 
       test_inp <= test_inp + 1;
 
       -- compute reference coefficients
 
       if x rem 2 = 0 then
 
         ref_matrix := COMPUTE_REF_DCT1D(input_data0,TRUE);
 
       else
 
         ref_matrix := COMPUTE_REF_DCT1D(input_data3,TRUE);
 
       end if;
 
       for i in 0 to N-1 loop
 
         j := 0;
 
         while(true) loop
 
 
 
           waitposedge;
 
           if odv1 = '1' then
 
             dcto_matrix(j,i) := TO_INTEGER(SIGNED( dcto1 ));
 
             j := j + 1;
 
           end if;
 
 
 
           if j = N then
 
             exit;
 
           end if;
 
 
 
         end loop;
 
       end loop;
 
       CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
 
     end loop;
 
     -------------------------
 
 
 
     -------------------------
 
     -- test 17-33
 
     -------------------------
 
     for x in 0 to 48 loop
 
       test_inp <= test_inp + 1;
 
       -- compute reference coefficients
 
       if xi < 4 then
 
         xi := xi + 1;
 
       else
 
         xi := 0;
 
       end if;
 
       case xi is
 
         when 0 =>
 
           ref_matrix := COMPUTE_REF_DCT1D(input_data1,TRUE);
 
         when 1 =>
 
           ref_matrix := COMPUTE_REF_DCT1D(input_data0,TRUE);
 
         when 2 =>
 
           ref_matrix := COMPUTE_REF_DCT1D(input_data3,TRUE);
 
         when 3 =>
 
           ref_matrix := COMPUTE_REF_DCT1D(input_data4,TRUE);
 
         when others =>
 
           ref_matrix := COMPUTE_REF_DCT1D(input_data0,TRUE);
 
       end case;
 
 
 
       for i in 0 to N-1 loop
 
         j := 0;
 
         while(true) loop
 
 
     waitposedge;
     waitposedge;
 
           if odv1 = '1' then
 
             dcto_matrix(j,i) := TO_INTEGER(SIGNED( dcto1 ));
 
             j := j + 1;
 
           end if;
 
 
 
           if j = N then
 
             exit;
 
           end if;
 
 
 
         end loop;
 
       end loop;
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
     CMP_MATRIX(ref_matrix,dcto_matrix,MAX_ERROR_1D,error_matrix,error_cnt);
 
     end loop;
     -------------------------
     -------------------------
 
 
     -------------------------
     -------------------------
     -- test 6
     -- test 6
     -------------------------
     -------------------------
     test_inp <= 6;
     test_inp <= 6;
 
 
 
     if RUN_FULL_IMAGE = TRUE then
     read_image_for1dct(error_cnt);
     read_image_for1dct(error_cnt);
 
     end if;
     -------------------------
     -------------------------
 
 
     -------------------------
     -------------------------
     -- test 7
     -- test 7
     -------------------------
     -------------------------
Line 616... Line 742...
   variable ref_idct_matrix : I_MATRIX_TYPE;
   variable ref_idct_matrix : I_MATRIX_TYPE;
   variable idcto_matrix    : I_MATRIX_TYPE;
   variable idcto_matrix    : I_MATRIX_TYPE;
   variable dcto_matrix     : I_MATRIX_TYPE;
   variable dcto_matrix     : I_MATRIX_TYPE;
   variable tmp_matrix      : I_MATRIX_TYPE;
   variable tmp_matrix      : I_MATRIX_TYPE;
   variable psnr            : REAL;
   variable psnr            : REAL;
 
   variable xi              : INTEGER := 0;
  -------------------------------------
  -------------------------------------
  -- wait for defined number of clock cycles
  -- wait for defined number of clock cycles
  -------------------------------------
  -------------------------------------
  procedure waitposedge(clocks : in INTEGER) is
  procedure waitposedge(clocks : in INTEGER) is
  begin
  begin
Line 933... Line 1060...
 
 
     -------------------------
     -------------------------
     -- test 4
     -- test 4
     -------------------------
     -------------------------
     test_out <= 4;
     test_out <= 4;
     tmp_matrix := input_data1;
     tmp_matrix := input_data0;
     -- compute reference coefficients
     -- compute reference coefficients
     ref_matrix_1d := COMPUTE_REF_DCT1D(tmp_matrix,TRUE);
     ref_matrix_1d := COMPUTE_REF_DCT1D(tmp_matrix,TRUE);
     ref_matrix_2d := COMPUTE_REF_DCT1D(ref_matrix_1d,FALSE);
     ref_matrix_2d := COMPUTE_REF_DCT1D(ref_matrix_1d,FALSE);
 
 
     for i in 0 to N-1 loop
     for i in 0 to N-1 loop
Line 993... Line 1120...
 
 
     waitposedge;
     waitposedge;
 
 
     CMP_MATRIX(ref_matrix_2d,dcto_matrix,MAX_ERROR_2D,error_matrix,error_cnt);
     CMP_MATRIX(ref_matrix_2d,dcto_matrix,MAX_ERROR_2D,error_matrix,error_cnt);
     idcto_matrix := COMPUTE_REF_IDCT(dcto_matrix);
     idcto_matrix := COMPUTE_REF_IDCT(dcto_matrix);
     --error_idct_matrix := CMP_MATRIX(tmp_matrix,idcto_matrix,MAX_ERROR_2D);
 
     psnr := COMPUTE_PSNR(tmp_matrix,idcto_matrix);
     psnr := COMPUTE_PSNR(tmp_matrix,idcto_matrix);
     -------------------------
     -------------------------
 
 
     -------------------------
     -------------------------
 
     -- test 6-16
 
     -------------------------
 
     for x in 0 to 10 loop
 
       test_out <= test_out+1;
 
 
 
       if x rem 2 = 0 then
 
         tmp_matrix := input_data0;
 
       else
 
         tmp_matrix := input_data3;
 
       end if;
 
       -- compute reference coefficients
 
       ref_matrix_1d := COMPUTE_REF_DCT1D(tmp_matrix,TRUE);
 
       ref_matrix_2d := COMPUTE_REF_DCT1D(ref_matrix_1d,FALSE);
 
 
 
       for i in 0 to N-1 loop
 
         j := 0;
 
         while(true) loop
 
 
 
           waitposedge;
 
           if odv = '1' then
 
             dcto_matrix(j,i) := TO_INTEGER(SIGNED( dcto ));
 
             j := j + 1;
 
           end if;
 
 
 
           if j = N then
 
             exit;
 
           end if;
 
 
 
         end loop;
 
       end loop;
 
 
 
       CMP_MATRIX(ref_matrix_2d,dcto_matrix,MAX_ERROR_2D,error_matrix,error_cnt);
 
       idcto_matrix := COMPUTE_REF_IDCT(dcto_matrix);
 
       psnr := COMPUTE_PSNR(tmp_matrix,idcto_matrix);
 
     end loop;
 
     -------------------------
 
 
 
     -------------------------
 
     -- test 17-33
 
     -------------------------
 
     for x in 0 to 48 loop
 
       test_out <= test_out+1;
 
       if xi < 4 then
 
         xi := xi + 1;
 
       else
 
         xi := 0;
 
       end if;
 
       case xi is
 
         when 0 =>
 
           tmp_matrix := input_data1;
 
         when 1 =>
 
           tmp_matrix := input_data0;
 
         when 2 =>
 
           tmp_matrix := input_data3;
 
         when 3 =>
 
           tmp_matrix := input_data4;
 
         when others =>
 
           tmp_matrix := input_data0;
 
       end case;
 
       -- compute reference coefficients
 
       ref_matrix_1d := COMPUTE_REF_DCT1D(tmp_matrix,TRUE);
 
       ref_matrix_2d := COMPUTE_REF_DCT1D(ref_matrix_1d,FALSE);
 
 
 
       for i in 0 to N-1 loop
 
         j := 0;
 
         while(true) loop
 
 
 
           waitposedge;
 
           if odv = '1' then
 
             dcto_matrix(j,i) := TO_INTEGER(SIGNED( dcto ));
 
             j := j + 1;
 
           end if;
 
 
 
           if j = N then
 
             exit;
 
           end if;
 
 
 
         end loop;
 
       end loop;
 
 
 
       CMP_MATRIX(ref_matrix_2d,dcto_matrix,MAX_ERROR_2D,error_matrix,error_cnt);
 
       idcto_matrix := COMPUTE_REF_IDCT(dcto_matrix);
 
       psnr := COMPUTE_PSNR(tmp_matrix,idcto_matrix);
 
     end loop;
 
     -------------------------
 
 
 
     -------------------------
     -- test 6
     -- test 6
     -------------------------
     -------------------------
     test_out <= 6;
     test_out <= 6;
 
     if RUN_FULL_IMAGE = TRUE then
     read_image_for2dct(error_cnt);
     read_image_for2dct(error_cnt);
 
     end if;
     -------------------------
     -------------------------
 
 
     -------------------------
     -------------------------
     -- test 7
     -- test 7
     -------------------------
     -------------------------

powered by: WebSVN 2.1.0

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