Saltar al contenido

WJEC A level Computer Science

A-Level · WJECComputer Science20 notas en 6 carpetas, 73 KB

20 apuntes de estudio para WJEC A-Level Computer Science, creados por cookie, en 6 secciones que siguen los temas del curso.

Revision notes for WJEC AS and A level Computer Science, covering hardware, data representation, logic, data structures, algorithms, systems, security and programming practice, in the order the course takes them.

Qué contiene

La primera nota

Hardware and communication / Processor and the fetch-execute cycle

A processor, or central processing unit (CPU), carries out instructions. Most contemporary computers follow the Von Neumann architecture: instructions and data are held in the same main memory, and the processor fetches them one at a time over a shared set of connections. Because instructions and data travel the same route, the processor's speed is limited by how fast it can move items to and from memory. This limit is called the Von Neumann bottleneck, and most of the caching and parallel designs in this course exist to ease it.

The main parts of the processor

The control unit decodes each instruction and sends control signals to the other parts of the processor, so that they act in the right order. The arithmetic logic unit (ALU) carries out arithmetic, such as addition and subtraction, and logical operations, such as AND and OR. Registers are small, very fast stores inside the processor. Each has a particular job, and the ones a student meets most often are these:

RegisterHolds
Program counter (PC)The address of the next instruction to be fetched
Memory address register (MAR)The address of the memory location being accessed
Memory data register (MDR)The data just read from memory, or about to be written to it
Current instruction register (CIR)The instruction being decoded and executed
AccumulatorThe result of the most recent arithmetic or logical operation

The cycle

The fetch-execute cycle is the sequence the processor repeats for every instruction. It has three stages.

In the fetch stage, the address in the program counter is copied to the memory address register, and the instruction at that address is copied through the memory data register into the current instruction register. The program counter is then increased, so that it points at the next instruction. In the decode stage, the control unit works out what the instruction in the CIR asks for: which operation to carry out, and which data it needs. In the execute stage, the operation is carried out, often by the ALU, and the result is stored, for example in the accumulator or back in memory.

The processor repeats these stages for every instruction in the program. A jump instruction works by loading a new address into the program counter, so the next fetch comes from somewhere other than the next location in sequence. This is how loops and selection are built at the level of the machine.

Buses

The components are linked by buses, which are sets of wires. The address bus carries memory addresses from the processor, and it is one-way. The data bus carries the data itself, in both directions. The control bus carries signals such as read and write. The width of the address bus limits how many memory locations the processor can address directly. An address bus of 16 lines can name 2162^{16} = 65,536 locations.

The clock

A clock sends regular pulses through the processor, and each pulse is a cycle in which the components can change state. Clock speed is measured in hertz, usually gigahertz (GHz), where 1 GHz is one thousand million cycles per second. A higher clock speed does not always mean a faster computer, because the number of instructions completed per cycle also matters. A processor that needs more cycles for each instruction can be slower than one with a lower clock speed.

Worked example

A processor has a clock speed of 2.5 GHz, and an instruction takes 4 cycles on average. The number of instructions it completes each second is

2.5×1094=6.25×108\frac{2.5 \times 10^{9}}{4} = 6.25 \times 10^{8}

so it carries out 625 million instructions per second.

Checking the cycle

Take a short program. Suppose the PC holds 200 and the instruction at address 200 is an ADD. During the fetch, the ADD is copied into the CIR and the PC becomes 201. During the decode, the control unit recognises the addition and finds its operands. During the execute, the ALU adds the values, and the result goes to the accumulator. The next cycle begins by fetching from address 201, unless the ADD was a jump.

Y 19 más: abre cualquiera desde la lista de arriba.

Reseñas

Todavía no hay reseñas escritas. Añade estas notas a las tuyas y podrás ser la primera persona en dejar una.