Haz una pregunta
  Foros de Electrónica » Diseño digital » Circuitos lógicos combinacionales y secuenciales
Foros Registrarse ¿Olvidaste tu contraseña?

Temas similares

03/03/2012 #1

Avatar de tckjonixx

duda en el siguiente codigo vhdl
que tal compañeros, este codigo lo encontre y pues note que en la parte de de los WHEN la señal sale mal un ejemplo: when "010111" => ossz <= "101000";-- H (no se supone que H es 011000 en bcd 6 bits por lo tanto esa linea quedaria when "010111" => ossz <= "011000";-- H
me corrigen si estoy mal.... gracias)asi como esa linea creeria q casi todas tineen ese problema....en si lo que hace el codigo es mostrar HELLO WORLD en una la fgpa... pero bueno este es el codigo.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use work.my_package.all; --PAQUETE CREADO PREVIAMENTE
entity lcd_6 is
Port ( clk,rst,ce : in STD_LOGIC;
sf_ce0 : out STD_LOGIC;

rs : out STD_LOGIC;
rw : out STD_LOGIC;
en : out STD_LOGIC;
out0,out1,out2,out3 : out STD_LOGIC);
end lcd_6;

architecture Behavioral of lcd_6 is

signal ossz : STD_LOGIC_VECTOR (5 downto 0);

signal ora : STD_LOGIC := '0';
signal lcd_stb : STD_LOGIC := '0';

signal lcd_stuff : STD_LOGIC_VECTOR (6 downto 0) := "0000000";
signal count : STD_LOGIC_VECTOR(26 downto 0) := "000000000000000000000000000";
signal b: STD_LOGIC := '1';

signal Q1,Q2,Q3:STD_LOGIC_VECTOR(3 downto 0):="0000";

begin



Q:COMPONENT BCD_3 PORT MAP(CLK,CE,RST,Q1,Q2,Q3);
process (clk) begin
if clk'event and clk='1' then
count <= count + 1;
sf_ce0 <= '1';
-------------------LCD initialization process -------------------------------
case (count(25 downto 20)) is
when "000000" => ossz <= "000011"; --X"03"
when "000001" => ossz <= "000011"; --X"03"
when "000010" => ossz <= "000000"; --X"03"
when "000011" => ossz <= "000010"; --X"02"
when "000100" => ossz <= "000010"; --X"02" function set
when "000101" => ossz <= "001000"; --X"08"
when "000110" => ossz <= "000000";-- X"00" entry mode
when "000111" => ossz <= "000110"; --X"06"
when "001000" => ossz <= "000000"; -- display on/off
when "001001" => ossz <= "001100";
when "001010" => ossz <= "000000"; -- display clear
when "001011" => ossz <= "000001";
when "001100" => ossz <= "000000"; -- Take cursor home
when "001101" => ossz <= "001111";
------------- Data operation for LCD ----------------------------------
when "001110" => ossz <= "100011"; -- Drive with the counter o/p
when "001111" => ossz(5 downto 4) <= "10";
ossz(3 downto 0) <= Q3;

when "010000" => ossz <= "100011";
when "010001" => ossz(5 downto 4) <= "10";
ossz(3 downto 0) <= Q2;
when "010010" => ossz <= "100011";
when "010011" => ossz(5 downto 4) <= "10";
ossz(3 downto 0) <= Q1;
when "010100" => ossz <= "101011";
when "010101" => ossz <= "100000";
-- ossz(3 downto 0) <= Q1;
when "010110" => ossz <= "100100";
when "010111" => ossz <= "101000";-- H
when "011000" => ossz <= "100100";
when "011001" => ossz <= "100101";-- E
when "011010" => ossz <= "100100";
when "011011" => ossz <= "101100";-- L
when "011100" => ossz <= "100100";
when "011101" => ossz <= "101100";-- L
when "011110" => ossz <= "100100";
when "011111" => ossz <= "101111";-- O
when "100000" => ossz <= "101010";
when "100001" => ossz <= "100000";--
when "100010" => ossz <= "100101";
when "100011" => ossz <= "100111";-- W
when "100100" => ossz <= "100100";
when "100101" => ossz <= "101111";-- O
when "100110" => ossz <= "100101";
when "100111" => ossz <= "100010";-- R
when "101000" => ossz <= "100100";
when "101001" => ossz <= "101100";-- L
when "101010" => ossz <= "100100";
when "101011" => ossz <= "100100";-- D
when "101100" => ossz <= "100100";
when "101101" => ossz <= "100100";-- D
when others => ossz <= "010000";
end case;

