学习笔记verilog控制12864显示汉字副本Word文档下载推荐.docx
- 文档编号:16402008
- 上传时间:2022-11-23
- 格式:DOCX
- 页数:16
- 大小:320.38KB
学习笔记verilog控制12864显示汉字副本Word文档下载推荐.docx
《学习笔记verilog控制12864显示汉字副本Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《学习笔记verilog控制12864显示汉字副本Word文档下载推荐.docx(16页珍藏版)》请在冰豆网上搜索。
使用内置ROM块
1,对所取字形取模(根据特点)
如:
汉字:
张,取出点阵如下:
{0x01,0x00,0xF9,0x08,0x09,0x08,0x09,0x10,0x09,0x20,0x79,0x40,0x41,0x00,0x47,0xFE},
{0x41,0x40,0x79,0x20,0x09,0x20,0x09,0x10,0x09,0x08,0x09,0x44,0x51,0x82,0x21,0x00},/*"
张
2,生成hex文件(在keil中生成hex)
3,创建ROM(利用内置的IP)
本次设置:
1024个word即2^10,可以存储16*16编码共32个(一个16*16编码占用8*2*2=32=2^5,2^10/2^5=2^5=32)
选择生成的hex文件
二:
一个汉字的写表示
此处写汉字所用的液晶模式为GDRAM形式,该形式下:
绘图RAM的空间结构如下图所示:
这些都是点阵,绘图RAM就是给这些点阵置1或置0,可以看到其实它本来是32行×
256列的,但是分成了上下两屏显示,每个点对应了屏幕上的一个点。
要使用绘图功能需要开启扩展指令。
然后写地址,再读写数据。
GDRAM的读写:
首先说明对GDRAM的操作基本单位是一个字,也就是2个字节,就是说读写GDRAM时一次最少写2个字节,一次最少读2个字节。
写数据:
先开启扩展指令集(0x36),然后送地址,这里的地址与DDRAM中的略有不同,DDRAM中的地址只有一个,那就是字地址。
而GDRAM中的地址有2个,分别是字地址(列地址/水平地址X)和位地址(行地址/垂直地址Y),上图中的垂直地址就是00H~31H,水平地址就是00H~15H,写地址时先写垂直地址(行地址)再写水平地址(列地址),也就是连续写入两个地址,然后再连续写入2个字节的数据。
如图中所示,左边为高字节右边为低字节。
为1的点被描黑,为0的点则显示空白。
这里列举个写地址的例子:
写GDRAM地址指令是0x80+地址,被加上的地址就是上面列举的X和Y。
(说明:
猛然一看似乎上述说明中,列地址只有16个,行地址有32个,将行地址16个一组来分配,这样就可以写2*16=32=8*4个汉字)
每个首行首列地址:
1,(0x80+0,0x80+X)X:
0~7
2,(0x80+16,0x80+X)X:
3,(0x80+0,0x80+X)X:
8~15
4,(0x80+16,0x80+X)X:
写一个汉字的过程:
三,整个全屏汉字显示设计
1,首先将写入ROM中的汉字字库编码,如下:
张(0)瑞
(1)全
(2)
重(3)庆(4)邮(5)电(6)大(7)学(8)
光(9)电(10)工(11)程(12)学(13)院(14)
微(15)电(16)子(17)学(18)
2,整屏编码如下:
(说明,因为第一个编码存空,方便刷屏,因此汉字字库编码+1)
0,0,1,2,3,0,0,0,
0,4,5,6,7,8,9,0,
0,10,11,12,13,14,15,0,
0,0,16,17,18,19,0,0,//排版
3,用常参数表示如下(5位可以存储一个汉字字库编码)
parametermem00=20'
b00000_00000_00001_00010,mem01=20'
b00011_00000_00000_00000;
parametermem10=20'
b00000_00100_00101_00110,mem11=20'
b00111_01000_01001_00000;
parametermem20=20'
b00000_01010_01011_01100,mem21=20'
b01101_01110_01111_00000;
parametermem30=20'
b00000_00000_10000_10001,mem31=20'
b10010_10011_00000_00000;
4,用缓存存储所用编码安排:
reg[159:
0]buff;
buff<
={mem00,mem01,mem10,mem11,mem20,mem21,mem30,mem31};
四,程序设计
用CN_cnt存储已经写完汉字的个数
cnt存储一个汉字写了多少行(32行一个周期)
主要汉字写状态过程转换:
Set_Fun1:
State<
=8'
h36;
ref_data<
=buff[159:
155];
=buff<
<
5;
={ref_data,5'
b00000};
end
Disp0:
begin
if(cnt==32)
begin
buff<
ref_data<
=buff[159:
CN_cnt<
=CN_cnt+1'
Read_addr<
cnt<
=0;
end
=Disp1;
={3'
b100,CN_cnt[3],cnt[4:
1]};
Disp1:
={4'
b1000,CN_cnt[4],CN_cnt[2:
0]};
//加1的话,显出的数据准确,不知为何
整体代码如下:
//moduleLCD_Disp_CN(
moduleLED(
inputsys_clk,
inputsys_rst,
outputregLCD_RS,
outputLCD_RW,
outputLCD_EN,
outputreg[7:
0]LCD_DATA
);
/*
张(0)瑞
(1)全
(2)
重(3)庆(4)邮(5)电(6)大(7)学(8)
光(9)电(10)工(11)程(12)学(13)院(14)
微(15)电(16)子(17)学(18)
0,0,1,2,3,0,0,0,
0,4,5,6,7,8,9,0,
0,10,11,12,13,14,15,0,
0,0,16,17,18,19,0,0,//排版
*/
reg[159:
/*-creatthe25kHzclock-*/
reg[11:
0]lcd_cnt;
reglcd_clk;
always@(posedgesys_clkornegedgesys_rst)begin
if(!
sys_rst)
lcd_cnt=0;
lcd_clk<
if(lcd_cnt==2000)//25kHz
begin
lcd_cnt=0;
lcd_clk<
=~lcd_clk;
end
else
lcd_cnt=lcd_cnt+1'
regflag;
assignLCD_RW=0;
//LCDWritemodle
assignLCD_EN=flag?
lcd_clk:
1'
b0;
/*LCD_RS*///usuallywrite_com
always@(posedgelcd_clkornegedgesys_rst)begin
sys_rst)
LCD_RS<
=0;
//
if(State==Write_Ram)
LCD_RS<
=1;
/*-Mainstatetranster-*/
reg[8:
0]State;
parameterIdle=9'
b0_0000_0001,
Set_Fun0=9'
b0_0000_0010,//basicinstruction
Set_M=9'
b0_0000_0100,//modesetting
Switch_M=9'
b0_0000_1000,//dispalyonoroff(curseconbling)setting
Set_Fun1=9'
b0_0001_0000,//drawingmode
Disp0=9'
b0_0010_0000,//rowaddressY
Disp1=9'
b0_0100_0000,//colunmaddressX
Write_Ram=9'
b0_1000_0000,
Stop=9'
b1_0000_0000;
reg[6:
0]cnt;
//count64,forchecksomoreonebit
reg[7:
0]CN_cnt;
//count32,forchecksomoreonebit
wire[7:
0]data_disp;
reg[9:
0]Read_addr;
reg[4:
0]ref_data;
//assignline_done=(cnt[3:
0]==4'
b1111);
State<
=Idle;
LCD_DATA<
bzzzz_zzzz;
flag<
=1'
cnt<
case(State)
Idle:
=Set_Fun0;
flag<
=0;
CN_cnt<
Set_Fun0:
=Set_M;
h30;
//basicinstruction
Set_M:
=Switch_M;
h06;
end
Switch_M:
=Set_Fun1;
h0c;
Stop:
=Stop;
b0;
default:
endcase
CN_ZK_ROMrom1(
.address(Read_addr),
.clock(sys_clk),
.q(data_disp)
endmodule
字库编码
/*
*/
unsignedcharcodeCN_ZK[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"
"
0*/
1*/
0x01,0x00,0xF9,0x08,0x09,0x08,0x09,0x10,0x09,0x20,0x79,0x40,0x41,0x00,0x47,0xFE,
0x41,0x40,0x79,0x20,0x09,0x20,0x09,0x10,0x09,0x08,0x09,0x44,0x51,0x82,0x21,0x00,/*"
张"
0x00,0x20,0x02,0x22,0xFA,0x22,0x22,0x22,0x23,0xFE,0x20,0x00,0x27,0xFE,0xF8,0x20,
0x20,0x40,0x23,0xFE,0x22,0x52,0x3A,0x52,0xE2,0x52,0x42,0x52,0x02,0x52,0x02,0x06,/*"
瑞"
0x01,0x00,0x01,0x00,0x02,0x80,0x04,0x40,0x08,0x20,0x10,0x10,0x2F,0xE8,0xC1,0x06,
0x01,0x00,0x01,0x00,0x1F,0xF0,0x01,0x00,0x01,0x00,0x01,0x00,0x7F,0xFC,0x00,0x00,/*"
全"
2*/
0x00,0x10,0x00,0xF8,0x3F,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,0x1F,0xF0,0x11,0x10,
0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x01,0x00,0x3F,0xF8,0x01,0x00,0xFF,0xFE,0x00,0x00,/*"
重"
3*/
0x01,0x00,0x00,0x80,0x3F,0xFE,0x20,0x00,0x20,0x80,0x20,0x80,0x20,0x80,0x2F,0xFC,
0x20,0x80,0x21,0x40,0x21,0x40,0x22,0x20,0x42,0x20,0x44,0x10,0x88,0x08,0x10,0x06,/*"
庆"
4*/
0x08,0x00,0x08,0x7C,0x08,0x44,0x7F,0x48,0x49,0x48,0x49,0x50,0x49,0x48,0x49,0x48,
0x7F,0x44,0x49,0x44,0x49,0x44,0x49,0x68,0x49,0x50,0x7F,0x40,0x41,0x40,0x00,0x40,/*"
邮"
5*/
0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,
0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x0A,0x01,0x02,0x01,0x02,0x00,0xFE,/*"
电"
6*/
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,0x01,0x00,
0x02,0x80,0x02,0x80,0x04,0x40,0x04,0x40,0x08,0x20,0x10,0x10,0x20,0x08,0xC0,0x06,/*"
大"
7*/
0x22,0x08,0x11,0x08,0x11,0x10,0x00,0x20,0x7F,0xFE,0x40,0x02,0x80,0x04,0x1F,0xE0,
0x00,0x40,0x01,0x80,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,/*"
学"
8*/
0x01,0x00,0x21,0x08,0x11,0x08,0x09,0x10,0x09,0x20,0x01,0x00,0xFF,0xFE,0x04,0x40,
0x04,0x40,0x04,0x40,0x04,0x40,0x08,0x42,0x08,0x42,0x10,0x42,0x20,0x3E,0xC0,0x00,/*"
光"
9*/
10*/
0x00,0x00,0x00,0x00,0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,/*"
工"
11*/
0x08,0x00,0x1D,0xFC,0xF1,0x04,0x11,0x04,0x11,0x04,0xFD,0xFC,0x10,0x00,0x30,0x00,
0x39,0xFE,0x54,0x20,0x54,0x20,0x91,0xFC,0x10,0x20,0x10,0x20,0x13,0xFE,0x10,0x00,/*"
程"
12*/
13*/
0x00,0x40,0x78,0x20,0x4B,0xFE,0x52,0x02,0x54,0x04,0x61,0xF8,0x50,0x00,0x48,0x00,
0x4B,0xFE,0x48,0x90,0x68,0x90,0x50,0x90,0x41,0x12,0x41,0x12,0x42,0x0E,0x44,0x00,/*"
院"
14*/
0x11,0x08,0x15,0x48,0x25,0x48,0x45,0x50,0x97,0xDE,0x10,0x24,0x20,0x14,0x6F,0xD4,
0xA0,0x14,0x27,0x94,0x24,0x94,0x24,0xA8,0x24,0xC8,0x24,0x94,0x28,0x14,0x30,0x22,/*"
微"
15*/
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学习笔记verilog控制12864显示汉字 副本 学习 笔记 verilog 控制 12864 显示 汉字