0% found this document useful (0 votes)
2 views

Computer Structure-2 (2)

The document outlines the essential components of a computer, focusing on the processor, which includes registers, the control unit, and the arithmetic logic unit (ALU), as well as memory organization and data transfer via buses. It also explains the roles of interpreters and compilers in translating high-level programming languages like Python into machine code, detailing their advantages and disadvantages. Additionally, it includes tasks and questions to reinforce understanding of computer structure and programming translation.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Computer Structure-2 (2)

The document outlines the essential components of a computer, focusing on the processor, which includes registers, the control unit, and the arithmetic logic unit (ALU), as well as memory organization and data transfer via buses. It also explains the roles of interpreters and compilers in translating high-level programming languages like Python into machine code, detailing their advantages and disadvantages. Additionally, it includes tasks and questions to reinforce understanding of computer structure and programming translation.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Part 2: Computer Structure

Components of the Computer


For National 5, you need to know that computers have a processor, which has three parts: registers,
the ALU and the control unit. The processor does the computer’s ‘thinking’. Data and instructions
from active programs are kept in memory locations. Data and instructions are moved back and forth
between memory and the processor through bundles of wires called buses.

You need to be able to describe these components:

● The processor: registers, ALU and control unit


● Memory locations with unique addresses
● Data bus and address bus

You need to know a little about how these are connected together. This is a simplified version of
how it works.

Processor Memory
(CPU)

Registers Address bus 110101

Control
if x > 2

ALU
Data bus
33 + 17
11011

The processor (CPU) has three parts:

● The registers are a small amount of memory inside the processor that can store data
temporarily, especially during calculations.

● The control unit decodes and executes instructions, and keeps other parts of the processor
in time with its clock. We talk about the control unit more in Higher.

● The arithmetic logic unit (ALU) does all of the calculations and logical decisions a program
requires.
When you have written programs with if statements, the == < > operators use the ALU.
In summary - what you need to know:

Component Description

Processor Does the ‘thinking’ of the computer. Has three parts - the registers, control unit
and arithmetic logic unit (ALU)

Registers Small amount of temporary memory inside the processor, holds data and
instructions while they are being processed

Control unit Decodes and executes instructions.


Keeps all of the other parts of the processor in time with its clock.

Arithmetic logic unit (ALU) Does all calculations and logic/comparisons.

Main memory Main memory is divided into memory locations. Each location has a unique
memory address. Connected to the processor by address and data buses.

Address bus Carries addresses in one direction from processor to main memory.

Data bus Carries data/instructions in both directions between memory and processor

There are lots of types of questions that can be asked about these components.

This question
starts off about
databases (part a),
but asks where in
the processor a

comparison/condition would be checked. Since this is an example of logic, it would be done in the
arithmetic logic unit, or ALU (1 mark).
In part (i) of this question,
you would say that the data
bus is what is used to
transfer data from memory
to the processor.

In part (ii), you would say


that memory is organised
into separate
locations/addresses (1
mark), and that each one is
unique (1 mark).

In this question, you are


asked the component
that calculates
something. This must be
the ALU.

The component that


transfers data (the value) is the data bus.

The part of the processor that


stores things temporarily is a
register. The important part of the
question is that it is temporary -
that’s the job of the registers.

The part of the processor that


compares two values (or does
calculations) is the arithmetic logic
unit (ALU).
Tasks - Computer Structure
1. State the part of the processor that would be used to calculate 157 + 269.

2. State the bus that carries addresses from the processor to main memory.

3. The data bus carries instructions. What else can it carry? (read the description of the data
bus carefully)

4. State the part of the processor that stores values temporarily while they are being used by
the processor.

5. State the part of the processor that keeps other parts in time using the clock.
6. In two marks, explain how memory is organised in the computer.

7. State the part of the processor that could decide if 259 was greater than 116.

8. State the part of the computer that carries data in both directions between memory and the
processor.

9. The computer fetches two numbers from memory, adds them together, and displays the
result. State the part of the system that would: (a) transfer the unique addresses of the
numbers to memory, (b) carry the numbers back to the processor, (c) carry out the
calculation to add them together.

(a)

(b)

(c)
Interpreters and Compilers
We write our programs in Python. Python is easy for us to read (it looks a bit like English), but it isn’t
readable for the computer. The computer only understands machine code (binary 1s and 0s). Before
the program can be run, it has to be translated into machine code by an interpreter or a compiler.

For National 5, you need to know:

● That programs must be translated into machine code


● That an interpreter translates line-by-line
● That a compiler translates all at once
● The advantages/disadvantages of each approach

Both interpreters and compilers are types of translators. What we use - Python in Replit - is
interpreted. That means you can see your errors ‘live’ as they happen.

A compiler would find all syntax errors once at the start of the program, but we would have to wait
while the whole program is compiled before we can run it.

Advantages of interpreters Advantages of compilers

An interpreter translates the program line by A compiler translates the program all at once
line. It takes each line of your program (e.g. in at the start of the program. It translates all the
Python), translates it, and runs it. Because it code, then tells you if there were any errors.
runs line by line, the interpreter can tell you
where an error happens, i.e. how far through A compiled program doesn’t need to be
the program you got when the error occurred - translated every time you run it. This saves
time - the program only needs to be translated
where it stopped.
once.
This makes it easier to find where errors are.
Once the program is compiled, it can’t be
Interpreters are often built into the program edited. If you are selling the program, you can
editing tools you use (e.g. Replit), so you can sell people the compiled version, and they
run the interpreter without leaving the editor. won’t be able to see or edit your original code.

A compiled program takes up less memory to


run. Because it doesn’t need translated each
time, the computer doesn’t have to have the
translator program (like an interpreter) in
memory.

You can be asked


questions that compare
interpreters and
compilers, or you can be
asked the advantages of
each type.
In this question, you could give any one advantage (above) for each of the translator types.

You might be
asked why a
particular
program was
compiled or
interpreted. To
answer this, you could give an advantage of using a compiler (or interpreter).

You could answer this


question by saying that it was
compiled because it only had
to be translated once (before
storing in the memory).

These are usually short 1-mark questions, and you don’t need to know a lot about interpreters and
compilers. Learn a few of the advantages of each, and remember that all programs must be
translated before they can run.

Tasks - Interpreters and Compilers


1. John is writing a program. Explain why the program must be compiled or interpreted before
it can be run.

2. State one advantage of using an interpreter when testing a program for errors.

3. State one advantage of using a compiler when you are going to sell the finished software.
4. State which translator type processes all of the code at once, and which translates line by
line.

All at once

Line by line
5. State why a compiled program (not the compiler itself!) uses less main memory than an
interpreted one.

6. State which translator type makes it easier to test the code without leaving the editor.

7. Explain the role of machine code when writing and running a program you have written.

8. State which translator type produces programs that don’t need to be translated every time
they run.

You might also like