How do instructions get executed on a cpu




















These slots or memory locations each have a unique memory address. The program counter stores the address of each instruction and tells the CPU in what order they should be carried out. When a program is being executed, the CPU performs the fetch-decode-execute cycle, which repeats over and over again until reaching the STOP instruction.

Fetch-decode-execute cycle The main job of the CPU is to execute programs using the fetch-decode-execute cycle also known as the instruction cycle. So this cycle takes the results of the addition in the accumulator and stores it back into RAM. Share this post. Great course and learning… 11 Apr, Visit the course. Great course, I learned a lot of Excellent 16 Jun, Interesting 18 Mar, Great content, lots to learn presented in a very interesting way.

It was an insightful short cours Now you are going to look at how the CPU can perform calculations, using a process known as the fetch-decode-execute cycle.

Want to keep learning? This content is taken from Raspberry Pi Foundation online course,. This content is taken from Raspberry Pi Foundation online course. See other articles from this course. This article is from the online course:. News categories. Other top stories on FutureLearn. We explore the current business landscape in India, identity the 5 best startup opportunities and …. Find out about some of the best startup ideas for the Philippines, as well as ….

The bit instruction set of the chip has survived for almost 20 years. Hardware is much easier to change than all the software. A modern CPU chip has a lot more than 7 registers, but they are invisible to the user and even to the operating system.

However, each of these operations may be independent of the other. Under the covers, the CPU may recognize this and speed up processing by allowing operations to run in parallel. I doing so, the CPU will assign two real registers to pretend to be the A and C registers for one group of operations, while a different pair of real registers will pretend to be A and C for different operations. Of course this pretending is complicated and only goes so far.

In AMD introduced its Athlon 64 family of processors with a bit instruction set. Initially Intel resisted, but it has finally caved in and cloned the AMD operating design. However, for every type of program the more important feature of the new bit instructions may be a new set of 8 registers that compilers can now use to optimize program execution.

Memory is a lot slower than the CPU. If an instruction requires data that is out in the main memory of the computer, it may have to wait for a period of time equal to the processing of hundreds of instructions. Since some of the subsequent instructions will depend on the results of this previous operation, the CPU will halt waiting for memory.

To get around this problem, a CPU has two types of internal high speed memory to hold recently used instructions and data. The best type of internal memory is the Level 1 L1 cache. This memory is part of the CPU core along with the units that decode instructions and perform arithmetic. If the instruction and data are in L1 cache then the CPU can execute at full speed.

The modern Intel processors have 32K of L1 internal cache. Competing processors from AMD have even more. When the instruction or data is not found in the L1 cache, modern processors have a larger amount of Level 2 cache associated with each CPU core. The 65nm generation of Intel processors commonly available during had 2 or 4 megabytes of L2 cache. The next generation of 45 nm processors available during will have larger L2 caches.

Each L2 cache is tied to a specific processor core. Eventually an instruction requires data that is not in any of the cache levels, so it has to get the data from memory. Random Access means that any location in memory can be used after any other location. Synchronous means that the memory transfers data at a fixed speed determined by an external clock, like music students in class keeping time to a ticking metronome.

Then it transfers data at the rated clock speed. The problem is that the latency is measured in tens of nanoseconds, and when a modern CPU can execute 12 to 24 instructions per nanosecond.

Latency is the performance killer. In the time it takes to fetch a new byte of data from a new address, the CPU could have executed hundreds of instructions. By reordering subsequent instructions that do not depend on the results of this memory fetch, a CPU might continue to run for a few dozen instructions, but then it will stop.

Even if the L1 and L2 cache handle more than The most visible number on a memory stick is its clock speed. DDR 4 memory may be rated at MHz. Latency is then expressed in terms of these clock ticks. There are several latency numbers, but the most important is CAS latency.

It was more like a pocket calculator than a real computer. It handled ordinary base 10 digits encoded as four bits. Later chips added the ability to handle 8 bit, 16 bit, and 32 bit numbers.

Instead, there are separate Add operations for digits, bytes, and every other size of number. The resulting set of possible instructions is a mess.

Look at the last few pages of the ad, where they show the tools. In reality, it is almost impossible to keep all the pieces organized, and you will spends minutes searching through all the attachments to find one of the right size. Go to a tire store. They lift your car off the floor, remove the hubcaps, and then pick up a gun shaped device connected to a hose. You could do the same thing with the Piece Socket Wrench Set, but every garage knows that automotive wheel bolts come in only one size.

Make all the instructions the same size. Use only one size of data. Simplify the instructions and therefore the operation decode. Then use all the room on the chip to optimize what is left, rather than filling the chip with support for instructions that are seldom executed.

However, the advantage of a Reduced Instruction Set turned out to be most important in the period when chips have million transistors during the period of the late chips and the early Pentium chips. Every 18 months the CPU chip doubles the number of transistors it can hold. It quickly became unimportant to alter the work to simplify the design of the computer.

RISC today has its greatest effect in video game consoles, where the computer program is specifically designed for the hardware and maximum performance is worth the extra investment in design. Although a tire store may be fast at changing tires, when you really need speed look at how they do things in Indianapolis. This physical restriction does not exist for the computer The computer can change update the program pointer to an arbitrary value Changing the program counter it contains the location of the next instruction will change the program flow Therefore: The computer can change the default program flow!!!

A branch instruction can alter change the default program flow When the CPU executes a branch x instruction , the next instruction that will be executed by the CPU is the instruction at memory location x. Notice there is a branch to location 4 instruction in the example. Transfer the content from some specific memory location to a specific register memory cell in the CPU.



0コメント

  • 1000 / 1000