In digital logic design, circuits fall into two categories:combinational logic and sequential logic.
Combinational logic circuits are implementation of Booleanfunctions. They compute their outputs as functions of theirinput. They do not have any memory elements.
Sequential logic circuits, implement functions with state.That is, they keep information internally (think of this informationbeing stored in data members of an object). The output of a sequentialcircuit depends not only on the input bits, but also on the internalstate.
It turns out, for sequential circuits, it’s easier to designwith a clock.
So, what’s a clock?
Most people think of a clock as a way to tell time. Why woulda computer need to know how to tell time?
A clock, on a computer, isn’t the same kind of clock usedin your home, or on a watch. If you’ve ever bought a computer,one of the more important features it the clock rate. For example,you may buy a machine that’s running at 2 GHz. Do you knowwhat 2 GHz refers to? It refers to a clock!
Timing Diagram of a Clock
The behavior of a clock can be easily described using atiming diagram. A timing diagram has timeon the horizontal axis (x-axis) and the voltage on thevertical axis (y-axis). For simplicity, we use 0 and 1,instead of voltages.
Here’s an example
A clock is a device that alternates between 0 and 1, repeatedly.We can define key features of this plot.
The most important is the amount of time it takes before thesignal repeats. This time is called the period, which we call T. In this period, there is a single cycle.
The period is related to the frequency, f. In fact,they are inversely related f = 1/T. The frequency meanshow many times the waveform repeats per second. The unit ofmeasurement for frequency is Hz (pronounced Hertz), andis the same as s-1 (inverse seconds).
The higher the frequency, the shorter the period of one cycle.When you hear a clock is 1 GHz, this means there is 109cycles per second (G = giga = 109).
Consequently, the period is 10-9seconds, which isa nanosecond.
Look at one cycle of the clock.
In this one cycle, the clock has an output of 1 for part of thetime, and 0 for part of the time. Now it appears that it is 1 forhalf the time (i.e., for T/2), and 0 for half the time, but it turnsout it’s not that important for the clock to have that property.It’s OK if the clock is 1 for 3/4 T and 0 for 1/4 T, even thoughit’s fairly common for it to be T/2 and T/2.
A clock also has “edges”. These are the times that the clocktransitions from 0 to 1 (this is called a positive edge) orfrom 1 to 0 (this is called a negative edge). In the originalclock diagram at the top, the edges are shown to go instantaneouslyfrom 0 to 1. In reality, that does not happen.
The clock looks more like:
In other words, there’s a small amount of time to transition from 0to 1 (call the rise time) and a small amount of time totransition from 1 to 0 (called the fall time). The timingdiagram has been exaggerated to make the rise and fall time more obvious.In general, those times are very short compared to the time the clockstays at 1 or 0. On the diagram, you see the label “positive”. This indicates a0 to 1 transition. That transition is considered a positive edge(since it has a positive slope). The 1 to 0 transition is calleda negative edge (since it has a negative slope).
Why Are Clock Edges Important?
Flip flops (and registers, which are built from flip flops) are timeddevices. They use a clock.
A flip flop can store 1 bit of information. In a positiveedge-triggered flip flop, the value stored in the flip flop can onlychange when a positive edge occurs. Thus, it can only change atthe circled portion (shown in the previous figure) that says “positive”.
At all other times (i.e., when the clock is steady at 1, or steadyat 0, or transitioning from 1 to 0 on a negative edge), the flip flopholds its value. That is, its value can not change.
Thus, edge triggered flip flops can only change its values atthe edge of a clock.
You might wonder why flip flops are designed this way, whencombinational logic circuits (i.e., AND gates, OR gates, etc)do not use any clocks.
It turns out that its easier to design digital circuits whichcan only change values at an edge. This will be explained later.
Why Not Faster Clocks?
If you’ve used a computer, you’ve heard clock rates get fasterand faster. In 1980, personal computers ran as slow as 4.77 MHz.Modern CPUs now run at 3 Ghz. It was probably fairly easy tocreate a very fast clock. I’m sure you can create clocks thatare 10 GHz or faster. However, circuits have to be built smallenough so that they can operate at the speed of the clock.
If you run a CPU with a clock rate that’s way too high, thenit may not complete certain computations before the clock edgeappears.
It’s similar to a conductor conducting an orchestra. Hecan only conduct the pace so quickly before the players can notkeep up with pace without making mistakes.
In a computer, it takes time to perform computations. Astechnology gets better, this time can be shortened, and the clockcan therefore be made quicker.
Here’s a summary of clocks.
- A clock is a periodic signal that alternates between 0 and 1.
- The time it takes for a waveform to repeat is called a period. We usually use T to indicate period.
- The frequency of a clock is the inverse of the period. Thus,f = 1/T. The smaller the period, the larger the frequency.
- Frequency is measured as s-1 which is inverseseconds. This is also called Hertz, abbreviated Hz.
- A clock does not necessarily output 1 half the time, and output 0the other half, although it is common for this to happen.
- A clock has a positive edge (which is the time it transitionsfrom 0 to 1) and a negative edge (which is the time it transitions from1 to 0).
- Clock rates are determined by how fast a CPU can performan operation. The faster an operation can be performed, the fasteryou can set the clock rate.
- Clock rates for modern CPUs are in the gigahertz range. Inthis case, giga refers to 109 (as opposed to gigabytes,which is 230)