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:
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.
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.