Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

quick help for novice - lcd code verilog

Status
Not open for further replies.

mahdiy

Newbie level 2
Joined
Apr 26, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,295
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:
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
 

initialize to zero verilog

Hi.
I'm learning myself. I have the same situation when doing counters. I use Modelsim and Quartus.
I noticed that when in Modelsim, register values don't initialize to a value unless told.
But in Quartus after programming, the hardware itself would initialize to a value and works fine.
So when writing testbenches in Modelsim, I write in such a way that the values can initialize to a definite value.

I'm still at the beginner's level so I may be wrong.

cheers.
 

verilog initialize lcd

thanks,
I also figured out the problem from before. I had to initialize some registers to zero, and a few changes I remember.
 

modelsim initialize register value

mahdiy said:
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?

NO, it is "x" by default. This is why in typical ASIC/FPGA designs you always use reset. Add a reset to your design, things should be fine. On some FPGAs doing it by default, that's an added feature by the tools, I recommend not to rely on it.

Ajeetha, CVC
www.cvcblr.com
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top