9
$\begingroup$

I am currently trying to understand how Computers are arranged and organized internally (so that I can learn Assembly Language) through an online book called The Art of Assembly by Randall Hyde. Irrespective of whether or not I'll learn Assembly, I'm finding it difficult to understand exactly how is everything synchronized in the Computer. I'm currently at 3.2 - System Timing topic.

Below are my observations and the things I currently understand not only from the book but also from the things I learned through understanding computers in general.

Reading the book, I've came to understand that there are atleast 2 clocks in the whole system. One is the System Clock which makes one of the lines within the Control Bus go HIGH and LOW periodically. The CPU also has it's own Internal Clock which controls the operations which are done by the CPU. Now the Internal Clock should be in sync with the System Clock for the whole system to make sense which means the control line (which oscillates between low and high) should be connected to the CPU so that both the clock combine and act like a single clock. But then this happened:

Note from the Book

The above snippet is from the PDF version of the same book.

I still didn't get confused after reading this. I perfectly understood that the Internal Clock just runs twice as fast as the System Clock which is fine. My confusion came when the Author mentioned the words "On a 5 MHz 8088/8086 CPU the memory access time..." and "On a 50 MHz 80486, the memory access time...". The question is, 'How can CPUs have their clocks running at certain frequencies when their Clock depends on the System Clock?'. 'Shouldn't their Internal Clock run at a certain multiple of the System Clock?'. I've also came across overclocking the CPU and stuff. 'Won't that make the Internal Clock of the CPU go out of Sync with the System Clock?'

Perhaps the main problem in understanding how everything is synchronized in Computer is the understanding of the word 'synchronized'. And also, 'How many clocks are there in the Computer as a whole?'. Because "Zafaria Kansa" says on the following link on Quora that there are 'Internal' and 'External' Clocks on the CPU: https://www.quora.com/What-does-GHz-mean-How-does-it-relate-to-processor-speed (I don't have enough reputation to post more than two links). Does she mean 'System Clock' when she said 'External Clock'? How does everything fit together?

$\endgroup$
8
  • $\begingroup$ I'm not sure this is ontopic as it seems to concern real CPUs as opposed to concepts. Community votes, please! $\endgroup$
    – Raphael
    Sep 14, 2016 at 12:50
  • $\begingroup$ I cannot find any other relevant Stack Exchange site to post this question on. $\endgroup$ Sep 14, 2016 at 13:08
  • 1
    $\begingroup$ Sorry, but that's not a good reason to post it here. Not all questions have a good place in the Stack Exchange network. $\endgroup$
    – Raphael
    Sep 14, 2016 at 13:22
  • 1
    $\begingroup$ And what do you mean by "clock": "Clock" inside a computer can be meant to be a time measuring device, or a device that produces changes at some more or less regular rate to keep things going, similar to a metronome. (In German, there are two entirely different words "Uhr" and "Taktgeber"). $\endgroup$
    – gnasher729
    Sep 14, 2016 at 20:12
  • 1
    $\begingroup$ electronics.se would perhaps be acceptable if the question was clearer and not relate to cs. But I think the hearth of the question is in the part of computer architecture acceptable for this site and for which this site is a better match than ese. But the question itself is broad and its formulation reveals misconceptions which make it even harder to answer concisely in a useful way for the OP. $\endgroup$ Sep 15, 2016 at 4:23

4 Answers 4

2
$\begingroup$

Modern processors tend to have more clocks than processors in the past, because that means when a part of the processor isn't used, it may be possible to switch off that part completely, including the clock, to save energy.

Clocks are often not synchronised, because synchronising and keeping them synchronised is expensive and complicated, and if you can make a part of the processor work correctly without synchronising its clock, that's overall cheaper.

$\endgroup$
2
$\begingroup$

So this is actually a very difficult question. It highly depends on the specific system used.

So first we have to clarify some naming issues:

