Altera_Forum
Honored Contributor
12 years agoD Flip Flop
Hi All,
I created a simple VHDL D flip flop but saw strange results on the logic analyzer. The code is as follows:
df:process(reset,clk) begin
if(reset='1') then
Q<=0;
else
if(clk'event AND clk='1') then
if(A AND B) then
Q<=D;
else
Q<=Q;
end if;
end if;
end if;
end process;
Where reset,clk, A, Q, D, and B are standard logic vectors. When I view what is happening on the logic analyzer, I see that Q always follows the value of D, regardless of the value of A and B. I'm new to VHDL but what from what I understand Q should never be updated with D unless A and B are true on a clock edge. I also got a compiler warning in Quartus 12.1 about not having D in my sensitivity list. Is there something wrong with this code? Thanks, DigitalEE