1.图像数据生成模块,设计本模块的目的是,以TFT时序控制模块传入的图像有效显示区域像素点坐标(pix_x,pix_y)为约束条件,产生图像像素点色彩信息pix_data并回传给TFT时序控制模块。在字符显示区域pi_data赋值为指定色,其他区域均为背景色。
2.利用取模软件
具体使用方法,见
3.
module tft_pic
(
input wire Clk33_3M , //输入工作时钟,频率9MHz
input wire Reset_n , //输入复位信号,低电平有效
input wire [9:0] pix_x , //输入有效显示区域像素点X轴坐标
input wire [9:0] pix_y , //输入有效显示区域像素点Y轴坐标
output reg [15:0] pix_data //输出像素点色彩信息
);
//\* Parameter and Internal Signal \//
parameter H_VALID = 10'd800 , //行有效数据
V_VALID = 10'd480 ; //场有效数据
parameter CHAR_B_H= 10'd112 , //字符开始X轴坐标
CHAR_B_V= 10'd104 ; //字符开始Y轴坐标
parameter CHAR_W = 10'd256 , //字符宽度
CHAR_H = 10'd64 ; //字符高度
parameter BLACK = 16'h0000, //黑色
GOLDEN = 16'hFEC0; //金色
//wire define
wire [9:0] char_x ; //字符显示X轴坐标
wire [9:0] char_y ; //字符显示Y轴坐标
//reg define
reg [255:0] char [63:0] ; //字符数据
//\* Main Code \//
//字符显示坐标
assign char_x = (((pix_x >= CHAR_B_H) && (pix_x < (CHAR_B_H + CHAR_W)))
&& ((pix_y >= CHAR_B_V) && (pix_y < (CHAR_B_V + CHAR_H))))
? (pix_x - CHAR_B_H) : 10'h3FF;
assign char_y = (((pix_x >= CHAR_B_H) && (pix_x < (CHAR_B_H + CHAR_W)))
&& ((pix_y >= CHAR_B_V) && (pix_y < (CHAR_B_V + CHAR_H))))
? (pix_y - CHAR_B_V) : 10'h3FF;
//char:字符数据
always@(posedge Clk33_3M)
begin
char[0] <= 256'h0000000000000000000000000000000000000000000000000000000000000000;
char[1] <= 256'h0000000000000000000000000000000000000000000000000000000000000000;
char[2] <= 256'h0000000000000000000000000000000000000000000000000000000000000000;
char[3] <= 256'h0000000000000000000000040000000000000000000008000000000000000000;
char[4] <= 256'h000000000000000000000007800000000000000000001C000000000000002000;
char[5] <= 256'h000000000000020000000007E00000000018000000003E000000000000007000;
char[6] <= 256'h000000000000070000000007C0000000001FFFFFFFFFFF00001FFFFFFFFFF800;
char[7] <= 256'h0000000000000F800000000780000000001FFFFFFFFFFF80000FFFFFFFFFFC00;
char[8] <= 256'h00FFFFFFFFFFFFC00000000780000000001E000010000000000400000001FE00;
char[9] <= 256'h007FFFFFFFFFFFE00000000780000000001E00003C000000000000000003FF00;
char[10] <= 256'h00300000F00000000000000780000800001E00003E000000000000000007E000;
char[11] <= 256'h00000000F00000000000000780001C00001E00003800000000000000001F8000;
char[12] <= 256'h00000000F00000000000000780003E00001E00007000000000000000003E0000;
char[13] <= 256'h00000000F000000000000007FFFFFF00001E00006000000000000000007C0000;
char[14] <= 256'h00000000F000000000000007FFFFFF80001E0000600020000000000000F00000;
char[15] <= 256'h00000000F00000000000000780000000001E0300C00038000000000001C00000;
char[16] <= 256'h00000000F00000000000000780000000001E03FFFFFFFC000000000003800000;
char[17] <= 256'h00000000F00000000000000780000000001E03FFFFFFFC00000000000E000000;
char[18] <= 256'h00000000F00000000000000780000000001E03C000007800000000031C000000;
char[19] <= 256'h00000000F00000000000000780000000001E03C00000780000000003B8000000;
char[20] <= 256'h00000000F00000000000000780000000001E03C00000780000000003E0000000;
char[21] <= 256'h00000000F00000000000000780000000001E03C00000780000000003F0000000;
char[22] <= 256'h0000C000F00000000000000780008000001E03C00000780000000003F8000000;
char[23] <= 256'h0000F000F0000000000180078001C000001E03C00000780000000003E0000000;
char[24] <= 256'h0000FC00F00000000001FFFFFFFFE000001E03C00000780000000003C0000100;
char[25] <= 256'h0000F800F00000000001FFFFFFFFF000001E03FFFFFFF80000000003C0000380;
char[26] <= 256'h0000F000F00010000001E0000003E000001E03FFFFFFF80000000003C00007C0;
char[27] <= 256'h0000F000F00038000001E0000003C000001E03C00000780000000003C0000FE0;
char[28] <= 256'h0000F000F0007C000001E0000003C000001E03C0000078001FFFFFFFFFFFFFF0;
char[29] <= 256'h0000F000FFFFFE000001E0000003C000001E03C0000078000FFFFFFFFFFFFFF8;
char[30] <= 256'h0000F000FFFFFF000001E0000003C000001E03C00000780004000003C0000000;
char[31] <= 256'h0000F000F00000000001E0000003C000000E03C00000780000000003C0000000;
char[32] <= 256'h0000F000F00000000001E0000003C000000E03C00000780000000003C0000000;
char[33] <= 256'h0000F000F00000000001E0000003C000000E03C00000780000000003C0000000;
char[34] <= 256'h0000F000F00000000001E0000003C000000E03FFFFFFF80000000003C0000000;
char[35] <= 256'h0000F000F00000000001E0000003C000001E03FFFFFFF80000000003C0000000;
char[36] <= 256'h0000F000F00000000001E0000003C000001E03C00F00780000000003C0000000;
char[37] <= 256'h0000F000F00000000001E0000003C000001E03C00F00780000000003C0000000;
char[38] <= 256'h0000F000F00000000001E0000003C000001E03000F00600000000003C0000000;
char[39] <= 256'h0000F000F00000000001FFFFFFFFC000001E00000F00000000000003C0000000;
char[40] <= 256'h0000F000F00000000001FFFFFFFFC000001C00000F00000000000003C0000000;
char[41] <= 256'h0000F000F00000000001E0000003C000001C00100F00000000000003C0000000;
char[42] <= 256'h0000F000F00000000001E0000003C000001C00180F00000000000003C0000000;
char[43] <= 256'h0000F000F00000000001E00000038000001C003E0F1C000000000003C0000000;
char[44] <= 256'h0000F000F00000000001800000020000001C007F0F0F000000000003C0000000;
char[45] <= 256'h0000F000F00000000000000000000000003800FC0F03E00000000003C0000000;
char[46] <= 256'h0000F000F00000000000000000004000003801F80F01F80000000003C0000000;
char[47] <= 256'h0000F000F00000000004000008006000003801E00F007E0000000003C0000000;
char[48] <= 256'h0000F000F0000000000401000C003000003003C00F003F0000000003C0000000;
char[49] <= 256'h0000F000F0000000000C01C006001C00007007800F001FC000000003C0000000;
char[50] <= 256'h0000F000F0000000000C01E007001E0000700E000F000FC000000003C0000000;
char[51] <= 256'h0000F000F0000300001C00F003800F0000E01C000F0007E000000001C0000000;
char[52] <= 256'h0000F000F0000780001C00F003C00F0000C078000F0003E000000003C0000000;
char[53] <= 256'h0000F000F0000FC00038007803C0078001C0E0000F0001E000000003C0000000;
char[54] <= 256'h0FFFFFFFFFFFFFE00078007801E007C00181C00FFE0000E000001FFFC0000000;
char[55] <= 256'h07FFFFFFFFFFFFF000F8007801E003C003030003FE0000C0000007FFC0000000;
char[56] <= 256'h020000000000000001F0007801E003C003040000FE000040000000FFC0000000;
char[57] <= 256'h000000000000000003F0003801C003C0060000003C0000000000003F80000000;
char[58] <= 256'h000000000000000003E000300080018004000000380000000000001F00000000;
char[59] <= 256'h000000000000000001C000000000018008000000200000000000001E00000000;
char[60] <= 256'h0000000000000000000000000000000000000000000000000000000800000000;
char[61] <= 256'h0000000000000000000000000000000000000000000000000000000000000000;
char[62] <= 256'h0000000000000000000000000000000000000000000000000000000000000000;
char[63] <= 256'h0000000000000000000000000000000000000000000000000000000000000000;
end
//pix_data:输出像素点色彩信息,根据当前像素点坐标指定当前像素点颜色数据
always@(posedge Clk33_3M or negedge Reset_n)
if(Reset_n == 1'b0)
pix_data <= BLACK;
else if(((pix_x >= CHAR_B_H) && (pix_x < (CHAR_B_H + CHAR_W)))
&& ((pix_y >= CHAR_B_V) && (pix_y < (CHAR_B_V + CHAR_H))))
begin
if(char[char_y][10'd255 - char_x] == 1'b1)
pix_data <= GOLDEN;
else
pix_data <= BLACK;
end
else
pix_data <= BLACK;
endmodule
4.其他代码与上一篇彩条实验一致