VGA显示文字
VGA显示文字
- VGA字符显示的原理
把要显示的字符转换成字符点阵,然后编码存储,着色的部分为1,其它为0.然后在VGA上输出显示。
字符点阵生成软件:
https://www.zhetao.com/fontarray.html
这里一个字符为32*32bit,字符点阵如下图:
字符编码存到内存里的代码如下:
//char dot reg
reg [159:0] char [31:0]; //5 char 32*32*5
//字符“电子实验室”
always@(posedge clk)
begin
char[0] <= 160'h0000000000000000000000000000000000000000;
char[1] <= 160'h0000000000000000000000000000000000000000;
char[2] <= 160'h00038000000000000007800000001e0000078000;
char[3] <= 160'h0003c000000001e00003c00000781f000007c000;
char[4] <= 160'h0003800007fffff00003e0007ff81e000003c000;
char[5] <= 160'h00038000078003f00001e00038783e000e01c030;
char[6] <= 160'h00038000000007e00e01e0000c703f000e01c038;
char[7] <= 160'h0e0381e000000f800e01c03c0f707b800ffffffc;
char[8] <= 160'h0fffffe000003e000ffffffc0f7073801e00007c;
char[9] <= 160'h0f0381e0000378000e00e03e1e70f3c01e0003f0;
char[10] <= 160'h0f0381c00003f0001e70f8781ef1e1e03e0007e0;
char[11] <= 160'h0f0381c00003e0003e7cf0f01cf1c0f03fffffe0;
char[12] <= 160'h0f0381c00003e0003c3ef0e01ce380fc038f8000;
char[13] <= 160'h0f0381c00003c038181ef0001ce701fe001f1c00;
char[14] <= 160'h0fffffc00003c07c000ef0001ceffffc003c0f00;
char[15] <= 160'h0f0381c07ffffffe0780f0001cfdc01800780780;
char[16] <= 160'h0f0381c07803c00003e0e0003ffc007001f003c0;
char[17] <= 160'h0f0381c00003c00001f0e0003c3f307803ffffe0;
char[18] <= 160'h0f0381c00003c00000f0e038003bb87803fffde0;
char[19] <= 160'h0f0381c00003c0000071e07c003bbcf001e381c0;
char[20] <= 160'h0f0381c00003c0007ffffffe00f9dcf00003e0c0;
char[21] <= 160'h0fffffc00003c0003801e0001ff9dee00003c180;
char[22] <= 160'h0f0381d80003c0000003c000ff39fee00003c3c0;
char[23] <= 160'h0f0381980003c0000003f8007839ffc007ffffe0;
char[24] <= 160'h0e0380180003c0000007fe002079efc00383c000;
char[25] <= 160'h000380180003c000000fbfc00079c1800003c000;
char[26] <= 160'h0003801c0003c000001f0fe01c7003980003c000;
char[27] <= 160'h0003801e007fc000007e03f01ff003bc0003c018;
char[28] <= 160'h0003fffe007fc00001f801f003fffffe0003c03c;
char[29] <= 160'h0003fffc000f80000fe000f001e700007ffffffe;
char[30] <= 160'h00000000000700007f0000700000000038000000;
char[31] <= 160'h0000000000000000000000000000000000000000;
end
- VGA显示内容布局
规划要显示的内容:
这里还是以1个block(16*16bit)为色块基本单位,字符显示范围行15~25(不包含25)block内,列8~10(不包含10)block内。下面三个色块布局类似。
在字符显示范围内,有效位置1:
- 总结
VGA字符显示,先规划字符大小,布局,利用字符点阵生成工具,然后限定显示范围,输出编码。其中,字符坐标要转换成像素坐标。字符正序显示,需要把坐标倒序处理。
参考:
https://mp.weixin.qq.com/s/WFioASjRQRj4KaSN1cCWkA