小弟写了一个1602LCD代码,下到板子上发现液晶无显示,先确定是代码有问题,可用MODELSIM
仿真发现功能实现正常,想搞时序仿真,但软件运行起来实在太卡了。望各位走过路过的高手不吝赐教
module lcd1602(rst,clk,rw,rs,d,e);
input clk,rst;
output rs,rw,e;
output [7:0]d;
reg rs,rw,e;
//reg[7:0]d_buf;
reg[1:0] state;
reg[7:0]m16[15:0];
reg[15:0]clk_cnt;
reg[4:0]dcnt;
reg[7:0]d;
//reg[15:0]cnt;
reg clk_en;
//wire dcnt_done;
parameter idle=2'b00;
parameter write=2'b01;
//parameter wait_a=2'b10;
//assign d<=rw?8'bzzzzzzzz:d_buf;
//assign clk_en=&clk_cnt;
//assign dcnt_done=&dcnt;
always@(posedge clk or negedge rst)begin
if(!rst)begin
clk_cnt<=0;
clk_en<=0;
end
else begin clk_cnt<=clk_cnt+16'b1;
if(clk_cnt==32767)
clk_en<=~clk_en; end
end
always@(posedge clk_en or negedge rst)begin
if(!rst)begin
d<=8'h00;
state<=idle;
dcnt<=0;
e<=0;
//cnt<=0;
end
else begin
case(state)
idle: begin
m16[0]<=8'h30;
m16[1]<=8'h0c;
m16[2]<=8'h06;
m16[3]<=8'h01;
m16[4]<=8'h80;
m16[5]<="H";
m16[6]<="E";
m16[7]<="L";
m16[8]<="L";
m16[9]<="O";
m16[10]<=" ";
m16[11]<="W";
m16[12]<="O";
m16[13]<="R";
m16[14]<="L";
m16[15]<="D";
rw<=0;
e<=0;
dcnt<=0;
state<=write;
end
write:begin
e<=1;
dcnt<=dcnt+4'd1;
d<=m16[dcnt];
if(dcnt<=3)begin
rs<=0;
state<=write;
end
else begin
if(dcnt==5'h0f)
state<=idle;
else begin
rs<=1;
state<=write;
end
end
end
default:state<=idle;
endcase
end
end
endmodule
谢谢,问题解决了,只要不要重复地清屏就可以了
谢谢,问题解决了,只要不重复地清屏就可以了,我的程序里,每次都要清一下屏,所以才会出现那种情况
嗯。。。。。。。。。。
一周热门 更多>