Search code examples
vhdllcd

Controlling an LCD in VHDL on spartan 6


I found this code which controls an LCD display of an FPGA but it can't seen to understand some of the code, in particular this part

    type LCD_CMDS_T is array(integer range <>) of std_logic_vector(9 downto 0);
    constant LCD_CMDS : LCD_CMDS_T := ( 0 => "00"&X"3C",            --Function Set
                        1 => "00"&X"0C",                --Display ON, Cursor OFF, Blink OFF
                        2 => "00"&X"01",                --Clear Display
                        3 => "00"&X"02",            --return home

                        4 => "10"&X"48",            --H 
                        5 => "10"&X"65",            --e
                        6 => "10"&X"6C",            --l
                        7 => "10"&X"6C",            --l
                        8 => "10"&X"6F",            --o
                        9 => "10"&X"20",            --blank
                        10 => "10"&X"46",           --F
                        11 => "10"&X"72",           --r
                        12 => "10"&X"6F",           --o
                        13 => "10"&X"6D",           --m

                        14 => "10"&X"20",           --blank

                        15 => "10"&X"44",           --D
                        16 => "10"&X"69",           --i
                        17 => "10"&X"67",           --g
                        18 => "10"&X"69",           --i
                        19 => "10"&X"6C",           --l
                        20 => "10"&X"65",           --e
                        21 => "10"&X"6E",           --n
                        22 => "10"&X"74",           --t
                        23 => "00"&X"18");          --Shift left


signal lcd_cmd_ptr : integer range 0 to LCD_CMDS'HIGH + 1 := 0;

I understand that an array has been made to hold values of character to be displayed on the display. but i don't understand this line.

signal lcd_cmd_ptr : integer range 0 to LCD_CMDS'HIGH + 1 := 0;

Can anyone help me to understand whats done here


Solution

  • This signal is being created to index into the string that was created. The constant LCD_CMDS is an array that needs to be indexed. The signal lcd_cmd_ptr is indexing into that constant to drive the display. It is an integer than can be from 0 to 23 in this case.

    I bet somewhere there's a line that has: LCD_CMDS(lcd_cmd_ptr)