Ilovepdf Merged
Ilovepdf Merged
www.pmt.education
Specification:
www.pmt.education
Relationship between hardware and software
Hardware
Hardware is the term given to the physical components of the computer system. If you can
touch a part of a computer, it’s hardware.
Hardware includes the internal components of a computer system like the hard drive and
the sound card as well as external components like printers and speakers.
Software
Software is the name given to program code. Sequences of instructions which are
executed in order to perform a task.
Each part of a computer system can be classified into hardware, software or hardware &
software. Some examples of each category are shown in the table below.
www.pmt.education
Classification of software
There are various categories into which different software packages can be placed.
Application software
Application software is the name given to programs that
complete a specific task for the user. Examples of application
software include word processors, web browsers and
spreadsheet software.
System software
System software operates, controls and maintains the computer and its components.
System software includes the computer’s operating system as well as the categories utility
programs, library programs and translators.
Operating system
A computer’s operating system allows its user to control the
computer with ease. It does this by providing what’s called a
virtual machine, hiding the true complexity of the computer
from the user.
Utility programs
Utility programs are used for completing housekeeping tasks in a computer system. Such
tasks include data backup, defragmenting hard drives (reorganising data on a hard drive in
order to improve speed of access), data compression and encryption.
www.pmt.education
Library programs
Libraries contain useful functions that are frequently used by a program. Programmers can
make use of libraries when developing a program to simplify the process. Should a
programmer wish to make use of a library, they must first import it within their program
code.
Translators
Translators are pieces of software which translate between
different types of language. This course covers three types of
translator: compilers, assemblers and interpreters.
www.pmt.education
AQA Computer Science A-Level
4.6.2 Classification of programming
languages
Advanced Notes
www.pmt.education
Specification:
www.pmt.education
The development of types of programming languages
The limited speed and memory of early computers forced programmers to write programs
using low-level languages. These languages directly manipulated the processor, required
a great deal of effort on the part of the programmer and were prone to errors.
Low-level languages
The earliest electronic computers could only be programmed with low-level languages.
Programs written in low-level languages are specific to the type of processor they are
written for and directly affect the computer’s processor.
There are two categories of low-level language: machine code and assembly language.
Machine code
Machine code uses only the binary digits 1and 0to represent instructions. This makes
programs written in machine code very long and extremely difficult for humans to
understand. Because of this, machine code programs are prone to errors and difficult to
debug.
01010101
11010110
01001011
10110110
www.pmt.education
Assembly language
Assembly language was developed with the intention of simplifying the process of writing
computer programs. Mnemonics, such as ADDand MOV
, are used in place of the binary
instructions that machine code uses. This makes assembly language more compact and
less error prone than machine code.
Each assembly language instruction has a 1-to-1 correlation to a machine code instruction.
For example, the assembly language instruction MOV R2, R1might be the exact
equivalent of the machine code instruction 11011101
.
1 1 0 1 1 0 0 1
Two bits Two bits
representing the representing the
Four-bit identifier for the MOVE command number of a number of a
register. In this register. In this
case, 2. case, 1.
MOV R2 R1
www.pmt.education
High-level languages
High-level languages are the type of programming language that you’re most likely used to
using. Examples of high-level languages include C#, Java, Pascal, Python and VB.Net.
Most high-level languages allow programmers to make use of built-in functions. These can
save vast amounts of time when programming.
While x < y
x = x + y
End While
www.pmt.education
High-level languages vs. low-level languages
Low-level High-level
Machine code Assembly language
An assembler must be
used before a program A compiler or interpreter
is executed, but each must be used to
Machine code is
Ease of instruction has a 1-to-1 translate source code
directly executed by
execution correlation to a into object code before
processors.
machine code it can be executed. This
instruction so can be time consuming.
translation is quick.
www.pmt.education
AQA Computer Science A-Level
4.6.3 Types of program translator
Advanced Notes
www.pmt.education
Specification:
www.pmt.education
Translators
There are three types of program translator: assemblers, compilers and interpreters.
Assemblers
An assembler translates assembly language into machine code. Because each assembly
language instruction has a 1-to-1 relationship to a machine code instruction, translation
between the two languages is fairly quick and straightforward.
Assemblers are platform specific, meaning that a different assembler must exist for each
different type of processor instruction set.
Compilers
A compiler can be used to translate programs written in high-level languages like C# and
Python into machine code. Compilers take a high-level program as their source code,
check it for any errors and then translate the entire program at once. If the source code
contains an error, it will not be translated. Because compilers produce machine code, they
are said to be platform specific.
Once translated, a compiled program can be run without the requirement for any other
software to be present. This is not the case with interpreters.
Interpreters
An interpreter translates high-level languages into machine code line-by-line. Interpreters
have procedures that can be used to translate each kind of program instruction.
Rather than checking for errors before translation begins (as a compiler does), interpreters
check for errors as they go. This means that a program with errors in can be partially
translated by an interpreter until the error is reached.
When a program is translated by an interpreter, both the program source code and the
interpreter itself must be present. This results in poor protection of the source code
compared to compilers which make the original code difficult to extract.
www.pmt.education
Comparison of compilers and interpreters
Compiler Interpreter
No need for source code or compiler to be Both the source code and the interpreter
present when the translated code is must be present when the program is
executed executed
Protects the source code from extraction Offers little protection of source code
Some compilers don’t produce machine code straight away but instead translate source
code into an intermediate language. This intermediate language, which is often bytecode,
allows for platform independence.
A compiler that uses an intermediate language will translate high-level code into an
intermediate language such as bytecode and then use a virtual machine to execute the
bytecode on different processors. Each different processor instruction set will have its own
virtual machine.
Using an intermediate language allows the interpreter to translate the source code just
once, while still being able to execute the translated code with a variety of different
processors.
Source code is the name given to the input to a translator. For an assembler, this is
assembly language code and for compilers and interpreters, this will be code written in a
high-level language.
A translator’s output is called object code and is produced from source code.
www.pmt.education
AQA Computer Science A-Level
4.6.4 Logic gates
Advanced Notes
www.pmt.education
Specification:
www.pmt.education
Logic Gates
A computer’s processor is made up of billions of logic gates, devices which apply logical
operations to one or more Boolean inputs in order to produce a single output.
Within a processor, logic gates are combined to form logic circuits. These can perform
more complex operations like binary addition.
Each of the six required logic gates has an internationally recognised symbol which you
should learn. The symbols have inputs on the left and outputs on the right.
Truth Tables
A truth table shows every possible combination of inputs and the corresponding output for
a logic gate or logic circuit. The inputs are labelled alphabetically starting with A and the
output is usually labelled Q.
NOT
The NOT gate has one input and one output. The gate’s output is always the opposite of
its input. If the input to the gate is a 1,it will output 0and vice versa.
A Q
0 1
1 0
The truth table for the NOT gate has just two columns, the input A and the output Q. There
are just two possible inputs, 1and 0
.
Q = A
www.pmt.education
AND
The AND gate has two inputs, labelled A and B in the truth table below, and outputs the
product of the two inputs.
A B Q
0 0 0
0 1 0
1 0 0
1 1 1
Q = A × B
The AND gate only outputs TRUE(1
) when both inputs are TRUE
, otherwise it outputs
FALSE
.
OR
In the same way that AND multiplies its inputs, OR adds them together. Therefore, the OR
gate is said to output the sum of its inputs.
A B Q
0 0 0
0 1 1
1 0 1
1 1 1
Q = A + B
OR only outputs FALSEwhen both inputs are FALSE
. When one or more of the gate’s
inputs are TRUE
, the logic gate outputs TRUE
.
www.pmt.education
XOR
The XOR gate’s full name is exclusively or and it outputs TRUEwhen strictly one of its
inputs is TRUE. The gate’s truth table is the same as the OR gate with the exception of the
last line in which FALSEis output with two TRUEinputs.
A B Q
0 0 0
0 1 1
1 0 1
1 1 0
Q = A ⊕ B
NAND
NAND is short for NOT AND. The NAND gate is actually a combination of two gates which
we’ve already covered, the NOT gate and the AND gate.
The NAND gate’s truth table is the same as the AND gate’s truth table, but the output is
reversed.
A B Q
0 0 1
0 1 1
1 0 1
1 1 0
Q = A×B
www.pmt.education
NOR
NOR, short for NOT OR is a combination of the two logic gates NOT and OR.
OR NOT NOR
Therefore, the NOR gate’s truth table is the same as the OR gate’s table, just with the output
reversed.
A B Q
0 0 1
0 1 0
1 0 0
1 1 0
Q = A + B
www.pmt.education
Combining Logic Gates
Logic gates can be combined to form more complex circuits. You may be asked to draw or
interpret a logic circuit involving multiple logic gates.
The logic circuit above combines four logic gates and can be
represented using the logical expression below.
Q = C ⊕ ((B×C) + A )
In order to create a truth table for this circuit, we first need to fill in all the possible
permutations of inputs like so:
1 0 0
1 0 1
1 1 0
1 1 1
www.pmt.education
Next, we add columns for each of the elements that make up the logical expression such
as B × C and A . This will make it easier for us to combine them to form the final
expression.
A B C B×C A (B × C) + A C ⊕ ((B × C) + A)
0 0 0 0 1 1 1
0 0 1 0 1 1 0
0 1 0 0 1 1 1
0 1 1 1 1 1 0
1 0 0 0 0 0 0
1 0 1 0 0 0 1
1 1 0 0 0 0 0
1 1 1 1 0 1 0
Once the column in the truth table for the finished expression is complete, the columns
used for working can be removed and the final column renamed Q .
A B C Q
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 0
www.pmt.education
Adders
An adder is a logic circuit that can be used to add Boolean values together. There are two
types of adder that you need to be aware of: half adders and full adders.
Half adders
A half adder is a logic circuit with two inputs, two outputs and two logic gates. The circuit
can be used to add two Boolean values.
The two inputs are labelled A and B and the outputs are labelled S and C. Short for sum
and carry.
A B S C
0 0 0 0 0 + 0 = 0
0 1 1 0 0 + 1 = 1
1 0 1 0 1 + 0 = 1
1 1 0 1 1 + 1 = 0 carry 1
You need to be able to draw the logic circuit for a half adder.
www.pmt.education
Full adders
A full adder has three inputs and two outputs, enabling it to input two Boolean values and
a carry bit from a previous, less significant operation.
The three inputs are labelled A, B and Cin for carry in. The two outputs are labelled S for
sum and Cout for carry out.
You need to be able to recognise this circuit as a full adder, but you’re not expected to be
able to draw it.
A B Cin S Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
www.pmt.education
Edge-triggered D-type flip-flop
An edge-triggered D-type flip-flop is a logic circuit which can be used as a memory unit for
storing the value of a single bit.
An edge-triggered D-type flip-flop has two inputs, one for data and another for a clock
signal. There is one output, which always holds the value of the stored bit.
The clock signal is generated by the computer and alternates between 0and 1at a set
frequency. The value of the stored bit is set to the value of the data input with each change
of the clock signal.
The clock signal can also be used to synchronise numerous flip-flops when they form part
of a larger system such as a shift register.
www.pmt.education
AQA Computer Science A-Level
4.6.5 Boolean algebra
Advanced Notes
www.pmt.education
Specification:
www.pmt.education
Boolean algebra
Just like algebra in Mathematics, Boolean algebra concerns representing values with
letters and simplifying expressions. Boolean algebra uses the Boolean values TRUEand
FALSEwhich can be represented as 1and 0respectively.
Notation
Expression Meaning
Order of precedence
Algebraic operations have an order of precedence, meaning that some operations must be
applied before others. You may have met BODMAS in Mathematics, this is the same idea.
Operator Precedence
Brackets Highest
.
NOT .
.
AND
.
OR Lowest
For example, the expression B OR NOT C AND Awould actually be carried out in the
order B OR ((NOT C) AND A) .
www.pmt.education
Boolean identities
There are a number of useful identities which can be used to simplify Boolean
expressions.
C C•C
1 1 × 1 = 1
0 0 × 0 = 0
F F+F
1 1 + 1 = 1
0 0 + 0 = 0
Any Boolean value with two lines above has had the
G = G NOT operation performed on it twice, meaning the
value has not been changed.
www.pmt.education
De Morgan’s laws
Named after British logician Augustus De Morgan, these two laws of Boolean algebra
come in incredibly useful when simplifying expressions.
For example, the Boolean expression A + B can have De Morgan’s law applied to it as
follows:
A+ B
A•B
A + B = A•B
De Morgan’s law can also be applied in reverse, by changing the sign and building the bar.
an be simplified as follows:
For example, the Boolean expression C + D c
C•D
C•D
C + D = C•D
www.pmt.education
Distributive rules
Just like expanding brackets in Mathematics, you can use distributive rules in Boolean
algebra as follows:
A • (B + C) = A • B + A • C
Examples
Example 1
Simplify the Boolean expression A + B • A
A + B•A
Use De Morgan’s laws. Break the bar and change the sign.
= A + B + A
Use A + A = 1
= B + 1
Use A + 1 = 1
=1
Example 2
Simplify the Boolean expression C • B + C • B
C•B + C•B
Use A + A = 1
B • ( 1)
Use A + 1 = A
B
www.pmt.education