0% found this document useful (0 votes)
23 views32 pages

Ilovepdf Merged

Uploaded by

Sameer Faisal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views32 pages

Ilovepdf Merged

Uploaded by

Sameer Faisal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

AQA Computer Science A-Level

4.6.1 Hardware and software


Advanced Notes

www.pmt.education
Specification:

4.6.1.1 Relationship between hardware and software:


Understand the relationship between hardware and software and be
able to define the terms:
● Hardware
● Software

4.6.1.2 Classification of software:


Explain what is meant by:
● System software
● Application software
Understand the need for, and attributes of, different types of software.

4.6.1.3 System software:


Understand the need for, and functions of the following system
software:
● Operating systems (OSs)
● Utility programs
● Libraries
● Translators (compiler, assembler, interpreter)

4.6.1.4 Role of an operating system (OS):


Understand that a role of the operating system is to hide the
complexities of the hardware.
Know that the OS handles resource management, managing hardware
to allocate processors, memories and I/O devices among competing
processes.

www.pmt.education
Relationship between hardware and software

Computer systems are composed of ​two parts​: 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.

Hardware Software Hardware & software

Monitor Word processor Wireless router

Processor Web browser Wireless keyboard

Graphics card Image editor

Webcam Video editor

www.pmt.education
Classification of software

There are ​various categories​ into which different software packages can be placed.

Application System software


software

Operating Utility Library


Translators
systems programs programs

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.

The operating system also ​manages ​and ​controls ​access to


the computer’s ​resources​. This includes the tasks of memory
management, processor scheduling (allocating processor
access to different applications) and handling ​interrupts​.

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:

4.6.2.1 Classification of programming languages:


Show awareness of the development of types of programming
languages and their classification into low-and high-level languages.
Know that low-level languages are considered to be:
● machine-code
● assembly language
Know that high-level languages include imperative high-level language.
Describe machine-code language and assembly language.
Understand the advantages and disadvantages of machine-code and
assembly language programming compared with high-level language
programming.
Explain the term ‘imperative high-level language’ and its relationship to
low-level languages.

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​.

High-level languages were developed to allow for ​instructions ​to be communicated to a


computer’s processor, making the job of programming far easier.

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 ​1​and ​0​to 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

Because machine code ​directly manipulates​ a computer’s processor, it is a ​very powerful


paradigm. Programmers ​are not constrained​ when using machine code. Furthermore,
there is ​no need to translate ​machine code before executing it, making the paradigm
useful for ​embedded systems ​and​ real-time applications​ where speed of execution is
paramount.

www.pmt.education
Assembly language
Assembly language was developed with the intention of ​simplifying the process​ of writing
computer programs. ​Mnemonics​, such as ​ADD​and ​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.

STR R4, #45


ADD R1, R2, 3
MOV R2, R1
HALT

Each assembly language instruction has a ​1-to-1 correlation ​to a machine code instruction.
For example, the assembly language instruction ​MOV R2, R1​might 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

AQA have made​ their own assembly language ​for use in


exams. You need to make sure you’re familiar with using it to
understand ​programs and even to ​write your own​.

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.

Unlike low-level languages, high-level languages are ​not


platform specific​. However, high-level languages must be
translated ​into machine code by a ​compiler ​or an ​interpreter
before they can be executed.

High-level languages don’t use binary digits or mnemonics


but use ​English instructions ​like “While” and ​mathematical
symbols​ like “+”. This makes high-level languages ​much easier ​for humans to learn and
understand as well as making them ​easier to debug​.

Most high-level languages allow programmers to make use of ​built-in functions​. These can
save ​vast amounts of time​ when programming.

Features such as ​named variables​, indentation and


commenting make programs written in high-level languages
far easier to debug​ than those written in low-level languages.

While x < y
x = x + y
End While

High-level languages include ​imperative high-level languages​. In a similar way to low-level


languages, imperative high-level languages are formed from instructions that specify ​how
the computer should complete a task, in contrast to declarative programming which
describes ​what ​a computer should do.

www.pmt.education
High-level languages vs. low-level languages

Low-level High-level
Machine code Assembly language

Portable. Programs are


Portability Not portable. Programs are ​processor specific​. not specific​ to certain
processors.

Code is ​difficult ​for Mnemonics help to


Code uses English,
humans to make code ​slightly
Ease of use making it ​easy ​for
understand. easier​ for humans to
humans to understand.
understand.

Debugging is ​easier Named variables,


Errors are ​very than with machine code indentation and
Ease of
difficult​ to spot and but still far more difficult
debugging commenting make
correct. than with high-level
languages. debugging ​fairly easy​.

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:

