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

Subversion Repositories warp

[/] [warp/] [rtl/] [tmu_scandivops.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
module tmu_scandivops(
20
        input sys_clk,
21
        input sys_rst,
22
 
23
        output busy,
24
 
25
        input pipe_stb_i,
26
        output pipe_ack_o,
27
        input [10:0] Y0,
28
        input [10:0] S_X0,
29
        input [10:0] S_U0,
30
        input [10:0] S_V0,
31
        input [10:0] E_X0,
32
        input [10:0] E_U0,
33
        input [10:0] E_V0,
34
 
35
        output pipe_stb_o,
36
        input pipe_ack_i,
37
        /* Points pass-through */
38
        output reg [10:0] Y,
39
        output reg [10:0] S_X,
40
        output reg [10:0] S_U,
41
        output reg [10:0] S_V,
42
        output reg [10:0] E_X,
43
        /* Dividends */
44
        output reg du_positive,
45
        output reg [10:0] du,
46
        output reg dv_positive,
47
        output reg [10:0] dv,
48
        /* Common divisor */
49
        output reg [10:0] divisor
50
);
51
 
52
wire en;
53
wire s0_valid;
54
reg s1_valid;
55
 
56
always @(posedge sys_clk) begin
57
        if(sys_rst)
58
                s1_valid = 1'b0;
59
        else if(en)
60
                s1_valid = s0_valid;
61
end
62
 
63
always @(posedge sys_clk) begin
64
        if(en) begin
65
                /* Find signs (whether we will increment or decrement later on) */
66
                du_positive = E_U0 > S_U0;
67
                dv_positive = E_V0 > S_V0;
68
 
69
                if(du_positive)
70
                        du = E_U0 - S_U0;
71
                else
72
                        du = S_U0 - E_U0;
73
                if(dv_positive)
74
                        dv = E_V0 - S_V0;
75
                else
76
                        dv = S_V0 - E_V0;
77
 
78
                if(E_X0 != S_X0)
79
                        divisor = E_X0 - S_X0;
80
                else
81
                        divisor = 11'd1;
82
        end
83
end
84
 
85
always @(posedge sys_clk) begin
86
        if(en) begin
87
                Y <= Y0;
88
                S_X <= S_X0;
89
                S_U <= S_U0;
90
                S_V <= S_V0;
91
                E_X <= E_X0;
92
        end
93
end
94
 
95
/* Pipeline management */
96
 
97
assign busy = s1_valid;
98
 
99
assign s0_valid = pipe_stb_i;
100
assign pipe_ack_o = pipe_ack_i;
101
 
102
assign en = pipe_ack_i;
103
assign pipe_stb_o = s1_valid;
104
 
105
endmodule

powered by: WebSVN 2.1.0

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