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

Subversion Repositories turbocodes

[/] [turbocodes/] [trunk/] [src/] [vhdl/] [interleaver_synth.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 dbrochart
----------------------------------------------------------------------
2
----                                                              ----
3
----  interleaver_synth.vhd                                       ----
4
----                                                              ----
5
----  This file is part of the turbo decoder IP core project      ----
6
----  http://www.opencores.org/projects/turbocodes/               ----
7
----                                                              ----
8
----  Author(s):                                                  ----
9
----      - David Brochart(dbrochart@opencores.org)               ----
10
----                                                              ----
11
----  All additional information is available in the README.txt   ----
12
----  file.                                                       ----
13
----                                                              ----
14
----------------------------------------------------------------------
15
----                                                              ----
16
---- Copyright (C) 2005 Authors                                   ----
17
----                                                              ----
18
---- This source file may be used and distributed without         ----
19
---- restriction provided that this copyright statement is not    ----
20
---- removed from the file and that any derivative work contains  ----
21
---- the original copyright notice and the associated disclaimer. ----
22
----                                                              ----
23
---- This source file is free software; you can redistribute it   ----
24
---- and/or modify it under the terms of the GNU Lesser General   ----
25
---- Public License as published by the Free Software Foundation; ----
26
---- either version 2.1 of the License, or (at your option) any   ----
27
---- later version.                                               ----
28
----                                                              ----
29
---- This source is distributed in the hope that it will be       ----
30
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
31
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
32
---- PURPOSE. See the GNU Lesser General Public License for more  ----
33
---- details.                                                     ----
34
----                                                              ----
35
---- You should have received a copy of the GNU Lesser General    ----
36
---- Public License along with this source; if not, download it   ----
37
---- from http://www.opencores.org/lgpl.shtml                     ----
38
----                                                              ----
39
----------------------------------------------------------------------
40
 
41
 
42
 
43
architecture synth of interleaver is
44
    type ARRAYfrSize is array (0 to FRSIZE - 1) of std_logic_vector(d'length - 1 downto 0);
45
    subtype cnt_t is integer range 0 to delay;
46
    subtype p_t is integer range 0 to 652;
47
    subtype frSize_t is integer range 0 to FRSIZE - 1;
48
    subtype frSize2_t is integer range 0 to 2 * FRSIZE - 1;
49
    signal array1   : ARRAYfrSize;
50
    signal array2   : ARRAYfrSize;
51
    signal cnt      : cnt_t;
52
    signal i        : frSize_t;
53
    signal iTmp     : frSize_t;
54
    signal j        : frSize_t;
55
    signal full     : std_logic;
56
    signal p0       : p_t;
57
    signal p1       : p_t;
58
    signal p2       : p_t;
59
    signal p3       : p_t;
60
begin
61
    frSize48_g : if FRSIZE = 48 generate
62
        p0 <= 11;
63
        p1 <= 24;
64
        p2 <= 0;
65
        p3 <= 24;
66
    end generate;
67
    frSize64_g : if FRSIZE = 64 generate
68
        p0 <= 7;
69
        p1 <= 34;
70
        p2 <= 32;
71
        p3 <= 2;
72
    end generate;
73
    frSize212_g : if FRSIZE = 212 generate
74
        p0 <= 13;
75
        p1 <= 106;
76
        p2 <= 108;
77
        p3 <= 2;
78
    end generate;
79
    frSize220_g : if FRSIZE = 220 generate
80
        p0 <= 23;
81
        p1 <= 112;
82
        p2 <= 4;
83
        p3 <= 116;
84
    end generate;
85
    frSize228_g : if FRSIZE = 228 generate
86
        p0 <= 17;
87
        p1 <= 116;
88
        p2 <= 72;
89
        p3 <= 188;
90
    end generate;
91
    frSize424_g : if FRSIZE = 424 generate
92
        p0 <= 11;
93
        p1 <= 6;
94
        p2 <= 8;
95
        p3 <= 2;
96
    end generate;
97
    frSize432_g : if FRSIZE = 432 generate
98
        p0 <= 13;
99
        p1 <= 0;
100
        p2 <= 4;
101
        p3 <= 8;
102
    end generate;
103
    frSize440_g : if FRSIZE = 440 generate
104
        p0 <= 13;
105
        p1 <= 10;
106
        p2 <= 4;
107
        p3 <= 2;
108
    end generate;
109
    frSize848_g : if FRSIZE = 848 generate
110
        p0 <= 19;
111
        p1 <= 2;
112
        p2 <= 16;
113
        p3 <= 6;
114
    end generate;
115
    frSize856_g : if FRSIZE = 856 generate
116
        p0 <= 19;
117
        p1 <= 428;
118
        p2 <= 224;
119
        p3 <= 652;
120
    end generate;
121
    frSize864_g : if FRSIZE = 864 generate
122
        p0 <= 19;
123
        p1 <= 2;
124
        p2 <= 16;
125
        p3 <= 6;
126
    end generate;
127
    frSize752_g : if FRSIZE = 752 generate
128
        p0 <= 19;
129
        p1 <= 376;
130
        p2 <= 224;
131
        p3 <= 600;
132
    end generate;
133
 
134
    process (clk, rst)
135
        variable p      : frSize2_t;
136
        variable iTmp1  : frSize2_t;
137
        variable iTmp2  : frSize2_t;
138
        variable iTmp3  : frSize2_t;
139
        variable ii     : frSize_t;
140
        variable jj     : frSize_t;
141
    begin
142
        if rst = '0' then
143
            cnt     <= 0;
144
            i       <= 0;
145
            j       <= 0;
146
            iTmp    <= 0;
147
            full    <= '0';
148
            q       <= std_logic_vector(conv_unsigned(0, q'length));
149
            for k in 0 to FRSIZE - 1 loop
150
                array1(k) <= (others => '0');
151
                array2(k) <= (others => '0');
152
            end loop;
153
        elsif clk = '1' and clk'event then
154
            if cnt < delay then
155
                cnt <= cnt + 1;
156
            else
157
                if j mod 4 = 0 then
158
                    p := 0;
159
                elsif j mod 4 = 1 then
160
                    p := FRSIZE / 2 + p1;
161
                elsif j mod 4 = 2 then
162
                    p := p2;
163
                else    -- if j mod 4 = 3 then
164
                    p := FRSIZE / 2 + p3;
165
                end if;
166
                iTmp1 := iTmp + p0;
167
                if iTmp1 >= FRSIZE then
168
                    iTmp2 := iTmp1 - FRSIZE;
169
                else
170
                    iTmp2 := iTmp1;
171
                end if;
172
                iTmp <= iTmp2;
173
                iTmp3 := iTmp2 + p + 1;
174
                if iTmp3 >= 2 * FRSIZE then
175
                    i <= iTmp3 - 2 * FRSIZE;
176
                elsif iTmp3 >= FRSIZE then
177
                    i <= iTmp3 - FRSIZE;
178
                else
179
                    i <= iTmp3;
180
                end if;
181
                if j = (FRSIZE - 1) then
182
                    j       <= 0;
183
                    full    <= not full;
184
                else
185
                    j <= j + 1;
186
                end if;
187
                if way = 0 then
188
                    ii := i;
189
                    jj := j;
190
                else
191
                    ii := j;
192
                    jj := i;
193
                end if;
194
                if full = '0' then
195
                    array1(jj) <= d;
196
                    q <= array2(ii);
197
                else
198
                    array2(jj) <= d;
199
                    q <= array1(ii);
200
                end if;
201
            end if;
202
        end if;
203
    end process;
204
end;

powered by: WebSVN 2.1.0

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