0

The data flip flop can delay operation based on the time of the cycle of the clock. If the clock's cycle is fast, the DFF is useless because it's like an instant change.

Is it possible to change the cycle speed of the clock? If yes, so for which purpose I would want to change something now -> and let it change only T time after?

I understand that DFF is used in computer RAMs for saving data, but I don't really understand how it saves data because:

If the clock cycle is really fast, it's like an instant result, so I don't need the clock, If the clock cycle is slow, I don't want it in the RAM because I need an immediate change to the data.

Basically, I'd like clarification about DFF generally and its connection to RAM registers :)

  • How would you build a counter? You need some means of storing the current count. – Kartman Feb 10 '21 at 07:55
  • 4
    Do you know what a logic hazard is? D flip flops help prevent logic hazards from getting clocked into the next clock period by registering or synchronizing inputs that are not naturally synchronous to the clock. – user57037 Feb 10 '21 at 07:56
  • @Kartman You can build a counter with any type of flip flop. Seems the OP is only asking about D flip flops. – user57037 Feb 10 '21 at 07:58

1 Answers1

4

Flip-flops (edge-triggered D type) serve several purposes in computer architectures:

  • as sequential state registers (e.g., program counter)
  • as cycle-delay elements (pipelines) that break up combinatorial paths
  • as fast storage elements (registers) for holding data

The cycle-delay use is important. It allows the clock speed to be increased because long delays are broken up into shorter ones and processed in a series of stages. The downside is, the overall latency is increased, and the impact of a program branch becomes greater if the pipeline has to be flushed.

When flip-flops are used for fast storage, they generally will have a clock enable to control when they are updated with data. So the data hangs around for longer, as long as the CPU needs it.

An array of these fast storage registers is called a register file, which can be thought of as a small type of RAM to supply operands and store results at CPU clock speed. Typical register files have multiple read and write ports, allowing single-cycle fetch of multiple operands at once.

Static RAMs, such as those used in caches and buffer memories, don't use edge-triggered flip-flops. Instead, they use latches, which require fewer transistors per cell to make than the flip-flop. RAM cells are about 6 transistors per cell, vs. 18 or more for a D flip-flop. This saves area and power, but costs a bit in speed.

Dynamic RAMs, used for main storage, use a capacitor to store data, and are about 1 transistor per cell. This makes them much more dense and much lower cost/bit than SRAM. The tradeoff is access time (latency) and somewhat lower throughput than SRAM. They also require periodic refreshing to restore the charge that leaks off.

So here's your hierarchy of CPU storage, in a nutshell:

  • local state machines (D flip flops)
  • pipelines (D flip-flops)
  • registers / register files (D flip-flops with enables)
  • SRAM (latches)
  • DRAM (capacitors)
hacktastical
  • 49,832
  • 2
  • 47
  • 138
  • First of all, That you for the great, detailed explanation. I'll upvote you when I'll have the ability. I have another question: When not using latches in registers? It seems like the D flipflops are made generally for clock synchronization, but the ability to save memory is dependant on the Enable. – igal leikin Feb 11 '21 at 06:17
  • Registers can use latches too, but the timing model for latches is more complex than using D flops with clock enables, since the output can change while the latch is being written. This isn’t the case with the D flop, whose output only changes state at the clock transition. As far as D flops being ‘generally for clock synchronization’, that kind of misses the purpose. D flops are for making any kind of *sequential* system that needs to hold state. – hacktastical Feb 11 '21 at 07:11
  • A D flop is two latches, one after the other – pjc50 Feb 11 '21 at 09:54
  • Yes, here's a detailed treatment of that: https://electronics.stackexchange.com/questions/543323/analysis-of-two-d-flip-flop-designs-based-on-d-latches/545102#545102 – hacktastical Feb 11 '21 at 17:34