完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
`//2017 3.15 zc in xidian module lcd1602(input clk_50M, input reset, output reg [7:0] data, output en, output reg rs, output rw); assign rw=1'b0; //只写不读 reg[31:0] cnt; reg clk_20ms; always@(posedge clk_50M) begin if(!reset) begin cnt<=0; end else if(clk_20ms==1) //上电等待20ms if(clk_50M==1) if(cnt==9_9999) begin cnt<=0;end //if(cnt==39) begin cnt<=0;end else begin cnt<=cnt+1; end else cnt<=0; end wire write_flag; assign en=(cnt<=4_9999)?1'b0:1'b1; assign write_flag=(cnt==4_9998)?1'b1:1'b0; //assign en=(cnt<=19)?1'b0:1'b1; //assign write_flag=(cnt==10)?1'b1:1'b0; reg[31:0] cnt2; always@(posedge clk_50M) begin if(!reset) begin cnt2<=0; clk_20ms<=0; end else if(clk_50M==1) if(cnt2==99_9999) begin clk_20ms<=1'b1; end //clk_20ms 作用只是延时20ms ,所以到了20m给个标志就行,cnt2不用清零 //if(cnt2==999) begin clk_20ms<=1'b1; end //if(cnt2==99) begin clk_20ms<=1'b1; end else begin cnt2<=cnt2+1; clk_20ms<=1'b0; end end parameter idle=8'h00, //初始化 disp_format=8'h01, disp_open=8'h02, clear=8'h03, set_cursor=8'h04, write_add_line1=8'h05,//第一行第一列地址 line1_0=8'h06,//第一行第一列写的数据 line1_1=8'h08, line1_2=8'h09, line1_3=8'h0a, line1_4=8'h0b, line1_5=8'h0c, line1_6=8'h0d, line1_7=8'h0e, line1_8=8'h10, line1_9=8'h11, line1_a=8'h12, line1_b=8'h13, line1_c=8'h14, line1_d=8'h15, line1_e=8'h16, line2_0=8'h17,//第一行第一列写的数据 line2_1=8'h18, line2_2=8'h19, line2_3=8'h1a, line2_4=8'h1b, line2_5=8'h1c, line2_6=8'h1d, line2_7=8'h1e, line2_8=8'h1f, line2_9=8'h21, line2_a=8'h22, line2_b=8'h23, line2_c=8'h24, line2_d=8'h25, line2_e=8'h26, write_add_line2=8'h27; reg[7:0] state; always@(posedge clk_50M) begin if(!reset) state<=idle; else if(write_flag==1) case(state) idle:state<=disp_format; disp_format:begin rs<=0; data<=8'h38; state<=disp_open;end disp_open:begin rs<=0; data<=8'h0c; state<=set_cursor;end set_cursor: begin rs<=0; data<=8'h06; state<=clear;end clear:begin rs<=0; data<=8'h01; state<=write_add_line1;end write_add_line1:begin rs<=0; data<=8'h80; state<=line1_0;end line1_0:begin rs<=1; data<="z"; state<=line1_1;end line1_1:begin rs<=1; data<="h"; state<=line1_2;end line1_2:begin rs<=1; data<="a"; state<=line1_3;end line1_3:begin rs<=1; data<="n"; state<=line1_4;end line1_4:begin rs<=1; data<="n"; state<=line1_5;end line1_5:begin rs<=1; data<="g"; state<=line1_6;end line1_6:begin rs<=1; data<="^"; state<=line1_7;end line1_7:begin rs<=1; data<="_"; state<=line1_8;end line1_8:begin rs<=1; data<="^"; state<=line1_9;end line1_9:begin rs<=1; data<="i"; state<=line1_a;end line1_a:begin rs<=1; data<="l"; state<=line1_b;end line1_b:begin rs<=1; data<="o"; state<=line1_c;end line1_c:begin rs<=1; data<="v"; state<=line1_d;end line1_d:begin rs<=1; data<="e"; state<=line1_e;end line1_e:begin rs<=1; data<="u"; state<=write_add_line2;end write_add_line2:begin rs<=0; data<=8'hc0; state<=line2_0;end line2_0:begin rs<=1; data<="z"; state<=line2_1;end line2_1:begin rs<=1; data<="h"; state<=line2_2;end line2_2:begin rs<=1; data<="a"; state<=line2_3;end line2_3:begin rs<=1; data<="n"; state<=line2_4;end line2_4:begin rs<=1; data<="n"; state<=line2_5;end line2_5:begin rs<=1; data<="g"; state<=line2_6;end line2_6:begin rs<=1; data<="^"; state<=line2_7;end line2_7:begin rs<=1; data<="_"; state<=line2_8;end line2_8:begin rs<=1; data<="^"; state<=line2_9;end line2_9:begin rs<=1; data<="i"; state<=line2_a;end line2_a:begin rs<=1; data<="l"; state<=line2_b;end line2_b:begin rs<=1; data<="o"; state<=line2_c;end line2_c:begin rs<=1; data<="v"; state<=line2_d;end line2_d:begin rs<=1; data<="e"; state<=line2_e;end line2_e:begin rs<=1; data<="u"; state<=write_add_line1;end endcase end endmodule ` |
|
相关推荐
|
|
这是Verilog HDL语言写的1602
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
谢谢您,给您推荐一个fpga公众号名字 FPGA干货,每天的都发送fpga干货,共同学习 |
|
|
|
|
|
1034 浏览 1 评论
助力AIoT应用:在米尔FPGA开发板上实现Tiny YOLO V4
1000 浏览 0 评论
2099 浏览 1 评论
1827 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
2051 浏览 0 评论
1709 浏览 44 评论
5951 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-13 11:08 , Processed in 0.894170 second(s), Total 95, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号