Reading the book, I've came to understand that there are atleast 2 clocks in the whole system. One is the System Clock which makes one of the lines within the Control Bus go HIGH and LOW periodically. The CPU also has it's own Internal Clock which controls the operations which are done by the CPU. Now the Internal Clock should be in sync with the System Clock for the whole system to make sense which means the control line (which oscillates between low and high) should be connected to the CPU so that both the clock combine and act like a single clock.

As you pointed out these clocks act as a "single" clock. So are these actually different clocks / clock domains? This highly depends on who you ask and with which requirements you look at it.

There are several relations, 2 clocks can be in with each other:

  • The same clock. I will identify 2 clocks as the same clock if they have the same frequency, phase etc and are generated by the same clock source. For the designers of the system, these 2 clocks might be differnet becasue these have two separate wires etc. But with a higher perspecitve, they are the same.
  • Synchronous clocks. Synchronous clocks must no be generated from the same clock sources but have a fixed phase / frequency relation to each other.
  • Asynchronous clocks. The two clocks are generated by different sources that do no share a common reference and do not have a guaranteed fixed phase and frequency relation.
  • In reality, even the same clock line will have different clock phases at different points on the wire, due to signal propagation delays. Clocks with the same frequency but unknown phases are called mesochronous.

So even inside a single microchip, the same clock can become mesochronous when routed to different locations with different distances. This is a real problem but I will ignore this in the further discussion.

So starting with the simplest case, there is only a single clock necessary for a computer system to operate. Although if it is used for your CPU, memory etc. and might have different names at specific points in the system, it stays the same clock.

Many simple microcontroller systems, especially small 8 bit controllers, only have a single clock. The CPU, RAM, and all the interfaces run on this clock. This is cheap and easy. And if the system is small enough you don't get severe problems by routing this clock to all places.

I've attached the clock tree of an STM32F4 microcontroller. This is still not a full "computer" like your PC, but looking at it, you can see, it's a mess. I won't go into much detail on how this works but we can observe some interesting things. STM32F4 Clock Tree

The squares on the left represent pyhsical Pins on the microcontroller's package and are used to get clocks in and out of the system. So we can see, that this specific microcontroller which is not bigger than a coin: enter image description here

already has teh follwoing clock sources:

  1. LSE OSC 32.768 kHz. An externally provided clock for real time clock applications
  2. HSE OSC 4-26 MHz An externally provided clock which is used to derive most clocks in the system
  3. I2S_CKIN A special clock for the Audio part of the system. Audio application require specific frequencies due to precision reasons or weird sample rates like 44.1 kHz which are not easily dividable from other clocks
  4. Ethernet PHY. Most Ethernet applications require a good 100 / 50 / 25 MHz clock
  5. USB Phy. Clock for the USB system
  6. LSI OSC. An internal 32.768 lHz osciallator
  7. HSI OSC. An internal oscillator to provice 16 MHz

Compared to a whole PC, this system is rather small and easy. It is just this small single chip. But it already hass 7 different primary clock sources that "generate clocks out of the blue". Either externally provided, or internally generated.

Usually on-chip clock sources have the advantage of being cheap (no external stuff required) and being available very early on system start. But most ways of generating clocks on a chip are not very precise. Many of these clocks have high temperature drifts and large manufacturing spread. So if a precise clock is required, most chips require an external clock to be provided from e.g. a crystal oscillator that derives its output from the machanical oscillation of an actual crystal.

This is the reason why this chip e.g. has an internal 16 MHz oscillator but also provides a way to feed an external Oscillator. If precision is of secondary concern the internal one can be used to optimize for cost.

Looking further into this system, we can see, that the clock inputs are spread all over the place. I want to move your attention to the PLL blocks. A PLL (Phase Locked Loop) is essentially a fancy way to generate a clock signal dependent on a reference clock. And the fancy thing is, that the generated output clock can have a different frequency than the reference clock. I won't go into details on how this works. There's plenty of explaination on the net on this topic.

So a PLL is a way to generate new clocks based on a reference clock with a specific frequency / pahse relation compared to an reference clock. These PLLs are usally used internally of semiconductors to either achieve variable clocking and/or higher clock frequencies that otherwise would be difficult to route over a board.

Using PLLs and Clock dividers this system uses the input clocks for generating different clocks.

