Dudas sobre Programación en VHDL

Gracias a Joquines y chclau por sus respuestas, efectivamente con los cambios propuestos por chclau se corrigio el asunto, ahora supongo que el uso de la variable cnt es propiamente una salida logica del contador propuesto y que admite la operacion de suma, y que q es una salida fisica a donde se enviara el valor de la variable cnt, por ello el uso de esa variable, ahora una pregunta la señal de rest y clk las hare a travez de unos interruptores, porque no usar el comando event en la instruccion reset ?? me explicas el uso de others, yo he visto ese comando pero con las directivas del tipo "case", el ejemplo y lo que les comento todo lo he visto en un libro, por ello mis dudas.

Saludos
 
Hola,

- La señal de rst no debe llevar event porque es una senal activa por nivel y no por flanco. Normalmente, las unicas senales activas por flanco deberian ser las del reloj. Si pusieses if (rst'event and rst = '0') then, implicaria que solo se resetearia en el flanco de bajada de rst, y pero despues del flanco no estarias reseteando, incluso si rst sigue a cero.

- others hace que todos los bits de ese vector se pongan al valor indicado, en este caso a cero.

- Un puerto de salida no puede leerse, por eso el uso de la señal auxiliar. Con esto puedes declarar q como puerto de salida (y no inout), y cnt es la que lees dentro del proceso (cnt <= cnt + 1;)

Saludos
 
¿Alguien podría decirme si es posible leer el programa de un FPGA para poder grabarlo en otro?
El problema es que tengo una tarjeta de la cual necesito sacar la programación del FPGA.
 
Última edición por un moderador:
En principio, no.

La mayoria de los FPGA no tienen grabado nada, se "cargan" luego del encendido a traves de una EPROM externa o de un procesador host que lee el archivo de, por ejemplo, una memoria Flash y carga al FPGA.
 
Hola buen día.

En mi clase de digitales nos piden hacer un programa que cuente cuantas veces se activa un sensor.
Deberá activarse el numero de veces que se indique con una botonera, puede ser de 0 a 99 veces.
Al contar las x cantidad de veces, el programa resetea el conteo y vuelve a comenzar.
Además, x cantidad de veces que cuente el sensor se indica en 2 displays de 7 segmentos y el conteo actual se muestra en otros 2 displays.
Los displays son multiplexados.

Ya escribí el programa, pero me marca muchos errores de mapeo.

¿Podría alguien decirme cual es el error?
A continuación pondré el código del programa y los errores que me marca.

Este es el código del programa:

PHP:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.STD_LOGIC_Arith.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity Pract15 is
    Port ( KB : in  Unsigned (9 downto 0);
           Start : in  STD_LOGIC;
              motor : out STD_LOGIC;
           Stop : in  STD_LOGIC;
           SEGDP : out  Unsigned (6 downto 0);
           sensor : in  STD_LOGIC;
           CLKfast : in  STD_LOGIC;
              PolDP : out Unsigned (3 downto 0));
              
end Pract15;

architecture Behavioral of Pract15 is
signal C,RA,RB,CU1,CU2 : Unsigned(3 downto 0);
signal Q : unsigned(6 downto 0);
signal tecla,QCU: unsigned (1 downto 0);
signal SP,CU099 : UNSIGNED(7 downto 0);
signal q1,q2 : unsigned(3 downto 0);
signal MUXDP : unsigned (3 downto 0);
signal reset : std_logic ;
begin
teclado: process(KB, C, tecla)                --este proceso es el encargado de registrar la cantidad
variable i: unsigned(1 downto 0) :="00"; --de veces que contará el sensor antes del reset de ciclo
begin
if KB ="0000000001" then
    C <="0000"; tecla <= i;
    elsif KB ="0000000010" then 
    C <= "0001"; tecla <= i;
    elsif KB ="0000000100" then
    C <= "0010"; tecla <= i;
    elsif KB ="0000001000" then 
    C <= "0011"; tecla <= i;
    elsif KB ="0000010000" then 
    C <= "0100"; tecla <= i;
    elsif KB ="0000100000" then
    C <= "0101"; tecla <= i;
    elsif KB ="0001000000" then
    C <= "0110"; tecla <= i;
    elsif KB ="0010000000" then
    C <= "0111"; tecla <= i;
    elsif KB ="0100000000" then
    C <= "1000"; tecla <= i;
    else 
    C <= "1001"; tecla <= i;
end if;

if tecla ="00" then
RB <= C; -- Unidades
else 
RA <= C; -- Decenas
end if;

i:= i+1;

if (i = "10") then 
i := "00";
end if;

end process;

Convert: process(RA, RB)     -- este proceso convierte los 2 numeros de BCD a entero
--variable X : UNsigned (7 downto 0);
begin
SP <= (RA*10)+(RB);
--SP <= X;
end process;

Memory: process(start, RA, RB) -- Esta memoria registra la cantidad a contar una vez que se 
begin                                     -- presiona el botón de iniciar (start)
if (start' event and start ='1') then
q1 <= RB;
q2 <= RA;
end if;
end process;

Contar99 : process(sensor,CU099, reset) -- Es el contador de conteo actual
begin
If reset = '1' or CU099 = "01100011" or stop = '1' then CU099 <= "00000000";
else
If sensor ' event and sensor = '1' then 
CU099 <= CU099+1;
end if;
end if;
end process;

QuickCU: process(CLKfast, QCU)  --Contador control de multiplexor de display
begin
if CLKfast' event and CLKfast = '1' then
    if QCU = "11" then QCU <= "00";
    else
    QCU <= QCU+1;
    end if;
end if;
end process;

CUnit : process ( sensor, CU1, CU2, reset) -- Este marca el conteo actual y lo envia al MUX para
begin                                                   -- los displays
IF stop = '1' or CU1 = "1010" or reset = '1' then CU1 <= "0000";
else
if sensor ' event and sensor = '1' then
    CU1 <= CU1+1;
    end if;
if (stop ='1' or CU2 = "1010") or reset = '1' then CU2 <= "0000";
if sensor' event and sensor ='1' and CU1 = "1010" then 
    CU2 <= CU2 +1;
end if;
end if;
end if;
end process;

CMP : process (SP, CU099)   -- compara el conteo actual con el solicitado
begin
if SP = CU099 then
reset <= '1';
else reset <= '0';
end if;
end process;

Encoder : process(QCU)   -- este polariza los displays
begin
case QCU is
when "11" => PolDP <= "1110";
when "10" => PolDP <= "1101";
when "01" => PolDP <= "1011";
when "00" => PolDP <= "0111";
when others => PolDP <= "1111";
end case;
end process;

MUX : process( q1,q2,CU1,CU2,QCU)  -- multiplexa el numero que se observará en cada display
begin
case QCU is
when "11" => MUXDP <= q1;
when "10" => MUXDP <= q2;
when "01" => MUXDP <= CU1;
when "00" => MUXDP <= CU2;
when others => MUXDP <= "0000";
end case;
end process;

DISP : Process(MUXDP)        --decoder de BCD a display 7 segmentos
begin
case MUXDP is
when "0000" => SEGDP <= "1000000";
when "0001" => SEGDP <= "1111001";
when "0010" => SEGDP <= "0100100";
when "0011" => SEGDP <= "0110000";
when "0100" => SEGDP <= "0011001";
when "0101" => SEGDP <= "0010010";
when "0110" => SEGDP <= "0000010";
when "0111" => SEGDP <= "1111000";
when "1000" => SEGDP <= "0000000";
when "1001" => SEGDP <= "0011000";
when others => SEGDP <= "1111111";
end case;
end process;
end Behavioral;


La lista de errores es la siguiente:

Código:
ERROR:MapLib:979 - LUT3 symbol "Mmux_MUXDP21" (output signal=Mmux_MUXDP2) has
   input signal "q1<0>" which will be trimmed. See Section 5 of the Map Report
   File for details about why the input signal will become undriven.
ERROR:MapLib:979 - LUT3 symbol "Mmux_MUXDP21" (output signal=Mmux_MUXDP2) has
   input signal "q2<0>" which will be trimmed. See Section 5 of the Map Report
   File for details about why the input signal will become undriven.
ERROR:MapLib:979 - LUT3 symbol "Mmux_MUXDP41" (output signal=Mmux_MUXDP4) has
   input signal "q1<1>" which will be trimmed. See Section 5 of the Map Report
   File for details about why the input signal will become undriven.
ERROR:MapLib:979 - LUT3 symbol "Mmux_MUXDP41" (output signal=Mmux_MUXDP4) has
   input signal "q2<1>" which will be trimmed. See Section 5 of the Map Report
   File for details about why the input signal will become undriven.
ERROR:MapLib:979 - LUT3 symbol "Mmux_MUXDP61" (output signal=Mmux_MUXDP6) has
   input signal "q1<2>" which will be trimmed. See Section 5 of the Map Report
   File for details about why the input signal will become undriven.
ERROR:MapLib:979 - LUT3 symbol "Mmux_MUXDP61" (output signal=Mmux_MUXDP6) has
   input signal "q2<2>" which will be trimmed. See Section 5 of the Map Report
   File for details about why the input signal will become undriven.
ERROR:MapLib:979 - LUT3 symbol "Mmux_MUXDP81" (output signal=Mmux_MUXDP8) has
   input signal "q1<3>" which will be trimmed. See Section 5 of the Map Report
   File for details about why the input signal will become undriven.
ERROR:MapLib:979 - LUT3 symbol "Mmux_MUXDP81" (output signal=Mmux_MUXDP8) has
   input signal "q2<3>" which will be trimmed. See Section 5 of the Map Report
   File for details about why the input signal will become undriven.
ERROR:MapLib:979 - LUT4 symbol "reset853" (output signal=reset853) has input
   signal "RB<0>" which will be trimmed. See Section 5 of the Map Report File
   for details about why the input signal will become undriven.
ERROR:MapLib:978 - LUT3 symbol "Mmux_MUXDP21" (output signal=Mmux_MUXDP2) has an
   equation that uses input pin I0, which no longer has a connected signal.
   Please ensure that all the pins used in the equation for this LUT have
   signals that are not trimmed (see Section 5 of the Map Report File for
   details on which signals were trimmed).
ERROR:MapLib:978 - LUT3 symbol "Mmux_MUXDP21" (output signal=Mmux_MUXDP2) has an
   equation that uses input pin I2, which no longer has a connected signal.
   Please ensure that all the pins used in the equation for this LUT have
   signals that are not trimmed (see Section 5 of the Map Report File for
   details on which signals were trimmed).
ERROR:MapLib:978 - LUT3 symbol "Mmux_MUXDP41" (output signal=Mmux_MUXDP4) has an
   equation that uses input pin I0, which no longer has a connected signal.
   Please ensure that all the pins used in the equation for this LUT have
   signals that are not trimmed (see Section 5 of the Map Report File for
   details on which signals were trimmed).
ERROR:MapLib:978 - LUT3 symbol "Mmux_MUXDP41" (output signal=Mmux_MUXDP4) has an
   equation that uses input pin I2, which no longer has a connected signal.
   Please ensure that all the pins used in the equation for this LUT have
   signals that are not trimmed (see Section 5 of the Map Report File for
   details on which signals were trimmed).
ERROR:MapLib:978 - LUT3 symbol "Mmux_MUXDP61" (output signal=Mmux_MUXDP6) has an
   equation that uses input pin I0, which no longer has a connected signal.
   Please ensure that all the pins used in the equation for this LUT have
   signals that are not trimmed (see Section 5 of the Map Report File for
   details on which signals were trimmed).
ERROR:MapLib:978 - LUT3 symbol "Mmux_MUXDP61" (output signal=Mmux_MUXDP6) has an
   equation that uses input pin I2, which no longer has a connected signal.
   Please ensure that all the pins used in the equation for this LUT have
   signals that are not trimmed (see Section 5 of the Map Report File for
   details on which signals were trimmed).
ERROR:MapLib:978 - LUT3 symbol "Mmux_MUXDP81" (output signal=Mmux_MUXDP8) has an
   equation that uses input pin I0, which no longer has a connected signal.
   Please ensure that all the pins used in the equation for this LUT have
   signals that are not trimmed (see Section 5 of the Map Report File for
   details on which signals were trimmed).
ERROR:MapLib:978 - LUT3 symbol "Mmux_MUXDP81" (output signal=Mmux_MUXDP8) has an
   equation that uses input pin I2, which no longer has a connected signal.
   Please ensure that all the pins used in the equation for this LUT have
   signals that are not trimmed (see Section 5 of the Map Report File for
   details on which signals were trimmed).
ERROR:MapLib:978 - LUT4 symbol "reset853" (output signal=reset853) has an
   equation that uses input pin I2, which no longer has a connected signal.
   Please ensure that all the pins used in the equation for this LUT have
   signals that are not trimmed (see Section 5 of the Map Report File for
   details on which signals were trimmed).

No sé ni a que se refieren los errores, estoy apenas comenzando en esto de programar en VHDL.

Saludos y gracias de antemano.
 
La verdad?

Tiene tantos errores que es dificil guiarte y decirte por donde empezar, y no entiendo como te dieron semejante practica sin comenzar por algo mas simple.

Te diria que empieces despacito, bloque por bloque, y pidas ayuda a tu profesor para los conceptos basicos. VHDL no es un programa, VHDL es una descripcion de hardware.

Cuando escribes VHDL debes imaginarte como el codigo que has escrito se convierte en un MUX, o en un FF, o en un registro. Entonces, te diria que empieces de ahi, y de a poco.
Escribe el codigo de un mux.
Escribe el codigo de un FF, y luego de un registro.
Cada ejemplo, lo simulas, lo verificas y lo sintetizas.

Asi podras entender por ejemplo que no se usa 'event para cualquier cosa, sino unicamente para señales de reloj.

Para ayudarte un poco, puse aqui una version corregida de parte del codigo que escribiste y que se sintetiza sin errores. Fijate si podes agregarle el resto de los bloques teniendo en cuenta lo que ya te dije. Nota que la señal start es utilizada dentro de una logica de flip flop (usa a CLKfast)

Código:
entity Pract15 is
    Port ( 
           SEGDP 	: out  Unsigned (6 downto 0);
           CLKfast  : in  STD_LOGIC;
           PolDP 	: out Unsigned (3 downto 0));
              
end Pract15;

architecture Behavioral of Pract15 is
signal RA,RB,CU1,CU2 : Unsigned(3 downto 0);
signal QCU: unsigned (1 downto 0);
signal q1,q2 : unsigned(3 downto 0);
signal MUXDP : unsigned (3 downto 0);
begin

Memory: process(CLKfast)	 					-- Esta memoria registra la cantidad a contar una vez que se 
begin                                       	-- presiona el botón de iniciar (start)
	if (CLKfast' event and CLKfast ='1') then
		if (start = '1') then
			q1 <= RB;
			q2 <= RA;
		end if;	
	end if;
end process;

QuickCU: process(CLKfast)  					-- Contador control de multiplexor de display
begin
	if CLKfast' event and CLKfast = '1' then
		QCU <= QCU+1;
    end if;
end process;

Encoder : process(QCU)   -- este polariza los displays
begin
	case QCU is
		when "11" => PolDP <= "1110";
		when "10" => PolDP <= "1101";
		when "01" => PolDP <= "1011";
		when "00" => PolDP <= "0111";
		when others => PolDP <= "1111";
	end case;
end process;

MUX : process(q1,q2,CU1,CU2,QCU)  			-- multiplexa el numero que se observará en cada display
begin
	case QCU is
		when "11" => MUXDP <= q1;
		when "10" => MUXDP <= q2;
		when "01" => MUXDP <= CU1;
		when "00" => MUXDP <= CU2;
		when others => MUXDP <= "0000";
	end case;
end process;

DISP : Process(MUXDP)        				--decoder de BCD a display 7 segmentos
begin
	case MUXDP is
		when "0000" => SEGDP <= "1000000";
		when "0001" => SEGDP <= "1111001";
		when "0010" => SEGDP <= "0100100";
		when "0011" => SEGDP <= "0110000";
		when "0100" => SEGDP <= "0011001";
		when "0101" => SEGDP <= "0010010";
		when "0110" => SEGDP <= "0000010";
		when "0111" => SEGDP <= "1111000";
		when "1000" => SEGDP <= "0000000";
		when "1001" => SEGDP <= "0011000";
		when others => SEGDP <= "1111111";
	end case;
end process;
end Behavioral;
 
Última edición:
Hola.
gracias por la ayuda Chclau.
Si puedo sintetizar el proyecto, pero al momento de entrar a la fase del "map" salen todos los errores que están listados.
No se ni a que se refieren y mi profesor, al parecer, tampoco.
Los programas ya los había realizado, bueno algunos de ellos, por ejemplo los contadores, el mux, deco de BCD a 7 segmentos.
Lo que agregué nuevo fue el del teclado.

Gracias por tu ayuda, investigaré a que se refieren los errores que me aparecen al momento del "map" para ver cual podría ser la solución.

Además tengo otra duda.
Si quiero solo registrar un flanco positivo, existe otra instrucción que no vea el pulso como de reloj?
No conozco mucho de como se ejecuta el programa pero imagino que es de forma secuencial de arriba hacia abajo de manera cíclica.
Por lo que supongo que si tengo un contador que cuente hacia arriba cuando esté en '1' la entrada 'x' por ejemplo, si 'x' se activa durante 1 segundo y el la ejecución del programa dura 10 ms, entonces el contador me contaría hasta 100? ya que durante ese segundo se ejecutaron 100 ciclos?
Es debido a eso por lo que uso event en varios lugares.
Si es de esa forma como se realizaría la ejecución? o estoy equivocado?

Espero haber sido claro con mi explicación.

Gracias de antemano.

Saludos.
 
Última edición:
Hola

Nuevamente, VHDL NO ES un programa. Si no entiendes eso, vamos mal.

VHDL es una manera de describir hardware. Por eso no se puede usar 'event para cualquier cosa, se utiliza UNICAMENTE para señales de reloj.

Un contador en VHDL cuenta pulsos de reloj, no existe ninguna "ejecucion del programa" de 100 ciclos ni de 10ms.

Disculpame pero tu profesor no te ha explicado bien, o no has entendido. Como ya te dije, si no entiendes cosas basicas como, como funciona un registro o un contador, mal puedes lograr logica que funcione.

Un contador cuenta pulsos de reloj. La cantidad de pulsos que cuente depende de la frecuencia del reloj y, en los casos en que tal señal existe, de la entrada de habilitacion. Un contador en VHDL es como poner, por dar un ejemplo, un TTL 7490 en tu proyecto. Si entiendes como funciona un contador TTL, entenderas y no tendras ninguna duda sobre como funciona un contador en VHDL.

Te enseñaron a utilizar Modelsim u otra herramienta para simular tus diseños?
 
Última edición:
¿Se pueden crear varios "vhdl file" dentro de un proyecto en Quartus?
Lo que pasa es que vi a un amigo que hacía eso y pues quise intentarlo, pero no corre en mi laptop.
Quisiera resolver mis dudas. Gracias, de ante mano.
 
Última edición por un moderador:
Hola. Apenas empiezo en VHDL y se me presenta un problema al abrir el fichero en Vivado, se queda abriendo el archivo de forma indefinida y termina en nada. Ya lo había guardado, solo me salió un error de sintaxis pero no me abre mas, ¿Qué podría haber pasado? Gracias.

Como apenas empiezo con este lenguaje de descripción ¿Alguien tiene un manual se sintaxis en VHDL?
 
Ando trabado con esta tarea hace unos cuantos días y siempre hay algún caso que me tira error y ya no sé qué probar para solucionarlo. Si alguien me tira una ayudita le estoy más que agradecido.

Este es el código que está hecho hasta ahora: EDA Playground

Y adjunto foto de la tarea a resolver.

1669060200534.png
 
Atrás
Arriba