I'm a newbie in VHDL Programming and I am having trouble with this VHDL code (sync counter). The variable Q_AUX_4 is never assigned to the output Q_OUT because when I try to run simulation, using modelsim, is always set to "UUUU". This is even more strange because Q_AUX_4 is initialized to "0000", so It's like that line is never triggered. Thank you for every response
counter4.vhdl
LIBRARY IEEE;
USE ieee.STD_LOGIC_1164.all;
ENTITY COUNTER4 IS
PORT ( EN,CK,CL: IN STD_LOGIC;
Q_OUT: OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
T_OUT_4: OUT STD_LOGIC);
END COUNTER4;
ARCHITECTURE BEHAVIOR OF COUNTER4 IS
COMPONENT T_FLIP_FLOP IS
PORT ( T,CLK,CL: IN STD_LOGIC;
Q, T_OUT: OUT STD_LOGIC);
END COMPONENT;
SIGNAL Q_AUX_4 : STD_LOGIC_VECTOR(3 DOWNTO 0) := (OTHERS=>'0');
SIGNAL T_AUX: STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN
F0: T_FLIP_FLOP PORT MAP(EN,CK,CL,Q_AUX_4(0),T_AUX(0));
F1: T_FLIP_FLOP PORT MAP(T_AUX(0),CK,CL,Q_AUX_4(1), T_AUX(1));
F2: T_FLIP_FLOP PORT MAP(T_AUX(1),CK,CL,Q_AUX_4(2), T_AUX(2));
F3: T_FLIP_FLOP PORT MAP(T_AUX(2),CK,CL,Q_AUX_4(3), T_AUX(3));
Q_OUT <= Q_AUX_4;
T_OUT_4 <= (T_AUX(2) AND Q_AUX_4(3));
END BEHAVIOR;
T_flip_flop.vhdl
LIBRARY IEEE;
USE ieee.std_logic_1164.all;
ENTITY T_flip_flop is
PORT ( T,CLK, CL: IN STD_LOGIC;
Q, T_OUT: OUT STD_LOGIC);
end T_flip_flop;
Architecture Behavior of T_flip_flop is
SIGNAL Q_AUX: STD_LOGIC := '0';
BEGIN
PROCESS (T,CLK,CL)
BEGIN
if ((CLK = '1' AND CLK'EVENT) AND T = '1') THEN
Q_AUX <= NOT Q_AUX;
else Q_AUX <= Q_AUX;
END IF;
IF (CL = '1') THEN Q_AUX <= '0';
END IF;
Q <= Q_AUX;
T_OUT <= (Q_AUX AND T);
END PROCESS;
END behavior;
I tried to put the assignment in a process triggered by Q_AUX_4 but the result is the same. I expect Q_OUT to be a copy of Q_AUX_4