Essentially this system can use a single 16 MHz internal clock generator to provide a 168 MHz CPU clock (via an PLL), an 48 MHz clock for its USB module via another PLL, several lower clocks for its periphjeral modules, like UART, that are divided form the 168 MHz system clock.

As you can see, we only need one clock source to derive several mesochronous clocks from this via PLLs and clock dividers. This is a common practice most moder semiconductors use.

Going back to your question: Essentially there is only a single main clock source needed in a computer system. If different clock frequencies are needed to speed up several parts of the system, these clocks can be generated via PLLs from this base clock. If slower clocks are required, these can be easily divided.

However, different use cases require different clocks with different specification regarding precision and stability.

  • All communication, that doesn't transmit the clock, requires somewhat precise clocking as the receiver has to either regenerate the clock from the received data or has its own clock that needs to be as close as possible to the one of the transmitter. This includes all wireless transmission. Most WiFi cards will have an onboard clock gerneration of the 2.4 GHz / 5 GHz clocks used for the modulation. But also other technologies like SATA, Ethernet, USB etc. do not share a common clock between receiver and transmitter and therefore precise generation and/or clock recovery is necessary.
  • The DDR memory inside a PC is usually clocked at a different speed than the CPU and most importantly this is not as frequently changed as the CPU clock. Most likely the memory clock is derived via one of the described means from a common clock source as the CPU clock.
  • Audio requires special clocks for the specific sample rates that are common. A 192 KHz sample clock is easier to be generated from a 12.288 MHz crystal than from a 8 MHz reference.
  • PCIe (usually) uses a 100 MHz reference clock that is send to the cards so they can internally generate a higher clock frequency for PCIe based on this clock. It is generated by the root complex of the PCIe e.g. your CPU or chipset. Providing a reference clock ensures, that all connected devices can generate a clock that is very precise compared to each other but does not need to be absolutely precise.
  • Digital video like HDMI, DVI etc. transmits a pixel clock in the cable.
  • etc.

As you can see, there are easily several hundreds of differnet clocks in a modern computer system. However, in some cases these hundreds of clocks are only derived from a hand full of primary clock sources.


So far we only looked at how many clocks there are in a system. And we came to the conclusion: A ton... So how are these synchronized:

This highly depends on the relationship of the different clocks.

  • If carefully designed synchronous clocks of the same frequency do not require any synchronization at all.
  • A slower clock that trasnmits data to a faster clock with a fixed clock and phase ratio (derived from the same reference using a PLL) might also not need a synchronization, as the faster clock is capable of processing all data coming from the slower clock and the cahnges of the source clock domain are guaranteed not to violate the setup and hold requirements of the flip flops in the destination domain due to the fixed phase and frequency relationship.

Problems arise when the clocks are asynchronous or mesosynchronous. As you've pointed out, these can run "out of sync" with each other. So a special clock domain crossing mechanism needs to be installed. There are several ways of ensuring this. I recommend searching the net regarding clock domain crossing (CDC) and synchroinization. The short answer is: All clock domain crossings require the synchronization of the signals into the destination clock. This is usually done by using 2 or more Flip-Flops clocked by the destination clock to sample the input signals.

For one bit wide signals this is already sufficient. Of course you would have to ensure by design that the signal is held stable in the source domain for long enough so that the target domain is able to capture it. This is especially problematic going from faster to slower clocks.

However, if multiple signals e.g a data bus needs to cross a clock domain, the signals cannot be simply synchronized bit by bit, as differnet routing delays and flip flop manufacturing tolerances etc. can lead to wrong sampling of the value in the destination clock domain if sampled right at the change.

One way of circumventing this is to proved the data in the source clock domain and toggle a qualifier signal. The data is synchronized by a signle flip flop in the destination domain and the qualifier signal is synchronized by 2 or more flip flops in the destination. Therefore, it is ensured, that once the toggling qualifier signal is fully synchronized into the destination domain, the data is also synchronized. Data and qulaifier need to be stbale during this process. Either by a fixed timing or by providing a feedback signal from the destination to the source.

