vi_gamma.v
1.94 KB
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
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
// $Id: vi_gamma.v,v 1.1 2002/05/21 23:55:45 berndt Exp $
////////////////////////////////////////////////////////////////////////
//
// Project Reality
//
// module: vi_gamma
// description: Gamma correction for video interface.
//
// designer: Phil Gossett
// date: 10/30/94
//
////////////////////////////////////////////////////////////////////////
module vi_gamma (vclk, gamma_dither_enable, gamma_enable, rgb, rand, sync,
gamma_rgb, gamma_sync);
input vclk;
input gamma_enable;
input gamma_dither_enable;
input [7:0] rgb;
input [5:0] rand;
input sync;
output [6:0] gamma_rgb;
output gamma_sync;
wire [6:0] sqrt_rgb;
wire [7:0] dither_rgb;
wire blank;
reg blank_reg;
reg [6:0] gamma_rgb;
reg gamma_sync;
vi_gamma_sqrt viga (.a({rgb,(rand & {6{gamma_dither_enable}})}), .q(sqrt_rgb));
assign dither_rgb = (rgb == 8'hFF) ?
8'hFF :
(rgb + {7'b0,(rand[5] & gamma_dither_enable)});
assign blank = sync ? rgb[7] : blank_reg;
always @(posedge vclk)
begin
blank_reg <= blank;
gamma_rgb <= sync ?
{3'b0,rgb[4:1]} :
({7{~blank}} & (gamma_enable ?
sqrt_rgb :
dither_rgb[7:1]));
gamma_sync <= sync;
end
endmodule // vi_gamma