A D master-slave type flip flop made with a D latch and a SR latch.
Inputs: D, CLK, PRE, CLR
Outputs: Q, ~Q
PRE sets Q to always true.
CLR sets Q to always false.
Note that the red wave is more stable. Small fluctuations in the system does not affect the output. The orange wave shows a conventional d flip flop, with way more fluctuations