mahdiy
Newbie level 2
code verilog
Hey all,
From what I see there is nothing wrong with this code. It is for a hd44780 lcd, and this should initialize for 4 bit mode and then turn on the display/cursor. I get a bunch of warning for parameters without init value having a constant value of zero or something. Aren't initial values for register types always zero?
I would appreciate it if someone could take the time to look at this for me. I always see this site for google searches to various questions and it seems there are a lot of helpful people here. Thanks in advance
verilog code:
Hey all,
From what I see there is nothing wrong with this code. It is for a hd44780 lcd, and this should initialize for 4 bit mode and then turn on the display/cursor. I get a bunch of warning for parameters without init value having a constant value of zero or something. Aren't initial values for register types always zero?
I would appreciate it if someone could take the time to look at this for me. I always see this site for google searches to various questions and it seems there are a lot of helpful people here. Thanks in advance
verilog code:
Code:
module topmod (clock, rs, re, en, databus);
output rs, re, en;
output reg [3:0] databus;
input clock;
reg [21:0] counter1;
reg [10:0] dcounter;
reg [15:0] encount;
assign re = 0;
assign rs = 0;
reg en;
reg flag;
reg [1:0] state;
reg [3:0] instr;
always @ (posedge clock)
begin
case(state)
2'b00: begin
counter1 <= counter1 + 1'b1;
databus <= 0;
en <= 0;
if(counter1 > 2250000)
state <= 2'b01;
end
2'b01: begin
case(instr)
0: databus <= 4'b0010;
1: databus <= 4'b0010;
2: databus <= 4'b0000;
3: databus <= 4'b0000;
4: databus <= 4'b1110;
default: flag <= 1;
endcase
instr <= instr + 1'b1;
state <= 2'b10;
end
2'b10: begin
if(flag)
en <= 0;
else
begin
en <= 1;
encount <= encount + 1'b1;
if(encount > 50000)
begin
encount <= 0;
en <= 0;
state <= 2'b11;
end
end
end
2'b11: begin
dcounter <= dcounter + 1'b1;
if(dcounter > 2000)
begin
dcounter <= 0;
state <= 2'b01;
end
end
endcase
end
endmodule