As you can see, clock domain crossing is

  1. Complex
  2. Requires time -> Can actually severely impact performance and latencies
  3. Is notoriously difficult to debug in anything goes wrong. Therefore, special care needs to be given when designing these crossings, so that they are functional.
$\endgroup$
0
$\begingroup$

The description is hopelessly outdated. For instance, "the Control Bus" ? I wouldn't even know what bus that would be. It's apparently not the "Internal Clock", so presumably "the Control Bus" is the external bus. Problem: modern CPU's don't have a single external bus. And it's not like each external bus has its own clock: modern high-speed parallel buses have a different clock per data line !

Yet another flawed assumption in your text there: that clock is in-band, not an extra pin. That would be too expensive, having one extra clock pin per data pin. Besides, that wouldn't work anyway. The reason to do clocking in-band is to eliminate the variation between pins.

As for the internal clock, a modern CPU may not even have a fixed number (!). Commonly, each core of a multi-core CPU can have its own clock, but an unneeded core may have its clock shut down to reduce energy consumption.

Of course, with those multiple cores, there has to be yet another bus to connect the cores on a CPU, and that too has a clock. This one can be especially funny: due to the limited speed of light, this clock can be both 0 and 1 at the same time, at different parts of the chip. Of course, half a clocktick later, it will be the other way around, so 1 and 0. The internal bus can have phase differences over its length.

You mention the 8086 and 80486. These are old chips. The increase in speed of modern CPU's is possible because of this added complexity. All those different clock domains prevent the fast parts from being slowed down by the rest of the system. Having 2 clocks, internal and external was just a first step, but today we can even use multiple clocks per bus.

$\endgroup$
0
$\begingroup$

If I am correct about your query then there are some of the links which I mentioned below that may help you to understand the procedure. But to make better understanding approach should not be how it is working the approach should be how it could possibly work.

Lets check with the first approach.

If you read some open documents of MCH you will see the PCI works on separate clock and FSB works on separate clock. Think of all the components working in the system works on different clock rate, the word synchronized doesnt mean that "If I say yes, at the same time you also say Yes", indeed it means things happenning at the rising edge of the clock. Now all the components such as circuits deal with busses like PCI, circuits deal with interrupt system and control unit itself has different clocks. One approach is in order to intercommunicate between the components the approach should be based on the handshaking signals. Lets suppose components X1 is the main component that deal with internal processing and component X2 is the component that deals with only ISA or I2C bus. Now data recieved by X2 should go to processing through X1, what handshaking signals required. The hypothetical approach is:-

1 X2 notification that he has the data to X1 2 X1 acknowledge and ask to share the data 3 X2 start sending the data by keeping another signal ON to tell the X1 that data is on the bus (Just like in RAM we have the concept of RAS and CAS signals) 4 Once the data is completed by X2 it sends complete signal 5. And X1 acknowledge

Second approach I read on the MP book for x86, based on my understanding.

There is separate clock generated circuit in the computer that sends the clock to the processor and to the system, This circuit is tunned by a variable for example 2Y is the clock frequency on which the computer processor work and processor and clock generator is designed in such a way that 2Y gives to the processor and processor is made aware that it receives the multiple of Y clock frequency like "2" in this case and the board designer (An important person) should know that Y is enough frequency for the operation of every component mentioned on the board, thats why when he send the board for selling in the Market he mentioned the list of specifications for the compatibility.

Third approach is my own idea where the system components have one controller and each controller has two clocks one that is running its part and the other for which it is communicating upstream with the single reference clock

Moreover if we study pentium structure there is one pin which is known as cache miss and also if you study X86 you will see one pin known as Data ready, such kind of implementation is done that if an environment comes where sync-synchronized (The idea of perfect matching) not be the option (Board designer person decision) then create the wait states until the data is reliably received.

Below are some links that might help you. Also search clock domain crossing protocols

https://en.wikipedia.org/wiki/Clock_synchronization http://paginas.fe.up.pt/~ee12248/Dissertation/wp-content/uploads/2015/03/PDI_ee12248.pdf

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.