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 |
10 |
petebleack |
|
37 |
|
|
|
38 |
7 |
petebleack |
library IEEE;
|
39 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
40 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
41 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
42 |
|
|
|
43 |
|
|
---- Uncomment the following library declaration if instantiating
|
44 |
|
|
---- any Xilinx primitives in this code.
|
45 |
|
|
--library UNISIM;
|
46 |
|
|
--use UNISIM.VComponents.all;
|
47 |
|
|
|
48 |
|
|
entity EXP_GOLOMB_DECODER is
|
49 |
|
|
Port ( ENABLE : in std_logic;
|
50 |
|
|
DATA_IN : in std_logic;
|
51 |
|
|
RESET : in std_logic;
|
52 |
|
|
CLOCK : in std_logic;
|
53 |
|
|
READY : out std_logic;
|
54 |
|
|
DATA_OUT : out std_logic_vector(31 downto 0));
|
55 |
|
|
end EXP_GOLOMB_DECODER;
|
56 |
|
|
|
57 |
|
|
architecture RTL of EXP_GOLOMB_DECODER is
|
58 |
10 |
petebleack |
signal DATA : std_logic_vector(31 downto 0);
|
59 |
7 |
petebleack |
signal MODE : std_logic;
|
60 |
|
|
signal CALC_COMPLETE : std_logic;
|
61 |
|
|
begin
|
62 |
|
|
|
63 |
|
|
READ_DATA : process (CLOCK)
|
64 |
|
|
begin
|
65 |
|
|
if CLOCK'event and CLOCK = '1' then --WHEN CLOCK EDGE DETECTED
|
66 |
|
|
if RESET = '1' then --SET ALL REGISTERS TO ZERO
|
67 |
10 |
petebleack |
DATA <= ((0)=>'1', others => '0');
|
68 |
7 |
petebleack |
DATA_OUT <= (others => '0');
|
69 |
10 |
petebleack |
CALC_COMPLETE <= '0';
|
70 |
7 |
petebleack |
MODE <= '0';
|
71 |
10 |
petebleack |
elsif CALC_COMPLETE = '1' then
|
72 |
|
|
DATA <= ((0)=> '1',others => '0');
|
73 |
7 |
petebleack |
CALC_COMPLETE <= '0';
|
74 |
|
|
MODE <= '0';
|
75 |
|
|
elsif ENABLE = '1' then --IF DATA IS BEING INPUT
|
76 |
10 |
petebleack |
if MODE = '0' then --FOR "FOLLOW_ON" BITS
|
77 |
|
|
CALC_COMPLETE <= DATA_IN;
|
78 |
7 |
petebleack |
MODE <= '1';
|
79 |
10 |
petebleack |
if DATA_IN = '1' then
|
80 |
|
|
DATA_OUT <= DATA - "00000000000000000000000000000001";
|
81 |
|
|
end if;
|
82 |
|
|
else --IN MODE 1 (FOR DATA_BITS)
|
83 |
|
|
DATA <= DATA (30 downto 0) & DATA_IN;
|
84 |
|
|
MODE <= '0';
|
85 |
7 |
petebleack |
end if;
|
86 |
|
|
end if;
|
87 |
|
|
end if;
|
88 |
|
|
end process READ_DATA;
|
89 |
|
|
|
90 |
|
|
READY <= CALC_COMPLETE;
|
91 |
|
|
|
92 |
|
|
end RTL;
|