11_Clocks_flipflops_and_registers

Clocks, Flipflops and registers

In this blog post the author will introduce multiple elements needed at a later stage.

Register-Transfer-Level needs a clock source

As for now we only learned about combinatiorial logic, which works without any clock source - every signal is just delayed by the time it needs to travel through the circuit. This is known as asynchronous. But for more sophisticated tasks, sequential circuits, having registers storing the input and output signals are necessary to get correct results. This is known as synchronous. Most, if not all designs used nowadays are synchronous, due to a lower design complexity.

Register-Transfer-Level

rtl scheme

The blue parts in the image above are showing registers where the values are stored, we will see later how those are implemented, lets first have a look at the clock source which is needed.

There are different ways to create a clock source:

  1. A crystal oscillator

  2. A ring oscillator

The former one is the classical, the later one a more modern variant.

crystal oscillator

ring oscillator

crystal symbol

inverter chain symbol

typical frequence range: 1Mhz..100Mhz

typical frequence range: 1Hz..15Mhz(discrete layout)

pierce gate circuit

inverter chain

frequency determined by crystal geometry

frequency determined by propagation delay and number of gates

accuracy mostly dependent from temperature; for precise applications crystal ovens are used

accuracy mostly dependent from power supply stability

The crystal oscillator

The crystal oscilltor is a clock source based on a quartz crystal. The frequency is dependent on the geometry of the quartz. Crystal oscillators are available in a metal box housing, with additional wiring, with the quartz being the heart of the circuit. The circuit is commonly based on the Pierce oscillator.

pierce gate circuit

Their accuracy is mostly dependent on the temperature,so for applications with high accuracy needs, they are housed in a quartz oven, holding the quartz on a constant temperature. An interesting teardown of such an oscillator is available on Ken Shirriffs blog.

The ring oscillator

Another common source of a clock source is the ring oscillator. The trick here is to chain an odd number of inverter gates and feedback the output of the last inverter as input to the first inverter. This way we create an oscillating circuit.

inverter chain

The frequency is dependent on the number of inverters as well as the propagation time Tp (see the equation below). The time the signal needs to travel trough the gate is known as propagation time Tp.

\[f_{ro} = \frac{1}{2nT_{p}}\]

Here the accuracy is mostly dependent on the stability of the power supply. An example where it is used - e.g. the 8087, intels® Floating Point Unit - is again provided by Ken Shirriffs blog. As shown there, the frequency can be decreased by adding an RC-network between the inverters.

The classic RS-flipflop

The classic flipflop consists of two Nand gates which outputs are feedback’ed to the complementary gate, as can be seen in the table below. Below the circuit the truth table is given. As can be seen the flipflop locks the output to one state, '1' or '0'. If both inputs are set low, the output is undefined (and conforms to the preferred position).

RS-flipflop structure

RS-flipflop symbol

flipflop circuit

flipflop symbol

̅R

̅S

Q

̅Q

comments

0

0

1

1

invalid

0

1

1

0

Reset

1

0

0

1

Set

1

1

Q

̅Q

 — 

One application of the classic RS-flipflop is to debounce switches.

But for most applications a more evolved flipflop is necessary. Let’s have a look at the (D)ata-flipflop.

The D-flipflop

In the D-flipflop the circuit of the RS-flipflop is preceeded by two Nand gates, controlled by a clock impulse. Only when the clock is high (i.e. '1') the date applied to the (D)ata-input is valid and stored in the RS-fliplop. Otherwise the applied data input is invalid.

D-flipflop structure

D-flipflop symbol

dflipflop circuit

dflipflop symbol

Clock

D

Q

̅Q

comments

🠓 >>0

x

Q

̅Q

no change

🠓 >>0

1

1

0

Reset

🠑 >>1

0

0

1

Set

🠑 >>1

1

Q

̅Q

-

A binary counter

Using the D-flipflop we got acquainted with in the last section, we can construct an (asynchronous) binary counter. This output can be used as adresses for a ROM table, as we will see in another blog post.

Asynchronous binary counter with D-flipflops

dflipflop counter

Using the outputs independent, it can be seen that the counter also works as frequency divider: On every output the frequency is divided by two referenced to the previous one.

Registers

What are registers? Registers are used to hold respectively store values. Every slighlty more complex nowadays CPU has copious quantities of registers inside. Register sizes vary widely dependent on the application. Reaching from status registers only holding one bit to registers over 32 and 64 bit for regular registers until vector registers with a size of 64 bytes (= 512 bits). Those registers are named after a certain scheme, in some architectures with numbers (e.g. MIPS and ARM), other times with a more comnplex scheme of alphabetic numbers (like in x86 architectures).

register

In the previous sections we have learned about the flipflop. These are the building blocks of registers. As can be seen in the picture above every flipflop is clocked by the same signal. We will also often use the term accumulator. Accumulators are registers which are source and destination registers at the same time. So e.g. on addition they store one input value and after the operation, holding the result in the same register.

Last update: January 21, 2024