User`s manual
81 /*always @ (posedge clk or posedge rst)
82 if (rst)
83 begin
84 R_int <= 0; G_int <= 0; B_int <= 0;
85 end
86 else
87 begin
88 X_int <= (const1 * (Y_reg - ’d64)) ;
89 R_int <= X_int + (const2 * (Cr_reg - ’d512));
90 G_int <= X_int - (const3 * (Cr_reg - ’d512)) - (const4 * (Cb_reg - ’d512));
91 B_int <= X_int + (const5 * (Cb_reg - ’d512));
92 end
93
94 */
95 /* limit output to 0 - 4095, <0 equals o and >4095 equals 4095 */
96 assign R = (R_int[20]) ? 0 : (R_int[19:18] == 2’b0) ? R_int[17:10] : 8’b11111111;
97 assign G = (G_int[20]) ? 0 : (G_int[19:18] == 2’b0) ? G_int[17:10] : 8’b11111111;
98 assign B = (B_int[20]) ? 0 : (B_int[19:18] == 2’b0) ? B_int[17:10] : 8’b11111111;
99
100 endmodule
A.1.7 ntsc2zbt.v
1 /**
2 NOTE: Code borrowed heavily from Pranav Kaundinya, et. al. (2012).
3 */
4
5 module ntsc_to_bram(clk, vclk, fvh, dv, din, ntsc_addr, ntsc_data, ntsc_we, sw);
6
7 input clk; // system clock
8 input vclk; // video clock from camera
9 input [2:0] fvh;
10 input dv;
11 input [29:0] din;
12 input sw;
13 output reg [16:0] ntsc_addr;
14 output reg [11:0] ntsc_data;
15 output ntsc_we; // write enable for NTSC data
16 parameter COL_START = 10’d0;
17 parameter ROW_START = 10’d0;
18
19 reg [9:0] col = 0;
20 reg [9:0] row = 0;
21 reg [29:0] vdata = 0;
22 reg vwe;
23 reg old_dv;
41