1 |
7 |
dbrochart |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- extInf_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 extInf is
|
44 |
|
|
begin
|
45 |
|
|
process (llr0, llr1, llr2, llr3, zin, a, b)
|
46 |
|
|
variable a_plus_b : std_logic_vector(SIG_WIDTH - 1 downto 0);
|
47 |
|
|
variable a_min_b : std_logic_vector(SIG_WIDTH - 1 downto 0);
|
48 |
|
|
variable tmp : ARRAY7a;
|
49 |
|
|
variable tmp2 : ARRAY4e;
|
50 |
|
|
begin
|
51 |
|
|
a_plus_b := std_logic_vector(conv_signed(((conv_integer(signed(a)) + conv_integer(signed(b))) / 2), SIG_WIDTH));
|
52 |
|
|
a_min_b := std_logic_vector(conv_signed(((conv_integer(signed(a)) - conv_integer(signed(b))) / 2), SIG_WIDTH));
|
53 |
|
|
tmp(0) := conv_integer(unsigned(llr0)) - conv_integer(signed(a_plus_b)) - conv_integer(unsigned(zin(0)));
|
54 |
|
|
tmp(1) := conv_integer(unsigned(llr1)) - conv_integer(signed(a_min_b)) - conv_integer(unsigned(zin(1)));
|
55 |
|
|
tmp(2) := conv_integer(unsigned(llr2)) + conv_integer(signed(a_min_b)) - conv_integer(unsigned(zin(2)));
|
56 |
|
|
tmp(3) := conv_integer(unsigned(llr3)) + conv_integer(signed(a_plus_b)) - conv_integer(unsigned(zin(3)));
|
57 |
|
|
if tmp(0) < tmp(1) then
|
58 |
|
|
tmp(4) := tmp(0);
|
59 |
|
|
else
|
60 |
|
|
tmp(4) := tmp(1);
|
61 |
|
|
end if;
|
62 |
|
|
if tmp(2) < tmp(3) then
|
63 |
|
|
tmp(5) := tmp(2);
|
64 |
|
|
else
|
65 |
|
|
tmp(5) := tmp(3);
|
66 |
|
|
end if;
|
67 |
|
|
if tmp(4) < tmp(5) then
|
68 |
|
|
tmp(6) := tmp(4);
|
69 |
|
|
else
|
70 |
|
|
tmp(6) := tmp(5);
|
71 |
|
|
end if;
|
72 |
|
|
tmp2(0) := tmp(0) - tmp(6);
|
73 |
|
|
tmp2(1) := tmp(1) - tmp(6);
|
74 |
|
|
tmp2(2) := tmp(2) - tmp(6);
|
75 |
|
|
tmp2(3) := tmp(3) - tmp(6);
|
76 |
|
|
if tmp2(0) >= (2 ** Z_WIDTH) then
|
77 |
|
|
zout(0) <= std_logic_vector(conv_unsigned((2 ** Z_WIDTH) - 1, Z_WIDTH));
|
78 |
|
|
else
|
79 |
|
|
zout(0) <= std_logic_vector(conv_unsigned(tmp2(0), Z_WIDTH));
|
80 |
|
|
end if;
|
81 |
|
|
if tmp2(1) >= (2 ** Z_WIDTH) then
|
82 |
|
|
zout(1) <= std_logic_vector(conv_unsigned((2 ** Z_WIDTH) - 1, Z_WIDTH));
|
83 |
|
|
else
|
84 |
|
|
zout(1) <= std_logic_vector(conv_unsigned(tmp2(1), Z_WIDTH));
|
85 |
|
|
end if;
|
86 |
|
|
if tmp2(2) >= (2 ** Z_WIDTH) then
|
87 |
|
|
zout(2) <= std_logic_vector(conv_unsigned((2 ** Z_WIDTH) - 1, Z_WIDTH));
|
88 |
|
|
else
|
89 |
|
|
zout(2) <= std_logic_vector(conv_unsigned(tmp2(2), Z_WIDTH));
|
90 |
|
|
end if;
|
91 |
|
|
if tmp2(3) >= (2 ** Z_WIDTH) then
|
92 |
|
|
zout(3) <= std_logic_vector(conv_unsigned((2 ** Z_WIDTH) - 1, Z_WIDTH));
|
93 |
|
|
else
|
94 |
|
|
zout(3) <= std_logic_vector(conv_unsigned(tmp2(3), Z_WIDTH));
|
95 |
|
|
end if;
|
96 |
|
|
end process;
|
97 |
|
|
end;
|