if ora='1' then
ora <= '0';

else
ora <= '1';

end if;

b <= count(19) or count(18);
lcd_stb <= b and NOT ossz(4);
lcd_stuff(6) <= lcd_stb;
lcd_stuff(5 downto 0) <= ossz;

(en, rs, rw,out3,out2,out1,out0 ) <= lcd_stuff;


end if;
end process;
end Behavioral;
04/03/2012 #2

Avatar de chclau

Hay algo medio raro ahí, parecen códigos ASCII pero sobre un bus de 6 bits?

Convendría que digas como se llama el LCD, para ver su hoja de datos.
04/03/2012 #3

Avatar de tckjonixx

es el display de la spartan 3e LCD SITRONIX ST7066U

otra pregunta...podria yo cambiar esas señales de 6 bits a 7 bits?....podria ser asi?
solo cambiarle en la parte de: (y logico, tambien cambiarles las señales de 6 a 7 bits)

signal ossz : STD_LOGIC_VECTOR (5 downto 0);

-------------------LCD initialization process -------------------------------
case (count(25 downto 20)) is

por
signal ossz : STD_LOGIC_VECTOR (6 downto 0);


-------------------LCD initialization process -------------------------------
case (count(25 downto 19)) is --- con 7 bits

....esto afectaria a la hora de declarar los pines de la spartan 3e??

gracias
04/03/2012 #4

Avatar de tckjonixx

hola ps quise modificarlo para que mostrara JOHN--MIGUEL pero esta vez lo hice con 7 bits no de 6 bits como estaba antes (lo compile y no me sale errores ) no se que dicen ustedes este es el codigo.
Código:
library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use IEEE.STD_LOGIC_ARITH.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 
use work.mi_paquete.all; 
entity lcd_6 is 
   Port ( clk,rst,ce : in  STD_LOGIC; 
          sf_ce0 : out STD_LOGIC; 
          
          rs : out  STD_LOGIC; 
          rw : out  STD_LOGIC; 
          en : out  STD_LOGIC; 
          out0,out1,out2,out3 : out  STD_LOGIC); 
end lcd_6; 

architecture Behavioral of lcd_6 is 

signal ossz : STD_LOGIC_VECTOR (6 downto 0); 

signal ora : STD_LOGIC := '0'; 
signal lcd_stb : STD_LOGIC := '0'; 

signal lcd_stuff : STD_LOGIC_VECTOR (6 downto 0) := "0000000"; 
signal count : STD_LOGIC_VECTOR(26 downto 0) := "000000000000000000000000000"; 
signal  b: STD_LOGIC := '1'; 

signal Q1,Q2,Q3:STD_LOGIC_VECTOR(3 downto 0):="0000"; 

begin   


  
   Q:COMPONENT BCD_3 PORT MAP(CLK,CE,RST,Q1,Q2,Q3);   
   process (clk) begin 
   if clk'event and clk='1' then 
           count <= count + 1; 
       sf_ce0 <= '1'; 
