Detection of two rising edges

Joined
Nov 24, 2010
Messages
1
Reaction score
0
Hi everyone,

I'm sure you have heard similar question from many other vhdl beginners however I couldn't find a solution to my problem anywhere. Here's the troublesome code:
Code:
PROCESS(clock, reset, ready)
		variable countInit: INTEGER range initcode'Low to initcode'High:=0;
		variable count: INTEGER range 0 to MAX_LINE_INDEX:=0;
		variable IsLine2 : boolean :=false;
	BEGIN
		IF(Reset = '1') THEN
			countInit := initcode'Low; count:=0; IsLine2:=false; 
			state <= Init_en_high;
		ELSIF(clock'EVENT AND clock = '1') THEN
			CASE state IS
			-- LCD initialization sequence
			-- The LCD_DATA is written to the LCD at the falling edge of the E line
			-- therefore we need to toggle the E line for each data write
			WHEN Init_en_high =>
				LCD_DATA <= initcode(countInit);
				LCD_EN <= '1';	-- EN=1;
				LCD_RS <= '0';	-- RS=0; an instruction
				state <= Init_en_low;
			WHEN Init_en_low =>
				LCD_EN <= '0';	-- set EN=0;
				IF countInit = initcode'HIGH THEN
					state <= WriteCharacter_en_high;
				ELSE
					countInit := countInit + 1;
                    state <= Init_en_high;
				END IF;
				
			-- write 1st line text
			WHEN WriteCharacter_en_high =>
				if (rising_edge(ready)) then
					LCD_DATA <= LCD_CHAR; --send data	    
					LCD_EN <= '1';	-- EN=1;
					LCD_RS <= '1';	-- RS=1; data
					state <= WriteCharacter_en_low;
				end if;
				
				
	
			WHEN WriteCharacter_en_low =>
				--check_led3<='1';
				LCD_EN <= '0';	-- EN=0; toggle EN
				IF (not IsLine2) and (count=MAX_LINE_INDEX) 
                        then state <= GoToLine2_en_high; --jsme na konci prvniho radku
                elsif IsLine2    and (count=MAX_LINE_INDEX) 
                        then state <= End_en_high;  -- end of the second line
				ELSE count := count + 1; 
				     state <= WriteCharacter_en_high; --back to writing
				end if;
				
			-- move cursor to second line of display
			WHEN GoToLine2_en_high =>
			                    	-- 
				LCD_DATA <= x"C0";  -- x"CO" is address of 1st position on 2nd line, 				                    
				LCD_EN <= '1';	-- EN=1;
				LCD_RS <= '0';	-- RS=0; an instruction
				state <= GoToLine2_en_low;

			WHEN GoToLine2_en_low =>
				LCD_EN <= '0';	-- EN=0; toggle EN
				---state <= WriteCharacter_en_high; 
				count:=0; 
				IsLine2:=true;
			    state <= WriteCharacter_en_high; --back to writing mode 

			WHEN End_en_high =>
				countInit:=6;
				count:=0;
				IsLine2:=false;
				--LCD_EN <= '1';	-- EN=1;
				--LCD_RS <= '0';	-- RS=0; an instruction
				state <= Init_en_high;

			WHEN OTHERS =>
				LCD_EN <= '0';	-- set EN=0;
				state <= Stop;
			END CASE;
		END IF;
	END PROCESS;

The error message i get during compilation is :
Error (10821): HDL error at LCD_Text.vhd(50): can't infer register for "state.WriteCharacter_en_low" because its behavior does not match any supported register model

(the code is basically i finite state machine that manages LCD display)

I suppose the problem lies with the "WriteCharacter_en_high" state. I know I can't detect rising edges of two different clocks in one process. I've tried many workarounds too, but nothing seems to work.

How do I do this? I would really appreciate any kind of suggestion or help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top