1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// --------------------------------------------------------------------
// Copyright (c) 2007 by Terasic Technologies Inc.
// --------------------------------------------------------------------
//
// Permission:
//
// Terasic grants permission to use and modify this code for use
// in synthesis for all Terasic Development Boards and Altera Development
// Kits made by Terasic. Other use of this code, including the selling
// ,duplication, or modification of any portion is strictly prohibited.
//
// Disclaimer:
//
// This VHDL/Verilog or C/C++ source code is intended as a design reference
// which illustrates how these types of functions can be implemented.
// It is the user's responsibility to verify their design for
// consistency and functionality through the use of formal
// verification methods. Terasic provides no warranty regarding the use
// or functionality of this code.
//
// --------------------------------------------------------------------
//
// Terasic Technologies Inc
// 356 Fu-Shin E. Rd Sec. 1. JhuBei City,
// HsinChu County, Taiwan
// 302
//
// web: http://www.terasic.com/
// email: support@terasic.com
//
// --------------------------------------------------------------------
//
// Major Functions: RAW2RGB
//
// --------------------------------------------------------------------
//
// Revision History :
// --------------------------------------------------------------------
// Ver :| Author :| Mod. Date :| Changes Made:
// V1.0 :| Johnny FAN :| 07/07/09 :| Initial Revision
// --------------------------------------------------------------------
module RAW2RGB( oRed,
oGreen,
oBlue,
oDVAL,
iX_Cont,
iY_Cont,
iDATA,
iDVAL,
iCLK,
iRST
);
input [10:0] iX_Cont;
input [10:0] iY_Cont;
input [11:0] iDATA;
input iDVAL;
input iCLK;
input iRST;
output [11:0] oRed;
output [11:0] oGreen;
output [11:0] oBlue;
output oDVAL;
wire [11:0] mDATA_0;
wire [11:0] mDATA_1;
reg [11:0] mDATAd_0;
reg [11:0] mDATAd_1;
reg [11:0] mCCD_R;
reg [12:0] mCCD_G;
reg [11:0] mCCD_B;
reg mDVAL;
assign oRed = mCCD_R[11:0];
assign oGreen = mCCD_G[12:1];
assign oBlue = mCCD_B[11:0];
assign oDVAL = mDVAL;
Line_Buffer u0 ( .clken(iDVAL),
.clock(iCLK),
.shiftin(iDATA),
.taps0x(mDATA_1),
.taps1x(mDATA_0) );
always@(posedge iCLK or negedge iRST)
begin
if(!iRST)
begin
mCCD_R <= 0;
mCCD_G <= 0;
mCCD_B <= 0;
mDATAd_0<= 0;
mDATAd_1<= 0;
mDVAL <= 0;
end
else
begin
mDATAd_0 <= mDATA_0;
mDATAd_1 <= mDATA_1;
mDVAL <= {iY_Cont[0]|iX_Cont[0]} ? 1'b0 : iDVAL;
if({iY_Cont[0],iX_Cont[0]}==2'b10)
begin
mCCD_R <= mDATA_0;
mCCD_G <= mDATAd_0+mDATA_1;
mCCD_B <= mDATAd_1;
end
else if({iY_Cont[0],iX_Cont[0]}==2'b11)
begin
mCCD_R <= mDATAd_0;
mCCD_G <= mDATA_0+mDATAd_1;
mCCD_B <= mDATA_1;
end
else if({iY_Cont[0],iX_Cont[0]}==2'b00)
begin
mCCD_R <= mDATA_1;
mCCD_G <= mDATA_0+mDATAd_1;
mCCD_B <= mDATAd_0;
end
else if({iY_Cont[0],iX_Cont[0]}==2'b01)
begin
mCCD_R <= mDATAd_1;
mCCD_G <= mDATAd_0+mDATA_1;
mCCD_B <= mDATA_0;
end
end
end
endmodule
|