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

Subversion Repositories warp

[/] [warp/] [rtl/] [tmu_divider11.v] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 lekernel
/*
2
 * Milkymist VJ SoC
3
 * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
4
 *
5
 * This program is free and excepted software; you can use it, redistribute it
6
 * and/or modify it under the terms of the Exception General Public License as
7
 * published by the Exception License Foundation; either version 2 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful, but WITHOUT
11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
 * FOR A PARTICULAR PURPOSE. See the Exception General Public License for more
13
 * details.
14
 *
15
 * You should have received a copy of the Exception General Public License along
16
 * with this project; if not, write to the Exception License Foundation.
17
 */
18
 
19
/* 11-bit, 11-cycle integer divider, non pipelined */
20
 
21
module tmu_divider11(
22
        input sys_clk,
23
        input sys_rst,
24
 
25
        input start,
26
        input [10:0] dividend,
27
        input [10:0] divisor,
28
 
29
        output ready,
30
        output [10:0] quotient,
31
        output [10:0] remainder
32
);
33
 
34
reg [21:0] qr;
35
 
36
assign remainder = qr[21:11];
37
assign quotient = qr[10:0];
38
 
39
reg [3:0] counter;
40
assign ready = (counter == 4'd0);
41
 
42
reg [10:0] divisor_r;
43
 
44
wire [11:0] diff = qr[21:10] - {1'b0, divisor_r};
45
 
46
always @(posedge sys_clk) begin
47
        if(sys_rst)
48
                counter = 4'd0;
49
        else begin
50
                if(start) begin
51
                        counter = 4'd11;
52
                        qr = {11'd0, dividend};
53
                        divisor_r = divisor;
54
                end else begin
55
                        if(~ready) begin
56
                                if(diff[11])
57
                                        qr = {qr[20:0], 1'b0};
58
                                else
59
                                        qr = {diff[10:0], qr[9:0], 1'b1};
60
                                counter = counter - 4'd1;
61
                        end
62
                end
63
        end
64
end
65
 
66
endmodule

powered by: WebSVN 2.1.0

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