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

Subversion Repositories warp

[/] [warp/] [rtl/] [tmu_scandiv.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_scandiv(
20
        input sys_clk,
21
        input sys_rst,
22
 
23
        output busy,
24
 
25
        input pipe_stb_i,
26
        output reg 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 du0_positive,
33
        input [10:0] du0,
34
        input dv0_positive,
35
        input [10:0] dv0,
36
        input [10:0] divisor0,
37
 
38
        output reg pipe_stb_o,
39
        input pipe_ack_i,
40
        output reg [10:0] Y,
41
        output reg [10:0] S_X,
42
        output reg [10:0] S_U,
43
        output reg [10:0] S_V,
44
        output reg [10:0] E_X,
45
        output reg du_positive,
46
        output [10:0] du_q,
47
        output [10:0] du_r,
48
        output reg dv_positive,
49
        output [10:0] dv_q,
50
        output [10:0] dv_r,
51
        output reg [10:0] divisor
52
);
53
 
54
/* Divider bank */
55
 
56
reg start;
57
wire ready;
58
 
59
tmu_divider11 d_du(
60
        .sys_clk(sys_clk),
61
        .sys_rst(sys_rst),
62
 
63
        .start(start),
64
        .dividend(du0),
65
        .divisor(divisor0),
66
 
67
        .ready(ready),
68
        .quotient(du_q),
69
        .remainder(du_r)
70
);
71
tmu_divider11 d_dv(
72
        .sys_clk(sys_clk),
73
        .sys_rst(sys_rst),
74
 
75
        .start(start),
76
        .dividend(dv0),
77
        .divisor(divisor0),
78
 
79
        .ready(),
80
        .quotient(dv_q),
81
        .remainder(dv_r)
82
);
83
 
84
/* Pipeline pass-through */
85
 
86
always @(posedge sys_clk) begin
87
        if(start) begin
88
                Y <= Y0;
89
                S_X <= S_X0;
90
                S_U <= S_U0;
91
                S_V <= S_V0;
92
                E_X <= E_X0;
93
                du_positive <= du0_positive;
94
                dv_positive <= dv0_positive;
95
                divisor <= divisor0;
96
        end
97
end
98
 
99
/* Glue logic */
100
 
101
reg state;
102
reg next_state;
103
 
104
parameter IDLE = 1'b0;
105
parameter WAIT = 1'b1;
106
 
107
always @(posedge sys_clk) begin
108
        if(sys_rst)
109
                state = IDLE;
110
        else
111
                state = next_state;
112
end
113
 
114
assign busy = state;
115
 
116
always @(*) begin
117
        next_state = state;
118
 
119
        start = 1'b0;
120
        pipe_stb_o = 1'b0;
121
        pipe_ack_o = 1'b0;
122
 
123
        case(state)
124
                IDLE: begin
125
                        pipe_ack_o = 1'b1;
126
                        if(pipe_stb_i) begin
127
                                start = 1'b1;
128
                                next_state = WAIT;
129
                        end
130
                end
131
                WAIT: begin
132
                        if(ready) begin
133
                                pipe_stb_o = 1'b1;
134
                                if(pipe_ack_i)
135
                                        next_state = IDLE;
136
                        end
137
                end
138
        endcase
139
end
140
 
141
endmodule

powered by: WebSVN 2.1.0

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