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

Subversion Repositories dirac

[/] [dirac/] [trunk/] [src/] [common/] [UPDATER.vhd] - Blame information for rev 10

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

Line No. Rev Author Line
1 8 petebleack
-- ***** BEGIN LICENSE BLOCK *****
2
-- 
3 10 petebleack
-- $Id: UPDATER.vhd,v 1.2 2006-10-05 16:17:11 petebleackley Exp $ $Name: not supported by cvs2svn $
4
-- *
5
-- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
-- *
7
-- * The contents of this file are subject to the Mozilla Public License
8
-- * Version 1.1 (the "License"); you may not use this file except in compliance
9
-- * with the License. You may obtain a copy of the License at
10
-- * http://www.mozilla.org/MPL/
11
-- *
12
-- * Software distributed under the License is distributed on an "AS IS" basis,
13
-- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14
-- * the specific language governing rights and limitations under the License.
15
-- *
16
-- * The Original Code is BBC Research and Development code.
17
-- *
18
-- * The Initial Developer of the Original Code is the British Broadcasting
19
-- * Corporation.
20
-- * Portions created by the Initial Developer are Copyright (C) 2004.
21
-- * All Rights Reserved.
22
-- *
23
-- * Contributor(s): Peter Bleackley (Original author)
24
-- *
25
-- * Alternatively, the contents of this file may be used under the terms of
26
-- * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
27
-- * Public License Version 2.1 (the "LGPL"), in which case the provisions of
28
-- * the GPL or the LGPL are applicable instead of those above. If you wish to
29
-- * allow use of your version of this file only under the terms of the either
30
-- * the GPL or LGPL and not to allow others to use your version of this file
31
-- * under the MPL, indicate your decision by deleting the provisions above
32
-- * and replace them with the notice and other provisions required by the GPL
33
-- * or LGPL. If you do not delete the provisions above, a recipient may use
34
-- * your version of this file under the terms of any one of the MPL, the GPL
35
-- * or the LGPL.
36 8 petebleack
-- * ***** END LICENSE BLOCK ***** */
37
 
38
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 lines to use the declarations that are
44
--  provided for instantiating Xilinx primitive components.
45
--library UNISIM;
46
--use UNISIM.VComponents.all;
47
 
48
entity UPDATER is
49 10 petebleack
    Port ( NUMERATOR : in std_logic_vector(7 downto 0);
50
           DENOMINATOR : in std_logic_vector(7 downto 0);
51 8 petebleack
           ENABLE : in std_logic;
52
           DATA_IN : in std_logic;
53
           RESET : in std_logic;
54
           CLOCK : in std_logic;
55 10 petebleack
           NUMERATOR_OUT : out std_logic_vector(7 downto 0);
56
           DENOMINATOR_OUT : out std_logic_vector(7 downto 0);
57 8 petebleack
                          UPDATE : out std_logic);
58
end UPDATER;
59
 
60
architecture RTL of UPDATER is
61 10 petebleack
        signal NUMERATOR1 : std_logic_vector(7 downto 0);
62
        signal NUMERATOR2 : std_logic_vector(7 downto 0);
63
        signal NUMERATOR3 : std_logic_vector(7 downto 0);
64
        signal NUMERATOR4       : std_logic_vector(7 downto 0);
65
        signal DENOMINATOR2 : std_logic_vector(7 downto 0);
66 8 petebleack
        signal HALVE_VALUES : std_logic;
67
        signal UPDATE_SWITCH : std_logic;
68
begin
69
 
70
DELAY_NUMERATOR : process (CLOCK)
71
begin
72
        if CLOCK'event and CLOCK='1' then
73
                if RESET='1' then
74 10 petebleack
                        NUMERATOR1<="00000001";
75 8 petebleack
                else
76
                        NUMERATOR1<=NUMERATOR;
77
                end if;
78
        end if;
79
end process DELAY_NUMERATOR;
80
 
81
INCREMENT_NUMERATOR : process (CLOCK)
82
begin
83
        if CLOCK'event and CLOCK = '1' then
84
                if RESET = '1' then
85 10 petebleack
                        NUMERATOR2 <= "00000001";
86 8 petebleack
                else
87 10 petebleack
                        NUMERATOR2 <= NUMERATOR + "00000001";
88 8 petebleack
                end if;
89
        end if;
90
end process INCREMENT_NUMERATOR;
91
 
92
HALVE_NUMERATOR : process (CLOCK)
93
begin
94
        if CLOCK'event and CLOCK='1' then
95
                if RESET='1' then
96 10 petebleack
                        NUMERATOR3 <= "00000001";
97 8 petebleack
                else
98 10 petebleack
                                NUMERATOR3 <= ('0' & NUMERATOR(7 downto 1)) + "00000001";
99 8 petebleack
                end if;
100
        end if;
101
end process HALVE_NUMERATOR;
102
 
103
INCREMENT_AND_HALVE_NUMERATOR : process (CLOCK)
104
begin
105
        if CLOCK'event and CLOCK='1' then
106
                if RESET='1' then
107 10 petebleack
                        NUMERATOR4 <= "00000001";
108 8 petebleack
                else
109 10 petebleack
                        NUMERATOR4 <= ('0' & NUMERATOR(7 downto 1)) + "00000001" + ("0000000" & NUMERATOR(0));
110 8 petebleack
                end if;
111
        end if;
112
end process INCREMENT_AND_HALVE_NUMERATOR;
113
 
114
INCREMENT_DENOMINATOR : process (CLOCK)
115
begin
116
        if CLOCK'event and CLOCK='1' then
117
                if RESET='1' then
118 10 petebleack
                        DENOMINATOR2 <= "00000010";
119 8 petebleack
                else
120 10 petebleack
                        DENOMINATOR2 <= DENOMINATOR + "00000001";
121 8 petebleack
                end if;
122
        end if;
123
end process INCREMENT_DENOMINATOR;
124
 
125
HALVE_DENOMINATOR : process (DENOMINATOR)
126
begin
127 10 petebleack
        if (DENOMINATOR = "11111111") then
128 8 petebleack
                HALVE_VALUES <= '1';
129
        else
130
                HALVE_VALUES <= '0';
131
        end if;
132
end process HALVE_DENOMINATOR;
133
 
134
OUTPUT_NUMERATOR : process(NUMERATOR1,NUMERATOR2,NUMERATOR3,NUMERATOR4,DENOMINATOR,DATA_IN,HALVE_VALUES)
135
begin
136
        if HALVE_VALUES='1' then
137
                if DATA_IN='1' then
138
                        NUMERATOR_OUT <= NUMERATOR3;
139
                else
140
                        NUMERATOR_OUT <= NUMERATOR4;
141
                end if;
142
        else
143
                if DATA_IN='1' then
144
                        NUMERATOR_OUT <= NUMERATOR1;
145
                else
146
                        NUMERATOR_OUT <= NUMERATOR2;
147
                end if;
148
        end if;
149
end process OUTPUT_NUMERATOR;
150
 
151
UPDATE_SWITCH <= DATA_IN xor NUMERATOR(0);
152
 
153 10 petebleack
OUTPUT_DENOMINATOR : process(DENOMINATOR,DENOMINATOR2,UPDATE_SWITCH,HALVE_VALUES)
154 8 petebleack
begin
155
        if HALVE_VALUES='1' then
156
                if UPDATE_SWITCH = '1' then
157 10 petebleack
                        DENOMINATOR_OUT <= "10000010";
158 8 petebleack
                else
159 10 petebleack
                        DENOMINATOR_OUT <= "10000001";
160 8 petebleack
                end if;
161
        else
162
                DENOMINATOR_OUT<=DENOMINATOR2;
163
        end if;
164
end process OUTPUT_DENOMINATOR;
165
 
166
OUTPUT_READY : process (CLOCK)
167
begin
168
        if CLOCK'event and CLOCK='1' then
169
                if RESET='1' then
170
                        UPDATE <= '0';
171
                else
172
                        UPDATE <=  ENABLE;
173
                end if;
174
        end if;
175
end process OUTPUT_READY;
176
 
177
end RTL;

powered by: WebSVN 2.1.0

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