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

Subversion Repositories dirac

[/] [dirac/] [trunk/] [src/] [common/] [Divider.vhd] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 petebleack
-- ***** BEGIN LICENSE BLOCK *****
2
-- 
3 10 petebleack
-- $Id: Divider.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 Divider 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
                          RESET : in std_logic;
52
           CLOCK : in std_logic;
53 10 petebleack
           QUOTIENT : out std_logic_vector(7 downto 0));
54 8 petebleack
end Divider;
55
 
56
architecture RTL of Divider is
57 10 petebleack
        signal NUMERATOR2 : std_logic_vector(7 downto 0);
58
        signal DENOMINATOR2 : std_logic_vector(7 downto 0);
59
        signal RECIPROCAL : std_logic_vector(15 downto 0);
60
        signal PRODUCT : std_logic_vector(23 downto 0);
61
        signal INDEX : std_logic_vector (7 downto 0);
62
        type ROM is array (253 downto 0) of std_logic_vector(15 downto 0);
63
        constant LUT : ROM :=  ( "0000000100000001",
64
"0000000100000010",
65
"0000000100000011",
66
"0000000100000100",
67
"0000000100000101",
68
"0000000100000110",
69
"0000000100000111",
70
"0000000100001000",
71
"0000000100001001",
72
"0000000100001010",
73
"0000000100001011",
74
"0000000100001101",
75
"0000000100001110",
76
"0000000100001111",
77
"0000000100010000",
78
"0000000100010001",
79
"0000000100010010",
80
"0000000100010011",
81
"0000000100010101",
82
"0000000100010110",
83
"0000000100010111",
84
"0000000100011000",
85
"0000000100011001",
86
"0000000100011010",
87
"0000000100011100",
88
"0000000100011101",
89
"0000000100011110",
90
"0000000100011111",
91
"0000000100100001",
92
"0000000100100010",
93
"0000000100100011",
94
"0000000100100101",
95
"0000000100100110",
96
"0000000100100111",
97
"0000000100101001",
98
"0000000100101010",
99
"0000000100101011",
100
"0000000100101101",
101
"0000000100101110",
102
"0000000100101111",
103
"0000000100110001",
104
"0000000100110010",
105
"0000000100110100",
106
"0000000100110101",
107
"0000000100110111",
108
"0000000100111000",
109
"0000000100111010",
110
"0000000100111011",
111
"0000000100111101",
112
"0000000100111110",
113
"0000000101000000",
114
"0000000101000001",
115
"0000000101000011",
116
"0000000101000100",
117
"0000000101000110",
118
"0000000101001000",
119
"0000000101001001",
120
"0000000101001011",
121
"0000000101001101",
122
"0000000101001110",
123
"0000000101010000",
124
"0000000101010010",
125
"0000000101010100",
126
"0000000101010101",
127
"0000000101010111",
128
"0000000101011001",
129
"0000000101011011",
130
"0000000101011101",
131
"0000000101011110",
132
"0000000101100000",
133
"0000000101100010",
134
"0000000101100100",
135
"0000000101100110",
136
"0000000101101000",
137
"0000000101101010",
138
"0000000101101100",
139
"0000000101101110",
140
"0000000101110000",
141
"0000000101110010",
142
"0000000101110100",
143
"0000000101110110",
144
"0000000101111001",
145
"0000000101111011",
146
"0000000101111101",
147
"0000000101111111",
148
"0000000110000010",
149
"0000000110000100",
150
"0000000110000110",
151
"0000000110001000",
152
"0000000110001011",
153
"0000000110001101",
154
"0000000110010000",
155
"0000000110010010",
156
"0000000110010101",
157
"0000000110010111",
158
"0000000110011010",
159
"0000000110011100",
160
"0000000110011111",
161
"0000000110100001",
162
"0000000110100100",
163
"0000000110100111",
164
"0000000110101010",
165
"0000000110101100",
166
"0000000110101111",
167
"0000000110110010",
168
"0000000110110101",
169
"0000000110111000",
170
"0000000110111011",
171
"0000000110111110",
172
"0000000111000001",
173
"0000000111000100",
174
"0000000111000111",
175
"0000000111001010",
176
"0000000111001110",
177
"0000000111010001",
178
"0000000111010100",
179
"0000000111010111",
180
"0000000111011011",
181
"0000000111011110",
182
"0000000111100010",
183
"0000000111100101",
184
"0000000111101001",
185
"0000000111101101",
186
"0000000111110000",
187
"0000000111110100",
188
"0000000111111000",
189
"0000000111111100",
190
"0000001000000000",
191
"0000001000000100",
192
"0000001000001000",
193
"0000001000001100",
194
"0000001000010001",
195
"0000001000010101",
196
"0000001000011001",
197
"0000001000011110",
198
"0000001000100010",
199
"0000001000100111",
200
"0000001000101011",
201
"0000001000110000",
202
"0000001000110101",
203
"0000001000111010",
204
"0000001000111111",
205
"0000001001000100",
206
"0000001001001001",
207
"0000001001001110",
208
"0000001001010100",
209
"0000001001011001",
210
"0000001001011111",
211
"0000001001100100",
212
"0000001001101010",
213
"0000001001110000",
214
"0000001001110110",
215
"0000001001111100",
216
"0000001010000011",
217
"0000001010001001",
218
"0000001010001111",
219
"0000001010010110",
220
"0000001010011101",
221
"0000001010100100",
222
"0000001010101011",
223
"0000001010110010",
224
"0000001010111001",
225
"0000001011000001",
226
"0000001011001000",
227
"0000001011010000",
228
"0000001011011000",
229
"0000001011100000",
230
"0000001011101001",
231
"0000001011110001",
232
"0000001011111010",
233
"0000001100000011",
234
"0000001100001100",
235
"0000001100010110",
236
"0000001100011111",
237
"0000001100101001",
238
"0000001100110011",
239
"0000001100111110",
240
"0000001101001000",
241
"0000001101010011",
242
"0000001101011110",
243
"0000001101101010",
244
"0000001101110110",
245
"0000001110000010",
246
"0000001110001110",
247
"0000001110011011",
248
"0000001110101000",
249
"0000001110110110",
250
"0000001111000100",
251
"0000001111010010",
252
"0000001111100001",
253
"0000001111110000",
254
"0000010000000000",
255
"0000010000010000",
256
"0000010000100001",
257
"0000010000110010",
258
"0000010001000100",
259
"0000010001010111",
260
"0000010001101010",
261
"0000010001111110",
262
"0000010010010010",
263
"0000010010101000",
264
"0000010010111110",
265
"0000010011010101",
266
"0000010011101100",
267
"0000010100000101",
268
"0000010100011111",
269
"0000010100111001",
270
"0000010101010101",
271
"0000010101110010",
272
"0000010110010001",
273
"0000010110110000",
274
"0000010111010001",
275
"0000010111110100",
276
"0000011000011000",
277
"0000011000111110",
278
"0000011001100110",
279
"0000011010010000",
280
"0000011010111101",
281
"0000011011101011",
282
"0000011100011100",
283
"0000011101010000",
284
"0000011110001000",
285
"0000011111000010",
286
"0000100000000000",
287
"0000100001000010",
288
"0000100010001001",
289
"0000100011010100",
290
"0000100100100101",
291
"0000100101111011",
292
"0000100111011001",
293
"0000101000111101",
294
"0000101010101011",
295
"0000101100100001",
296
"0000101110100011",
297
"0000110000110001",
298
"0000110011001101",
299
"0000110101111001",
300
"0000111000111001",
301
"0000111100001111",
302
"0001000000000000",
303
"0001000100010001",
304
"0001001001001001",
305
"0001001110110001",
306
"0001010101010101",
307
"0001011101000110",
308
"0001100110011010",
309
"0001110001110010",
310
"0010000000000000",
311
"0010010010010010",
312
"0010101010101011",
313
"0011001100110011",
314
"0100000000000000",
315
"0101010101010101",
316
"1000000000000000");
317 8 petebleack
begin
318
 
