1 概述
该方案用于生成RGB信号,通过lvds接口驱动逻辑输出,点亮并驱动BP101WX-206液晶屏幕。
参考:下面为参考文章,内容非常详细。Xilinx LVDS Output——原语调用_vivado原语_ShareWow丶的博客http://t.csdn.cn/Zy37p
2 功能描述
MMCM模块为时钟模块,负责将系统时钟变频与输出,产生各模块所需要的时钟;data_generator模块用于生成各种数据与信号,并传输给lvds_output_driver模块,lvds_output_driver模块将这些数据进行并串转换并按指定的lvds格式输出给液晶屏。
3 模块详细设计
MMCM模块用于时钟的变频与输出,data_generator模块用于生成8bit RGB数据,行场同步信号(h_sync、v_sync)和数据使能信号data_en,并传输给lvds_output_driver模块,该模块将这些数据进行并串转换并按指定格式输出给液晶屏。具体详细设计图如下:
3.1 MMCM模块
以下为时钟模块MMCM的接口示意图输出65Mhz和455Mhz的时钟,输出locked作为其他模块的复位信号,改模块采用IP核实现。
3.2 Data_generator模块设计
手册中给出的时序信息如下图:
依照这样的逻辑,画出大致的设计时序图:
3.3 lvds_output_driver模块设计
该模块的详细设计如下:
手册中的输出逻辑时序如下:
4 详细代码设计
4.1 data_generator模块详细设计
/*
this module is used for data generation
BP101WX1-206
1280 * 800 pixel
*/
//count H_SYNC
always @(posedge i_clk_65mhz or posedge i_rst) begin
if (i_rst) begin
cnt_h <= 0;
end
else if (end_cnt_h) begin
cnt_h <= 0;
end
else begin
cnt_h <= cnt_h + 1;
end
end
assign end_cnt_h = cnt_h == (H_TOTAL - 1);
//count V_SYNC
always @(posedge i_clk_65mhz or posedge i_rst) begin
if (i_rst) begin
cnt_v <= 0;
end
else if (end_cnt_h) begin
if (end_cnt_v) begin
cnt_v <= 0;
end
else begin
cnt_v <= cnt_v + 1;
end
end
end
assign end_cnt_v = end_cnt_h && (cnt_v == (V_TOTAL - 1));
//OUTPUT h_sync v_sync DE
always @(posedge i_clk_65mhz or posedge i_rst) begin
if (i_rst) begin
o_h_sync <= 1;
end
else if ((cnt_h == H_FRONT - 1) || (cnt_h == H_FRONT + H_SYNC - 1)) begin
o_h_sync <= ~o_h_sync;
end
end
always @(posedge i_clk_65mhz or posedge i_rst) begin
if (i_rst) begin
o_v_sync <= 1;
end
else if ((cnt_v == V_FRONT - 1 && end_cnt_h) || (cnt_v == V_FRONT + V_SYNC - 1 && end_cnt_h)) begin
o_v_sync <= ~o_v_sync;
end
end
always @(posedge i_clk_65mhz or posedge i_rst) begin
if (i_rst) begin
o_data_en <= 0;
end
else if ((cnt_h == H_BLANK - 1 && cnt_v >= V_BLANK) || (cnt_h == H_TOTAL - 1 && cnt_v >= V_BLANK)) begin
o_data_en <= ~o_data_en;
end
end
//RGB data generation
assign x_cnt = (cnt_h >= H_BLANK)? cnt_h - (H_BLANK - 1) : 0;
assign y_cnt = (cnt_v >= V_BLANK)? cnt_v - (V_BLANK) : 0;
always @(posedge i_clk_65mhz or posedge i_rst) begin
if (i_rst) begin
rgb_data <= 0;
end
/* else if (x_cnt == h_vo || y_cnt == v_vo) begin
rgb_data <= 24'hff_00_00;
end */
else if (x_cnt == 0 || x_cnt == 639 || x_cnt == 1279) begin
rgb_data <= 24'hff_00_00;
end
else if (y_cnt == 0 || y_cnt == 20 || y_cnt == 40) begin
rgb_data <= 24'hff_00_00;
end
else begin
rgb_data <= 24'hffffff;
end
end
assign {o_red_data, o_gre_data, o_blu_data} = rgb_data;
4.2 lvds_output_driver详细设计
第一种写法:
// CLK
OSERDESE2 #(
.DATA_RATE_OQ ("SDR" ), // DDR, SDR
.DATA_RATE_TQ ("SDR" ), // DDR, BUF, SDR
.DATA_WIDTH (7 ), // Parallel data width (2-8,10,14)
.INIT_OQ (1'b0 ), // Initial value of OQ output (1'b0,1'b1)
.INIT_TQ (1'b0 ), // Initial value of TQ output (1'b0,1'b1)
.SERDES_MODE ("MASTER" ), // MASTER, SLAVE
.SRVAL_OQ (1'b0 ), // OQ output value when SR is used (1&#