📄 turbopack.vhd
字号:
-------------------------------------------------------------------------- -------- turbopack.vhd -------- -------- This file is part of the turbo decoder IP core project -------- http://www.opencores.org/projects/turbocodes/ -------- -------- Author(s): -------- - David Brochart(dbrochart@opencores.org) -------- -------- All additional information is available in the README.txt -------- file. -------- ------------------------------------------------------------------------------ -------- Copyright (C) 2005 Authors -------- -------- This source file may be used and distributed without -------- restriction provided that this copyright statement is not -------- removed from the file and that any derivative work contains -------- the original copyright notice and the associated disclaimer. -------- -------- This source file is free software; you can redistribute it -------- and/or modify it under the terms of the GNU Lesser General -------- Public License as published by the Free Software Foundation; -------- either version 2.1 of the License, or (at your option) any -------- later version. -------- -------- This source is distributed in the hope that it will be -------- useful, but WITHOUT ANY WARRANTY; without even the implied -------- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -------- PURPOSE. See the GNU Lesser General Public License for more -------- details. -------- -------- You should have received a copy of the GNU Lesser General -------- Public License along with this source; if not, download it -------- from http://www.opencores.org/lgpl.shtml -------- --------------------------------------------------------------------------library ieee;use ieee.std_logic_1164.all;package turbopack is constant RATE : integer := 12; -- code rate (e.g. 13 for rate 1/3) constant IT : integer := 5; -- number of decoding iterations constant FRSIZE : integer := 64; -- interleaver frame size in bit couples constant TREL1_LEN : integer := 24; -- first trellis length constant TREL2_LEN : integer := 12; -- second trellis length constant SIG_WIDTH : integer := 4; -- received decoder signal width constant Z_WIDTH : integer := 5; -- extrinsic information width constant ACC_DIST_WIDTH : integer := 9; -- accumulated distance width subtype INT2BIT is integer range 0 to 3; subtype INT3BIT is integer range 0 to 7; subtype SUBINT0 is integer range -(2**(SIG_WIDTH-1)) - (2**Z_WIDTH) to 2**ACC_DIST_WIDTH + 2**(SIG_WIDTH-1) - 1; subtype SUBINT1 is integer range 0 to 2**ACC_DIST_WIDTH + 2**(SIG_WIDTH-1) + 2**(SIG_WIDTH-1) + 2**Z_WIDTH - 1; type ARRAY32a is array (0 to 31) of integer; type ARRAY32b is array (0 to 31) of std_logic_vector(ACC_DIST_WIDTH downto 0); type ARRAY32c is array (0 to 31) of std_logic_vector(ACC_DIST_WIDTH - 1 downto 0); constant FROM2TO : ARRAY32a := (0, 25, 6, 31, 8, 17, 14, 23, 20, 13, 18, 11, 28, 5, 26, 3, 4, 29, 2, 27, 12, 21, 10, 19, 16, 9, 22, 15, 24, 1, 30, 7); constant DISTINDEX : ARRAY32a := (0, 7, 11, 12, 0, 7, 11, 12, 2, 5, 9, 14, 2, 5, 9, 14, 3, 4, 8, 15, 3, 4, 8, 15, 1, 6, 10, 13, 1, 6, 10, 13); constant TRANS2STATE : ARRAY32a := (0, 6, 1, 7, 2, 4, 3, 5, 5, 3, 4, 2, 7, 1, 6, 0, 1, 7, 0, 6, 3, 5, 2, 4, 4, 2, 5, 3, 6, 0, 7, 1); constant STATE2TRANS : ARRAY32a := (0, 2, 1, 3, 1, 3, 0, 2, 2, 0, 3, 1, 3, 1, 2, 0, 2, 0, 3, 1, 3, 1, 2, 0, 0, 2, 1, 3, 1, 3, 0, 2); type ARRAY2a is array (0 to 1) of std_logic_vector(SIG_WIDTH - 1 downto 0); type ARRAY3a is array (0 to 2) of std_logic_vector(ACC_DIST_WIDTH - 1 downto 0); type ARRAY4a is array (0 to 3) of std_logic_vector(ACC_DIST_WIDTH - 1 downto 0); type ARRAY4b is array (0 to 3) of std_logic_vector(ACC_DIST_WIDTH downto 0); type ARRAY4c is array (0 to 3) of std_logic_vector(Z_WIDTH - 1 downto 0); type ARRAY4d is array (0 to 3) of std_logic_vector(2 downto 0); type ARRAY4e is array (0 to 3) of SUBINT1; type ARRAY6a is array (0 to 5) of std_logic_vector(ACC_DIST_WIDTH - 1 downto 0); type ARRAY6b is array (0 to 5) of INT2BIT; type ARRAY7a is array (0 to 6) of SUBINT0; type ARRAY8a is array (0 to 7) of std_logic_vector(ACC_DIST_WIDTH - 1 downto 0); type ARRAY8b is array (0 to 7) of std_logic_vector(1 downto 0); type ARRAY8d is array (0 to 7) of INT3BIT; type ARRAY16a is array (0 to 15) of std_logic_vector(ACC_DIST_WIDTH - 1 downto 0); type ARRAY16b is array (0 to 15) of std_logic_vector(SIG_WIDTH + 1 downto 0); type ARRAY_TREL1_LENx8 is array (0 to TREL1_LEN * 8 - 1) of INT2BIT; type ARRAY_TREL2_LENx8 is array (0 to TREL2_LEN * 8 - 1) of std_logic_vector(1 downto 0); type ARRAY_4xTREL2_LEN is array (0 to 4 * TREL2_LEN - 1) of std_logic_vector(ACC_DIST_WIDTH - 1 downto 0); type ARRAY_ITa is array (0 to IT) of std_logic_vector(SIG_WIDTH - 1 downto 0); type ARRAY_ITb is array (0 to IT) of ARRAY4c; component delayer generic ( delay : integer := 1 -- number of clock cycles to delay ); port ( clk : in std_logic; -- clock rst : in std_logic; -- negative reset d : in std_logic_vector; -- signal to be delayed by "delay" clock cycles q : out std_logic_vector -- delayed signal ); end component; component subs port ( op1 : in std_logic_vector; -- first operand op2 : in std_logic_vector; -- second operand res : out std_logic_vector -- result of the substraction ); end component; component mux4 port ( in1 : in std_logic_vector; -- first input signal in2 : in std_logic_vector; -- second input signal in3 : in std_logic_vector; -- third input signal in4 : in std_logic_vector; -- fourth input signal sel : in std_logic_vector(1 downto 0); -- 2-bit control signal outSel : out std_logic_vector -- selected output signal ); end component; component mux8 port ( in8x4 : in ARRAY32c; -- 8x4 input signals sel : in std_logic_vector(2 downto 0); -- 3-bit control signal outSel4 : out ARRAY4a -- selected output signals ); end component; component distances port ( a : in std_logic_vector(SIG_WIDTH - 1 downto 0); -- received decoder signal b : in std_logic_vector(SIG_WIDTH - 1 downto 0); -- received decoder signal y : in std_logic_vector(SIG_WIDTH - 1 downto 0); -- received decoder signal w : in std_logic_vector(SIG_WIDTH - 1 downto 0); -- received decoder signal z : in ARRAY4c; -- extrinsic information array distance16 : out ARRAY16a -- distance signals (x16) ); end component; component partDistance generic ( ref : integer := 0 -- reference to compute the distance from ); port ( a : in std_logic_vector(SIG_WIDTH - 1 downto 0); -- received decoder signal b : in std_logic_vector(SIG_WIDTH - 1 downto 0); -- received decoder signal y : in std_logic_vector(SIG_WIDTH - 1 downto 0); -- received decoder signal w : in std_logic_vector(SIG_WIDTH - 1 downto 0); -- received decoder signal res : out std_logic_vector(SIG_WIDTH + 1 downto 0) -- partial distance signal ); end component; component opposite port ( pos : in std_logic_vector(SIG_WIDTH + 1 downto 0); -- original number neg : out std_logic_vector(SIG_WIDTH + 1 downto 0) -- opposite number ); end component; component distance port ( partDist : in std_logic_vector(SIG_WIDTH + 1 downto 0); -- sum of the decoder input signals z : in std_logic_vector(Z_WIDTH - 1 downto 0); -- extrinsic information dist : out std_logic_vector(ACC_DIST_WIDTH - 1 downto 0) -- distance ); end component; component reg port ( clk : in std_logic; -- clock rst : in std_logic; -- negative reset d : in std_logic_vector; -- next value q : out std_logic_vector -- current value ); end component; component adder port ( op1 : in std_logic_vector; -- first operand op2 : in std_logic_vector; -- second operand res : out std_logic_vector -- result of the addition ); end component; component reduction port ( org : in ARRAY8a; -- original array of 8 accumulated distances chd : out ARRAY8a -- reduced array of 8 accumulated distances ); end component; component accDist port ( clk : in std_logic; -- clock rst : in std_logic; -- negative reset accDistReg : in ARRAY8a; -- original array of 8 accumulated distance registers dist : in ARRAY16a; -- array of 16 distances accDistNew : out ARRAY32c -- array of 32 accumulated distances ); end component; component cmp2 port ( op1 : in std_logic_vector; -- first operand op2 : in std_logic_vector; -- second operand res : out std_logic -- compare result (0 if op2 < op1, 1 otherwise) ); end component; component mux2 port ( in1 : in std_logic_vector; -- first input signal in2 : in std_logic_vector; -- second input signal sel : in std_logic; -- 1-bit control signal outSel : out std_logic_vector -- selected output signal ); end component; component min4 port ( op1 : in std_logic_vector; -- first input signal op2 : in std_logic_vector; -- second input signal op3 : in std_logic_vector; -- third input signal op4 : in std_logic_vector; -- fourth input signal res1 : out std_logic; -- partial code of the minimum value
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -