Electrical – How to build PIPO register

digital-logicflipfloplogic-gatesnandregister

Ive got problem with simulating 8-bit register. Ive built register using eight D flip – flop. Every flip-flop was made with 5 NAND gates + 2 NAND gates for Preset. My problem is that register doesnt really store input value. When ie D0 change to 1 the Output Q0 change to 1 but when Input change back to 0 output change as well. Do I need some extra latch on output or input? Ive added three-state buffers on inputs and outputs pins and it works good but when I change "Input enabled" pin to 0, buffers outputs change to 0 and register is changing output.
Is this regular behaviour of regsiters or I should add something to this circuit?
8-bit register, D flip-flops, NAND


Should I use flip flop like this one?
RS flip flop

Best Answer

What you have constructed would more properly be called a "latch" (level-sensitive) rather than a "register" (edge-sensitive). In order for it to hold the data, you need to drive the Clk input low.

In other words, whenever Clk is high, the output will follow the input, as you have described. When Clk is low, the output will retain whatever value the input had at the moment Clk went from high to low.