Dinho
Newbie level 4
- Joined
- Apr 30, 2011
- Messages
- 6
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,462
Hello people,
I start short time to student VHDL, and in this moment I can not solve one problem.
I want use the LCD GDM1602A is in UP3 Education Kit the Altera.
But I don’t know how I can do this. My Idea is use one signal (b) for came the other code to show your velour in LCD display, and use other signal (flag_lcd) to inform when have to exchange information on the display.
If anyone can help me thank you people.
I did this code but it does not work.
-- FILE NAME : Liquid Crystal Display
-- AUTHOR : Dinho.
-- ---------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Libraries
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
-------------------------------------------------------------------------------
-- Entity
-------------------------------------------------------------------------------
ENTITY tela IS
generic(
COUNT_LENG : integer := 8
);
PORT(
LCD_RS ut std_logic:='0'; -- Resgister select (Seleciona registrar)
LCD_RW ut std_logic:='0'; -- Read / Wirte
LCD_E ut std_logic:='0'; -- Enable signal
clk :in std_logic; -- Clk kit
SF_D ut std_logic_vector(COUNT_LENG-1 downto 0):= (others => '0'); -- informacao frequencia (quero)
b :in std_logic_vector(4 downto 0):= (others => '0'); -- valor do divisor de clk
flag_lcd :in std_logic:='0' -- controla a escrita lcd
);
END tela;
-------------------------------------------------------------------------------
-- Architecture
-------------------------------------------------------------------------------
ARCHITECTURE tela OF tela IS
-----------------------------------
-- Signal Declarations
-----------------------------------
type state_type is (stA, stB, stC, stD, stE);
signal state : state_type := stA;
signal clken : std_logic_vector(16 downto 0):= (others => '0');
signal reset : std_logic := '0';
signal enable : std_logic := '0';
signal counter : std_logic_vector(2 downto 0) := "000";
signal digit1 : std_logic_vector(7 downto 0):= (others => '0');
signal digit2 : std_logic_vector(7 downto 0):= (others => '0');
signal b01_sr : std_logic_vector(1 downto 0):= (others => '0'); --registrador de borda
signal clken_sr : std_logic_vector(1 downto 0):= (others => '0');
BEGIN
-----------------------------------
-- Asynchronous Assignments
-----------------------------------
digit2 <= "00110000" when b = "00000" else
"00110001" when b = "00001" else
"00110010" when b = "00010" else
"00110011" when b = "00011" else
"00110100" when b = "00100" else
"00110101" when b = "00101" else
"00110110" when b = "00110" else
"00110111" when b = "00111" else
"00111000" when b = "01000" else
"00111001" when b = "01001" else
"00110000" when b = "01010" else
"00110001" when b = "01011" else
"00110010" when b = "01100" else
"00110011" when b = "01101" else
"00110100" when b = "01110" else
"00110101" when b = "01111" else
"00110110" when b = "10000" else
"00110111" when b = "10001" else
"00111000" when b = "10010" else
"00111001" when b = "10011" else
"00111010";
digit1 <= "00110000" when b = "00000" else
"00110000" when b = "00001" else
"00110000" when b = "00010" else
"00110000" when b = "00011" else
"00110000" when b = "00100" else
"00110000" when b = "00101" else
"00110000" when b = "00110" else
"00110000" when b = "00111" else
"00110000" when b = "01000" else
"00110000" when b = "01001" else
"00110001" when b = "01010" else
"00110001" when b = "01011" else
"00110001" when b = "01100" else
"00110001" when b = "01101" else
"00110001" when b = "01110" else
"00110001" when b = "01111" else
"00110001" when b = "10000" else
"00110001" when b = "10001" else
"00110001" when b = "10010" else
"00110001" when b = "10011" else
"00111010";
SF_D <= "00000001" when counter = "000" else -- Clear
"00001000" when counter = "001" else -- Clear
"01000010" when counter = "010" else -- B
"00111101" when counter = "011" else -- =
digit1 when counter = "100" else -- Primeiro Digito
digit2; -- Segundo Digito
LCD_RS <= '0' when counter = "000" else
'0' when counter = "001" else
'1' when counter = "010" else
'1' when counter = "011" else
'1' when counter = "100" else
'1';
LCD_E <= enable;
-----------------------------------
-- Processes
-----------------------------------
PROCESS(clk)
BEGIN
IF(clk'EVENT AND clk = '1')THEN -- edge of the clock
clken <= clken +1;
clken_sr <= clken_sr(0) & clken(16);
if clken_sr = "01" then
b01_sr <= b01_sr(0) & flag_lcd ;
-- ESTADO A
if state = stA then
if b01_sr = "01" then
enable <= '0';
counter <= "000";
state <= stB;
else
state <= stA;
end if;
end if;
-- ESTADO B
if state = stB then
enable <= '0';
state <= stC;
end if;
-- ESTADO C
if state = stC then
enable <= '1';
state <= stD;
end if;
-- ESTADO D
if state = stD then
enable <= '0';
state <= stE;
end if;
-- ESTADO E
if state = stE then
counter <= counter + '1';
if counter = "101" then
state <= stA;
else
state <= stB;
end if;
end if;
end if;
end if;
end process;
end tela;
Thank you very much.
Best regards,
I start short time to student VHDL, and in this moment I can not solve one problem.
I want use the LCD GDM1602A is in UP3 Education Kit the Altera.
But I don’t know how I can do this. My Idea is use one signal (b) for came the other code to show your velour in LCD display, and use other signal (flag_lcd) to inform when have to exchange information on the display.
If anyone can help me thank you people.
I did this code but it does not work.
-- FILE NAME : Liquid Crystal Display
-- AUTHOR : Dinho.
-- ---------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Libraries
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
-------------------------------------------------------------------------------
-- Entity
-------------------------------------------------------------------------------
ENTITY tela IS
generic(
COUNT_LENG : integer := 8
);
PORT(
LCD_RS
LCD_RW
LCD_E
clk :in std_logic; -- Clk kit
SF_D
b :in std_logic_vector(4 downto 0):= (others => '0'); -- valor do divisor de clk
flag_lcd :in std_logic:='0' -- controla a escrita lcd
);
END tela;
-------------------------------------------------------------------------------
-- Architecture
-------------------------------------------------------------------------------
ARCHITECTURE tela OF tela IS
-----------------------------------
-- Signal Declarations
-----------------------------------
type state_type is (stA, stB, stC, stD, stE);
signal state : state_type := stA;
signal clken : std_logic_vector(16 downto 0):= (others => '0');
signal reset : std_logic := '0';
signal enable : std_logic := '0';
signal counter : std_logic_vector(2 downto 0) := "000";
signal digit1 : std_logic_vector(7 downto 0):= (others => '0');
signal digit2 : std_logic_vector(7 downto 0):= (others => '0');
signal b01_sr : std_logic_vector(1 downto 0):= (others => '0'); --registrador de borda
signal clken_sr : std_logic_vector(1 downto 0):= (others => '0');
BEGIN
-----------------------------------
-- Asynchronous Assignments
-----------------------------------
digit2 <= "00110000" when b = "00000" else
"00110001" when b = "00001" else
"00110010" when b = "00010" else
"00110011" when b = "00011" else
"00110100" when b = "00100" else
"00110101" when b = "00101" else
"00110110" when b = "00110" else
"00110111" when b = "00111" else
"00111000" when b = "01000" else
"00111001" when b = "01001" else
"00110000" when b = "01010" else
"00110001" when b = "01011" else
"00110010" when b = "01100" else
"00110011" when b = "01101" else
"00110100" when b = "01110" else
"00110101" when b = "01111" else
"00110110" when b = "10000" else
"00110111" when b = "10001" else
"00111000" when b = "10010" else
"00111001" when b = "10011" else
"00111010";
digit1 <= "00110000" when b = "00000" else
"00110000" when b = "00001" else
"00110000" when b = "00010" else
"00110000" when b = "00011" else
"00110000" when b = "00100" else
"00110000" when b = "00101" else
"00110000" when b = "00110" else
"00110000" when b = "00111" else
"00110000" when b = "01000" else
"00110000" when b = "01001" else
"00110001" when b = "01010" else
"00110001" when b = "01011" else
"00110001" when b = "01100" else
"00110001" when b = "01101" else
"00110001" when b = "01110" else
"00110001" when b = "01111" else
"00110001" when b = "10000" else
"00110001" when b = "10001" else
"00110001" when b = "10010" else
"00110001" when b = "10011" else
"00111010";
SF_D <= "00000001" when counter = "000" else -- Clear
"00001000" when counter = "001" else -- Clear
"01000010" when counter = "010" else -- B
"00111101" when counter = "011" else -- =
digit1 when counter = "100" else -- Primeiro Digito
digit2; -- Segundo Digito
LCD_RS <= '0' when counter = "000" else
'0' when counter = "001" else
'1' when counter = "010" else
'1' when counter = "011" else
'1' when counter = "100" else
'1';
LCD_E <= enable;
-----------------------------------
-- Processes
-----------------------------------
PROCESS(clk)
BEGIN
IF(clk'EVENT AND clk = '1')THEN -- edge of the clock
clken <= clken +1;
clken_sr <= clken_sr(0) & clken(16);
if clken_sr = "01" then
b01_sr <= b01_sr(0) & flag_lcd ;
-- ESTADO A
if state = stA then
if b01_sr = "01" then
enable <= '0';
counter <= "000";
state <= stB;
else
state <= stA;
end if;
end if;
-- ESTADO B
if state = stB then
enable <= '0';
state <= stC;
end if;
-- ESTADO C
if state = stC then
enable <= '1';
state <= stD;
end if;
-- ESTADO D
if state = stD then
enable <= '0';
state <= stE;
end if;
-- ESTADO E
if state = stE then
counter <= counter + '1';
if counter = "101" then
state <= stA;
else
state <= stB;
end if;
end if;
end if;
end if;
end process;
end tela;
Thank you very much.
Best regards,