-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVGA_OSD_RAM.v
76 lines (73 loc) · 1.46 KB
/
VGA_OSD_RAM.v
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
module VGA_OSD_RAM ( // Read Out Side
oRed,
oGreen,
oBlue,
iVGA_ADDR,
iVGA_CLK,
// Write In Side
iWR_DATA,
iWR_ADDR,
iWR_EN,
iWR_CLK,
// CLUT
iON_R,
iON_G,
iON_B,
iOFF_R,
iOFF_G,
iOFF_B,
// Control Signals
iRST_N );
// Read Out Side
output reg [9:0] oRed;
output reg [9:0] oGreen;
output reg [9:0] oBlue;
input [18:0] iVGA_ADDR;
input iVGA_CLK;
// Write In Side
input [18:0] iWR_ADDR;
input iWR_DATA;
input iWR_EN;
input iWR_CLK;
// CLUT
input [9:0] iON_R;
input [9:0] iON_G;
input [9:0] iON_B;
input [9:0] iOFF_R;
input [9:0] iOFF_G;
input [9:0] iOFF_B;
// Control Signals
input iRST_N;
// Internal Registers/Wires
reg [2:0] ADDR_d;
reg [2:0] ADDR_dd;
wire [7:0] ROM_DATA;
always@(posedge iVGA_CLK or negedge iRST_N)
begin
if(!iRST_N)
begin
oRed <= 0;
oGreen <= 0;
oBlue <= 0;
ADDR_d <= 0;
ADDR_dd <= 0;
end
else
begin
ADDR_d <= iVGA_ADDR[2:0];
ADDR_dd <= ~ADDR_d;
oRed <= ROM_DATA[ADDR_dd]? iON_R:iOFF_R;
oGreen <= ROM_DATA[ADDR_dd]? iON_G:iOFF_G;
oBlue <= ROM_DATA[ADDR_dd]? iON_B:iOFF_B;
end
end
Img_RAM u0 ( // Write In Side
.data(iWR_DATA),
.wren(iWR_EN),
.wraddress({iWR_ADDR[18:3],~iWR_ADDR[2:0]}),
.wrclock(iWR_CLK),
// Read Out Side
.rdaddress(iVGA_ADDR[18:3]),
.rdclock(iVGA_CLK),
.q(ROM_DATA));
endmodule