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/] [quant_rom.m] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
%Quantizer
2
%Quantizer constants (1/QP, 1/DC_scaler, DC_scaler)
3
%Timo Alho, timo.a.alho@tut.fi
4
%10.6.2004
5
 
6
%generates percalculated values for quantizer block
7
coeffw=16;
8
mul = 2^coeffw;
9
 
10
fout=fopen('ROM_INV_QP', 'w');
11
fprintf(fout, 'TYPE Rom32x%i IS ARRAY (0 TO 31) OF unsigned(%i-1 downto 0);\n' , coeffw, coeffw);
12
fprintf(fout, 'CONSTANT ROM_INV_QP : Rom32x%i := (\n', coeffw);
13
 
14
q=0;
15
CTAB=[q];
16
fprintf(fout, 'conv_unsigned(%.0f, %i),\n', q, coeffw);
17
 
18
for i=1:30
19
    q=round(1/(i)*mul);
20
    if (q==mul)
21
        q=mul-1;
22
    end
23
    CTAB=[CTAB q];
24
    fprintf(fout, 'conv_unsigned(%.0f, %i),\n', q, coeffw);
25
end
26
q=round(1/(31)*mul);
27
CTAB=[CTAB q];
28
fprintf(fout, 'conv_unsigned(%.0f, %i));\n', q, coeffw);
29
fclose(fout);
30
 
31
type1=[];
32
type2=[];
33
%generate dc_scaler values
34
for i=1:4
35
    type1=[type1 8];
36
    type2=[type2 8];
37
end
38
for i=5:8
39
    type1=[type1 2*i];
40
    type2=[type2 fix((i+13)/2)];
41
end
42
for i=9:24
43
    type1=[type1 i+8];
44
    type2=[type2 fix((i+13)/2)];
45
end
46
for i=25:31
47
    type1=[type1 2*i-16];
48
    type2=[type2 i-6];
49
end
50
 
51
fout=fopen('ROM_INV_DCSCALER', 'w');
52
fprintf(fout, 'TYPE Rom64x%i IS ARRAY (0 TO 63) OF unsigned(%i-1 downto 0);\n' , coeffw, coeffw);
53
fprintf(fout, 'CONSTANT ROM_INV_DCSCALER : Rom64x%i := (\n', coeffw);
54
 
55
q=0;
56
fprintf(fout, 'conv_unsigned(%.0f, %i),\n', q, coeffw);
57
 
58
for i=1:31
59
    q=2*round(1/type1(i)*mul);
60
    fprintf(fout, 'conv_unsigned(%.0f, %i),\n', q, coeffw);
61
end
62
 
63
q=0;
64
fprintf(fout, 'conv_unsigned(%.0f, %i),\n', q, coeffw);
65
 
66
for i=1:30
67
    q=2*round(1/type2(i)*mul);
68
    fprintf(fout, 'conv_unsigned(%.0f, %i),\n', q, coeffw);
69
end
70
 
71
q=2*round(1/type2(31)*mul);
72
fprintf(fout, 'conv_unsigned(%.0f, %i));\n', q, coeffw);
73
 
74
fclose(fout);
75
 
76
coeffw=6;
77
 
78
fout=fopen('ROM_DCSCALER', 'w');
79
fprintf(fout, 'TYPE Rom64x%i IS ARRAY (0 TO 63) OF unsigned(%i-1 downto 0);\n' , coeffw, coeffw);
80
fprintf(fout, 'CONSTANT ROM_DCSCALER : Rom64x%i := (\n', coeffw);
81
 
82
q=0;
83
fprintf(fout, 'conv_unsigned(%.0f, %i),\n', q, coeffw);
84
 
85
for i=1:31
86
    q=round(type1(i));
87
    fprintf(fout, 'conv_unsigned(%.0f, %i),\n', q, coeffw);
88
end
89
 
90
q=0;
91
fprintf(fout, 'conv_unsigned(%.0f, %i),\n', q, coeffw);
92
 
93
for i=1:30
94
    q=round(type2(i));
95
    fprintf(fout, 'conv_unsigned(%.0f, %i),\n', q, coeffw);
96
end
97
 
98
q=round(type2(31));
99
fprintf(fout, 'conv_unsigned(%.0f, %i));\n', q, coeffw);
100
 
101
fclose(fout);

powered by: WebSVN 2.1.0

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