Intel® FPGA University Program
University Program Material, Education Boards, and Laboratory Exercises
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
1098 Discussions

FSM with LCD Controller

Honored Contributor II

Hello.. Can anyone guide me in creating a state machine for LCD controller. Input is keyboard, and when a key is pressed it is shown on LCD, and the next key pressed is shown on LCD next to the first key pressed. This is what I got so far, but this one doesn't work properly. What is essential for building a FSM for this purpose? 

Im using DE2 and Quartus. 


type statetype is (POS0, POS1, POS2, POS3, POS4, POS5, POS6, POS7, POS8, POS9, POS10, POS11, POS12, POS13, POS14, POS15); 

signal statepos, nextstate: statetype; 


process(clk, wEn)  

variable count : integer range 0 to 3; 


if (clk'event and clk='1') then 

if (wEn='1') then 

count := count + 1; 

if (count = 3) then 

statepos <= nextstate; 

count := 0; 

end if; 

end if; 

end if; 

end process; 



-- next state logic 

process (statepos, lcdcharcode) begin 

case statepos is 


when POS0 => charRAM(0) <= lcdcharcode; 

nextstate <= POS1; 


when POS1 => charRAM(1) <= lcdcharcode; 

nextstate <= POS2; 


when POS2 => charRAM(2) <= lcdcharcode; 

nextstate <= POS3; 


when POS3 => charRAM(3) <= lcdcharcode; 

nextstate <= POS4; 


when POS4 => charRAM(4) <= lcdcharcode; 

nextstate <= POS5; 


when POS5 => charRAM(5) <= lcdcharcode; 

nextstate <= POS6; 


when POS6 => charRAM(6) <= lcdcharcode; 

nextstate <= POS7; 


when POS7 => charRAM(7) <= lcdcharcode; 

nextstate <= POS8; 


when POS8 => charRAM(8) <= lcdcharcode; 

nextstate <= POS9;  


when POS9 => charRAM(9) <= lcdcharcode; 

nextstate <= POS10; 


when POS10 => charRAM(10) <= lcdcharcode; 

nextstate <= POS11; 


when POS11 => charRAM(11) <= lcdcharcode; 

nextstate <= POS12; 


when POS12 => charRAM(12) <= lcdcharcode; 

nextstate <= POS13; 


when POS13 => charRAM(13) <= lcdcharcode; 

nextstate <= POS14; 


when POS14 => charRAM(14) <= lcdcharcode; 

nextstate <= POS15; 


when POS15 => charRAM(15) <= lcdcharcode; 

nextstate <= POS0;  


when others => nextstate <= POS0; 

end case; 

end process;
0 Kudos
1 Reply
Honored Contributor II

Please do net multipost your question. 


I don't see any key input in your module. Besides, the code could be replaced by a simple counter. 

Do you really need to store all characters in a RAM? What kind of LCD is it?