4.6.2.1 Classification of programming languages:


Understand the role of each of the following:
● Assembler
● Compiler
● Interpreter
Explain the differences between compilation and interpretation.
Describe situations in which each would be appropriate.
Explain why an intermediate language such as bytecode is produced as
the final output by some compilers and how it is subsequently used.
Understand the difference between source code and object
(executable) code.

www.pmt.education
Translators

In order for a program to be executed by a computer’s


processor, it must be in the form of a machine code program.
This means that programs written in ​assembly language ​or
high-level languages​ need to be translated into machine code
before they can be executed by a computer.

Types of program translator

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

Checks source code for errors line-by-line


Translation begins immediately
before translating

Each line is checked for errors and then


Entire source code translated at once
translated sequentially

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

Compilers with intermediate languages

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 and object code

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:

4.6.4.1 Logic gates:


Construct truth tables for the following logic gates:
● NOT
● AND
● OR
● XOR
● NAND
● NOR
Be familiar with drawing and interpreting logic gate circuit diagrams
involving one or more of the above gates.
Complete a truth table for a given logic gate circuit.
Write a Boolean expression for a given logic gate circuit.
Draw an equivalent logic gate circuit for a given Boolean expression.
Recognise and trace the logic of the circuits of a half-adder and a
full-adder.
Construct the circuit for a half-adder.
Be familiar with the use of the edge-triggered D-type flip-flop as a
memory unit.

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.

Logic Gate Symbols

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.

NOT AND OR XOR NAND NOR

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 ​0​and 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, ​1​and ​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 ​FALSE​when ​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 ​TRUE​when ​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 ​FALSE​is output with two ​TRUE​inputs.

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.

AND NOT NAND

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:

A B C Notice that the input column furthest to the left


alternates ​between ​0​and ​1​ , the next column
0 0 0
to the right ​alternates ​between ​00​and ​11​and
0 0 1 the column furthest to the right has four ​0​s
followed by four ​1​ s. You’ll see this convention
0 1 0 used time and time again with truth tables.
0 1 1

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 C​in​ for ​carry in​. The two outputs are labelled S for
sum ​and C​out​ 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.

The full adder’s​ truth table​ looks like this:

A B C​in S C​out

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 ​0​and ​1​at 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:

4.6.5.1 Using Boolean algebra:


Be familiar with the use of Boolean identities and De Morgan’s laws to
manipulate and simplify Boolean expressions.

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 ​TRUE​​and
FALSE​​which can be represented as ​1​and ​0​respectively.

Notation

Expression Meaning

An ​unknown ​Boolean value being represented by a letter


A, B, C, etc. just like x or y in conventional algebra.

NOT A​ . An ​overline ​represents the ​NOT​operation being


A applied to what is ​below the line​.

A AND B​ , said “A ​dot ​B” where a dot represents the ​AND


A•B (multiplication) operation.

An ​alternative notation​ for ​A AND B​


. Just like in
AB Mathematics, the ​product ​of two algebraic values can be
represented without any symbol.

A OR B​ , where an ​addition ​symbol represents the ​OR


A + B operation.

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 A​would 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.

A • 0 = 0 Anything ​AND 0​is always ​0.​This is because the


AND​operation represents ​multiplication​.

B • 1 = B Anything ​AND 1​is always the original value. This is


because the ​AND​operation represents ​multiplication​.

C • C = C Any Boolean value ​AND​itself is equivalent to ​just the


value​, as the truth table below shows.

C C•C

1 1 × 1 = 1

0 0 × 0 = 0

D + 0 = D Any Boolean value ​OR 0​is the equivalent of ​adding


0​​to the value, which leaves the value unchanged.

E + 1 = 1 Any Boolean value ​OR 1​is the equivalent of ​adding


1​to the value, which will always result in ​1​
.

F + F = F Any Boolean value ​OR​itself equals ​the value itself​,


as the truth table shows.

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.

De Morgan’s laws can be remembered by recalling the phrase:

“break the bar and change the sign.”


Where “the bar” refers to an ​overline ​representing the ​NOT​operation and “the sign” refers
to changing between + (​OR​) and • (​AND​ ).

For example, the Boolean expression A + B can have De Morgan’s law applied to it as
follows:

Break the bar:

A+ B

Change the sign:

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

Change the sign:

C•D

Build the bar:

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

Take out B as a common factor


B • ( C + C)

Use A + A = 1
B • ( 1)

Use A + 1 = A
B

www.pmt.education

You might also like