| 1 |
2 |
mfehrenz |
--!
|
| 2 |
6 |
mfehrenz |
--! Copyright (C) 2011 - 2014 Creonic GmbH
|
| 3 |
2 |
mfehrenz |
--!
|
| 4 |
|
|
--! This file is part of the Creonic Viterbi Decoder, which is distributed
|
| 5 |
|
|
--! under the terms of the GNU General Public License version 2.
|
| 6 |
|
|
--!
|
| 7 |
|
|
--! @file
|
| 8 |
|
|
--! @brief Recursion unit for recursive code.
|
| 9 |
|
|
--! @author Markus Fehrenz
|
| 10 |
|
|
--! @date 2011/01/12
|
| 11 |
|
|
--!
|
| 12 |
|
|
--! @details The recusion handling buffers the reorder ouput and
|
| 13 |
|
|
--! calculates the correct output depending on the feedback polynomial.
|
| 14 |
|
|
--!
|
| 15 |
|
|
|
| 16 |
|
|
library ieee;
|
| 17 |
|
|
use ieee.std_logic_1164.all;
|
| 18 |
|
|
use ieee.numeric_std.all;
|
| 19 |
|
|
|
| 20 |
|
|
library dec_viterbi;
|
| 21 |
|
|
use dec_viterbi.pkg_param.all;
|
| 22 |
|
|
use dec_viterbi.pkg_param_derived.all;
|
| 23 |
|
|
|
| 24 |
|
|
entity recursion is
|
| 25 |
|
|
port(
|
| 26 |
|
|
clk : in std_logic;
|
| 27 |
|
|
rst : in std_logic;
|
| 28 |
|
|
|
| 29 |
|
|
--
|
| 30 |
|
|
-- Decoded bits input from the reordering units in std_logic
|
| 31 |
|
|
--
|
| 32 |
|
|
s_axis_input_tvalid : in std_logic;
|
| 33 |
|
|
s_axis_input_tdata : in std_logic;
|
| 34 |
|
|
s_axis_input_tlast : in std_logic;
|
| 35 |
|
|
s_axis_input_tready : out std_logic;
|
| 36 |
|
|
|
| 37 |
|
|
--
|
| 38 |
|
|
-- Output decoded bits convolved with the feedback polynomial
|
| 39 |
|
|
--
|
| 40 |
|
|
m_axis_output_tvalid : out std_logic;
|
| 41 |
|
|
m_axis_output_tdata : out std_logic;
|
| 42 |
|
|
m_axis_output_tlast : out std_logic;
|
| 43 |
|
|
m_axis_output_tready : in std_logic
|
| 44 |
|
|
);
|
| 45 |
|
|
end entity recursion;
|
| 46 |
|
|
|
| 47 |
|
|
architecture rtl of recursion is
|
| 48 |
|
|
signal recursion_sreg : unsigned(ENCODER_MEMORY_DEPTH downto 0);
|
| 49 |
|
|
signal s_axis_input_tready_int : std_logic;
|
| 50 |
|
|
signal m_axis_output_tvalid_int : std_logic;
|
| 51 |
|
|
|
| 52 |
|
|
begin
|
| 53 |
|
|
s_axis_input_tready_int <= '1' when m_axis_output_tready = '1' or m_axis_output_tvalid_int = '0' else
|
| 54 |
|
|
'0';
|
| 55 |
|
|
|
| 56 |
|
|
s_axis_input_tready <= s_axis_input_tready_int;
|
| 57 |
|
|
m_axis_output_tvalid <= m_axis_output_tvalid_int;
|
| 58 |
|
|
|
| 59 |
|
|
-- Use the feedback polynomial to convolve the global path.
|
| 60 |
|
|
pr_recursion : process(clk) is
|
| 61 |
|
|
variable v_bit : std_logic := '0';
|
| 62 |
|
|
variable v_recursion_state : unsigned(ENCODER_MEMORY_DEPTH downto 0);
|
| 63 |
|
|
begin
|
| 64 |
|
|
if rising_edge(clk) then
|
| 65 |
|
|
if rst = '1' then
|
| 66 |
|
|
recursion_sreg <= (others => '0');
|
| 67 |
|
|
m_axis_output_tdata <= '0';
|
| 68 |
|
|
m_axis_output_tlast <= '0';
|
| 69 |
|
|
else
|
| 70 |
|
|
m_axis_output_tvalid_int <= s_axis_input_tvalid;
|
| 71 |
|
|
|
| 72 |
|
|
if s_axis_input_tvalid = '1' and s_axis_input_tready_int = '1' then
|
| 73 |
|
|
|
| 74 |
|
|
-- move current decoded output bits into shift register and reset if last flag is valid
|
| 75 |
|
|
if s_axis_input_tlast = '1' then
|
| 76 |
|
|
recursion_sreg <= (others => '0');
|
| 77 |
|
|
else
|
| 78 |
|
|
recursion_sreg <= s_axis_input_tdata & recursion_sreg(ENCODER_MEMORY_DEPTH downto 1);
|
| 79 |
|
|
end if;
|
| 80 |
|
|
|
| 81 |
|
|
-- convolve with feedback polynomial with the output register.
|
| 82 |
|
|
v_bit := '0';
|
| 83 |
|
|
v_recursion_state := (s_axis_input_tdata & recursion_sreg(ENCODER_MEMORY_DEPTH downto 1)) and
|
| 84 |
|
|
('1' & to_unsigned(FEEDBACK_POLYNOMIAL, ENCODER_MEMORY_DEPTH));
|
| 85 |
|
|
for i in ENCODER_MEMORY_DEPTH downto 0 loop
|
| 86 |
|
|
v_bit := v_bit xor v_recursion_state(i);
|
| 87 |
|
|
end loop;
|
| 88 |
|
|
m_axis_output_tdata <= v_bit;
|
| 89 |
|
|
|
| 90 |
|
|
m_axis_output_tlast <= s_axis_input_tlast;
|
| 91 |
|
|
end if;
|
| 92 |
|
|
end if;
|
| 93 |
|
|
end if;
|
| 94 |
|
|
end process pr_recursion;
|
| 95 |
|
|
|
| 96 |
|
|
end architecture rtl;
|