module HDMI(
input CLK_100MHZ_i,
input sys_rst_n_i,
output hdmi_clk_o,
output hdmi_blank_o,
output hdmi_hs_o,
output hdmi_vs_o,
output [7:0]hdmi_rgb_r_o,
output [7:0]hdmi_rgb_g_o,
output [7:0]hdmi_rgb_b_o
);
parameter BLACK_RGB = {8'd0,8'd0,8'd0};
parameter BLUE_RGB = {8'd0,8'd0,8'd255};
parameter GREEN_RGB = {8'd0,8'd255,8'd0};
parameter CYAN_RGB = {8'd0,8'd255,8'd255};
parameter RED_RGB = {8'd255,8'd0,8'd0};
parameter PURPLE_RGB = {8'd255,8'd0,8'd255};
parameter YELLOW_RGB = {8'd255,8'd255,8'd0};
parameter WHITE_RGB = {8'd255,8'd255,8'd255};
parameter H_DISP=12'd1920;
wire[11:0]x_pos;
wire[11:0]y_pos;
wire data_en;
wire data_request;
wire [7:0]rgb_r;
wire [7:0]rgb_g;
wire [7:0]rgb_b;
wire clk_40m;
wire clk_65m;
wire clk_106_5m;
wire clk_108m;
wire clk_148_5m;
wire used_clk;
dcm_148_5m dcm_148_5m
(
// Clock in ports
.clk_in1( CLK_100MHZ_i), // input clk_in1
// Clock out ports
.clk_out1(clk_148_5m));
hdmi_driver hdmi_driver_u0(
.rst_n_i(sys_rst_n_i),
.clk_i(used_clk),
.rgb_r_i(rgb_r),
.rgb_g_i(rgb_g),
.rgb_b_i(rgb_b),
.data_requst_o(data_requst),
.x_pos_o(x_pos),
.y_pos_o(y_pos),
.clk_o(hdmi_clk_o),
.hs_o(hdmi_hs_o),
.vs_o(hdmi_vs_o),
.blank_o(hdmi_blank_o),
.rgb_r_o(hdmi_rgb_r_o),
.rgb_g_o(hdmi_rgb_g_o),
.rgb_b_o(hdmi_rgb_b_o)
);
//assign used_clk = clk_40m;
//assign used_clk = clk_65m;
//assign used_clk = clk_106_5m;
//assign used_clk = clk_108m;
assign used_clk = clk_148_5m;
reg[7:0]red_data;
reg[7:0]green_data;
reg[7:0]blue_data;
always@(posedge used_clk)
begin
if(data_requst)//-数据请求-//
begin
case(x_pos)
12'd1: //-输出绿色RGB值-//
begin
{red_data,green_data,blue_data} <= GREEN_RGB;
end
(H_DISP/8)*1://-输出蓝色RGB值-//
begin
{red_data,green_data,blue_data} <= BLUE_RGB;
end
(H_DISP/8)*2://-输出黑色RGB值-//
begin
{red_data,green_data,blue_data} <= BLACK_RGB;
end
(H_DISP/8)*3://-输出青色RGB值-//
begin
{red_data,green_data,blue_data} <= CYAN_RGB;
end
(H_DISP/8)*4://-输出红色RGB值-//
begin
{red_data,green_data,blue_data} <= RED_RGB;
end
(H_DISP/8)*5://-输出紫色RGB值-//
begin
{red_data,green_data,blue_data} <= PURPLE_RGB;
end
(H_DISP/8)*6://-输出黄色RGB值-//
begin
{red_data,green_data,blue_data} <= YELLOW_RGB;
end
(H_DISP/8)*7://-输出白色RGB值-//
begin
{red_data,green_data,blue_data} <= WHITE_RGB;
end
default://-数据保持不变-//
begin
{red_data,green_data,blue_data} <= {red_data,green_data,blue_data};
end
endcase
end
else
begin
{red_data,green_data,blue_data} <= {8'd0,8'd0,8'd0};
end
end
assign {rgb_r,rgb_g,rgb_b} = {red_data,green_data,blue_data};
endmodule
|
|