319
INIT : process(DENOMINATOR,RESET)
320
begin
321
        if RESET = '1' then
322 10 petebleack
                DENOMINATOR2 <= "00000010";
323 8 petebleack
        else
324
                DENOMINATOR2 <= DENOMINATOR;
325
        end if;
326
end process INIT;
327
 
328
SETNUMERATOR : process (CLOCK)
329
begin
330
        if CLOCK'event and CLOCK = '1' then
331
                if RESET = '1' then
332 10 petebleack
                        NUMERATOR2 <= "00000001";
333 8 petebleack
                else
334
                        NUMERATOR2 <= NUMERATOR;
335
                end if;
336
        end if;
337
end process SETNUMERATOR;
338
 
339
 
340 10 petebleack
INDEX <= DENOMINATOR2 - "00000010";
341 8 petebleack
 
342
LOOKUP: process(CLOCK)
343
begin
344
        if CLOCK'event and CLOCK = '1' then
345
                 RECIPROCAL <= LUT(conv_integer(INDEX));
346
        end if;
347
end process LOOKUP;
348
 
349 10 petebleack
DIVIDE: process(CLOCK)
350 8 petebleack
begin
351
        if CLOCK'event and CLOCK='1' then
352 10 petebleack
                PRODUCT<=NUMERATOR2*RECIPROCAL;
353 8 petebleack
        end if;
354 10 petebleack
end process DIVIDE;
355 8 petebleack
 
356
 
357 10 petebleack
QUOTIENT <=      PRODUCT(15 downto 8);
358 8 petebleack
 
359
 
360
end RTL;

powered by: WebSVN 2.1.0

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