makanaky
Advanced Member level 4
I was designing T flipflop , I wrote the following code :
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 instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity TFF is
Port ( reset : in STD_LOGIC;
enable : in STD_LOGIC;
clk : in STD_LOGIC;
Q : out STD_LOGIC);
end TFF;
architecture Behavioral of TFF is
signal A:std_logic:='0';
begin
process (clk,reset)
begin
if reset='1' then
Q<='0';
elsif rising_edge(clk) then
if enable='1' then
A<= not A;
end if;
end if;
end process;
Q<= A;
end Behavioral;
problem is when simulating : Q doesnt get to '1' when A changes to '1' , instead it becomes dont care 'X'
Can anybody help me please why does this happen ?
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 instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity TFF is
Port ( reset : in STD_LOGIC;
enable : in STD_LOGIC;
clk : in STD_LOGIC;
Q : out STD_LOGIC);
end TFF;
architecture Behavioral of TFF is
signal A:std_logic:='0';
begin
process (clk,reset)
begin
if reset='1' then
Q<='0';
elsif rising_edge(clk) then
if enable='1' then
A<= not A;
end if;
end if;
end process;
Q<= A;
end Behavioral;
problem is when simulating : Q doesnt get to '1' when A changes to '1' , instead it becomes dont care 'X'
Can anybody help me please why does this happen ?