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

Subversion Repositories warp

[/] [warp/] [rtl/] [tmu_pixout.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_pixout #(
20
        parameter fml_depth = 26
21
) (
22
        input sys_clk,
23
        input sys_rst,
24
 
25
        output reg busy,
26
 
27
        input pipe_stb_i,
28
        output reg pipe_ack_o,
29
        input [fml_depth-5-1:0] burst_addr,
30
        input [15:0] burst_sel,
31
        input [255:0] burst_do,
32
 
33
        output reg [fml_depth-1:0] fml_adr,
34
        output reg fml_stb,
35
        input fml_ack,
36
        output reg [7:0] fml_sel,
37
        output reg [63:0] fml_do
38
);
39
 
40
reg [15:0] burst_sel_r;
41
reg [255:0] burst_do_r;
42
 
43
reg load;
44
always @(posedge sys_clk) begin
45
        if(load) begin
46
                fml_adr = {burst_addr, 5'd0};
47
                burst_sel_r = burst_sel;
48
                burst_do_r = burst_do;
49
        end
50
end
51
 
52
reg [1:0] bcounter;
53
always @(posedge sys_clk) begin
54
        case(bcounter)
55
                2'd0: begin
56
                        fml_sel <= {
57
                                burst_sel_r[15], burst_sel_r[15],
58
                                burst_sel_r[14], burst_sel_r[14],
59
                                burst_sel_r[13], burst_sel_r[13],
60
                                burst_sel_r[12], burst_sel_r[12]
61
                                };
62
                        fml_do <= burst_do_r[255:192];
63
                end
64
                2'd1: begin
65
                        fml_sel <= {
66
                                burst_sel_r[11], burst_sel_r[11],
67
                                burst_sel_r[10], burst_sel_r[10],
68
                                burst_sel_r[ 9], burst_sel_r[ 9],
69
                                burst_sel_r[ 8], burst_sel_r[ 8]
70
                                };
71
                        fml_do <= burst_do_r[191:128];
72
                end
73
                2'd2: begin
74
                        fml_sel <= {
75
                                burst_sel_r[ 7], burst_sel_r[ 7],
76
                                burst_sel_r[ 6], burst_sel_r[ 6],
77
                                burst_sel_r[ 5], burst_sel_r[ 5],
78
                                burst_sel_r[ 4], burst_sel_r[ 4]
79
                                };
80
                        fml_do <= burst_do_r[127: 64];
81
                end
82
                2'd3: begin
83
                        fml_sel <= {
84
                                burst_sel_r[ 3], burst_sel_r[ 3],
85
                                burst_sel_r[ 2], burst_sel_r[ 2],
86
                                burst_sel_r[ 1], burst_sel_r[ 1],
87
                                burst_sel_r[ 0], burst_sel_r[ 0]
88
                                };
89
                        fml_do <= burst_do_r[ 63:  0];
90
                end
91
        endcase
92
end
93
 
94
reg [1:0] state;
95
reg [1:0] next_state;
96
 
97
parameter IDLE  = 2'd0;
98
parameter WAIT  = 2'd1;
99
parameter XFER2 = 2'd2;
100
parameter XFER3 = 2'd3;
101
 
102
always @(posedge sys_clk) begin
103
        if(sys_rst)
104
                state <= IDLE;
105
        else
106
                state <= next_state;
107
end
108
 
109
always @(*) begin
110
        next_state = state;
111
 
112
        busy = 1'b1;
113
        pipe_ack_o = 1'b0;
114
        fml_stb = 1'b0;
115
 
116
        load = 1'b0;
117
        bcounter = 2'bxx;
118
 
119
        case(state)
120
                IDLE: begin
121
                        busy = 1'b0;
122
                        pipe_ack_o = 1'b1;
123
                        bcounter = 2'd0;
124
                        if(pipe_stb_i) begin
125
                                load = 1'b1;
126
                                next_state = WAIT;
127
                        end
128
                end
129
                WAIT: begin
130
                        fml_stb = 1'b1;
131
                        bcounter = 2'd0;
132
                        if(fml_ack) begin
133
                                bcounter = 2'd1;
134
                                next_state = XFER2;
135
                        end
136
                end
137
                XFER2: begin
138
                        bcounter = 2'd2;
139
                        next_state = XFER3;
140
                end
141
                XFER3: begin
142
                        bcounter = 2'd3;
143
                        next_state = IDLE;
144
                end
145
        endcase
146
end
147
 
148
endmodule

powered by: WebSVN 2.1.0

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