HDMI RGB_TO_DVI模块
一、模块简介
在HDMI视频数据传输过程中,将24位的RGB888格式的图像,在编码和并串转换后,以TMDS数据输出至HDMI。HDMI_Encoder模块负责对数据进行编码,HDMI_Serializer模块对编码后的数据进行并串转换,最后通过OBUFDS转化成TMDS差分信号传输。
二、逻辑代码
module HDMI_RGBtoDVI(
input wire [00:00] i_pixel_clk , //像素数据输入时钟
input wire [00:00] i_pixel_5_clk , //像素数据输出shizhong
input wire [00:00] i_rst_n , //复位时钟,低有效
input wire [23:00] i_pixel_data , //像素输入数据
input wire [00:00] i_hsync , //行同步数据
input wire [00:00] i_vsync , //场同步数据
input wire [00:00] i_de , //像素数据有效信号
output wire [02:00] o_tmds_data_p , //TMDS数据信号
output wire [02:00] o_tmds_data_n ,
output wire [00:00] o_tmds_clk_p , //TMDS时钟信号
output wire [00:00] o_tmds_clk_n ,
output wire [00:00] o_tmds_en //TMDS使能信号
);
reg [00:00] rst_temp1 ;
reg [00:00] rst_temp2 ;
wire [00:00] sys_rst ; //异步复位信号,高有效
wire [00:00] tmds_data_r ;
wire [00:00] tmds_data_g ;
wire [00:00] tmds_data_b ;
wire [00:00] tmds_clk ;
wire [09:00] tmds_red ;
wire [09:00] tmds_green ;
wire [09:00] tmds_blue ;
wire [09:00] tmds_clk_bit ;
assign o_tmds_en = 1'b1;
assign tmds_clk_bit = 10'b11_1110_0000;
//同步信号,异步复位,高有效
assign sys_rst = rst_temp2;
always@(posedge i_pixel_clk or negedge i_rst_n)
begin
if(!i_rst_n)
begin
rst_temp1 <= 1'b1;
rst_temp2 <= 1'b1;
end
else begin
rst_temp1 <= 1'b0;
rst_temp2 <= rst_temp1;
end
end
OBUFDS #(
.IOSTANDARD("TMDS33"), // Specify the output I/O standard
.SLEW("SLOW") // Specify the output slew rate
)OBUFDS_inst_r (
.O(o_tmds_data_p[2]), // Diff_p output (connect directly to top-level port)
.OB(o_tmds_data_n[2]), // Diff_n output (connect directly to top-level port)
.I(tmds_data_r) // Buffer input
);
OBUFDS #(
.IOSTANDARD("TMDS33"), // Specify the output I/O standard
.SLEW("SLOW") // Specify the output slew rate
)OBUFDS_inst_g (
.O(o_tmds_data_p[1]), // Diff_p output (connect directly to top-level port)
.OB(o_tmds_data_n[1]), // Diff_n output (connect directly to top-level port)
.I(tmds_data_g) // Buffer input
);
OBUFDS #(
.IOSTANDARD("TMDS33"), // Specify the output I/O standard
.SLEW("SLOW") // Specify the output slew rate
)OBUFDS_inst_b (
.O(o_tmds_data_p[0]), // Diff_p output (connect directly to top-level port)
.OB(o_tmds_data_n[0]), // Diff_n output (connect directly to top-level port)
.I(tmds_data_b) // Buffer input
);
OBUFDS #(
.IOSTANDARD("TMDS33"), // Specify the output I/O standard
.SLEW("SLOW") // Specify the output slew rate
)OBUFDS_inst_clk (
.O(o_tmds_clk_p), // Diff_p output (connect directly to top-level port)
.OB(o_tmds_clk_n), // Diff_n output (connect directly to top-level port)
.I(tmds_clk) // Buffer input
);
HDMI_Encoder HDMI_Encoder_b(
.i_pixel_clk (i_pixel_clk ) ,
.i_rst (sys_rst ) ,
.i_data (i_pixel_data[07:00]) ,
.i_de (i_de ) ,
.i_ctrl_1 (i_hsync ) ,
.i_ctrl_2 (i_vsync ) ,
.o_data (tmds_blue )
);
HDMI_Encoder HDMI_Encoder_g(
.i_pixel_clk (i_pixel_clk ) ,
.i_rst (sys_rst ) ,
.i_data (i_pixel_data[15:08]) ,
.i_de (i_de ) ,
.i_ctrl_1 (1'b0 ) ,
.i_ctrl_2 (1'b0 ) ,
.o_data (tmds_green )
);
HDMI_Encoder HDMI_Encoder_r(
.i_pixel_clk (i_pixel_clk ) ,
.i_rst (sys_rst ) ,
.i_data (i_pixel_data[23:16]) ,
.i_de (i_de ) ,
.i_ctrl_1 (1'b0 ) ,
.i_ctrl_2 (1'b0 ) ,
.o_data (tmds_red )
);
HDMI_Serializer HDMI_Serializer_r(
.i_pixel_clk (i_pixel_clk ) ,
.i_pixel_5_clk (i_pixel_5_clk) ,
.i_rst (sys_rst ) ,
.i_pixel_data (tmds_red ) ,
.o_pixel_data (tmds_data_r )
);
HDMI_Serializer HDMI_Serializer_g(
.i_pixel_clk (i_pixel_clk ) ,
.i_pixel_5_clk (i_pixel_5_clk) ,
.i_rst (sys_rst ) ,
.i_pixel_data (tmds_green ) ,
.o_pixel_data (tmds_data_g )
);
HDMI_Serializer HDMI_Serializer_b(
.i_pixel_clk (i_pixel_clk ) ,
.i_pixel_5_clk (i_pixel_5_clk) ,
.i_rst (sys_rst ) ,
.i_pixel_data (tmds_blue ) ,
.o_pixel_data (tmds_data_b )
);
HDMI_Serializer HDMI_Serializer_clk(
.i_pixel_clk (i_pixel_clk ) ,
.i_pixel_5_clk (i_pixel_5_clk) ,
.i_rst (sys_rst ) ,
.i_pixel_data (tmds_clk_bit ) ,
.o_pixel_data (tmds_clk )
);
endmodule