-3

Verilog HDL を使用して、 16 文字 * 2 行の LCD (HD44780)を 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

これは、そのインスタンス「Sender」のコードです。

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

ボードでこのコードを確認してください。EP2C8Q208C8 fpga を搭載した「DIGIASIC Altera Cyclone II ボード」で試してみました。また、送信側インスタンスの遅延を低くしたり高くしたりしてみましたが、どれも機能しませんでした。

4

1 に答える 1