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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.accelerator/] [dctqidct/] [1.0/] [hdl/] [matlab/] [idct_rom_coeff.m] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
%IDCT
2
%IDCT constant coefficient generator for odd and even terms.
3
%Timo Alho, timo.a.alho@tut.fi
4
%10.6.2004
5
 
6
coeff_width=15;
7
 
8
%all coefficients are scaled by 1/sqrt(2)
9
mult=2^(coeff_width-1) /sqrt(2);
10
 
11
 
12
N=8;
13
A=zeros(N, N);
14
j=[0:1:N-1];
15
A(1, :) = sqrt(1/N) * cos(0);
16
for i = 1:N-1
17
    A(i+1, :) = sqrt(2/N) * cos((2.*j+1)*i*pi/(2*N));
18
end
19
A=A'; %transpose DCT -> IDCT
20
 
21
Aodd=A(1:4, 1:2:8);
22
Aeven=A(1:4, 2:2:8);
23
 
24
fout=fopen('ROM_IDCT_ODD', 'w');
25
fprintf(fout, 'TYPE Rom16x4x%i IS ARRAY (0 TO 15) OF signed(%i*4-1 downto 0);\n' , coeff_width, (coeff_width));
26
fprintf(fout, 'CONSTANT ROM_IDCT_ODD : Rom16x4x%i := (\n', coeff_width);
27
for a3=0:1
28
    for a2=0:1
29
        for a1=0:1
30
            for a0=0:1
31
                Y0 = Aodd(1,1)*a0 + Aodd(1,2)*a1 + Aodd(1,3)*a2 + Aodd(1,4)*a3;
32
                Y1 = Aodd(2,1)*a0 + Aodd(2,2)*a1 + Aodd(2,3)*a2 + Aodd(2,4)*a3;
33
                Y2 = Aodd(3,1)*a0 + Aodd(3,2)*a1 + Aodd(3,3)*a2 + Aodd(3,4)*a3;
34
                Y3 = Aodd(4,1)*a0 + Aodd(4,2)*a1 + Aodd(4,3)*a2 + Aodd(4,4)*a3;
35
                Y0=round(mult*Y0);
36
                Y1=round(mult*Y1);
37
                Y2=round(mult*Y2);
38
                Y3=round(mult*Y3);
39
                fprintf(fout, 'conv_signed(%i, %i) & conv_signed(%i, %i) & conv_signed(%i, %i) & conv_signed(%i, %i),\n', Y0, coeff_width, Y1, coeff_width, Y2, coeff_width, Y3, coeff_width);
40
            end
41
        end
42
    end
43
end
44
fprintf(fout, 'REMOVE THIS, AND LAST dot\n);\n');
45
fclose(fout);
46
 
47
fout=fopen('ROM_IDCT_EVEN', 'w');
48
fprintf(fout, 'TYPE Rom16x4x%i IS ARRAY (0 TO 15) OF signed(%i*4-1 downto 0);\n' , coeff_width, (coeff_width));
49
fprintf(fout, 'CONSTANT ROM_IDCT_EVEN : Rom16x4x%i := (\n', coeff_width);
50
for a3=0:1
51
    for a2=0:1
52
        for a1=0:1
53
            for a0=0:1
54
                Y0 = Aeven(1,1)*a0 + Aeven(1,2)*a1 + Aeven(1,3)*a2 + Aeven(1,4)*a3;
55
                Y1 = Aeven(2,1)*a0 + Aeven(2,2)*a1 + Aeven(2,3)*a2 + Aeven(2,4)*a3;
56
                Y2 = Aeven(3,1)*a0 + Aeven(3,2)*a1 + Aeven(3,3)*a2 + Aeven(3,4)*a3;
57
                Y3 = Aeven(4,1)*a0 + Aeven(4,2)*a1 + Aeven(4,3)*a2 + Aeven(4,4)*a3;
58
                Y0=round(mult*Y0);
59
                Y1=round(mult*Y1);
60
                Y2=round(mult*Y2);
61
                Y3=round(mult*Y3);
62
                fprintf(fout, 'conv_signed(%i, %i) & conv_signed(%i, %i) & conv_signed(%i, %i) & conv_signed(%i, %i),\n', Y0, coeff_width, Y1, coeff_width, Y2, coeff_width, Y3, coeff_width);
63
            end
64
        end
65
    end
66
end
67
fprintf(fout, 'REMOVE THIS, AND LAST dot\n);\n');
68
fclose(fout);

powered by: WebSVN 2.1.0

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