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

Subversion Repositories warp

[/] [warp/] [rtl/] [tmu_decay.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_decay #(
20
        parameter fml_depth = 26
21
) (
22
        input sys_clk,
23
        input sys_rst,
24
 
25
        output busy,
26
 
27
        input [5:0] brightness,
28
 
29
        input pipe_stb_i,
30
        output pipe_ack_o,
31
        input [15:0] src_pixel,
32
        input [fml_depth-1-1:0] dst_addr,
33
 
34
        output pipe_stb_o,
35
        input pipe_ack_i,
36
        output [15:0] src_pixel_d,
37
        output reg [fml_depth-1-1:0] dst_addr1
38
);
39
 
40
wire en;
41
wire s0_valid;
42
reg s1_valid;
43
reg s2_valid;
44
reg s3_valid;
45
 
46
always @(posedge sys_clk) begin
47
        if(sys_rst) begin
48
                s1_valid <= 1'b0;
49
                s2_valid <= 1'b0;
50
                s3_valid <= 1'b0;
51
        end else if(en) begin
52
                s1_valid <= s0_valid;
53
                s2_valid <= s1_valid;
54
                s3_valid <= s2_valid;
55
        end
56
end
57
 
58
/* Pipeline operation on three stages. */
59
 
60
reg [fml_depth-1-1:0] s1_dst_addr;
61
reg [fml_depth-1-1:0] s2_dst_addr;
62
/* third stage register is output */
63
 
64
reg s1_full_brightness;
65
reg s2_full_brightness;
66
reg s3_full_brightness;
67
 
68
reg [15:0] s1_pixel_full;
69
reg [15:0] s2_pixel_full;
70
reg [15:0] s3_pixel_full;
71
 
72
wire [5:0] brightness1 = brightness + 6'd1;
73
reg [5:0] s1_brightness1;
74
 
75
wire [4:0] r = src_pixel[15:11];
76
wire [5:0] g = src_pixel[10:5];
77
wire [4:0] b = src_pixel[4:0];
78
 
79
reg [4:0] s1_r;
80
reg [5:0] s1_g;
81
reg [4:0] s1_b;
82
 
83
reg [10:0] s2_r;
84
reg [11:0] s2_g;
85
reg [10:0] s2_b;
86
 
87
reg [10:0] s3_r;
88
reg [11:0] s3_g;
89
reg [10:0] s3_b;
90
 
91
always @(posedge sys_clk) begin
92
        if(en) begin
93
                s1_dst_addr <= dst_addr;
94
                s2_dst_addr <= s1_dst_addr;
95
                dst_addr1 <= s2_dst_addr;
96
 
97
                s1_full_brightness <= brightness == 6'b111111;
98
                s2_full_brightness <= s1_full_brightness;
99
                s3_full_brightness <= s2_full_brightness;
100
 
101
                s1_pixel_full <= src_pixel;
102
                s2_pixel_full <= s1_pixel_full;
103
                s3_pixel_full <= s2_pixel_full;
104
 
105
                s1_r <= r;
106
                s1_g <= g;
107
                s1_b <= b;
108
                s1_brightness1 <= brightness1;
109
 
110
                s2_r <= s1_brightness1*s1_r;
111
                s2_g <= s1_brightness1*s1_g;
112
                s2_b <= s1_brightness1*s1_b;
113
 
114
                s3_r <= s2_r;
115
                s3_g <= s2_g;
116
                s3_b <= s2_b;
117
        end
118
end
119
 
120
assign src_pixel_d = s3_full_brightness ? s3_pixel_full : {s3_r[10:6], s3_g[11:6], s3_b[10:6]};
121
 
122
/* Pipeline management */
123
 
124
assign busy = s1_valid|s2_valid|s3_valid;
125
 
126
assign s0_valid = pipe_stb_i;
127
assign pipe_ack_o = pipe_ack_i;
128
 
129
assign en = pipe_ack_i;
130
assign pipe_stb_o = s3_valid;
131
 
132
endmodule

powered by: WebSVN 2.1.0

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