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

Subversion Repositories viterbi_decoder_axi4s

[/] [viterbi_decoder_axi4s/] [trunk/] [src/] [branch_distance.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
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  Branch distance calculation unit.
9
--! @author Markus Fehrenz
10
--! @date   2011/08/04
11
--!
12
--! @details Each branch has to be calculated only once.
13
--!          The branch calculations are configured with a generic.
14
--!          There is no limitation in branch calculations.
15
--!
16
 
17
library ieee;
18
use ieee.std_logic_1164.all;
19
use ieee.numeric_std.all;
20
 
21
library dec_viterbi;
22
use dec_viterbi.pkg_param.all;
23
use dec_viterbi.pkg_param_derived.all;
24
use dec_viterbi.pkg_types.all;
25
 
26
 
27
entity branch_distance is
28
        generic(
29
                EDGE_WEIGHT : in std_logic_vector(0 to NUMBER_PARITY_BITS - 1)
30
        );
31
        port(
32
                clk                 : in std_logic;
33
                rst                 : in std_logic;
34
 
35
                --
36
                -- Input LLR values
37
                --
38
                s_axis_input_tvalid : in  std_logic;
39
                s_axis_input_tdata  : in  t_input_block;
40
                s_axis_input_tlast  : in  std_logic;
41
                s_axis_input_tready : out std_logic;
42
 
43
 
44
                --
45
                -- Output branch metrics, going to ACS unit.
46
                --
47
                m_axis_output_tvalid : out std_logic;
48
                m_axis_output_tdata  : out std_logic_vector(BW_BRANCH_RESULT - 1 downto 0);
49
                m_axis_output_tlast  : out std_logic;
50
                m_axis_output_tready : in  std_logic
51
        );
52
end entity branch_distance;
53
 
54
 
55
architecture rtl of branch_distance is
56
 
57
        signal m_axis_output_tvalid_int : std_logic;
58
        signal s_axis_input_tready_int  : std_logic;
59
 
60
begin
61
 
62
        -- We are ready, when we are allowed to write to the output, or the output is idle.
63
        s_axis_input_tready_int <= '1' when m_axis_output_tready = '1' else
64
                                   '0';
65
 
66
        -- Connect internal versions of signal to output port.
67
        s_axis_input_tready   <= s_axis_input_tready_int;
68
        m_axis_output_tvalid  <= m_axis_output_tvalid_int;
69
 
70
 
71
        -- Calculation of specific branch distance with a geometric distance function.
72
        pr_branch : process(clk) is
73
                variable v_branch_result : integer;
74
        begin
75
        if rising_edge(clk) then
76
                if rst = '1' then
77
                        m_axis_output_tvalid_int <= '0';
78
                        m_axis_output_tdata      <= (others => '0');
79
                        m_axis_output_tlast      <= '0';
80
                else
81 6 mfehrenz
 
82
                        if m_axis_output_tvalid_int = '1' and m_axis_output_tready = '1' then
83
                                m_axis_output_tvalid_int <= '0';
84
                                m_axis_output_tlast      <= '0';
85
                        end if;
86
 
87 2 mfehrenz
                        if s_axis_input_tready_int = '1' and s_axis_input_tvalid = '1' then
88
                                v_branch_result := 0;
89
 
90
                                for i in NUMBER_PARITY_BITS - 1 downto 0 loop
91
 
92
                                        --
93 6 mfehrenz
                                        -- Either the value is added or subtracted, depending on
94 2 mfehrenz
                                        -- the current branch metric we are computing.
95
                                        --
96
                                        if EDGE_WEIGHT(i) = '0' then
97
                                                v_branch_result := v_branch_result + to_integer(s_axis_input_tdata(i));
98
                                        else
99
                                                v_branch_result := v_branch_result - to_integer(s_axis_input_tdata(i));
100
                                        end if;
101
                                end loop;
102
                                m_axis_output_tdata <= std_logic_vector(to_signed(v_branch_result, BW_BRANCH_RESULT));
103 6 mfehrenz
                                m_axis_output_tvalid_int <= '1';
104
                                m_axis_output_tlast      <= s_axis_input_tlast;
105 2 mfehrenz
                        end if;
106
 
107
                end if;
108
        end if;
109
        end process pr_branch;
110
 
111
end architecture rtl;

powered by: WebSVN 2.1.0

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