如何使用Verilog将16*2 LCD(HD44780)连接到FPGA/CPLD?

如何使用Verilog将16*2 LCD(HD44780)连接到FPGA/CPLD?,verilog,fpga,xilinx,system-verilog,intel-fpga,Verilog,Fpga,Xilinx,System Verilog,Intel Fpga,我想使用Verilog HDL将a接口连接到我的FPGA板。我写的程序根本不起作用,我也不知道为什么,尽管我做了一个状态机并插入了延迟。注意,我使用了8位模式。这是我的密码: module lcd(input wire clk,output reg [7:0]data,output reg rs,output reg rw ,output reg enb); wire sclk;//Slow Clock for Giving 450 ns Wide Delay reg [3:0]

我想使用Verilog HDL将a接口连接到我的FPGA板。我写的程序根本不起作用,我也不知道为什么,尽管我做了一个状态机并插入了延迟。注意,我使用了8位模式。这是我的密码:

module lcd(input wire clk,output reg [7:0]data,output reg rs,output reg rw ,output reg enb);        
wire sclk;//Slow Clock for Giving 450 ns Wide Delay
reg [3:0]state=4'b0000;
reg [3:0]next_state;
sender send(clk,sclk);  //Instance of Counter For Generating Delay

always@(sclk)
begin
state=next_state;
end

//Always First Block thant Handles flow of Our state machines means Always Second block//
//Always Second Block For State Machine of Our 16 * 2 LCD///////////////////////////////    

always@(state)
begin
////////////////These State are For LCD Commands////////////////
enb=1'b0;

case(state)

4'b0000:begin    //Do Noting because this state waste in Initialization of "state" variable..
next_state=4'b0001;
end         


4'b0001:begin    //Using LCD Command 0X38(00111000)
rs=1'b0;
rw=1'b0;
data=8'b00111000;
enb=1'b1; //Logic is Sending High(1) then uses clocks Delay then Low(0) of Next state..
next_state=4'b0010;
end      

4'b0010:begin   //Using LCD Command 0X0E(00001110)
rs=1'b0;
rw=1'b0;
data=8'b00001110;   
enb=1'b1; //Logic is Sending High(1) then uses clocks Delay then Low(0) of Next state..
next_state=4'b0011;
end


4'b0011:begin   //Using LCD Command 0X01(00000001)
rs=1'b0;
rw=1'b0;
data=8'b00000001;   
enb=1'b1; //Logic is Sending High(1) then uses clocks Delay then Low(0) of Next state..
next_state=4'b0100;
end

4'b0100:begin   //Using LCD Command 0X06(00000110)
rs=1'b0;
rw=1'b0;
data=8'b00000110;
enb=1'b1; //Logic is Sending High(1) then uses clocks Delay then Low(0) of Next state..
next_state=4'b0110; 
end



////////////These State Are for LCD Data////////////////////

4'b0110:begin    //Using LCD "S" Having Value
rs=1'b1;
rw=1'b0;
data=8'b01010111;
enb=1'b1; //Logic is Sending High(1) then uses clocks Delay then Low(0) of Next state..
next_state=4'b0110;
end




endcase
end


endmodule
这是其实例发送方的代码:

module sender(input wire clkin,output reg clkout);
 reg [19:0]tmp=20'b00000_00000_00000_00000;

//Always Block for Greater than 450ns wide delay Generation////////

always@(posedge clkin)
 begin 
  tmp = tmp+1'b1;
  clkout=tmp[19]; 
 end        

 endmodule

请在您的板上检查此代码。我在我的DIGIASIC Altera Cyclone II板上试过,它有一个。我还尝试在sender实例中降低和提高延迟,但都没有成功。

有比您在代码中实现的更多的计时要求。您需要仔细查看LCD模块的数据表。请注意,LCD模块执行命令需要很多微秒……您的450 ns延迟远远不够。

您模拟过吗?Altera工具附带了ModelSim的免费版本。是的,先生,我已经在许多模拟器中进行了模拟,包括ModelSim、ALDEC的有源HDL和Synapticad的Verilogger Extream…它在这些模拟器中运行良好…显示了一些模拟波形。以及LCD驱动程序数据表的链接。让人们更容易地帮助你。与其说它不起作用,你能更具体地说问题出在哪里吗?先生,我不知道问题出在哪里。实际上,先生,对于LCD接口,我们必须记住两件事,一件是延迟,另一件是LCD初始化,但我已经做到了……还有什么时间要求,先生?你能给我解释一下吗?先生,根据你的说法,我必须增加延误时间。。。。。?请给我解释一下,以便我修改代码…请