-------------------LCD inicio -------------------------------            
        case (count(26 downto 20)) is 
           when "0000000" => ossz <= "0000011";             --X"03" 
           when "0000001" => ossz <= "0000011";             --X"03" 
           when "0000010" => ossz <= "0000011";             --X"03" 
           when "0000011" => ossz <= "0000011";             --X"02" 
           when "0000100" => ossz <= "0000010"; --X"02" function set 
           when "0000101" => ossz <= "0001000"; --X"08" backspace 
           when "0000110" => ossz <= "0000000";-- X"00" entry mode 
           when "0000111" => ossz <= "0000110";--X"06" Acknowledge character/reconocimiento de caracteres 
           when "0001000" => ossz <= "0010001"; -- display on/off 
           when "0001001" => ossz <= "0010011"; 
           when "0001010" => ossz <= "0000000"; -- display clear 
           when "0001011" => ossz <= "0000001"; 
           when "0001100" => ossz <= "0000001"; -- Take cursor home 
           when "0001101" => ossz <= "0001111"; 
------------- Operacion LCD     ----------------------------------            
            when "0001110" => ossz <= "0100011"; -- Drive with the counter o/p 
           when "0001111" =>  ossz(5 downto 4) <= "10"; 
           ossz(3 downto 0) <= Q3; 

           when "0010000" =>  ossz <= "0100011";   
   when "0010001" =>  ossz(5 downto 4) <= "10"; 
   ossz(3 downto 0) <= Q2; 	
           when "0010010" => ossz <= "0100011"; 
   when "0010011" =>  ossz(5 downto 4) <= "10";     
     ossz(3 downto 0) <= Q1; 
   when "0010100" => ossz <= "0101011"; 
   when "0010101" => ossz <= "0100000";     
--      ossz(3 downto 0) <= Q1; 
   when "0010110" => ossz <= "0100000"; 
   when "0010111" => ossz <= "1001010";--J
   when "0011000" => ossz <= "0100000"; 
   when "0011001" => ossz <= "1001111";-- O 
   when "0011010" => ossz <= "0100000"; 
   when "0011011" => ossz <= "1001000";-- H 
   when "0011100" => ossz <= "0100000"; 
   when "0011101" => ossz <= "1001110";-- N 
   when "0011110" => ossz <= "0100000"; 
   when "0011111" => ossz <= "0101101";-- - 
   when "0100000" => ossz <= "0101101"; -- -
   when "0100001" => ossz <= "0101101";-- -
   when "0100010" => ossz <= "0100000"; 
   when "0100011" => ossz <= "1001101";-- M 
   when "0100100" => ossz <= "0100000"; 
   when "0100101" => ossz <= "1001001";-- I 
   when "0100110" => ossz <= "0100000"; 
   when "0100111" => ossz <= "1000111";-- G 
   when "0101000" => ossz <= "0100000"; 
   when "0101001" => ossz <= "1010101";-- U
   when "0101010" => ossz <= "0100000"; 
   when "0101011" => ossz <= "1000101";-- E
   when "0101100" => ossz <= "0100000"; 
   when "0101101" => ossz <= "1001100";-- L 
   when others => ossz   <= "0011010"; --
       end case; 
    
   if ora='1' then 
       ora <= '0'; 
        
   else 
       ora <= '1'; 
      
   end if; 
    
   b <= count(19) or count(18); 
   lcd_stb <= b and NOT ossz(4);   
   lcd_stuff(6) <= lcd_stb; 
    lcd_stuff(6 downto 0) <= ossz; 
    
   (en, rs, rw,out3,out2,out1,out0 ) <= lcd_stuff; 
    
    
   end if; 
   end process;     
end Behavioral;
05/03/2012 #5

Avatar de chclau

Leí el manual de esa tarjeta y usa la interfaz de 4 bits, los bits adicionales son bits de control. Tienes que leer primero como funciona la tarjeta, y después elegir los códigos para las letras según la tabla que define el LCD.

http://www.xilinx.com/support/docume...kits/ug230.pdf
14/03/2012 #6

Avatar de tckjonixx

