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

Subversion Repositories dirac

[/] [dirac/] [trunk/] [src/] [expgolomb/] [EXP_GOLOMB_DECODER.vhd] - Blame information for rev 7

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 petebleack
-- ***** BEGIN LICENSE BLOCK *****
2
-- 
3
-- 
4
--  Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
-- 
6
--  The contents of this file are subject to the Mozilla Public License
7
--  Version 1.1 (the "License"); you may not use this file except in compliance
8
--  with the License. You may obtain a copy of the License at
9
--  http://www.mozilla.org/MPL/
10
-- 
11
--  Software distributed under the License is distributed on an "AS IS" basis,
12
--  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
13
--  the specific language governing rights and limitations under the License.
14
-- 
15
--  The Original Code is BBC Research and Development code.
16
-- 
17
--  The Initial Developer of the Original Code is the British Broadcasting
18
--  Corporation.
19
--  Portions created by the Initial Developer are Copyright (C) 2006.
20
--  All Rights Reserved.
21
-- 
22
--  Contributor(s): Peter Bleackley (Original author)
23
-- 
24
--  Alternatively, the contents of this file may be used under the terms of
25
--  the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
26
--  Public License Version 2.1 (the "LGPL"), in which case the provisions of
27
--  the GPL or the LGPL are applicable instead of those above. If you wish to
28
--  allow use of your version of this file only under the terms of the either
29
--  the GPL or LGPL and not to allow others to use your version of this file
30
--  under the MPL, indicate your decision by deleting the provisions above
31
--  and replace them with the notice and other provisions required by the GPL
32
--  or LGPL. If you do not delete the provisions above, a recipient may use
33
--  your version of this file under the terms of any one of the MPL, the GPL
34
--  or the LGPL.
35
-- * ***** END LICENSE BLOCK ***** */
36
library IEEE;
37
use IEEE.STD_LOGIC_1164.ALL;
38
use IEEE.STD_LOGIC_ARITH.ALL;
39
use IEEE.STD_LOGIC_UNSIGNED.ALL;
40
 
41
---- Uncomment the following library declaration if instantiating
42
---- any Xilinx primitives in this code.
43
--library UNISIM;
44
--use UNISIM.VComponents.all;
45
 
46
entity EXP_GOLOMB_DECODER is
47
    Port ( ENABLE : in std_logic;
48
           DATA_IN : in std_logic;
49
           RESET : in std_logic;
50
           CLOCK : in std_logic;
51
           READY : out std_logic;
52
           DATA_OUT : out std_logic_vector(31 downto 0));
53
end EXP_GOLOMB_DECODER;
54
 
55
architecture RTL of EXP_GOLOMB_DECODER is
56
        signal DATA_1 : std_logic_vector(31 downto 0);
57
        signal DATA_2 : std_logic_vector(31 downto 0);
58
        signal SUM : std_logic_vector(31 downto 0);
59
        signal NUMBITS_1 : std_logic_vector(4 downto 0);
60
        signal NUMBITS_2 : std_logic_vector(4 downto 0);
61
        signal MODE : std_logic;
62
        signal CALC_COMPLETE : std_logic;
63
begin
64
 
65
READ_DATA : process (CLOCK)
66
begin
67
        if CLOCK'event and CLOCK = '1' then             --WHEN CLOCK EDGE DETECTED
68
                if RESET = '1' then             --SET ALL REGISTERS TO ZERO
69
                        DATA_1 <= (others => '0');
70
                        DATA_2 <= (others => '0');
71
                        NUMBITS_1 <= (others => '0');
72
                        NUMBITS_2 <= (others => '0');
73
                        DATA_OUT <= (others => '0');
74
                        MODE <= '0';
75
                        CALC_COMPLETE <= '0';
76
                elsif CALC_COMPLETE = '1' then
77
                        DATA_1 <= (others => '0');
78
                        DATA_2 <= (others => '0');
79
                        NUMBITS_1 <= (others => '0');
80
                        NUMBITS_2 <= (others => '0');
81
                        MODE <= '0';
82
                        CALC_COMPLETE <= '0';
83
                elsif (NUMBITS_2 = NUMBITS_1) and (MODE = '1') then --IF CALCULATION IS COMPLETE 
84
                        DATA_OUT <= SUM;
85
                        CALC_COMPLETE <= '1';
86
                elsif ENABLE = '1' then         --IF DATA IS BEING INPUT
87
                        if MODE = '1' then               --READ INPUT DATA INTO REGISTER DATA_2, AND COUNT THE NUMBER OF BITS READ IN
88
                                DATA_2 <= DATA_2 (30 downto 0) & DATA_IN;
89
                                NUMBITS_2 <= NUMBITS_2 + "00001";
90
                        elsif DATA_IN = '1' then         --DETECT END OF EXPONENT, SWITCH TO MODE 1, FOR READING DATA
91
                                MODE <= '1';
92
                        else                      --IN MODE 0 (FOR READING EXPONENT)
93
                                DATA_1 <= DATA_1 (30 downto 0) & '1';
94
                                NUMBITS_1 <= NUMBITS_1 + "00001";
95
                        end if;
96
                end if;
97
end if;
98
end process READ_DATA;
99
 
100
SUM <= DATA_1 + DATA_2;
101
READY <= CALC_COMPLETE;
102
 
103
end RTL;

powered by: WebSVN 2.1.0

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