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

Subversion Repositories viterbi_decoder_axi4s

[/] [viterbi_decoder_axi4s/] [trunk/] [src/] [reorder.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  Reorder twisted output due to windowing
9
--! @author Markus Fehrenz
10
--! @date   2011/05/12
11
--!
12
--! @details The windowing output is twisted.
13
--!          The correct order is simply rebuilt by reversing
14
--!          the output of each traceback unit.
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 reorder is
28
        port(
29
                clk :   in std_logic;
30
                rst :   in std_logic;
31
 
32
                --
33
                -- Traceback unit output, twisted order
34
                --
35
                s_axis_input_tvalid     : in  std_logic;
36
                s_axis_input_tdata      : in  std_logic;
37
                s_axis_input_tlast      : in  std_logic;
38
                s_axis_input_last_tuser : in  std_logic;
39
                s_axis_input_tready     : out std_logic;
40
 
41
                --
42
                -- Viterbi decoder output, original (input) order.
43
                --
44
                m_axis_output_tvalid     : out std_logic;
45
                m_axis_output_tdata      : out std_logic;
46
                m_axis_output_tlast      : out std_logic;
47
                m_axis_output_last_tuser : out std_logic; -- Last bit of one traceback window
48
                m_axis_output_tready     : in  std_logic
49
        );
50
end entity reorder;
51
 
52
 
53
architecture rtl of reorder is
54
 
55 6 mfehrenz
        -- used to store one reversed output of a traceback unit
56 2 mfehrenz
        signal buffer_sreg              : unsigned(MAX_WINDOW_LENGTH - 1 downto 0);
57
        signal buffer_cnt               : unsigned(BW_MAX_WINDOW_LENGTH - 1 downto 0);
58
        signal buffer_end               : integer range ENCODER_MEMORY_DEPTH downto 0;
59
        signal send_output, last_window : boolean;
60
 
61
        signal s_axis_input_tready_int  : std_logic;
62
 
63
begin
64
 
65
        s_axis_input_tready     <= s_axis_input_tready_int;
66
        s_axis_input_tready_int <= '1' when not(send_output) else
67
                                   '0';
68
 
69 6 mfehrenz
--      m_axis_output_tvalid     <= '1' when send_output and m_axis_output_tready= '1' else
70
        m_axis_output_tvalid     <= '1' when send_output else
71 2 mfehrenz
                                    '0';
72
        m_axis_output_tdata      <= buffer_sreg(0);
73
 
74
        m_axis_output_tlast      <= '1' when buffer_cnt = ENCODER_MEMORY_DEPTH  and last_window else
75
                                    '0';
76
 
77 6 mfehrenz
        -- Reorder the global path given from an traceback unit with the help of a shift register.
78 2 mfehrenz
        pr_reorder : process(clk) is
79
        begin
80
        if rising_edge(clk) then
81
                if rst = '1' then
82
                        buffer_sreg              <= (others => '0');
83
                        buffer_cnt               <= (others => '0');
84
                        send_output              <= false;
85
                        last_window              <= false;
86
                        buffer_end               <= 0;
87
                        m_axis_output_last_tuser <= '0';
88
                else
89
 
90
                        -- store output of traceback unit
91
                        if s_axis_input_tvalid = '1' and s_axis_input_tready_int = '1' then
92
                                if s_axis_input_tlast = '1' then
93
                                        last_window <= true;
94
                                        buffer_end <= ENCODER_MEMORY_DEPTH;
95
                                end if;
96
                                if s_axis_input_last_tuser = '1' then
97
                                        send_output <= true;
98
                                        buffer_sreg <= buffer_sreg(MAX_WINDOW_LENGTH - 2 downto 0) & s_axis_input_tdata;
99
                                else
100
                                        buffer_sreg <= buffer_sreg(MAX_WINDOW_LENGTH - 2 downto 0) & s_axis_input_tdata;
101
                                        buffer_cnt  <= buffer_cnt + 1;
102
                                end if;
103
                        end if;
104
 
105
                        -- send reordered data to the output
106
                        if m_axis_output_tready = '1' and send_output then
107
                                buffer_sreg <= '0' & buffer_sreg(MAX_WINDOW_LENGTH - 1 downto 1);
108
 
109
                                -- Next transfer will be the last one of this window.
110
                                if buffer_cnt = 1 then
111
                                        m_axis_output_last_tuser <= '1';
112
                                end if;
113
 
114
                                -- This was the last data transfer. Tailbits are cut off
115
                                if buffer_cnt = buffer_end then
116
                                        send_output              <= false;
117
                                        last_window              <= false;
118
                                        buffer_end               <= 0;
119
                                        buffer_cnt               <= (others => '0');
120
                                        m_axis_output_last_tuser <= '0';
121
                                else
122
                                        buffer_cnt <= buffer_cnt - 1;
123
                                end if;
124
                        end if;
125
                end if;
126
        end if;
127
        end process pr_reorder;
128
 
129
end architecture rtl;

powered by: WebSVN 2.1.0

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