hola....pues esto es lo que tengo ahora...ya me escribe en la spartan pero no logro que me escriba completo (solo me escribe JOHN y la idea es que me escriba JOHN-MIGUEL) no encuentro ese error
Código:
----------------------------------------------------------------------------------
-- Company: 
-- Engineer: 
-- 
-- Create Date:    21:56:40 03/03/2012 
-- Design Name: 
-- Module Name:    lcd - Behavioral 
-- Project Name: 
-- Target Devices: 
-- Tool versions: 
-- Description: 
--
-- Dependencies: 
--
-- Revision: 
-- Revision 0.01 - File Created
-- Additional Comments: 
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity lcd is
GENERIC(CLK_DIVIDE:INTEGER:=50000);

    Port ( CLK,RST: 	IN BIT;
           RS,RW,SF_CEO: out BIT;
			  E:BUFFER BIT;
			  DB:out BIT_VECTOR(3 downto 0));
end lcd;
architecture Behavioral of lcd is
TYPE Estados IS (F_INIT_1A,F_INIT_1B,F_INIT_2A,
F_INIT_2B,F_INIT_3A,F_INIT_3B,BORRAR1,BORRAR2,
Control1,Control2,Modo1,Modo2,Z1,Z2,J1,J2,O1,O2,H1,H2,N1,N2,M1,M2,I1,I2,G1,G2,U1,U2,E1,E2,L1,L2);---Z1,Z2,J1,J2,O1,O2,H1,H2,N1,N2,
SIGNAL pr_estado, nx_estado:Estados;
begin
SF_CEO<='1';
RELOJ_500Hz: PROCESS(CLK)
VARIABLE Cuenta: INTEGER RANGE 0 TO CLK_DIVIDE;
 begin
       IF(CLK'EVENT AND CLK='1')THEN
		    Cuenta:=Cuenta+1;
			 IF(Cuenta=CLK_DIVIDE)THEN
			    E<=NOT E;
				 Cuenta:=0;
			 END IF;
		 END IF;
   END PROCESS;
MAQUINA: PROCESS(E)
BEGIN
   IF(E'EVENT AND E='1')THEN
	   IF(RST='1')THEN
		  pr_estado<=F_INIT_1A;
		ELSE
		  pr_estado<=nx_estado;
	   END IF;
	END IF;
END PROCESS;

FSM: PROCESS(pr_estado)
    BEGIN
	   CASE pr_estado IS
		   WHEN F_INIT_1A =>
			    RS<='0';RW<='0';
				 DB<="0010";
				 nx_estado<=F_INIT_1B;
			WHEN F_INIT_1B =>
			    RS<='0';RW<='0';
		       DB<="1000";
			    nx_estado<=F_INIT_2A;
			WHEN F_INIT_2A =>
			    RS<='0';RW<='0';
		       DB<="0010";
			    nx_estado<=F_INIT_2B;
			WHEN F_INIT_2B =>
			    RS<='0';RW<='0';
		       DB<="1000";
			    nx_estado<=F_INIT_3A;
			WHEN F_INIT_3A =>
			    RS<='0';RW<='0';
		       DB<="0010";
			    nx_estado<=F_INIT_3B;
			WHEN F_INIT_3B =>
			    RS<='0';RW<='0';
		       DB<="1000";
			    nx_estado<=BORRAR1;
----------------------------------------------------------------------------------
			WHEN BORRAR1 =>
			    RS<='0';RW<='0';
		       DB<="0000";
			    nx_estado<=BORRAR2;
			WHEN BORRAR2 =>
			    RS<='0';RW<='0';
		       DB<="0001";
			    nx_estado<=Control1;
----------------------------------------------------------------------------------
			WHEN Control1 =>
			    RS<='0';RW<='0';
		       DB<="0000";
			    nx_estado<=Control2;
			WHEN Control2 =>
			    RS<='0';RW<='0';
		       DB<="1100";
			    nx_estado<=Modo1;
----------------------------------------------------------------------------------
         WHEN Modo1 =>
			    RS<='0';RW<='0';
		       DB<="0000";
			    nx_estado<=Modo2;
			WHEN Modo2 =>
			    RS<='0';RW<='0';
		       DB<="0110";
			    nx_estado<=J1;
--------------------------------------------------------------------------------
         WHEN J1 =>
			    RS<='1';RW<='0';
		       DB<="0100";
			    nx_estado<=J2;
			WHEN J2 =>
			    RS<='1';RW<='0';
		       DB<="1010";
			    nx_estado<=O1;
----------------------------------------------------------------------------------
         WHEN O1 =>
			    RS<='1';RW<='0';
		       DB<="0100";
			    nx_estado<=O2;
			WHEN O2 =>
			    RS<='1';RW<='0';
		       DB<="1111";
			    nx_estado<=H1;
----------------------------------------------------------------------------------
         WHEN H1 =>
			    RS<='1';RW<='0';
		       DB<="0100";
			    nx_estado<=H2;
			WHEN H2 =>
			    RS<='1';RW<='0';
		       DB<="1000";
			    nx_estado<=N1;
----------------------------------------------------------------------------------
         WHEN N1 =>
			    RS<='1';RW<='0';
		       DB<="0100";
			    nx_estado<=N2;
			WHEN N2 =>
			    RS<='1';RW<='0';
		       DB<="1110";
			    nx_estado<=Z1;
--------------------------------------------------------------------------------
         WHEN Z1 =>
			    RS<='0';RW<='0';
		       DB<="1011";
			    nx_estado<=Z2;
			WHEN Z2 =>
			    RS<='0';RW<='0';
		       DB<="0000";
			    nx_estado<=M1;
----------------------------------------------------------------------------------
         WHEN M1 =>
			    RS<='0';RW<='0';
		       DB<="0100";
			    nx_estado<=M2;
			WHEN M2 =>
			    RS<='0';RW<='0';
		       DB<="1101";
			    nx_estado<=M1;
----------------------------------------------------------------------------------
         WHEN I1 =>
			    RS<='0';RW<='0';
		       DB<="0100";
			    nx_estado<=I2;
			WHEN I2 =>
			    RS<='0';RW<='0';
		       DB<="1001";
			    nx_estado<=G1;
----------------------------------------------------------------------------------
         WHEN G1 =>
			    RS<='0';RW<='0';
		       DB<="0100";
			    nx_estado<=G2;
			WHEN G2 =>
			    RS<='0';RW<='0';
		       DB<="0111";
			    nx_estado<=U1;
----------------------------------------------------------------------------------
         WHEN U1 =>
			    RS<='0';RW<='0';
		       DB<="0101";
			    nx_estado<=U2;
			WHEN U2 =>
			    RS<='0';RW<='0';
		       DB<="0101";
			    nx_estado<=E1;
----------------------------------------------------------------------------------
         WHEN E1 =>
			    RS<='0';RW<='0';
		       DB<="0100";
			    nx_estado<=E2;
			WHEN E2 =>
			    RS<='0';RW<='0';
		       DB<="0101";
			    nx_estado<=L1;
----------------------------------------------------------------------------------
        WHEN L1 =>
			    RS<='0';RW<='0';
		       DB<="0100";
			    nx_estado<=L2;
			WHEN L2 =>
			    RS<='0';RW<='0';
		       DB<="1100";
			    nx_estado<=L1;


  END CASE;
END PROCESS;

end Behavioral;
14/03/2012 #7

Avatar de chclau

Revisá la señal RS
Respuesta
¿Tienes una mejor respuesta a este tema? ¿Quieres hacerle una pregunta a nuestra comunidad y sus expertos? Registrate

Buscar más temas sobre:
Lupa Circuitos lógicos combinacionales y secuenciales

Compuertas, flips flops, registros, PLDs, codificadores, contadores, multiplexores, ...

Cerrar
Foros de Electrónica » Diseño digital » Circuitos lógicos combinacionales y secuenciales

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2011, Crawlability, Inc.