Electronic – weird Altera simulation result

digital-logicflipflopsimulation

I am trying to build a T flip-flop from a D flip-flop. The D flip-flop looks like this
enter image description here

and the simulated waveform shows that it works.(when there is a rising edge D will be passed to Q)
enter image description here

So I started building a T flip-flop by connecting Qnot to D (I am expecting every clock rising edge Q will be toggled because Qnot is passed to Q)
enter image description here

but the simulated waveform looks like this
enter image description here

Q will oscillate when CLK is low. One oscillation period is around couple ns.
I played with different Clear and Preset signals but it still happens.

If anyone can point out my errors.
Thanks.

Best Answer

The first schematic shows a latch rather than a D flip-flop -- it forwards D to Q when CLK is high. Q maintains its value for CLK low.

This would almost explain the behavior of your latter circuit. Q should remain constant when CLK is low. It will forward !Q when CLK is high and therefore oscillate.

Why the oscillation happens with CLK low I cannot explain (perhaps the two screenshots are inconsistent?).