# A-level Computing/AQA/Print version/Unit 2

A-level Computing is an A-level course run for students in the UK

Note: current version of this book can be found at http://en.wikibooks.org/wiki/A-level_Computing/AQA

# Authors

• (AQA) Peter EJ Kemp (editor) - London
• (CIE) Peter Astbury - Alexandria, Egypt

• Students from Christ the King Sixth Form College
• Students from Loxford School
• Peter L Higginson - Reading

Thanks for helping out!

# Book Overview

This is a book about A-Level Computing. It aims to fit in with the AQA GCE A-Level Computing syllabus but is not endorsed by AQA. It should be useful as a revision guide or to find alternative explanations to the ones in your textbook. If you haven't heard of an A-Level then this book probably won't be of much interest to you but you can find out about them at Wikipedia.

If any part of this book is unclear or even wrong then please post a comment on the discussion page or simply fix it yourself! In particular, please say if the book assumes any knowledge or skills which not all A-Level Computing students have.

## Programming

Accepted languages (please note that support for PHP, C and C# at AS Level was withdrawn in 2011)

A2 Projects can be written in any language.

### How to read the book

You will meet several coloured boxes, here are their meanings:

 Specification link What the specification says you must learn for each chapter
 Examples Example questions and how to solve them
 Questions Questions to test yourself, click below Answer : to check if you were right
 Extension Topics that aren't examined but you might be interested in

There will be a lot of concepts that you need to be familiar with, definitions are highlighted like so:

Word - meaning

# Unit 2 - Summary

This exam is worth 40% of your AS grade (20% of A2). It is examined in June.

# Fundamentals of Computer Systems

 From the Specification : Hardware and Software Understand the relationship between hardware and software and be able to define both.
 From the Specification : Classification of Software Be aware of how software is classified. Be able to explain what is meant by system software and application software. Understand the need for and attributes of different types of software
 From the Specification : System Software Understand the need for, and functions of, system software: Operating system software Utility programs Library programs Translator software (compiler, assembler, interpreter)

 From the Specification : Application Software Describe the different types of application software and the criteria for selecting appropriate software for particular purposes. General purpose application software. Special purpose application software. Bespoke application software

 From the Specification : Generations of Programming Language Describe machine-code language and assembly language. Awareness of the development of programming languages and the limitations of both machine-code and assembly-language programming First generation - Machine code Second generation - Assembly language Third generation - Imperative high level language Explain the term imperative high level language and its relationship to first and second generation languages Fourth generation - Declarative language Explain the term declarative programming language and where and why declarative languages are used

 From the Specification : Types of Program Translator Define each type of language translator and describe situations where each would be appropriate. Assembler Compiler Interpreter

## Hardware and software

Hardware - Physical components that make up a computer system

Software - Computer programs and related data that provide the instructions for telling computer hardware what to do and how to do it

Hardware and Software have a symbiotic relationship, this means that without software hardware is very limited; and without hardware, software wouldn't be able to run at all. They need each other to fulfill their potential.

Standard hardware components The relationship between Hardware and Software
Hardware of a modern personal computer, can you name all the components?
A layer structure showing the relationship between various layers of software and hardware
 Exercise: Hardware and Software Define Hardware: Answer : Physical components that make up a computer system. Define Software: Answer : Computer programs and related data that provide the instructions for telling computer hardware what to do and how to do it. Give names to all the numbered hardware components above: Answer : Monitor Motherboard CPU RAM Expansion cards / graphics card / sound card / network card Power supply Optical disc drive Hard disk drive Keyboard Mouse Give 2 examples of software: Answer : Word Processor Operating System Game Spreadsheet Virus Scanner etc NOTE: If you mentioned a brand name such as Windows TM, you get no marks, the exam wants software types meaning you should have written Operating System. After all, for the previous question, you probably didn't answer ATI radeon HD 3000.

## Classification of Software

You have probably used a lot of software over the years, here we are going to study the different classifications (types) of software that are out there.

The two main classifications of software that all programs fit under are:

• System software
• Application software

Without software, most hardware would sit there doing nothing or perform specific tasks. To make most hardware run we need to use software, and your task here is to select the correct type of software for each job.

### System software

System software - software designed to operate the computer hardware and to provide a platform for running application software

An example of a modern GUI as used in Ubuntu

Modern computers are complex instruments involving many different parts. To keep it running well you will need system software. System software will handle the smooth running of all the components of the computer as well as providing general functionality for other programs to use, tools to speed up the computer, tools to develop new software and programs to keep you safe from attacks. There are several different types of system software that we will look at in more detail very shortly:

• Operating Systems are a collection of programs that make the computer hardware conveniently available to the user and also hide the complexities of the computer's operation. The Operating System (such as Windows 7 or Linux) interprets commands issued by application software (e.g. word processor and spreadsheets). The Operating System is also an interface between the application software and computer. Without the operating system, the application programs would be unable to communicate with the computer.
• Utility programs are small, powerful programs with a limited capability, they are usually operated by the user to maintain a smooth running of the computer system. Various examples include file management, diagnosing problems and finding out information about the computer etc. Notable examples of utility programs include copy, paste, delete, file searching, disk defragmenter, disk cleanup. However, there are also other types that can be separately installable from the Operating System.
• Library programs are a compiled collection of subroutines
• Translator software (Compiler, Assembler, Interpreter)

### Application software

Application software - software designed to help the user to perform specific tasks

GIMP is an example of photo editing general purpose application software

Application software is designed for people like me and you to perform tasks that we consider useful. This might be the ability of a scientist to work out statistical information using a set of results, or someone who wants to play the latest computer game. There are several categories of Application software that we'll look into shortly:

• General purpose application software.
• Special purpose application software.
• Bespoke application software
 Example: Software categories Place the following software into its correct category: Computer Game - This is built for a human user, therefore it is application software Virus Scanner - This is built to make the computer run better, therefore it is system software
 Exercise: Software categories What are the two main categories of software? Answer : System Software Application software Why is software important for computer systems? Answer : Without software the tasks that hardware can perform is often fixed and limited For each of the two main classifications of software give three sub categories: Answer : System software Operating system software Utility programs Library programs Translator software (Compiler, assembler, interpreter) Application software General purpose application software. Special purpose application software. Bespoke application software Place each of these software products into its correct category (application or system): Word processor Operating system Defragmenter GPS mapping software Music encoding library Answer : Word processor (Application) Operating system (System) Defragmenter (System) GPS mapping software (Application) Music encoding library (System) Fill in the missing software categories: Answer :

## System software

We should know by now that system software is software that helps a computer to run. We will now look at the different types of system software out there and why each is needed:

### Operating system software

An operating system (OS) is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system. Without an operating system, a user cannot run an application program on their computer (unless the application program is self booting).

Xfce Graphical User Interface to a Linux operating system

Time-sharing operating systems schedule tasks for efficient use of the system and may also include accounting for cost allocation of processor time, mass storage, printing, and other resources.

For hardware functions such as input/output and main memory management, the operating system acts as an middleman between application programs and the computer hardware, although the application code is usually executed directly by the hardware it will frequently call the OS or be interrupted by it. Operating systems can be found on almost any device that contains a computer, from mobile phones and video game consoles to supercomputers and web servers.

Examples of popular modern operating systems include Android, iOS, Linux, Mac OS X and Microsoft Windows, but don't use these names in the exam!

 Extension: Open vs Closed Source operating systems You might hear the words Open Source when you read about operating systems. Linux is the most well known Open Source OS and Windows is the most well known Closed Source OS. So what does this mean? Open Source programs are programs where you can see the code (the source), you can edit it, copy it and use as you wish within the confines of an open source license. You can even sell it, but the person would be welcome to acquire the code for free if they wanted. As a result of this Linux is not developed by one person or one company but uses code developed by thousands of people, working for different organisations all over the world. And as a result there are many different versions (known as distributions) of Linux out there including Ubuntu, Slackware and Fedora. Android is built using Linux code. Closed Source software doesn't allow people to look at the code or adapt it. Companies normally sell closed source products and you'll have to pay for a copy of Windows. Currently about 83% of desktops run the Windows OS.

### Utility programs

Utility software is a type of system software designed to help analyse, configure, optimize and maintain the computer. A single piece of utility software is usually called a utility or tool.

Utility software should be contrasted with application software, which allows users to do things like creating text documents, playing games, listening to music or surfing the web. Rather than providing these kinds of user-oriented or output-oriented functionality, utility software usually focuses on how the computer infrastructure (including the computer hardware, operating system, application software and data storage) operates. Due to this focus, utilities are often rather technical and targeted at people with an advanced level of computer knowledge.

KDE System Guard monitoring the CPU usage, processes and memory usage

Examples of utility software include:

### Library programs

Library programs are collections of resources used to develop software. These include pre-written code and subroutines.

Illustration of an application which uses libvorbisfile to play an Ogg Vorbis media file

Library programs contain code and data that provide services to other programs such as interface (look and feel), printing, network code and even the graphic engines of computer games. If you have ever wondered why all Microsoft Office programs have the same look and feel, that is because they are using the same graphical user interface libraries. For computer games a developer might not have the time and budget to write a new graphics engine so they often buy graphical libraries to speed up development, this will allow them to quickly develop a good looking game that runs on the desired hardware. For example Battlefield 3 and Need for Speed both use the same Frostbite engine.

The history of game engine development

Most programming languages have a standard set of libraries that can be used, offering code to handle input/output, graphics and specialist maths functions. You can also create your own custom libraries and when you start to write lots of programs with similar functionality you'll find them very useful. Below is an example of how you might import libraries into VB.NET:

'imports the libraries allowing a program to send emails
Imports System.Net.Mail

'imports the libraries allowing a program to draw in 2D
Imports System.Drawing.Drawing2D


### Translator software

The final type of system software that you need to know is translator software. This is software that allows new programs to be written and run on computers, by converting source code into machine code. There are three types that we'll cover in a lot more detail shortly:

• Assembler - converts assembly code into machine code
• Interpreter - converts 3rd generation languages such as javascript into machine code one line at a time
• Compiler - converts 3rd generation languages such as C++ into machine code all at once
 Exercise: System software Give the 4 system software types Answer : Operating system Utility programs Library programs Translator software Explain two functions of an operating system: Answer : Memory management Provides interface between applications and hardware Printing Processor time allocation Give a benefit of using library programs: Answer : You can use code made by other people without having to write it yourself You can use the same code again and again without having to re-write it Give two examples of utility programs: Answer : Virus scanner Disk defragmenter File manager What is system software for? Answer : System software performs tasks to analyse and help with the smooth running of a computer system What is utility software for? Answer : Utility software is a kind of system software designed to help analyze, configure, optimize and maintain the computer What is the purpose of translator software, give two examples Answer : to convert program source code into machine code that can be executed on the processor Assembler Compiler Interpreter

## Application software

### General purpose application software

General purpose application software is a type of software that can be used for a variety of tasks. It is not limited to one particular function. For example a word processor could be classed as general purpose software as it would allow a user to write a novel, create a restaurant menu or even make a poster.

Impress presentation software in LibreOffice 3.3.0

Examples of General purpose application software include: Word processors, Spreadsheet and Presentation software. Whatever you do, do not use brand names!

### Special purpose application software

Special purpose application software is a type of software created to execute one specific task. For example a camera application on your phone will only allow you to take and share pictures. Another example would be a chess game, it would only allow you to play chess.

Chromium web browser

Other examples of special purpose application software are web browsers, calculators, media players, calendar programs etc. Again, make sure that you don't use brand names!

### Bespoke application software

Bespoke application software is tailor made for a specific user and purpose. For example a factory may require software to run a robot to make cars, however, it is the only factory making that car in the world, so the software required would have to be specially build for the task.

Other examples might include software for the military, missile/UAV operations, software for hospitals and medical equipment, software being written inside banks and other financial institutions.

There are several things to consider before purchasing bespoke software, on the plus side:

Software is built for and will meet your precise needs

However, you must also consider

Software will be expensive as you have to cover all of the production costs
It may take some time to develop the software, when special purpose software could be brought straight away
The software is more likely to be buggy as it probably won't have thousands of clients using and testing it

 Exercise: Application Software List and describe the three types of application software: Answer : General purpose software - software that can be used for multiple purposes Special purpose software - software built for a specific purpose Bespoke application software - software built for a specific user and purpose Give an example of each: Answer : (Don't let the examiner catch you using product names!) General purpose software - word processor / presentation software / spreadsheet Special purpose software - Web browser / media players / calender programs Bespoke application software - car robot control software / military control software Why might you choose to use general purpose software instead of bespoke software, why might it not be suitable? Answer : general purpose software is: cheaper than bespoke readily available, whilst bespoke may take some time to write able to perform multiple tasks probably less buggy However, it might not perform all the tasks needed by the user

## Generations of programming language

There are many types of programming languages out there and you might already have heard of a few of them, for example: C++, VB.NET, HTML, Python, Assembly. We will now look at the history of how these languages came about and what they are still useful for. In all cases keep in mind that the only thing a computer will execute is machine code or object code when it has been converted from a language to run on a processor.

Generation First Second Third Fourth
Code example

1010101001100010
1001101010000001
1111111110100010

LDA 34
STO 34

x = x + 1

body.top { color : red;
font-style : italic
}

Language (LOW) Machine Code (LOW) Assembly Code (HIGH) Visual Basic, C, python etc. (HIGH) SQL, CSS, Haskell etc.
Relation to Object Code
(generally)
-- one to one one to many one to many

### First generation

The Colossus Mark 2 was the world's first electronic digital programmable computer. Operators had to write the machine code directly by setting switches.

The first generation program language is pure machine code, that is just ones and zeros, e.g.$0010010010101111101010110$. Programmers have to design their code by hand then transfer it to a computer by using a punch card, punch tape or flicking switches. There is no need to translate the code and it will run straight away. This may sound rather archaic, but there are benefits:

Code can be fast and efficient
Code can make use of specific processor features such as special registers

And of course drawbacks

Code cannot be ported to other systems and has to be rewritten
Code is difficult to edit and update

### Second generation programming

As you can imagine, writing in 1s and 0s all day will leave you prone to mistakes. Second-generation programming languages are a way of describing Assembly code which you may have already met.

By using codes resembling English programming becomes much easier. The use of these mnemonic codes such as LDA for load and STA for store means the code is easier to read and write. To convert an assembly code program into object code to run on a computer requires an Assembler and each line of assembly can be replaced by the equivalent one line of object (machine) code:

Assembly Code Object Code
LDA A
STA A
JMP #3


-> Assembler ->

000100110100
001000000101
001100110100
010000000011

Assembly code has similar benefits to writing in machine code, it is a one to one relationship after all. This means that assembly code is often used when writing low level fast code for specific hardware. Until recently machine code was used to program things such as mobile phones, but with the speed and performance of languages such as C being very close to Assembly, and with C's ability to talk to processor registers, Assembly's use is declining.

As you can hopefully see there are benefits to using Second-Generation Languages over First-Generation, plus a few other things that makes Assembly great:

Code can be fast and efficient
Code can make use of specific processor features such as special registers
As it is closer to plain English, it is easier to read and write when compared to machine code

And of course drawbacks

Code cannot be ported to other systems and has to be rewritten

### Third generation (High Level Languages)

Even though Assembly code is easier to read than machine code, it is still not straightforward to perform loops and conditionals and writing large programs can be a slow process creating a mish-mash of goto statements and jumps. Third-generation programming languages brought many programmer-friendly features to code such as loops, conditionals, classes etc. This means that one line of third generation code can produce many lines of object (machine) code, saving a lot of time when writing programs.

Imperative languages - code is executed line by line, in a programmer defined sequence

Third generation (High Level Languages) codes are imperative. Imperative means that code is executed line by line, in sequence. For example:

1. dim x as integer

2. x = 3

3. dim y as integer

4. y = 5

5. x = x + y

6. console.writeline(x)


Would output: 8

Third generation languages can be platform independent, meaning that code written for one system will work on another. To convert a 3rd generation program into object code requires a Compiler or an Interpreter, we'll look into these in more detail very soon.

To summarise:

Hardware independence, can be easily ported to other systems and processors
Time saving programmer friendly, one line of 3rd gen is the equivalent of many lines of 1st and 2nd gen

However

Code produced might not make the best use of processor specific features unlike 1st and 2nd gen
 Extension: Programming Paradigms There are several types of Third-generation languages that you will cover in more detail at A2. They include:

### Fourth generation

Fourth-generation languages are designed to reduce programming effort and the time it takes to develop software, resulting in a reduction in the cost of software development. They are not always successful in this task, sometimes resulting in inelegant and hard to maintain code. Languages have been designed with a specific purpose in mind and this might include languages to query databases (SQL), languages to make reports (Oracle Reports) and languages to construct user interface (XUL). An example of 4th generation programming type is the declarative language

--an example of a Structured Query Language (SQL) to select criminal details from a database
SELECT name, height, DoB FROM criminals WHERE numScars = 7;


Declarative languages - describe what computation should be performed and not how to perform it. Not imperative!

An example of a declarative language is CSS which we'll learn more about when completing the web design unit

/*code to change the headings on a page to green and the paragraphs to red and italic*/
h1 { color : #00FF00; }
p { color : #FF0000; font-style : italic }

 Exercise: Generations of programming language Describe what is meant by an imperative language: Answer : code is executed line by line, in sequence What is the relationship between lines of object code and lines of 2nd generation language code Answer : one line of 2nd generation = one line of object code What is the relationship between lines of object code and lines of 3rd generation language code: Answer : one line of 3rd generation = many lines of object code Give two benefits of using 3rd gen over using assembly, give one drawback Answer : quicker and easier to write and maintain hardware independent, written once, can be used many times may lack the low level, processor specific functionality, meaning slower code Give the definition of a declarative language Answer : describes what computation should be performed and not how to perform it. Not imperative! For 2nd and 3rd generation languages give the program translator required to convert the language generation to object code: Answer : 2nd (Assembly) requires an assembler 3rd requires an interpreter or a compiler

# Fundamental Hardware Elements of Computers

 From the specification: Logic Gate: Construct truth tables for the following gates: NOT, AND, OR, XOR, NAND, NOR Be familiar with drawing logic diagrams involving one or more of the above gates. Boolean Algebra: Be familiar with the use of De Morgan’s laws and Boolean identities to manipulate and simplify simple Boolean expressions.

## Logic Gates

In 1854 a British mathematician, George Boole, developed Boolean Algebra. Instead of an algebra that uses numbers, boolean algebra uses truth values, true(1) and false(0). By defining sentences using truth values and performing operations on these truth values you can work out the overall conclusion of complex statements. Boolean Algebra has had a massive impact on Computer Science and the language that computers understand is a language of 1s and 0s, boolean.

Examples of Boolean Algebra shown in a truth table
 $x$ $y$ $x.y$ $x+y$ 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 1
 $x$ $\overline{x}$ 0 1 1 0

Logic gates are pieces of hardware that perform operations on boolean inputs, allowing us to create complex devices out of abstract boolean algebra. Logic gates are the fundamental building blocks of hardware and processors will be made out of billions of them. A logic gate will typically have one or two inputs, in the examples here defined by A and B, There are six types of gate that you need to know:

### NOT

A NOT gate takes only one input and gives one output

A NOT gate will always give an output opposite to what the input is e.g. 1 (not gate) 0. A NOT gate takes one boolean input and flips it. It is possible to have a double NOT. This will reverse the original NOT. The symbol would have an extra bar over it.

In Boolean Algebra we write a NOT symbol by placing a bar on top of a letter($\overline{A}$) or letters ($\overline{C+B}$).

 Examples of a NOT gate at work are as follows: NOT(It is not raining) = It is raining $\overline{TRUE} = FALSE$ $\overline{0} = 1$

To summarise here is a truth table showing the relationship between A and $\overline{A}$

A $\overline{A}$
0 1
1 0

### AND (.)

An AND gate takes two inputs and combines them to form one output

An AND gate will combine the boolean values of two inputs (you can get more than two inputs but we don't need to know about that type of gate here). If and only if both inputs are true will it output true. If any of the inputs are false it will out put false.

In Boolean Algebra we write an AND symbol by placing a bullet point between two (${A}.{B}$) or more (${A}.{B}.C$) values.

 Examples of an AND gate at work are as follows: Six is bigger than four AND Cats are bigger than gerbils = TRUE $TRUE . FALSE = FALSE$ $(7 < 8) . (2 > 1) = TRUE$ $(8 > 0) . \overline{(20 = 19)} = TRUE$

An easy way to remember how an AND gate works is thinking about a circuit to turn a light bulb on. If both switches are on then the bulb will light up, if any switch is off then the bulb won't light.

a circuit diagram equivalent to an AND gate

To summarise here is a truth table showing all the different values for two inputs A and B and the result of ANDing those values together

A B A.B
0 0
0
0 1
0
1 0
0
1 1
1

### OR (+)

An OR gate takes two inputs and combines them to form one output

An OR gate will combine the boolean values of two inputs. If one or more inputs are true then the output will be true. If both the inputs are false then the output will be false.

In Boolean Algebra we write an OR symbol by placing a plus symbol between two (${A}+{B}$) or more (${A}+{B}+C$) values.

 Examples of an OR gate at work are as follows: humans have two legs OR Elephants have 8 legs = TRUE $TRUE + FALSE = TRUE$ $(9 > 3) + (2 > 1) = TRUE$ $\overline{(20 = 20)} + (5 > 6) = FALSE$

An easy way to remember how an OR gate works is thinking about a circuit to turn a light bulb on. If one or more switches are on then the bulb will light up, if both switch are off then the bulb won't light.

a circuit diagram equivalent to an OR gate

To summarise here is a truth table showing all the different values for two inputs A and B and the result of ORing those values together

A B A+B
0 0
0
0 1
1
1 0
1
1 1
1

### XOR ($\oplus$)

A XOR gate takes two inputs and combines them to form one output

An exclusive- OR, XOR, gate will combine the boolean values of two inputs. If exactly one input is true then the output will be true. If both the inputs are false or both the inputs are true then the output will be false.

In Boolean Algebra we write an XOR symbol by placing a plus symbol surrounded by a circle between two (${A}\oplus{B}$) or more (${A}\oplus{B}\oplus{C}$) values.

 Examples of an XOR gate at work are as follows: it is raining XOR it is not raining = TRUE $TRUE \oplus TRUE = FALSE$ $(9 < 3) \oplus (2 < 1) = FALSE$ $\overline{(20 = 20)} \oplus (8 > 2) = TRUE$

To summarise here is a truth table showing all the different values for two inputs A and B and the result of XORing those values together

A B $~A \oplus B$
0 0
0
0 1
1
1 0
1
1 1
0

### NAND

A NAND gate takes two inputs and combines them to form one output

A NAND gate will combine the boolean values of two inputs, AND them together, and NOT the result. If one or less input is true then the output will be true. If both the inputs are true then the output will be false. To draw a NAND gate you draw an AND gate and add a circle to the front, as you can see above.

In Boolean Algebra we write an NAND symbol by taking an AND equation and NOTing the result ($\overline{{A} . {B}}$).

 Examples of an NAND gate at work are as follows: (A=A) NAND (A<>B) = TRUE $\overline{TRUE . TRUE} = FALSE$ $\overline{(9 < 3) . (2 < 1)} = TRUE$ $\overline{(20 > 20) . (8 > 2)} = TRUE$

To summarise here is a truth table showing all the different values for two inputs A and B and the result of NANDing those values together

A B $A . B$ $\overline{A . B}$
0 0 0
1
0 1 0
1
1 0 0
1
1 1 1
0

### NOR

A NOR gate takes two inputs and combines them to form one output

A NOR gate will combine the boolean values of two inputs, OR them together, and NOT the result. If no input is true then the output will be true. If either or both inputs are true then the result will be false. To draw a NOR gate you draw an OR gate and add a circle to the front, as you can see above.

In Boolean Algebra we write an NOR symbol by taking an OR equation and NOTing the result ($\overline{{A} + {B}}$).

 Examples of an NAND gate at work are as follows: (A=A) NOR (A<>B) = FALSE $\overline{FALSE + TRUE} = FALSE$ $\overline{(9 < 3) + (2 < 1)} = TRUE$ $\overline{(20 > 20) + (8 > 2)} = FALSE$
A B $A + B$ $\overline{A + B}$
0 0 0
1
0 1 1
0
1 0 1
0
1 1 1
0

Exercise: Logic Gates

Give the symbol and gate diagram for an OR statement

+

Give the symbol and gate diagram for an AND statement

.

Give the symbol and gate diagram for a XOR statement

$\oplus$

Give answers to the following equations:

TRUE AND TRUE

TRUE

TRUE + FALSE

TRUE

TRUE + TRUE

TRUE

TRUE $\oplus$ TRUE

FALSE

NOT(TRUE) . TRUE

FALSE

$\overline{\overline{TRUE}} + FALSE$

TRUE

Draw a NAND gate and truth table

A B $A . B$ $\overline{A . B}$
0 0 0
1
0 1 0
1
1 0 0
1
1 1 1
0

Complete the following table:

Name NAND NOR AND NOT OR XOR
Gate
Symbol
Truth Table

Name NAND NOR AND NOT OR XOR
Gate
Symbol $\overline{A . B}$ $\overline{A + B}$ $.$ $\overline{A}$ $+$ $\oplus$
Truth Table
A B $A . B$ $\overline{A . B}$
0 0 0
1
0 1 0
1
1 0 0
1
1 1 1
0
A B $A + B$ $\overline{A + B}$
0 0 0
1
0 1 1
0
1 0 1
0
1 1 1
0
A B A.B
0 0
0
0 1
0
1 0
0
1 1
1
A $\overline{A}$
0 1
1 0
A B A+B
0 0
0
0 1
1
1 0
1
1 1
1
A B $~A \oplus B$
0 0
0
0 1
1
1 0
1
1 1
0

## Boolean gate combinations

Now you have learnt logic gates we will take a look at how they are combined inside hardware. You may well be asked in an exam to draw your own logic gates or to work out what a combination of logic gates will output. In this section we will look at the best way to describe what a set of logic gates is in boolean algebra. Let's take a look at a quick example:

 Exercise: Logic gate combination outputs For the following logic gate combinations work out output Q for each: Answer : Answer : Answer : This equation can be simplified to equal $A.B$, as $B . B = B$, we'll find out why this is the case in the simplifying boolean equations section coming up Answer : This equation can be simplified to equal 0 (always false), as $\overline{A+B}.A = 0$, we'll find out why this is the case in the simplifying boolean equations section coming up Answer :

## Building circuits

A common question in the exam is to be given some boolean algebra and be asked to express it as logic gates. Let's take a look at an addition and subtraction example that you should be familiar with:

$9-(7+1)$


First we are going to deal with the inner-most brackets

$(7+1) = 8$


Finally we combine this answer with the $9-$

$= 9-(8) = 1$


It will work exactly in the same way for boolean algebra, but instead of using numbers to store our results, we'll use logic gates:

 Example: Building circuits $C.(A+B)$  As with any equation, we are going to deal with the inner-most brackets first$(A+B)$, then combine this answer with the $C.$
 Exercise: Building circuits Draw the circuit diagrams for the following (Remember: do we deal with AND or OR first?): $A.B+C$ Answer : $(\overline{A}+\overline{B}).C$ Answer : $\overline{(A+B)}.C$ Answer : $(A.\overline{B})\oplus(B.C)$ Answer : $\overline{(A.B).(C+\overline{D})}$ Answer :

A common question in the exam is to give you a description of a system. You'll then be asked to create a boolean statement from this description, and finally build a logic gate circuit to show this system:

Example: Building circuits

Using boolean algebra describe the following scenario:

 “ A car alarm is set off if a window is broken or if it senses something moving inside car, and the car is not being towed, or the engine is not on. ”

Where:

• A = being towed,
• B = window broken,
• C = engine on,
• D = senses movement

Before you rush into answering a question like this, let's try and break it down into its components. The questioner will often be trying to trick you. The two occasions that the alarm will sound are: $B+D$ but there is a caveat, the alarm will sound if either of these are true AND two things are also true, namely the engine is NOT on, and the car is NOT being towed: $\overline{A}+\overline{C}$

Combining both we get (remember the brackets!): $(B+D).(\overline{A}+\overline{C})$

The next step is to create a diagram out of this:

 Exercise: Building circuits A security system allows people of two different clearance levels access to a building. Either they have low privileges and they have a card and they are not carrying a mobile. Alternatively they have a key and are allowed to carry a mobile. The inputs available are: A = carrying a card B = carrying a mobile phone C = carrying a key Write down the boolean equation to express this: Answer : $(A.\overline{B})+(C)$ If you wrote: $(A.\overline{B})+(C.B)$ You'd be wrong! The reason being the text says: Alternatively they have a key and are allowed to carry a mobile. This doesn't mean $C.B$, it means they can carry a mobile, or they can choose not to: $C.(B+\overline{B})$, which simplifies to: $C.(B+\overline{B}) = C.(1) = C$. Draw the logic gate diagram to solve this: Answer :

## Gate conversion

Sometimes it is cheaper to create circuits using only one sort of gate, and you might be asked to do so in the exam. These gates tend to be NAND & NOR gates. "But how can you create complex circuits by using only one type of gate?!" you may well ask. We'll now cover how other gates can be made from NAND & NOR gates:

Step NOR Gate Equivalent
Diagram
Description If you split the same input (A) and feed it into NOR both gate inputs you create a NOT Gate
Truth Table

Because:

A A $A + A$ $\overline{A + A}$ $\overline{A}$
0 0 0
1
1
1 1 1
0
0

Step NAND Gate Equivalent
Diagram
Description If you split the same input (A) and feed it into both NAND gate inputs you create a NOT Gate
Truth Table

Because:

A A $A . A$ $\overline{A . A}$ $\overline{A}$
0 0 0
1
1
1 1 1
0
0
 Exercise: Gate Conversion Render the following boolean equations using only NAND gates: $\overline{\overline{A}.B}$ Answer : $\overline{A}.\overline{B}$ Answer : Now try the similar questions using only NOR gates (you might need De Morgan's Law to help you out here, or use a truth table to simplify things) $A+\overline{B}$ Answer : $\overline{A}.\overline{B}$ Answer : Why might you want to use only one sort of gate to create a circuit? Answer : It might be cheaper to make circuits with only one sort of gate, it might make for simpler circuits

## Boolean algebra

We have met gate logic and combinations of gates. Another way of representing gate logic is through boolean algebra, a way of algebraically representing logic gates. You should have already covered the symbols, below is a quick reminder:

Bitwise Operator NOT($\overline{A}$) AND(.) OR(+) XOR($\oplus$) NAND($\overline{A . B}$) NOR($\overline{A + B}$)
Description invert input where exactly two 1s where one or more 1s where exactly one 1 where less than two 1s where exactly two 0s

For the exam you might have:

• to convert logic gates into boolean algebra,
• build logic gate combinations from boolean algebra,
• simplify boolean algebra.

## Simplifying boolean equations

A common question is to give you a complex boolean equation, which you will then have to work out a simpler exact equivalent. This is useful when you are designing circuits and want to minimise the number of gates you are using or make circuits that only use particular types of gates. To simplify boolean equations you must be familiar with two methods. You can normally use either, but try to master both:

• Truth tables
• Boolean algebra - identities and De Morgans Law
Example: Simplifying boolean equations with Truth Tables

Draw the truth table for the following:

$(A . B) + A$


We are going to solve this using a truth table and we need to break the problem down into its component parts:

As the equation uses A and B list the different values they can take (4 in total)

$A$ $B$
0 0
0 1
1 0
1 1

Next we are going to work out the brackets first: $A.B$ and add this to our truth table

$A$ $B$ $A.B$
0 0 0
0 1 0
1 0 0
1 1 1

Finally we will OR this result ($A.B$) with A to find $(A.B)+A$, the final column of the truth table

$A$ $B$ $A.B$ $(A.B)+A$
0 0 0 0
0 1 0 0
1 0 0 1
1 1 1 1

Now that our truth table is complete, look at the final column, is there a simpler way of writing this? Why aye! The final column is true when, and only when, A is true, it doesn't require B's input at all. So we can simplify to A telling us that:

$(A.B)+A = A$

Example: Simplifying boolean equations with Truth Tables

Let's look at another example

$\overline{A . \overline{B}}$


We first of all need to break down the equation into its component parts. Starting off with A and B we the work out $\overline{B}$, then $A.\overline{B}$ and finally $\overline{A . \overline{B}}$.

$A$ $B$ $\overline{B}$ $A.\overline{B}$ $\overline{A . \overline{B}}$
0 0
1
0
1
0 1
0
0
1
1 0
1
1
0
1 1
0
0
1

This can be simplified to $\overline{A} + B$ telling us that: $\overline{A . \overline{B}} = \overline{A} + B$. How did we jump to this conclusion? Let's take a look at all the places where the result is true:

$A$ $B$ $\overline{A . \overline{B}}$
0 0
1
0 1
1
1 0
0
1 1
1

We need to get a combination of A, B that gives the result shown above. We can see that whenever A is false ($\overline{A}$)the answer is true:

$A$ $B$ $\overline{A . \overline{B}}$
0 0
1
0 1
1
1 0
0
1 1
1

We can also see that whenever the B value is true then the answer is also true:

$A$ $B$ $\overline{A . \overline{B}}$
0 0
1
0 1
1
1 0
0
1 1
1

So we know that we need to combine $\overline{A} with B$ to get an equation solving all cases.

If we AND them $\overline{A} . B$ this only gives us one of the scenarios, so that's not the answer.

If we OR them $\overline{A} + B$ then this gives us three answers, matching all the responses above. This is our solution.

Exercise: Simplifying boolean equations with Truth Tables

Give a simplified boolean description, ?, for the following truth tables:

$A$ $B$ $?$
0 0 0
0 1 1
1 0 0
1 1 1

$B$

$A$ $B$ $?$
0 0 0
0 1 0
1 0 0
1 1 1

$A.B$

$A$ $B$ $?$
0 0 1
0 1 1
1 0 1
1 1 1

$1$

$A$ $B$ $?$
0 0 1
0 1 0
1 0 1
1 1 1

$A+\overline{B}$

Simplify the following boolean equations using truth tables:

$(\overline{A.B}).A$

$A$ $B$ ${A.B}$ $\overline{A.B}$ $\overline{A.B}.A$
0 0
0
1
0
0 1
0
1
0
1 0
0
1
1
1 1
1
0
0

This can be simplified to: $A.\overline{B}$

$(\overline{A.B})+A$

$A$ $B$ ${A.B}$ $\overline{A.B}$ $\overline{A.B}+A$
0 0
0
1
1
0 1
0
1
1
1 0
0
1
1
1 1
1
0
1

The answer in all cases is a plain $1$

$(A.\overline{B})+B$

$A$ $B$ $\overline{B}$ $(A.\overline{B})$ $(A.\overline{B})+B$
0 0
1
0
0
0 1
0
0
1
1 0
1
1
1
1 1
0
0
1

This can be simplified to: $\overline{\overline{A}.\overline{B}}$ OR $A+B$ (because of De Morgan's Laws)

$\overline{B}+A.B$

Remember that we deal with the AND before the OR, meaning we can read the equation as: $\overline{B}+(A.B)$

$A$ $B$ $(A.B)$ $\overline{B}$ $\overline{B}+(A.B)$
0 0
0
1
1
0 1
0
0
0
1 0
0
1
1
1 1
1
0
1

This can be simplified to: $A+\overline{B}$

$(\overline{A}+\overline{B}).B$

$A$ $B$ $\overline{A}$ $\overline{B}$ $(\overline{A}+\overline{B})$ $(\overline{A}+\overline{B}).B$
0 0
1
1
1
0
0 1
1
0
1
1
1 0
0
1
1
0
1 1
0
0
0
0

This can be simplified to: $\overline{A}.B$

## Boolean identities

Sometimes a very complex set of gates can be simplified to save on cost and make faster circuits. A quick way to do that is through boolean identities. Boolean identities are quick rules that allow you to simplify boolean expressions. For all situations described below:

A = It is raining upon the British Museum right now (or any other statement that can be true or false)
B = I have a cold (or any other statement that can be true or false)

Identity Explanation Truth Table
$A.A = A$ It is raining AND It is raining is the same as saying It is raining
$A$ $A$ $A.A$
0 0 0
1 1 1
$A.\overline{A}=0$ It is raining AND It isn't raining is impossible at the same time so the statement is always false
$A$ $\overline{A}$ $A.\overline{A}$
0 1 0
1 0 0
$1+A=1$ 2+2=4 OR It is raining. So it doesn't matter whether it's raining or not as 2+2=4 and it is impossible to make the equation false
1 $A$ $1+A$
1 0 1
1 1 1
$0+A=A$ 1+2=4 OR It is raining. So it doesn't matter about the 1+2=4 statement, the only thing that will make the statement true or not is whether it's raining
$0$ $A$ $0+A$
0 0 0
0 1 1
$A+A=A$ It is raining OR It is raining is the equivalent of saying It is raining
$A$ $A$ $A+A$
0 0 0
1 1 1
$0.A=0$ 1+2=4 AND It is raining. It is impossible to make 1+2=4 so this equation so this equation is always false
$0$ $A$ $0.A$
0 0 0
0 1 0
$1.A=A$ 2+2=4 AND It is raining. This statement relies totally on whether it is raining or not, so we can ignore the 2+2=4 part
$1$ $A$ $1.A$
1 0 0
1 1 1
$A+B=B+A$ It is raining OR I have a cold, is the same as saying: I have a cold OR It is raining
$A$ $B$ $A+B$ $B+A$
0 0 0 0
0 1 1 1
1 0 1 1
1 1 1 1
$A.B=B.A$ It is raining AND I have a cold, is the same as saying: I have a cold AND It is raining
$A$ $B$ $A.B$ $B.A$
0 0 0 0
0 1 0 0
1 0 0 0
1 1 1 1
$A+(A.B)=A$ It is raining OR (It is raining AND I have a cold). If It is raining then both sides of the equation are true. Or if It is not raining then both sides are false. Therefore everything relies on A and we can replace the whole thing with A. Alternatively we could play with the boolean algebra equation:

$A+(A.B)=(1.A)+(A.B)$ Using the identity rule $1.A=A$
$(1.A)+(A.B)=A.(1+B)$ Take out the A, common to both sides of the equation
$A.(1+B)=A.1$ Using the identity rule $1+B=1$
$A.1=A$ Using the identity rule $1.A=A$

$A$ $B$ $A.B$ $A+(A.B)$
0 0 0 0
0 1 0 0
1 0 0 1
1 1 1 1
$A.(A+B)=A$ It is raining AND (It is raining OR I have a cold). If It is raining then both sides of the equation are true. Or if It is not raining then both sides are false. Therefore everything relies on A and we can replace the whole thing with A. Alternatively we could play with the boolean algebra equation:

$A.(A+B)=(0+A).(A+B)$ Using the identity rule $0+A=A$
$(0+A).(A+B)=A+(0.B)$ Take out the A, common to both sides of the equation
$A+(0.B)=A+0$ Using the identity rule $0.B=0$
$A+0=A$ Using the identity rule $0+A=A$

$A$ $B$ ${A+B}$ $A.(A+B)$
0 0 0 0
0 1 1 0
1 0 1 1
1 1 1 1

Examples of manipulating and simplifying simple Boolean expressions.

 Example: Simplifying boolean expressions Let's try to simplify the following: $A+B+B$  Using the rule $B + B = B$ $A+B+B = A+B$  Trying a slightly more complicated example: $(A.0)+B$  dealing with the bracket first $(0)+B$ as $0.A = 0$ $B$ as $0+B = B$ $(A.0)+B = B$ 
 Exercise: Simplifying boolean expressions $A+0$ Answer : $A$ $A.0$ Answer : $0$ $E+1$ Answer : $1$ $A+A+B+B+C$ Answer : $A+B+C$ $(A.B)+(A.B)$ Answer : $A.B$ $A.A.B.B.C$ Answer : $A.B.C$ $(A+\overline{A}).B$ Answer : $(A+\overline{A}).B$ applying the identity $A+\overline{A} = 1$ $(1).B$ applying the identity $1.B = B$ $B$

Sometimes we'll have to use a combination of boolean identities and 'multiplying' out the equations. This isn't always simple, so be prepared to write truth tables to check your answers:

 Example: Simplifying boolean expressions $(A.B) + A$  Where can we go from here, let's take a look at some identities $(A.B) + (A.1)$ using the identity A = A.1 $A.(B+1)$ taking the common denominator from both sides $A.1$ as B+1 = 1 $A$ Now for something that requires some 'multiplication' $(\overline{A}.B) + A$ $(\overline{A}+A).(B+A)$multiply it out $1.(B+A)$cancel out the left hand side as $(\overline{A}+A)=1$ $B+A$using the identity $1.Q = Q$
 Exercise: Simplifying boolean expressions $(A.\overline{B}) + B$ Answer : $(A.\overline{B}) + B$ $(A+B).(\overline{B}+B)$ multiplying out $(A+B).(1)$ $(A+B)$  $(A+B).\overline{A}$ Answer : This takes some 'multiplying' out: $(A+B).\overline{A}$ $(A.\overline{A})+(\overline{A}.B)$ $0+(\overline{A}.B)$ $B.\overline{A}$  $B.(A+A.B)$ Answer : This takes some 'multiplying' out: $B.(A+(A.B))$ treat the brackets first and the AND inside the brackets first $(B.A)+(B.A.B)$ multiply it out $(B.A)+(A.B)$ as $B.A.B = A.B$ $A.B$ as $(B.A)=(A.B)$  $(A+B).(A+A)$ Answer : $(A+B).(A+A)$ $(A+B).A$ as $A = A+A$ $(A+B).(A+0)$ as $A = A+0$ $A+(B.0)$ take A out as the common denominator $A$ as $(B.0) = 0$  $(A.\overline{B})+\overline{A}$ Answer : This takes some 'multiplying' out: $(A.\overline{B})+\overline{A}$ $(A+\overline{A}).(\overline{B}+\overline{A})$ $1.(\overline{B}+\overline{A})$ $\overline{B}+\overline{A}$  $(A.B)+\overline{A}$ Answer : This takes some 'multiplying' out: $(A.B)+\overline{A}$ $(A+\overline{A}).(B+\overline{A})$ multiplied out $(1).(B+\overline{A})$ as $(A+\overline{A}) = 1$ $B+\overline{A}$ as $1.Q = Q$  $(A.\overline{B})+(A.B)$ Answer : Take the common factor, $A$ from both sides: $A.(\overline{B}+B)$ As $\overline{B}+B = 1$ Then $A.(\overline{B}+B) = A . 1$ As $A . 1 = A$ Then $(A.\overline{B})+(A.B) = A$ 

## De Morgan's Laws

De Morgan's laws are used to simplify Boolean equations so that you can build equations only involving one sort of gate, generally only using NAND or NOR gates. This can lead to cheaper hardware. There are two laws that you need to remember:

Rule 1 $\overline{P . Q} = \overline{P}+\overline{Q}$ $\overline{P + Q} = \overline{P}.\overline{Q}$

Let's prove that I'm not lying to you by creating a truth table to prove that: $\overline{P + Q} = \overline{P}.\overline{Q}$

P Q ${P}+{Q}$ $\overline{P + Q}$ $\overline{P}$ $\overline{Q}$ $\overline{P}.\overline{Q}$
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0

Since the values in the 4th and last columns are the same for all rows (which cover all possible truth value assignments to the variables), we can conclude that the two expressions are logically equivalent.

Now we prove $\overline{P . Q} = \overline{P}+\overline{Q}$ by the same method:

P Q ${P}.{Q}$ $\overline{P . Q}$ $\overline{P}$ $\overline{Q}$ $\overline{P}+\overline{Q}$
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0

We'll use $P$ to stand for padlock 1 is open, and $Q$ to stand for padlock 2 is open.

You can go through the gate if padlock 1 is open AND padlock 2 is open ($P . Q$) You can not go through the gate if padlock 1 is locked OR padlock 2 is locked ($\overline{P} + \overline{Q}$)

Since 'You can not go through the gate' is the same as the opposite (negation) of 'You can go through the gate' and, remembering

gate is open = $P.Q$ gate is closed = $\overline{P} + \overline{Q}$ you should be able to see that NOT{gate is open} = $\overline{P} + \overline{Q}$ or

$\overline{P . Q}$ = $\overline{P} + \overline{Q}$

Example: Simplifying boolean equations using boolean algebra

Simplify the following: $\overline{(A . \overline{B})+\overline{A}}$

$A$ $B$ $\overline{A}$ $\overline{B}$ $A.\overline{B}$ $(A.\overline{B})+\overline{A}$ $\overline{(A . \overline{B})+\overline{A}}$
0 0
1
1
0
1
0
0 1
1
0
0
1
0
1 0
0
1
1
1
0
1 1
0
0
0
0
1

From looking at the truth table we can see that it equates to $A.B$. But we should also know how to get to this result by using boolean identities. Let's give it a go:

1. Using De Morgans Law: $\overline{P + Q} = \overline{P}.\overline{Q}$. Where P = $(A . \overline{B})$ and Q = $(\overline{A})$
2. Take each side separately and applying De Morgans Law convert the centre gate to an AND:
$\overline{(A . \overline{B})+(\overline{A})} = (\overline{A . \overline{B}}).(\overline{\overline{A}})$
3. Now dealing with the left hand side of our new equation ($\overline{A . \overline{B}}$), apply De Morgans Law again ($\overline{P . Q} == \overline{P}+\overline{Q}$) and cancel out the double bars:
$(\overline{\overline{\overline{A} + \overline{\overline{B}}}}).({A}) = (\overline{A} + {B}).({A})$
4. Multiply out both sides:
$(\overline{A}.A) + (B.A)$
5. From the Identity $\overline{A}.A = 0$ we can replace the left hand side:
$0 + (B.A)$
6. From the Identity $0 + X = X$ we can ignore the 0 leaving us with:
$B.A$
7. From the Identity $X.Y = Y.X$ we can swap the values around:
$A.B$ = the value we calculated by truth table

Let's try another

Exercise: Simplifying boolean equations
Simplify the following using De Morgan's Laws and boolean identities. Check your answers by making truth tables:

$\overline{A . B}+A$

1. Using Demorgans rule that: $\overline{A . B} = \overline{A}+\overline{B}$
2. Making $\overline{A . B}+A = \overline{A}+\overline{B}+A$
3. Using the boolean identity that $\overline{A}+A = 1$
4. Making $\overline{A}+\overline{B}+A = \overline{B}+1$
5. Using the boolean identity that $\overline{B}+1 = 1$
6. We simplify down to $\overline{A . B} + A == 1$

$\overline{(A + \overline{B}).\overline{A}}$

$A$ $B$ $\overline{A}$ $\overline{B}$ $A+\overline{B}$ $(A+\overline{B}).\overline{A}$ $\overline{(A + \overline{B}).\overline{A}}$
0 0
1
1
1
1
0
0 1
1
0
0
0
1
1 0
0
1
1
0
1
1 1
0
0
1
0
1

If you're catching on to this, you'll notice that this is the equivalent of $A+B$. But we better check it with boolean algebra identities and De Morgans Law to confirm we have the correct answer.

1. Using De Morgans Law: $\overline{P . Q} = \overline{P}+\overline{Q}$
2. Take each side separately and applying De Morgans Law convert the centre gate to an AND:
$\overline{(A + \overline{B}).(\overline{A})} = {(\overline{A + \overline{B}})+(\overline{\overline{A}})}$
3. Cancel out the double bars:
${(\overline{A + \overline{B}})+(\overline{\overline{A}})} = (\overline{A + \overline{B}})+({A})$
4. Now dealing with the left hand side of our new equation, apply De Morgans Law again and cancel out the double bars:
$(\overline{\overline{\overline{A} . \overline{\overline{B}}}})+({A}) = (\overline{A} . {B})+({A})$
5. Multiply out both sides:
$(\overline{A}+A) . (B+A)$
6. From the Identity $\overline{A}+A = 1$ we can replace the left hand side:
$1 . (B.A)$
7. From the Identity $1 . X = X$ we can ignore the 1 leaving us with:
$B+A$
8. From the Identity $X+Y = Y+X$ we can swap the values around:
$A+B$ = the value we calculated by truth table

$\overline{(\overline{A + B})+B}$

$A$ $B$ $A+B$ $\overline{A+B}$ $(\overline{A+B})+B$ $\overline{(\overline{A+B})+B}$
0 0
0
1
1
0
0 1
1
0
1
0
1 0
1
0
0
1
1 1
1
0
1
0
$\overline{(\overline{A+B})+B}$


If you're catching on to this, you'll notice that this is the equivalent of $A.\overline{B}$. But we better check it with boolean algebra identities and De Morgans Law to confirm we have the correct answer.

1. Using De Morgans Law: $\overline{P . Q} = \overline{P}+\overline{Q}$
2. Take each side separately (P=$\overline{A+B}$ and Q=$B$) and applying De Morgans Law convert the centre gate to an AND:
$\overline{(\overline{A+B})+B} = (\overline{\overline{A+B}}).\overline{B}$
3. Cancel out the double bars:$(\overline{\overline{A+B}}).\overline{B} = (A+B).\overline{B}$
4. Multiply out both sides:
$(A.\overline{B})+(B.\overline{B})$
5. From the Identity $(B.\overline{B}) = 0$ we can replace the right hand side:
$(A.\overline{B})+0$
6. From the Identity $X + 0 = X$ we can ignore the 0 leaving us with:
$A.\overline{B}$ = the value we calculated by truth table

# Hardware and software

Hardware - Physical components that make up a computer system

Software - Computer programs and related data that provide the instructions for telling computer hardware what to do and how to do it

Hardware and Software have a symbiotic relationship, this means that without software hardware is very limited; and without hardware, software wouldn't be able to run at all. They need each other to fulfill their potential.

Standard hardware components The relationship between Hardware and Software
Hardware of a modern personal computer, can you name all the components?
A layer structure showing the relationship between various layers of software and hardware
 Exercise: Hardware and Software Define Hardware: Answer : Physical components that make up a computer system. Define Software: Answer : Computer programs and related data that provide the instructions for telling computer hardware what to do and how to do it. Give names to all the numbered hardware components above: Answer : Monitor Motherboard CPU RAM Expansion cards / graphics card / sound card / network card Power supply Optical disc drive Hard disk drive Keyboard Mouse Give 2 examples of software: Answer : Word Processor Operating System Game Spreadsheet Virus Scanner etc NOTE: If you mentioned a brand name such as Windows TM, you get no marks, the exam wants software types meaning you should have written Operating System. After all, for the previous question, you probably didn't answer ATI radeon HD 3000.

## Internal and external hardware components of a computer

Modern computing (arguably) started in 1822 when Charles Babbage, a British Mathematician, proposed 'the difference engine'. This was a mechanical machine that could calculate numbers from given inputs. Unfortunately Babbage never got enough funding to realise his plans and there was no Victorian Computing Revolution, however, you can see a completed modern version in the Science Museum (along with half of Babbage's brain!).

Since Babbage there have been several different designs of computers, and the one we are going to focus on here is called the 3-Box Model, or Von Neumann machine. In this machine:

• All data and instructions are stored in the Main Memory
• Instructions are sent to the Processor along the System Bus to be executed
• Any input and output (such as printing and entering instruction) is performed by I/O devices with the data travelling from the I/O devices to the Processor and Main Memory by means of the System Bus:
Von Neumann's Architecture

Consider a program stored on a DVD, to get the machine to run it, you will have to input the data from the DVD to the memory using the system bus. Once the program is loaded into memory the instructions it will be sent to the CPU line by line using the system bus and executed there. Any things to be printed or shown on a screen will be sent to the Output box.

We'll now look in more detail at these components:

### Processor

Plot of CPU transistor counts against dates of introduction. Note the logarithmic scale; the fitted line corresponds to exponential growth, with transistor count doubling every two years.

The processor (or Central Processor Unit - CPU) is one of the most complex parts of any computer system. The processor executes programs and supervises the operation of the rest of the system. Single chip processors are otherwise known as microprocessors. Gordon E Moore theorized that the number of transistors that could be integrated onto the chip would double every 18–24 months, most modern processors will contain billions of transistors. Multicore microprocessors are now very popular, where the processor will have several cores allowing for multiple programs or threads to be run at once.

### Main Memory

Main memory - data store that can be directly addressed by the CPU

Main memory is used to store program instruction and data, using the System Bus to communicate with CPU. Main memory is often created using Random Access Memory (or RAM) or Read Only Memory (ROM). Modern computers will have gigabytes of RAM, meaning that large programs can run and multiple programs can run at once. The more main memory that you have the larger the number of programs you can run at once.

Main memory is often made up of RAM modules, where you can adjust the amount by swapping in higher capacity modules or adding more modules

Main memory consists of data stored in addresses, in general, the more main memory you have the more addresses you'll have and vice versa.

1024 Cabbage
1025 Celery
1026 Courgette
1027 Carrot
1028 Cucumber
1029 Chard

In the above example if we were to perform the following assembly code instruction:

LDA 1026 ;LOAD memory location 1026

This would return the word: "Courgette"

If we were to perform the following assembly code instruction:

STO "Beetroot", 1025 ;STORE data given into memory location 1025

This would change the value stored in memory location 1025 from "Celery" to "Beetroot"

#### ROM and RAM

RAM - Random Access Memory can be read from and written to. Data is cleared when the power is off

ROM - Read Only Memory can only be read from, data is maintained when the power is off

The two main types of main memory are ROM and RAM. Whilst RAM might be several gigabytes in size, ROM will often be a few kilobytes. As ROM is read only memory, it tends to store core software instructions such as the code needed to load the Operating System into RAM (known as bootstrapping) or change the bios. RAM is much much larger and stores the code to run the operating system and programs that you run on your computer. When you load a disc into a games console, the code won't do anything until it has loaded from the disc into the system RAM, that's why you see a loading screen.

 Exercise: Central Processing Unit Give a definition for main memory: Answer : Main memory is a data store that can be directly addressed by the CPU What is the difference between ROM and RAM? Answer : ROM is Read Only Memory, RAM is random access memory. This means that ROM cannot be written to, it can only be read from. RAM can be both read from and written to. Name the four components of Von Neumann Architecture Answer : Processor Main memory I/O devices System bus

### System Bus

A Bus is a connection between different devices. This connection will normally consist of multiple wires along which signals, instructions and data will be carried. In Von Neumann Architecture there is a single bus to manage the connection between the three main components. The System Bus consists of 3 separate buses, each with a specific task that you need to know. This three bus model is an expansion of the Von Neumann architecture showing greater detail.

• The flow chart has an error. The arrow going to 'Input and Output' from 'Address Bus', shouldn't be bi-directional.

A single-directional bus that carries address signals from the CPU to Main Memory and I/O devices. This might involve the CPU requesting some data from Main Memory, sending the address of the data to Main Memory, then Main Memory returning the data along the data bus. Let's take a look at some code:

LDA 23


This code is asking to load the data from memory address 23 into the CPU, the address bus does not send addresses to the processor, but only sends them from the processor. To do this the CPU would send 23 along the Address Bus, and the value from memory location 23 would be sent along the Data Bus back to the CPU. The size of the Address Bus can dictate how much Main Memory you can have in your system. For example, if you had an Address Bus of 3 bits, then:

Maximum value   = 111 = 7
Range of values =
000
001
010
011
100
101
110
111


This would mean that your Main Memory could only have 8 different addressable blocks

#### Data bus

A bi-directional bus, typically consisting of 32 wires, used to transport data and instructions between the three components of the three-box model. The larger the Data Bus the more data can be transported at one time. For example if we have an 8 bit Data Bus, the maximum value we could send along the Bus would be:

1111 1111 = 255


The larger the Data Bus the more data we can send at once and the more complex instructions we can use.

#### Control bus

A bi-directional bus, typically consisting of more than 16 wires, used to transport control signals between the three components of the three-box model. The control bus is used to carry important information such as messages to say when a device has finished a job or when a device has just been plugged in. A simple example would be when you plug in your USB key and after a few moments a screen pops up asking you what you want to do with it. The control bus also contains interrupt signals which allow devices (printers, keyboards, disks, etc.) to signal that they have finished a request. The CPU temporarily suspends its current program, services the device and then resumes the previous program.

 Extension: Modern Architecture The information above will serve you well for the exam; however, the way many modern processors work break the definitions you have just learnt: Since modern CPUs now have internal memory(cache) and I/O devices have the ability to access memory without the need for the CPU(DMA), the address bus has to be bi-directional. However, for the exam you should treat it as being uni-directional. Some modern systems combine address and data buses since they are used at different parts of the fetch decode execute cycle. What is now called ROM is nowadays just hard to write Flash memory requiring special equipment, voltages or processes. It isn't truly Read Only as you can change it with some difficulty. You may have upgraded the BIOS on your computer for example. Modern chip designs have evolved either towards integrating more logic onto the CPU chip (memory controllers, Ethernet interfaces, serial ports etc.) for embedded applications (driven originally by the design of printers and photocopiers and called SOC - System On a Chip) or towards a single fast bus towards a second chip that has multiple busses for various types of device (see Northbridge for more information).
Exercise: Central Processing Unit

Complete the following table:

Name Direction Description
Data Bus
Control Bus

Name Direction Description
Address Bus uni-directional Carries addresses from the CPU to main memory or other devices
Data Bus bi-directional Transports data and instructions
Control Bus bi-directional Transports control signals

What is the largest number the follow width data buses can carry:

width 4 wires

$1111 = 2^4 - 1 = 15$

width 6 wires

$11 1111 = 2^6 - 1 = 63$

width 10 wires

$11 1111 1111 = 2^{10} - 1 = 1023$

width 4 wires

$1111 = 2^4 = 16$

width 5 wires

$1 1111 = 2^5 = 32$

width 8 wires

$1111 1111 = 2^8 = 256$

An address bus that can address a maximum of 2GB memory is 31 wires in width. How many wires would it need if it were to address a maximum of 4GB of memory?

32 as $2^{32} = 4 194 304$ bytes or 4GB of memory

But you don't have to be really good at maths to answer this. 4GB is twice 2GB and we know that 2^x is half the size of 2^x+1.

### Peripherals

Input/Output devices are used by the system to get information in and out, as they are not internal but are connected to the CPU, we refer to them as peripherals (your hands are peripheral to your torso). We'll cover the specific ones you need to learn a little later, but for the moment you need to know the fundamental difference:

• Input Devices - used to get information into the system. E.g. Keyboard
• Output Devices - used to send information out of the system. E.g. Visual Display Unit (VDU)

If you look at the Von Neumann Architecture notice that it doesn't mention Keyboard or display, this is a very smart move as you don't want to force every computer to have a keyboard (think about a games console, there is no keyboard on that) or a VDU (some computer such as MP3 players don't have a screen). However, some computer architecture does include specific I/O controllers:

#### I/O controllers

An I/O controller is an electronic circuit that connects to a system bus and an I/O device; it provides the correct voltages and currents for the system bus and the I/O device. Examples would include:

• keyboard controller, attached to a keyboard
• disk controller for a Hard Disk (Hard Disks are not main memory!)
• video display controller, attaching a video display unit (monitor)

#### I/O ports

I/O ports is a complementary method of performing input/output between the CPU and peripheral devices in a computer. This allows I/O devices to be connected to the CPU without having to have specialist hardware for each one. Think about the USB port on your computer, you can connect Keyboards, Mice, Game pads, Cameras, Phones, etc. and they all connect using the same port.

### Secondary storage

Main memory can be very expensive and you often require storing data that you won't use constantly. Think about a computer game that you haven't played for a couple of months. The last thing you want to do is to store this code in main memory taking up all that precious and expensive space. To get past this issue we use secondary storage. This is normally inexpensive data storage sitting external to the CPU, connected through an I/O controller, that we can use as and when we need. Secondary Storage will store data permanently, without the need for the electricity to remain always on (Think about a USB key, it doesn't need to be plugged in to keep its data). So taking the game example again, we only load the game into main memory (maybe from a DVD or hard disk), as and when we need it. Examples of secondary storage include:

• Hard Disk drive
• USB thumb drives
• CD-ROM / DVD / Blu-ray
• Tape drives
A hard disk drive with protective cover removed.
 Exercise: I/O and Peripherals Name 2 input peripherals: Answer : Keyboard Mouse Scanner Camera Microphone Games pad Name 2 output peripherals: Answer : Speakers Printer Visual Display Unit Name two ways to connect peripherals to a CPU: Answer : I/O controller I/O ports Name 2 secondary storage devices: Answer : Hard Disk USB thumb stick CD-ROM / DVD / Blu-Ray Name 2 I/O controllers Answer : Hard Disk controller Keyboard controller Visual Display Unit Controller

## Functional characteristics of a processor

A computer must be able to access main memory for reading and writing, they do this by using addressable memory. Main memory is a little like a set of school lockers, each with a different number. Each locker contains a block of data and if you fill up one locker you can use the next locker to expand into.

Looking at the example above you can see locker '0' contains '8975', whilst lockers 1 to 6 contain the sentence "The Cat sat on the dog!". Locker '7' is empty, locker '8' contains a boolean value and locker '9' contains the number 48. As you can see if we only used one character for the locker number then we could only ever have 10 lockers. If you limit the number of addresses you can use then you limit the amount of memory you can talk to. If you have a small address bus then you won't be able to have much main memory.

The way that data is stored in a computer is very similar:

### Stored program concept

stored program concept - a program must be in main memory in order for it to be executed. The instructions are fetched, decoded and executed one at a time

Building on the Von Neumann architecture we get the idea of how the stored program concept works. If you have ever loaded a game on a console you might notice that:

1. you need to insert a disc
2. the disc whirrs
4. the game plays

This is the stored program concept in motion! Let's take apart what is happening:

1. You insert an optical disk (secondary storage) with the code on
2. The code is loaded (whirrs) into main memory
3. The processor fetches, decodes and executes instructions from main memory to play game
 Exercise: Characteristics of a processor How many different addresses can a 8 line address bus address? Answer : $2^8 = 256$ How does the address bus affect main memory? Answer : If you have a small address bus then you will be limited in the number of addresses you can talk to and therefore how much main memory you can directly address. How wide would the address bus have to be to talk to 1024 addresses? Answer : 10 lines wide since $2^{10} = 1024$ What is wrong with using a 9 bit address bus but having 700 memory locations in main memory? Answer : We can only address $2^9 = 512$ different locations. It wouldn't be able to talk to address locations $513-700$. Define the stored program concept: Answer : A program must be in main memory in order for it to be executed. The instructions are fetched from main memory, then decoded and executed in the CPU.

## Structure and role of the processor

A processor (CPU) has several core components that work together to perform calculations. You need to know each of these and how they interact:

### Arithmetic logic unit

A simple example of an arithmetic logic unit (2-bit ALU) that does AND, OR, XOR, and addition

The Arithmetic Logic Unit or the ALU is a digital circuit that performs arithmetic and logical operations. Where arithmetic operations include things such as ADD and SUBTRACT and the logical operations include things such as AND, OR, NOT.

The ALU is a fundamental building block in the central processing unit (CPU) of a computer and without it the computer wouldn't be able to calculate anything! Some examples of assembly code instructions that would use the ALU are as follows (not all processors will have all these instructions):

ADD ;add one number to another number
SUB ;subtract one number to another number
INC ;increment a number by 1
DEC ;decrements a number by 1
MUL ;multiply numbers together
OR  ;boolean algebra function
AND ;boolean algebra function
NOT ;boolean algebra function
XOR ;boolean algebra function
JNZ ;jump to another section of code if a number is not zero (used for loops and ifs)
JZ  ;jump to another section of code if a number is zero (used for loops and ifs)


### Control unit

The control unit sits inside the CPU and coordinates the input and output devices of a computer system. It coordinates the fetching of program code from main memory to the CPU and directs the operation of the other processor components by providing timing and control signals.

### Clock

Processor clock - A timing device connected to the processor that synchronises when the fetch, decode execute cycle runs

Your computer might contain several clocks that each regulate different things. The clock we are going to look at here will keep the processor in line. It will send the processor a signal at regular times telling it to start the fetch decode execute routine.

Lights flash at frequency f = 0.5 Hz (Hz = hertz), 1.0 Hz and 2.0 Hz, where $x$ Hz means $x$ flashes per second.

Clock speed - The number of cycles that are performed by the CPU per second

Clock speed is measured in Hertz, which means 'per second'. You have probably heard of clock speeds such as 1 MHz, this means 1,000,000 cycles per second and potentially a million calculations. A computer of speed 3.4 GHz means it might be capable of processing 3,400,000,000 instructions per second! However it isn't as simple at that, as some processors can perform more than one calculation on each clock cycle, and processors from different manufacturers and using different architecture are often difficult to compare. (See the Megahertz myth). Also with the increase in multi-core processors such as the PS3 (7 cores) and the Xbox 360 (3 cores) there might be times where the clock might be ticking but there is nothing for the processor to calculate, the processor will then sit idle.

### General purpose and dedicated registers

Registers - a small amount of fast storage which is part of the processor

For immediate calculations, using main memory is too slow. Imagine having to send a signal along the address bus and some data along the data bus when all you want to do is store the result of adding two numbers together. The distance between the processor and main memory, even though it might be a few centimetres, is far enough for the signal to take a significant time to get there. To get past this issue there are small amounts of memory stored inside the processor itself, these are called registers. Registers are incredibly fast pieces of memory that are used to store the results of arithmetic and logic calculations.

Different processors will have different sets of registers. A common register is the Accumulator (acc) which is a data register, where the user is able to directly address (talk to) it and use it to store any results they wish. Processors may also have other registers with particular purposes:

• General purpose register - allow users to use them as they wish
• Conditional registers - hold truth values for loop and selection

There are also 4 registers in particular that you need to know, we'll meet them in more detail in the next chapter:

• Program Counter (PC) - an incrementing counter that keeps track of the memory address of which instruction is to be executed next...
• Memory Address Register (MAR) - holds the address in memory of the next instruction to be executed
• Memory Buffer Register (MBR) - a two-way register that holds data fetched from memory (and ready for the CPU to process) or data waiting to be stored in memory
• Current Instruction register (CIR) - a temporary holding ground for the instruction that has just been fetched from memory
 Exercise: Structure and role of the processor Give a description of the Arithemtic Logic Unit: Answer : The Arithmetic Logic Unit or the ALU is a digital circuit that performs arithmetic and logical operations. What does 3MHz mean: Answer : 3,000,000 clock cycles per second What does a processor clock do: Answer : Synchronises the operation of the processor What are registers: Answer : a small amount of fast storage which is part of the processor Name 3 registers used by the processor and explain what each does: Answer : Program Counter (PC) - an incrementing counter that keeps track of the memory address of which instruction is to be executed next... Memory Address Register (MAR) - holds the address in memory of the next instruction to be executed Memory Buffer Register (MBR) - a two-way register that holds data fetched from memory (and ready for the CPU to process) or data waiting to be stored in memory Current Instruction register (CIR) - a temporary holding ground for the instruction that has just been fetched from memory General purpose registers - Accumulator - Used to store results of calculations

### Increasing performance

If we want to increase the performance of our computer, we can try several things

• Increasing the clock speed
• Increasing bus widths

For each different methods we are going to look at these old games consoles to see how performance increase was achieved:

System Year Speed Word size Notes
NES 1983 1.79 MHz 8 bit
SNES 1990 3.58 MHz 16 bit
Nintendo 64 1996 93.75 MHz 64 bit
Gamecube 2001 486 MHz 128 bit cooling fan introduced

#### Clock speed

Clock speed - The number of cycles that are performed by the CPU per second

The most obvious way to increase the speed of a computer would be to increase the speed of the computer clock. With a faster clock speed the processor would be forced to perform more instructions per second.

 Example: Clock Speed As you can see on the console table above, each successive console showed an increase in clock speed. A clock speed of 800 MHz is twice as fast as a clock speed of 400 MHz, meaning it should be able to calculate twice as many calculations in a given time.

But what is to stop us increasing the clock speed as much as we want? If you study Physics you might already know this, but the problem with increased clock speed is that an increased current will have to flow through the circuits. The more current that flows, the hotter things get. You might notice that a laptop will get hot or even your mobile phone when you are doing something processor intensive like playing a game. The faster the clock speed, the hotter the processor runs. To counter this computer scientists have come up with smarter chip designs and introduced heat sinks, fans, and even liquid cooling into computers. If a processor runs too hot it can burn out!

NES processor Heat sink CPU fan water cooling
No need for fans or heat sinks Draws the heat away from the
processor, which sits beneath
Fan draws cold air over the cpu to cool it Metal contacts are placed on
the cpu drawing heat away, water
then passes over these contacts to
draw heat away

#### Word size

Word size - The number of bits of information that a processor can process at one time

Another way to increase the performance of a computer is to increase the word size. This means increasing the number of bits a computer can process at one time. As you can see from our console table, increasing word size was a big part of creating faster consoles, they even named a console the N64 to boast about its word size. With a larger word, computers can handle larger or more precise calculations and do more complicated things. Modern computer mostly have 32 or 64 bit word sizes, with specialist hardware such as games consoles being able to handle up to 128bit words.

Example: Word Length
Compsognathus

Imagine that we were only able to use words of length 6 letters or less and we wanted to describe the Compsognathus dinosaur to someone. We might try the following:

 “ A small living thing, with little claws and tough skin. It lived over ten plus five, times ten, plus seven, times ten, times ten, times ten, times ten, times ten, times ten years ago. ”

If we were able to use more letters per word (have a larger word size), then we could achieve more in fewer words.

 “ A small dinosaur with little claws and tough skin. It lived over one hundred and fifty-seven million years ago. ”

However, to understand the longer words you would have to know what dinosaur and million meant, maybe stopping for a brief moment to remember. In computing terminology, you would have to have more complicated hardware and using lots of little words could be faster than processing larger ones.

#### Bus size

Bus Size - The number of bits of information a bus can carry at one time (the number of wires making up a bus)

Now that we understand what word size is. Imagine that you have a processor able to understand 32 bit words at a single time. This is pretty standard. But what happens if the bus sending the words from memory to the processor was only 8 bits wide? We'd get a bottle neck. It would involve four chunks of data to be sent along the Data Bus before we had a word for the processor to execute. In other words, to increase performance we must also increase the bus size to avoid bottle necks:

 Example: Bus Size Imagine our friend can understand words of 28 bit length and we are sending the word: antidisestablishmentarianism to them. If the link between us (the bus), say a chat window on a website, only allowed for 4 letters at a time (the bus width). We'd have to send the following: anti dise stab lish ment aria nism  Requiring seven data sends before our friend is ready to process the word we sent them. If we were able to send more letters at once, through a larger bus width, then our friend wouldn't have to wait around until they had received all the data.
 Exercise: Increasing Processor Performance Name three ways to increase Processor performance: Answer : Increase clock speed Adjust word length Increase bus width What draw back might increasing clock speed bring? Answer : Processor might need extra cooling hardware to stop it over heating What is a benefit of increasing word length? Answer : Computers can perform more complex instructions in one go, dealing with larger numbers and greater number accuracy How might bus width impact on the speed of a computer? Answer : If the bus width is smaller than the word size, then the CPU will have to wait around whilst the the bus delivers data and instructions to it.

### How does it all fit together?

A very common exam question is to name the components of a computer architecture diagram. Now we have met the processor, buses and various other computer components we can start to answer questions like the following:

 Example: Name the component Match the following components to the numbers on the diagram: Processor, Data bus, Control Bus, Main memory, Keyboard, Secondary storage, Address bus, Clock, Monitor, VDU controller, disk controller, keyboard controller Don't worry about the size of this problem, we are going to tackle it bit by bit. the first step is to remember the differences between each of the components: Processor - connected to other devices using buses Data bus - bi-directional connection between devices Main memory - internal to the computer and linked through the buses Keyboard - external to the computer, an input device Secondary storage - external device, an input and output device Address bus - uni-directional connection between devices Clock - regulates the processor Monitor - external output device VDU controller - connects system to external monitor Disk controller - connects system to external secondary storage Keyboard controller - connects system to external keyboard device Control Bus - A bi-directional bus used to control signals between the components Now we have remembered what each device does, can you label them all? Answer : Clock Processor Main memory keyboard controller VDU controller Disk controller Data bus (or Control bus) Control bus (or Data bus) Address bus Keyboard Monitor Secondary storage
 Exercise: System Diagrams For the following diagram where applicable add single or multi directional connections between devices and buses Answer :

## Machine code and processor instruction set

### Machine code

Machine code - simple instructions that are executed directly by the CPU

As we should hopefully already know, computers can only understand binary, 1s and 0s. We are now going to look at the simplest instructions that we can give a computer. This is called machine code.

Machine code allows computers to perform the most basic, but essential tasks. For this section we are going to use the Accumulator (you met this register earlier) to store the intermediate results of all our calculations. Amongst others, the following instructions are important for all processors:

• LDA - Loads the contents of the memory address or integer into the accumulator
• STO - Stores the contents of the accumulator into the addressed location

Assembly code is the easy to read interpretation of machine code, there is a one to one matching, one line of assembly equals one line of machine code:

Machine code Assembly code
000000110101 =
Store 53


Let's take a look at a quick coding example using assembly code.

LDA #23 ;loads the number 23 into the accumulator
ADD #42 ;adds the number 42 to the contents of the accumulator = 65
STO 34  ;save the accumulator result to the memory address 34


The code above is the equivalent of saying x = 23 + 42 in VB.NET.

### Instruction set

Instruction set - the range of instructions that a CPU can execute

There are many different instructions that we can use in machine code, you have already met three (LDA, ADD, STO), but some processors will be capable of understanding many more. The selection of instructions that a machine can understand is called the instruction set. Below are a list of some other instructions that might be used:

ADD ;add one number to another number
SUB ;subtract one number to another number
INC ;increment a number by 1
DEC ;decrement a number by 1
MUL ;multiply numbers together
OR  ;boolean algebra function
AND ;boolean algebra function
NOT ;boolean algebra function
XOR ;boolean algebra function
JNZ ;jump to another section of code if a number is not zero (used for loops and ifs)
JZ  ;jump to another section of code if a number is zero (used for loops and ifs)
JMP ;jump to another section of code (used for loops and ifs)


Let us look at a more complex example of assembly code instructions:

1. LDA #12 ;loads the number 12 into the accumulator

2. MUL #2  ;multiplies the accumulator by 2 = 24

3. SUB #6  ;take 6 away from the accumulator = 18

4. JNZ 6   ;if the accumulator <> 0 then goto line 6

5. SUB #5  ;take 5 away from the accumulator (this line isn't executed!)

6. STO 34  ;saves the accumulator result (18) to the memory address 34


You'll notice that in general instructions have two main parts:

• opcode - instruction name
• operand - data or address

Depending on the word size, there will be different numbers of bits available for the opcode and for the operand. There are two different philosophies at play, with some processors choosing to have lots of different instructions and a smaller operand (Intel, AMD) and others choosing to have less instructions and more space for the operand (ARM).

• CISC - Complex Instruction Set Computer - more instructions allowing for complex tasks to be executed, but range and precision of the operand is reduced. Some instruction may be of variable length, for example taking extra words (or bytes) to address full memory addresses, load full data values or just expand the available instructions.
• RISC - Reduced Instruction Set Computer - less instructions allowing for larger and higher precision operands.
 Exercise: Instruction sets What is the instruction set: Answer : the range of instructions that a CPU can execute Name and explain the two parts that make up an machine code instruction: Answer : opcode - the command to be executed operand - the data or address being worked upon For a word with 4 bits for an opcode and 6 bits for an operand How many different instructions could I fit into the instruction set? What is the largest number that I could use as data? Answer : Number of instructions: $2^4 = 16$ largest operand: $2^6 - 1 = 63$ For a 16 bit word with 6 bits for an opcode How many different instructions could I fit into the instruction set? What is the largest number that I could use as data? Answer : Number of instructions: $2^6 = 64$ largest operand: $2^{10} - 1 = 1023$ Why might a manufacturer choose to increase the instruction set size? Answer : so that they can increase the number of discrete instructions that can be executed What might be the problem with increasing the space taken up by the opcode? Answer : less space for the operand, meaning reduced range and precision in data be processed in a single instruction Give two benefits for increasing the word size of a processor? Answer : more space available to increase the instruction set size greater range and precision available in the operand

You might notice that some instructions use a # and others don't, you might even have an inkling as to what the difference is. Well here is the truth:

        # = number


Let's take a look at a quick example:

Assembly code Main memory start Main memory end
LOAD #10
STORE 12

10 9
11 2
12 7
13 10
14 12
10 9
11 2
12 22
13 10
14 12
This code loads the number 10 into the accumulator, then adds the number 12, it then stores the result 22 into memory location 12.

Let's take a look at doing this without the hashes:

Assembly code Main memory start Main memory end
LOAD 10
STORE 12

10 9
11 2
12 7
13 10
14 12
10 9
11 2
12 16
13 10
14 12
This code loads the value stored in memory location 10 into the accumulator (9), then adds the value stored in memory location 12 (7), it then stores the result into memory location 12 (9 + 7 = 16).

There are many types of codes addressing modes. But we only need to know 3, they are:

Integer # LOAD #15 15 is treated as a number
Nothing HALT Some instruction don't need operands such as halting a program
Exercise: Assembly code and Addressing modes

For the following memory space, what would it look like after executing the assembly code below:

10 1
11 4
12 4
13 100
14 5
LOAD 14
STORE 12


10 1
11 4
12 17
13 100
14 5

For the following memory space, what would it look like after executing the assembly code below:

211 6
212 3
213 78
214 21
LOAD #100
STORE 213
STORE 214


211 6
212 3
213 100
214 121

For the following memory space, what would it look like after executing the assembly code below:

99 6
100 6
101 8
102 9
LOAD 100
DIV 7
STORE 102


99 6
100 6
101 8
102 2

Write some assembly code to do the following:

34 + 35 and store in memory location 100

LOAD #34
STORE 100


Write some assembly code to do the following:

4 + (100 / 2) and store in memory location 100

LOAD #100
DIV #2
STORE 100


List and give examples of three addressing modes:

• Memory Locations - LOAD 15
• Integers (Whole Numbers) - LOAD #15
• Nothing - HALT

#### Machine code and instruction sets

There is no set binary bit pattern for different opcodes in an instruction set. Different processors will use different patterns, but sometimes it might be the case that you are given certain bit patterns that represent different opcodes. You will then be asked to write machine code instructions using them. Below is an example of bit patterns that might represent certain instructions.

0000 STORE Address 0 STO 12
0001 LOAD Number 1 LDA #12
1111 HALT None F HALT
 Exercise: Machine Code Using the table above provide machine code to do the following: LOAD 12 ADD #6  Answer : 0010 00001100 0100 00000110  Using the table above give the assembly code for the following machine code: 0001 00000111 0100 00001001 0000 00011110  Answer : LOAD #7 ADD #9 STORE 30  Explain what the above code does: Answer : loads the integer 7 into the Accumulator, adds the integer 9 to the Accumulator, stores the result, 16, in memory location 30 Convert the following machine code into hexadecimal: 0001 00111011 0100 00001001 0000 00011110 1111 00000000  Answer : 1 3 B 4 0 9 0 1 E F 0 0  If we were lacking Assembly code, why might we want to convert machine code into Hexadecimal? Answer : It makes it easier for humans to read and understand.
 Extension: Little Man Computer If you would like to play around with Assembly language a great place to state is the Little man computer. You can find a Java applet and some examples at the York University website.

## The Fetch–Execute cycle and the role of registers within it

The Fetch-Decode-Execute cycle of a computer is the process by which a computer:

1. fetches a program instruction from its memory,
2. determines what instruction wants to do,
3. and carries out those actions.

This cycle is repeated continuously by the central processing unit (CPU), from bootup to when the computer is shut down. In modern computers this means completing the cycle billions of times a second! Without it nothing would be able to be calculated.

### Registers involved

The circuits used in the CPU during the cycle are:

• Program Counter (PC) - an incrementing counter that keeps track of the memory address of which instruction is to be executed next...
• Memory Address Register (MAR) - the address in main memory that is currently being read or written
• Memory Buffer Register (MBR) - a two-way register that holds data fetched from memory (and ready for the CPU to process) or data waiting to be stored in memory
• Current Instruction register (CIR) - a temporary holding ground for the instruction that has just been fetched from memory
• Control Unit (CU) - decodes the program instruction in the CIR, selecting machine resources such as a data source register and a particular arithmetic operation, and coordinates activation of those resources
• Arithmetic logic unit (ALU) - performs mathematical and logical operations

### Register notation

To describe the cycle we can use register notation. This is a very simple way of noting all the steps involved. In all cases where you see brackets e.g. [PC], this means that the contents of the thing inside the brackets is loaded. In the case of the first line, the contents of the program counter is loaded into the Memory Address Register.

$MAR\gets [PC]$

$MBR\gets [Memory]_{MAR address}; PC\gets [PC]+1$ (Increment the PC for next cycle at the same time)

$CIR\gets [MBR]$

$[CIR]$ decoded then executed


### Detailed description of Fetch-Decode-Execute Cycle

To better understand what is going on at each stage we'll now look at a detailed description:

The contents of the Program Counter, the address of the next instruction to be executed, is placed into the Memory Address Register

The address is sent from the MAR along the address bus to the Main Memory. The instruction at that address is found and returned along the data bus to the Memory Buffer Register. At the same time the contents of the Program Counter is increased by 1, to reference the next instruction to be executed.

The MBR loads the Current Instruction Register with the instruction to be executed.

The instruction is decoded and executed using the ALU if necessary.

The Cycle starts again!

 Exercise: Fetch Execute Cycle Name 3 registers involved in the Fetch Execute Cycle and describe what each does: Answer : Program Counter (PC) - an incrementing counter that keeps track of the memory address of which instruction is to be executed next... Memory Address Register (MAR) - holds the address in memory of the next instruction to be executed Memory Buffer Register (MBR) - a two-way register that holds data fetched from memory (and ready for the CPU to process) or data waiting to be stored in memory Current Instruction register (CIR) - a temporary holding ground for the instruction that has just been fetched from memory Describe the Fetch Execute Cycle using register notation: Answer : $MAR\gets [PC]$ $MBR\gets [Memory]_{MAR address}; PC\gets [PC]+1$ $CIR\gets [MBR]$ $CIR executes$  Complete the following diagrams showing each step of the fetch decode execute cycle: Answer : Answer : Answer : Answer :

# Hardware Devices

 Input and Output Devices Know the main characteristics, purpose and suitability of contemporary devices (see the Teacher Resource Bank), and understand their principles of operation, including methods of error checking (check digit).
 Secondary Storage Devices Explain the need for secondary storage within a computer system, know the main characteristics, purpose and suitability, and understand the principles of operation of contemporary devices (see the Teacher Resource Bank). Compare the capacity and speed of access of various media and make a judgement about their suitability for different applications

## Input and output devices

You should already have met the internal components of the computer and the peripherals, that sit outside. We are now going to look at two different categories of peripherals. Those that input data into a computer, and those that output data from the computer.

Computers work along the lines shown above, they receive inputs (instructions etc.), they process the input working out what to do with it, then they output some form of result

How do we tell what is an input and what is an output device? Think about it from the computer's perspective. If a device is putting data into the computer in the form of text, sound, images, button presses etc. then it is an input device, if the device is outputting things from the computer such as sound, movement, printing, images etc., then it is an output device. It really is that easy to tell the difference, but be warned, some devices can be both input and output!

Let's take a look at two examples:

 Example: Telling the difference between input and output devices An LG LCD monitor When you are using the monitor it displays things that you are doing, such as moving windows and clicking on website links. At no point do you click on the screen or put anything into the monitor. The only thing it does is output information, therefore it is an output device. Easy! An optical mouse A mouse is used to move a little cursor around the screen, clicking and dragging as you go. if you let go of the mouse, the cursor will stop. The computer is relying on you to move the mouse, the mouse won't move on its own! Therefore it is an input device.
 Exercise: Input and output devices Note whether the following devices are input or output devices (or both!) Printer Mouse Keyboard Monitor Web cam Scanner USB thumb drive Graphics tablet Joypad Speakers Answer : Printer - output Mouse - input Keyboard - input Monitor - output Web cam - input Scanner - input USB thumb drive - input and output (read and write!) Graphics tablet - input Joypad - input (output as well if it rumbles!) Speakers - output

## Input devices

Pay special attention to devices with an orange background, you need to be able to describe exactly how they work!

Input Device - Devices that send data or instructions into a computer

#### Mouse

Enables the user to execute commands or issue instructions to the computer by controlling a pointer on the screen.

#### Keyboard

The keyboard is one of the most popular ways of inputting information into a computer. The basic mechanical keyboard relies on springed keys being pressed down to complete an electrical circuit. This circuit then transmits a binary signal (commonly using ASCII) to the computer to represent the key pressed.

Stylised cross-section of a Chiclet keyboard (there are other technologies out there used to make keyboards). The bottom right hand button has been pressed, completing the circuit shown in red.

There are many different keyboard layouts, with differences between languages and countries. The most popular layout is the QWERTY keyboard. Other layouts include:

• AZERTY - for countries such as France and Belgium
• QWERTZ - for countries such as Germany and Austria
• Arabic - different values to most keys
• Ukranian
• Chinese - laid over a QWERTY keyboard

There are variations QWERTY keyboard with the UK and the USA having very slight differences in layout. There also variations in English language keyboards such as the Dvorak layout, which followers claim to be superior to QWERTY.

QWERTY keyboard

#### Voice recognition

Microphone connected to software that converts human speech into commands or text. Pros

Natural interface with a computer allowing for new users to execute commands without having to learn complex command set

Cons

Speech recognition might not recognise the difference between similar words i.e. "their" and "they're" or be able to understand regional accents
microphone

#### Digital camera

1. Light is focused through the lens onto the image sensor at the back of the camera
2. The image sensor is made up of an array of Red, Green and Blue photosensors, called a Bayer filter. Each sensor will only record values for that particular colour.

And became these:

3. The different colour arrays are combined to form an image and makes this:

4. Once the RGB values have been captured, they can then be stored digitally using SD or compact flash cards. Save formats include JPEG or TIFF.

Pros

You can preview images taken without having to get them developed
You can apply filters and images to add special effects

Cons

Some people argue that the quality of photos taken using the traditional film medium is better
Camara2sig

Used in supermarkets, keeping track of produce etc. They allow for quick reading of product details so that prices and information can be retrieved and/or stock levels updated. However the amount of data stored in a barcode is very limited

barcodes are very common
1. A laser is directed towards the barcode, scanning across it and the reflected light is captured by the reader
2. The intensity of light reflected back is read by a sensor in the bar code reader
• High intensity = white bar
• Low intensity = black bar
3. The pattern received is translated into a code which gives the identity of the barcode being scanned
4. This code is checked against a product database and the product details displayed
Plessey code is one way to encode barcodes

To make sure that the number you have received is correct barcodes employ check digits. Read on to find out more

Pros

Cheap to produce as all you need to do is print a black and white image
Quick to read, and with multi-direction scanners, can be read from different angles

Cons

Only a limited amount of data can be stored

Used in things like multi choice question papers. The student would be given a selection of answers and then mark the ones they thought correct with a pen or pencil. When finished, the forms would be fed into a machine that would look for black marks. The position of these marks correspond to answers and the form could be marked at some speed.

multi choice exam paper ready for OMR

Used in scanning printed or written text into a digital format. Used by Amazon and Google to scan books.

Sketch of a typical manual book scanner

Used to read data from bank cards and access cards. Data is stored in the magnetic, generally black, strip on the back of these cards

An example of the reverse side of a typical credit card: Green circle #1 labels the Magnetic stripe

Used in bank cards, often known as part of 'chip and pin'. More secure than Magnetic stripes though more expensive to produce.

A smart card. The 3 by 5 mm security chip embedded in the card is clearly visible on the left hand side. The contact pads on the card enables electronic access to the chip.

Used to read data without physical contact. Examples include the London Oyster Card System. Where the card has a Radio Frequency Identification(RFID) chip.

1. The card is then placed above a reader and the magnetic field produced by the reader creates a current in the cards circuitry (no physical contact is required)
3. If the details of the card are legitimate (checked on database) then it lets the person through the gate

Pros

Can be read without physical contact (health and safety concerns)
Fast way to pay for things

Cons

Having multiple RFID cards together, means that they can interfere with each other and none of them can be read
A damaged card, revealing the microchip in the lower right corner, and the aerial running around the edge of the card.
Oyster card readers on London Underground ticket barriers at Canary Wharf.

### Touch sensitive

More and more devices are relying on touch technologies.

#### Touch-sensitive screen

1. Each of the four corners of a screen emits a uniform electric field which covers the screen
2. When you place your finger on or near the screen it disrupts this field and draws current
3. measuring the amount of current pulled from each corner you can triangulate the position of the finger

Pros

Natural, intuitive interface with devices
The ability to remap screen functions to suit the task (for example bringing up a keyboard when necessary

Cons

Cold weather can effect the functioning of touch screens
Won't work through gloves, as this stops your fingers conducting electricity

#### Graphics tablet

Used in the design and architectural industries. This allows for people to draw on the tablet in a natural way (as they would with a pencil and paper) and for their drawing to appear on the computer.

Wacom Pen-tablet

### Scanners

Several of the scanners featured here record biological (bio) measurements (metrics) about human beings. Physical data such as finger prints are unique to each person.

#### Flatbed Scanner

Flat bed scanners are used to convert images and text into a digital format.

The main components of a flatbed scanner
1. Place the object you want to scan on the glass pane, face down
2. the light moves to the start of the document and illuminates a slice
3. The slice is reflected into the CCD where it's image is stored
4. the light and mirror move down to the next slice and so on
5. once all the slices are completed they are put together into a digital image
Flatbed Scanner

#### Fingerprint Scanner

A finger print

The ridges and troughs on a person's finger and toes are unique to that person. Using a scanner a finger print pattern can be recorded and compared to others on a database, allowing a computer to match finger prints from crimes to a suspect, or to allow people into restricted areas.

Fingerprint scanner in Tel Aviv

#### Retina Scanner

The blood vessels in a normal human retina form a unique pattern for each person

Retina scanners are used to record the pattern of blood vessels at the back of someone's eye. As every has a different pattern of vessels, then retina scanners can be used to uniquely identify people and are very difficult to fake.

#### Iris Scanner

Iris patterns can be different colours and form a unique identifier for each person

By taking a picture of the blood vessels and colouring of someone's eye, we can get a unique pattern that can be used to identify individuals. People might try and circumvent this by using contact lenses

A U.S. Marine Corps Sergeant uses an iris scanner to positively identify a member of the Baghdadi city council prior to a meeting with local tribal leaders, sheiks, community leaders and U.S. service members.
 Exercise: Scanners Explain how a flat bed scanner works: Answer : Place the object you want to scan on the glass plane, face down the light moves to the start of the document and illuminates a slice The slice is reflected into the CCD where it's image is stored the light and mirror move down to the next slice and so on once all the slices are completed the image is assembled using them Give two examples of devices that collect biometric data: Answer : Retina scanners Finger print scanners Iris recognition

### Check digits

Check Digit - an additional digit added to a data string and depending on that string, used for checking that the string has been sent correctly

With input devices we have a lot of data being sent into the computer, with image capture devices we could be talking about billions of ones and zeroes. How can we make sure that they all get from the input device to the computer safely, without becoming corrupted? There are many error checking methods out there and you will cover some of them in more detail in Unit 1, however, for the moment we will learn a little about check digits:

An example of using check digits (The exam will not expect you to know this technique) is the final digit of a Universal Product Code computed as follows:

1. Add the digits (up to but not including the check digit) in the odd-numbered positions (first, third, fifth, etc.) together and multiply by three.
2. Add the digits (up to but not including the check digit) in the even-numbered positions (second, fourth, sixth, etc.) to the result.
3. Take the remainder of the result divided by 10 (modulo operation) and subtract this from 10 to derive the check digit.
 Example: Check Digits For instance, the UPC-A barcode for a box of tissues is "036000241457". The last digit is the check digit "7", and if the other numbers are correct then the check digit calculation must produce 7. Add the odd number digits: 0+6+0+2+1+5 = 14 Multiply the result by 3: 14 * 3 = 42 Add the even number digits: 3+0+0+4+4 = 11 Add the two results together: 42 + 11 = 53 To calculate the check digit, take the remainder of (53 / 10), which is also known as (53 modulo 10), and subtract from 10. Therefore, the check digit value is 7. Correct!
 Exercise: Check digits Calculate the check digit for the following food item "01010101010": Answer : Add the odd number digits: $0+0+0+0+0+0 = 0$ Multiply the result by 3: $0 * 3 = 0$ Add the even number digits: $1+1+1+1+1 = 5$ Add the two results together: $0 + 5 = 5$ To calculate the check digit, take the remainder of (5 / 10), which is also known as (5 modulo 10), and subtract from 10 i.e. (10 - 5 modulo 10) = 5. Therefore, the check digit value is 5. If the remainder is 0, subtracting from 10 would give 10. In that case, use 0 as the check digit. Did the following barcode scan correctly: "01234567890 6"? Answer : Add the odd number digits: 0+2+4+6+8+0 = 20 Multiply the result by 3: 20 * 3 = 60 Add the even number digits: 1+3+5+7+9 = 25 Add the two results together: 60 + 25 = 85 To calculate the check digit, take the remainder of (85 / 10), which is also known as (85 modulo 10), and subtract from 10 i.e. (10 - 85 modulo 10) = 5. Therefore, the check digit value is 5. If the remainder is 0, subtracting from 10 would give 10. In that case, use 0 as the check digit. Therefore the check digit given, 6, shows that the code is incorrect. Why do we use check digits? Answer : We use check digits to make sure that data received has been received correctly

## Output devices

Pay special attention to devices with an orange background, you need to be able to describe exactly how they work!

Output Devices - Device that a computer sends data or instructions to

### Visual display units

#### Cathode-Ray Tube

A cathode ray tube is a Visual Display Unit. You might know them as the old 'fat' televisions and monitors that have mostly been superseded by LCD screens.

Pro

the image on a CRT can be viewed from a wide range of angles

Cons

Heavy, large and power hungry compared to LCD screens
Cutaway rendering of a color CRT:
1. Three Electron guns (for red, green, and blue phosphor dots)
2. Electron beams
3. Focusing coils
4. Deflection coils
5. Anode connection
6. Mask for separating beams for red, green, and blue part of displayed image
7. Phosphor layer with red, green, and blue zones
8. Close-up of the phosphor-coated inner side of the screen

#### Flat Screen (LCD)

A 19-inch LG flat-panel LCD monitor.

LCDs are Visual Display Units. Most modern Televisions and Monitors are are liquid crystal displays (LCD). An LCD screen is made up by an array of pixels or picture elements, each pixel contains Red Green and Blue and there is a back light that shines through the pixel, creating an image

To change the image displayed on the screen will require different combinations of Red, Green and Blue pixels. To do this the pixels are sandwiched between two polarized grills.

These grills are controlled by an electric current and when current is applied, the grids go perpendicular to each other, blocking out all light from a particular colour.

Applying different current patterns to different pixels means that you can choose whether each pixel displays Red, Green or Blue, thus building an image:

Pros LCD screens have several benefits over traditional CRT screens:

Smaller and lighter than equivalent sized CRT
More energy efficient than CRT

Cons

viewing angles of LCD screens can be smaller than an equivalent CRT. This means the viewers can't see images from the side of the screen
Dead pixels can plague LCD Monitors, where the grills governing the colour of an individual pixel get stuck and fix that pixel to always displaying a certain colour or no colour at all
an example of a dead pixel

#### Plasma Screen

Plasma screens are Visual Display Units. They are generally more expensive than LCDs and CRTs, and offer similar performance to an LCD. They are power hungry and used mainly for large television sets

 Exercise: Visual Display Units Explain how an LCD screen works: Answer : An LCD screen is made up by an array of pixels, each pixel contains Red Green and Blue and there is a back light that shines through the pixel, creating an image. The pixels are sandwiched between two polarized grills. These grills are controlled by an electric current and when current is applied, the grids go perpendicular to each other, blocking out all light from a particular colour. Applying different current patterns to different pixels means that you can choose whether each pixel displays Red, Green or Blue, thus building an image Give two benefits and one drawback of using a LCD screen over a CRT: Answer : Smaller and lighter than equivalent sized CRT More energy efficient than CRT dead pixels can effect the image Name 3 types of Visual display unit: Answer : LCD Plasma CRT

### Sound output

Speech output might include speech synthesis, headphones or speakers

A pair of speakers for notebook computers, runs off USB

### Electronic paper

Amazon Kindle using an e-paper display

Electronic paper is made up of tiny plastic balls that have different colours on each side (black and white). Applying an electrical current to the 'paper' flips the balls to make the pattern of a picture and an image is displayed. The image stays there until you apply another current. This is used in modern e-book readers such as the Amazon Kindle and in other devices such as phones

If you look closely you can see the 'ball's on the Kindle 3
Appearance of pixels

Pros

Images are easy to read in sunlight, unlike most electronic screens
You only need to use electricity to change the image, not maintain it, meaning batteries last longer than LCD screens. In some cases batteries may last weeks, whilst an LCD equivalent would only last a day or two

Cons

The refresh rate of screens is too slow to show moving images
Ghosting might occur, where the shadow of old images remains on the screen after you have refreshed
An e-ink screen showing the "ghost" of a prior image
 Exercise: Electronic paper Give two benefits and one drawback for using electronic paper over an LCD screen: Answer : Images are easy to read in sunlight You only need to use electricity to change the image, not maintain it, meaning batteries last longer than LCD screens The refresh rate of screens is too slow to show moving images

### Printers

There are several different types of Printers, the one's you need to know are below

#### Impact Printer

Impact printers rely on a forcible impact to transfer ink to the media, similar to the action of a typewriter. All but the dot matrix printer rely on the use of formed characters, letterforms that represent each of the characters that the printer was capable of printing. Impact printers varieties include, typewriter-derived printers, teletypewriter-derived printers, daisy wheel printers, dot matrix printers and line printers. Dot matrix printers remain in common use in businesses where multi-part forms are printed, such as car rental services, this allows several sheets of paper to be written to with one strike of the printer head, it also allows for carbon paper to be written to through sealed envelopes:

Dot matrix printers use a print head containing a line of pins. The number of pins can vary from 7 into the dozens. As the print head passes over the paper the pins impact on the ink ribbon forming characters on the paper line by line.

Pros

Can print multi-part stationary
very cheap to run

Cons

unable to produce high definition images, you are limited to the number of pins available
slow when compared to laser

output from a dot-matrix printer, showing the individual rod strikes on the ribbon to make an image on the paper

#### Inkjet Printer

Fixed head (right) with ink cartridge (middle)

Inkjets are examples of non-impact printer. They operate by propelling variably-sized droplets of liquid or molten material (ink) onto almost any sized page. They are the most common type of computer printer used by consumers.

1. The paper is fed into the printer
2. The print head contains one or more cartridges of ink of different colours (some only have black ink)
3. The print head moves from one side to another, each cartridge spraying tiny particles of ink onto the paper to form the correct pattern
4. After one line is finished the paper is fed through a little more, and the next line printed
Output from an inkjet printer showing the individual blobs of ink on the paper

Pros

Inkjet printers are cheaper than lasers
They can produce high quality images for photos etc

Cons

They are slower than lasers
Per page they are relatively expensive

#### Laser Printer

Lasers are examples of non-impact printers. A laser printer rapidly produces high quality text and graphics. They work in the following way:

1. The drum is given a negative charge
2. This charge is erased in the correct places by the laser to create the image using the photoelectric effect
1. The drum is coated in toner, a fine dust, which is attracted to the charge on the drum
2. The drum rolls over the paper and transfers the toner onto it(if your printing gets jammed the paper might have this dust on it which comes off on your hands)
3. The paper is then put through heated rollers which melts the toner and seals it to the paper, thus finishing the image.

Pros

Fast
Cheap to Produce large volumes of printing

Cons

Expensive hardware
Hp laserjet 4200

#### Plotter

Plotters were an alternate printing technology once common in engineering and architectural firms. Pen-based plotters rely on contact with the paper, but not impact, per se, and special purpose pens that are mechanically run over the paper to create text and images. They were particularly adept to printing vector graphics, though they have generally been replaced with wide-format conventional inkjet/laser printers.

1. Paper is placed in the plotter.
2. The plotter arm selects a pen of the correct colour
3. the arm then moves the pen to the area where printing needs to start.
4. the pen is lowered onto the paper and the arm moves it drawing a continuous image.
5. The pen raises and lowers depending on what needs to be drawn, the plotter can also select from a group of colour pens

(some plotters involve keeping the pens stationary and moving the paper instead)

Pros

cheap to run
can produce very precise technical drawings

Cons

there may be issues around the colour pens available, it is hard to combine colours as you would in an inkjet
slow

Plotter at work on a technical drawing
 Exercise: Printers What printing device is best for printing thousands of leaflets to advertise a shop opening? Why? Answer : Laser printer: it can print incredibly fast it can print in colour toner doesn't run in the rain, meaning the leaflets won't be spoilt during delivery For a seven pin impact printer, what character would the following line codes output: 1,2,3,4,5,6,7 | 1,4 | 1,4 | 2,3  Answer : Describe how a laser printer works: Answer : Electrical charge version of the image is transferred to the drum Paper passes over the drum and the charge is transferred to the paper Toner, a fine dust, is attracted to the charge on the paper, making the image The paper is then put through heated rollers which then melts the toner and seals it to the paper, thus finishing the image. When might you want to use an impact printer over an inkjet printer? Answer : When you are printing multi-part stationary When might you want to use an inkjet printer over an impact printer? Answer : When you want detail and colour

## Secondary storage devices

This section will be looking at the various forms of secondary storage devices (media). For each device you should be familiar with the following details:

• Seek time - The average time taken from requesting data to starting to read the requested data
• Capacity - The amount of data it is possible to store on a medium
• Write type - Whether it is read only, write only, or readable and writable
• Cost - How much it costs per megabyte
• Access type - Whether it uses Random Access or Serial Access
sequential access requires all memory locations before the one sought to be read, before reaching it. Random access memory allows you to jump directly to the memory location you are seeking

Pay special attention to devices with an orange background, you need to be able to describe exactly how they work!

## Magnetic media

Magnetic media stores data by assigning a magnetic charge to metal. This metal is then processed by a read head, which converts the charges into ones and zeros. Historically, magnetic media has been very popular for storing programs, data, and making backups. It looks set to continue in this role for some time. However, solid state technology is starting to be used more and more, storing programs and data on new devices such as mobile phones and cameras.

Solid-state memory
Device Size

Hard Disk

Up to 4 Terabytes

Magnetic Tape

Up to 2 Terabytes

### Hard disk

Video of exposed hard disk drive (HDD)

Hard disks are usually found inside computers to store programs and data. They are increasingly cheap and more and more companies are using them to back things up. Hard disks can vary in physical size with some disks getting as small as your thumb. The capacity of a commercial disk is currently up to about 4 terabytes allowing users to read and write to them. They are constructed from several key components:

• Platter - Metallic disks where One or both sides of the platter are magnetized, allowing data to be stored. The platter spins thousands of times a second around the spindle. There may be several platters, with data stored across them
• Head - The head reads magnetic data from the platter. For a drive with several platters there may two heads per platter allowing data to be read from top and bottom of each
• Actuator Arm - used to move the read heads in and out of the disk, so that data can be read and written to particular locations and you can access data in a Random fashion, you don't need to read your way through the entire disk to fetch a particular bit of information, you can jump right there. Seek time is very low.
• Power connector - provides electricity to spin the platters, move the read head and run the electronics
• IDE connector - allows for data transfer from and to the platters
• Jumper block - used to get the disk working in specific ways such as RAID

For the exam you must be able to explain how a hard disk works:

1. The platters spin around the spindle
2. data is requested to be read from a particular area of a platter
4. Once the data sector that is required has spun around and under the read head, data is read
5. Read data is sent from the IDE connector to main memory
Description of a hard disk platter

Writing data is very similar:

1. The platters spin around the spindle
2. data is sent to the hard disk using the IDE connector
3. the actuator arm moves the write head to the track that will be written to
4. Once the data sector that is required has spun around and under the write head, data is written to the platter

Pros

Fast seek times
Random access
High capacities possible
Low cost per megabyte

Cons

Very susceptible to damage from physical shocks

### Magnetic Tape drive

DDS tape drive. Above, from left right: DDS-4 tape (20 GB), 112m Data8 tape (2.5 GB), QIC DC-6250 tape (250 MB), and a 3.5" floppy disk (1.44 MB)

Increasingly obsolete, the tape has been a medium to deliver software and back up data since the early days of computing. Nowadays they are used mostly for corporate backing up and archiving of data. Tapes are sequential data stores, meaning that if you had information stored at the end of the tape you would have to wind your way through the entirety of the tape before you could read it. There is no random access like with a hard disk! Tapes can be several terabytes in size and reading and writing can be very fast as long as you read or write continuous sections of the tape at once.

Pros

Fast
High capacity
Cheap per megabyte

Cons

## Optical media

Optical media works by creating a disc with a pitted metallic surface. There are several different types of disk out there ranging from 650 MB to 128 GB, with the pits and lands getting closer together for higher volume disks. The principle behind how each of them works is the same.

pitted surface visible on the surface of a CD. Massively zoomed in!
Optical media
Device Type Size Image
• Write once then Read only
• re-Writable
650 - 900 MB
• DVD-ROM
• DVD-R
• DVD-RW
• DVD-RAM
• Write once then Read only
• re-Writable
• re-Writable
4.7 - 9.4 GB
• Blu-ray (BD) disc
• HD DVD (obsolete)

Re-Writable and Read Only versions available. Uses a blue laser, that is able to recognise smaller pits and lands, which allows for the pits and lands to be more closely packed, and so store more data

25 - 128 GB

### CD-ROM

close up of the surface of a CD being read

A CD-ROM is a metal disc embedded into a plastic protective housing. Each disc has to be 'mastered'; this is the process of creating the CD and placing the data on it. CDs are WORM (Write Once, Read Many) media; this refers to the fact that once they have been mastered, there is no way to change the data on them.

Writing to a CD-ROM

1. A single track runs in a spiral pattern from the centre of the disc to the outside, this track is made of pits and lands to represent the ones and zeroes of binary data
2. A high-powered laser is shone onto the CD-ROM, burning pits into the metal
3. The disc spins and the laser follows the track, putting the binary data onto the CD in a spiral track
4. The data has been written

1. A single track runs in a spiral pattern from the centre of the disc to the outside, this track is made of pits and lands to represent the ones and zeroes of binary data
2. A low-powered laser is shone on the metallic surface and the reflection is captured in a photodiode sensor, the lands reflect differently to the pits, meaning it can tell the difference between a 1 and a 0
3. The disc spins and the laser follows the track
4. The binary data (the 1s and 0s) are put together and the CD-ROM has been read

Pros

Cheap
Data cannot be written over by the consumer

Cons

Slow seek time
Data degrades with time, discs from 20 years ago might not work!
Can only be written to with a very high powered laser, which is not usually available in home computers
Data cannot be written over

### CD-R

The CD-R is made of a reflective metal disk with a layer of (usually green, opaque) dye on top.

Writing to a CD-R

1. A single track runs in a spiral pattern from the centre of the disc to the outside.
2. A high-powered laser is shone onto the CD-R, changing the transparency (permanently) of the dye above. The transparent and opaque parts represent binary 1s and 0s
3. The disc spins and the laser follows the track, putting the binary data onto the CD-R in a spiral track
4. The data has been written

1. A single track runs in a spiral pattern from the centre of the disc to the outside, this track is made of pits and lands to represent the ones and zeroes of binary data
2. A low-powered laser is shone on the surface and the reflection is captured in a photodiode sensor. The opaque dye will reflect differently to the transparent dye (which would just reflect the metal underneath it), meaning it can tell the difference between a 1 and 0
3. The disc spins and the laser follows the track
4. The binary data (the 1s and 0s) are put together and the CD-R has been read

Pros

Cheap
Can be written to using a conventional home computer

Cons

Slow seek time
Data degrades with time, discs from 20 years ago might not work!
Data cannot be written over

### CD-RW

The CD-RW is made of a reflective metal disk with a layer of a special ('phase change') metal on top.

Writing to a CD-RW

1. A single track runs in a spiral pattern from the centre of the disc to the outside.
2. A high-powered laser is shone onto the CD-ROM. Depending on whether this is very high powered or heats at a slightly lower temperature, the top layer of metal cools differently. These will result in different amounts of reflectivity, which represent the 1s and 0s.
3. The disc spins and the laser follows the track, putting the binary data onto the CD in a spiral track
4. The data has been written

1. A single track runs in a spiral pattern from the centre of the disc to the outside, this track is made of pits and lands to represent the ones and zeroes of binary data
2. A low-powered laser is shone on the surface and the reflection is captured in a photodiode sensor. The different ways the metal has cooled reflect different amounts, meaning it can tell the difference between a 1 and 0
3. The disc spins and the laser follows the track
4. The binary data (the 1s and 0s) are put together and the CD-ROM has been read

Pros

Cheap
Can be written to using a conventional home computer

Cons

Slow seek time
Data degrades with time, discs from 20 years ago might not work!
Data can be changed after writing
Not all CD players (mostly older ones) can read CD-RWs, as opposed to CD-ROMs and CD-Rs

## Solid-state memory

Solid-state memory
Device Description

USB flash drive

Up to 256 GB

Memory card

Up to 256 GB

### USB(memory stick) Flash Drive

1 Internals of a typical USB flash drive USB Standard-A plug USB mass storage controller device Test points Flash memory chip Crystal oscillator LED Write-protect switch (Optional) Space for second flash memory chip

USB Flash drives are solid state, that means that there are no moving parts. This is very useful for seek times as we don't have to wait for mechanical movement, meaning seek time is very low and it allows for fast Random Access Memory. Flash drives can be set to read only mode, but they will always allow for reading and writing. The size of flash drives is not as great as a Hard Disk and they are generally much more expensive per megabyte

1. put drive into USB socket
2. USB driver loads, providing the computer with code on how to read and write from the USB
3. The USB is read, giving information on the file and folder structure (File Allocation Table) to the Computer
4. [Reading] The user chooses to open a file, the Computer sends the address wanted to the USB port
5. [Reading] The USB returns the data at the location requested
6. [Writing] The computer sends data to the USB port where it is place into empty space on the drive
7. [Writing] The computer then requests a new version of the file and folder structure

Pros

Very fast seek times
Very portable

Cons

Limited capacity
expensive per MB when compared to Hard Disks

### Memory cards

Work in much the same way as a Flash drive and can often be converted into Flash Drives. They have different connectors and are generally smaller than USB Flash drives allowing for them to be used in cameras, mobile phones and game consoles.

comparison of different memory cards

# Structure of the Internet

 The Internet and its Uses Internet World Wide Web (WWW) and routers. Intranet Understand the structure of the Internet, the role of packet switching Understand the difference between the Internet, the Web and an intranet.
 The Internet and its Uses Uniform Resource Locator (URL) Describe the term URL in the context of Internet working. Uniform Resource Identifier (URI) Describe the role of URIs in the context of Internet working. Domain Names and IP Addresses Explain the terms domain name and IP address. Describe how domain names are organised. Know that an IP address is split into a network identifier part and a host identifier part.
 The Internet, Intranet and World Wide Web Internet registries and Internet registrars Explain why such services are provided. Internet Service Providers (ISP) Understand the role of an ISP. Domain Name Server (DNS) Understand the purpose of Domain Name Server. The Client–Server Model Be familiar with the client–server model. Common Standard Protocols: TCP/IP - Describe the role of the four layers of the TCP/IP protocol stack, including sockets. FTP - FTP client software and an FTP server to transfer files using anonymous and non-anonymous access. HTTP - Web server to retrieve web pages in text form HTTPS TELNET - Telnet server for remote management of a server POP3, SMTP - E-mail server to read and send e-mail Well-known ports Client ports Understand the role of a web browser in retrieving web pages and web page resources and rendering these accordingly.

## The Internet

The Internet - a global system of interconnected computer networks that use the standard Internet Protocol suite (TCP/IP)

The internet impacts heavily upon the way that we live, study and work. But it hasn't always been that way. In the 1960s ARPA, a part of the American Department of Defence, funded several large computing projects. These projects were very expensive and situated in different parts of the USA. It was unreasonable to expect research groups to travel to each of these sites, and it was far too expensive to build more of them, what was needed was a method to link them together so that information could be easily exchanged. ARPANET was created, basing communication on packet switching. This system of communication broke messages into chunks which were then passed to other sites using a network of interlinked computers. Due to the unreliable nature of connections, if any link in the network broke, a packet could be re-routed around the problem to reach its destination. The concept is similar to how drivers can take different routes when they meet a blocked off road.

ARPANET logical map, March 1977
 Extension: Cold War Rumours A popular myth is that the internet was started because the American Department of Defense were looking at how they could maintain control of military installations in the event that they were on the receiving end of a Soviet Nuclear strike. This would mean that communications between sites would have to be maintained even if one or more of the sites connecting installations were knocked out. A sound idea, but not the reason for starting ARPANET. The network never carried any classified material and was predominantly used for research purposes, connecting research institutions, including Universities in the UK.

In the 70s ARPA funded other experimental networks and made an effort to unite them. At the same time the limits of the initial network to 63 nodes and 252 hosts were reached and so the TCP/IP protocol was created. This protocol, or set of rules, allowed different networks to talk to each other. This protocol still forms the main link between networks in the internet to this day.

As the internet consists of many different networks interlinking with each other, the internet has no central structure or governing body. This makes it very robust, meaning that if one connection between two hosts is lost, you can probably find another route to send information by. It also poses a threat to some governments, as they struggle to restrict information available to their citizens. Countries such as North Korea and China funnel their internet links through a few connections to the outside world, this means the government can control what comes in an out of the country, giving them the ability to filter which websites are available and allow them to switch the internet 'off' at times of crisis, by cutting these connections. This happened during the 2011 Arab Spring, where Tunisia, Egypt and Libya tried to stop their citizens' getting information from the outside world.

Diagram of routing paths through a portion of the Internet, notice the multiple routes you can take to get from one network to another

## World Wide Web (WWW)

World Wide Web - a system of interlinked hypertext documents accessed via the Internet

The first thing to notice is that the World Wide Web is not the internet, but a subset of what the internet offers. The internet hosts all forms of data, including games, video, telecommunications etc. while the WWW only transmits hypertext documents. The WWW is accessed through a web browser linking files together using hyperlinks and was invented by a British computer scientist, Sir Tim Berners-Lee in 1989.

## Intranet

Intranet - a private network within an organisation which may offer printer sharing, file sharing, communication, private websites etc...which is generally connected to the internet

the relationships between the internet, intranets and the World Wide Web

## Routers

Router - a device that interconnects with two or more computer networks, which then interchange packets with each other

To link multiple computers together we need to use devices called routers or switches. These devices co-ordinate sending messages from one system to another, making sure that packets get to their destinations

A typical home or small office router showing the ADSL telephone line and Ethernet network cable connections

## Packet switching

Packet switching is the method by which the internet works, it features delivery of packets of data between devices over a shared network. For example the school web server sending you a webpage over the internet or you sending an email to a friend. To get from one device to another the data packets will have to travel through network adapters, switches, routers and other network nodes. The route taken by each packet might vary and at times there might be a lot of data travelling through these nodes meaning packets will be queued. This will result in varying times it takes to send data from one device to another depending on the traffic load in the network.

Different routes taken by three different data packets being sent to the same destination

If you play computer games online you might have heard the term latency (or lag), this is the time taken to send data from one device to another. The higher the latency (time taken to send data), the less responsive your game will be. People with very low latency tend to do better at games as their machines will be more responsive.

 Example: The ping command To see the time it takes to send a message using packet switching you can use the ping command to time how long it takes to send data to another device, in this case we have used the command prompt to ping the www.example.com server: # ping -c 5 www.example.com PING www.example.com (192.0.43.10) 56(84) bytes of data. 64 bytes from 43-10.any.icann.org (192.0.43.10): icmp_seq=1 ttl=250 time=80.5 ms 64 bytes from 43-10.any.icann.org (192.0.43.10): icmp_seq=2 ttl=250 time=180.1 ms 64 bytes from 43-10.any.icann.org (192.0.43.10): icmp_seq=3 ttl=250 time=80.3 ms 64 bytes from 43-10.any.icann.org (192.0.43.10): icmp_seq=4 ttl=250 time=80.3 ms 64 bytes from 43-10.any.icann.org (192.0.43.10): icmp_seq=5 ttl=250 time=80.4 ms  As you can see the same data is being sent to the same location in all 5 attempts, but the second attempt met traffic on the way and took much longer. However, at 180.1 milliseconds you probably wouldn't notice.

As packet switching doesn't define a set route for data to be sent by, any disruption in the network can be circumnavigated by re-routing:

demonstration of how the internet can re-route message if nodes fail. This makes the internet very robust
 Example: The trace command The tracert command is used to map the route from one machine to another on the internet showing all the intermediate nodes, in this case, the message took ten steps to get there. The code above shows a trace from a home network to the www.google.com website. You can see that the 4th hop got lost and the data had to be re-routed. # tracert www.google.com Tracing route to www.l.google.com [209.85.147.99] over a maximum of 30 hops: 1 62 ms 99 ms 99 ms bebox.config [192.168.1.254] 2 53 ms 19 ms 18 ms 87-194-56-8.bethere.co.uk [87.194.56.8] 3 * * 83 ms 10.1.2.177 4 * * * Request timed out. 5 20 ms 17 ms 17 ms 64.233.175.25 6 20 ms 38 ms 19 ms 209.85.253.92 7 26 ms 56 ms 23 ms 66.249.95.173 8 45 ms 24 ms 24 ms 72.14.236.191 9 33 ms 35 ms 35 ms 216.239.46.221 10 27 ms 22 ms 22 ms bru01m01-in-f99.1e100.net [209.85.147.99] Trace complete.  If you want to try this at home there are different commands used on different operating systems: Windows - tracert Linux - tracepath or traceroute Mac - traceroute

### Packet switching steps

1. Data split into chunks (packets)
3. If data requires multiple chunks then the order of each packet is noted
4. Packets sent onto the network, moving from router to router taking different paths (set by the router). Each packet's journey time can therefore differ.
5. Once packets arrive they are re-ordered
6. Message sent from recipient to sender indicating that the message has been received
7. If no confirmation message, sender transmits data again
 Exercise: Internet/Intranet/World Wide Web For the following packets (Green, Blue, Red), assuming each step from router to router takes an equal time. What order will the packets arrive at their destination? How do we make sure that the packets are read in the correct order? Answer : Green Red Blue Each packet has a sequence number attached to it, so that it can be ordered when it reaches its destination. What happens if a packet gets permanently lost on the way to a host? Answer : The packet will be resent until a confirmation message is returned from the recipient What happens if a router on the network fails? How will the packets get to their destination? Answer : The packets will be re-routed around the failed node

IP Address - numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol

Every device attached to a network has a number assigned to it. This unique number is called the IP Address, and you might be familiar with the format of:

nnn.nnn.nnn.nnn e.g. 192.168.7.1


Currently the most common form of IP Address is IPv4 which uses 32 bits to store an address. This means that there are theoretically $2^{32} = 4,294,967,296$ different IP Addresses that can exist. However, due to the allocation of IP ranges to different organisations and tasks, the number is lower.

An IP address (version 4) in both dot-decimal notation and binary code

An IPv4 is split into 4 chunks as shown above. Different ranges of IP addresses are categorised differently, with the first part of the IP specifying who or where the IP address is (the network identifier), and the second part defining which host/machine it is (the host identifier).

$\underbrace{192 \cdot 168}_\text{network} \cdot \underbrace{12 \cdot 162}_\text{host}$

Different sets of IP ranges are allocated to particular networks, geographic areas, companies etc. The table below shows several examples of IP ranges and the uses that they have been put to:

IP range Description Example
192.168.___.___
172.16.___.___ - 172.31.___.___
10.___.___.___
Private networks, e.g. intranets 192.168.1.23
41.___.___.___
102.___.___.___
105.___.___.___
AfriNIC allocations for IP addresses in Africa 102.43.1.65
81.___.___.___
217.___.___.___
62.___.___.___
European allocations for IP addresses 81.202.17.89
200.___.___.___ Latin America and the Caribbean 200.100.50.25
9.___.___.___ IBM 9.1.2.3
17.___.___.___ Apple 17.19.23.29

As you saw with packet switching, every request that gets sent over the internet is sent with the sender's IP address attached. This is useful for many different reasons. Firstly you can send a confirmation message to the sender to confirm that you received the data. Secondly websites can keep track of where their users come from. Thirdly websites can block requests from certain IP address ranges. For example if you were running a national television service such as the BBC, where your programming was paid for by your fellow countrymen, you wouldn't want people from other countries watching programmes that they hadn't paid for. If you try and access the BBC iPlayer from the USA it will say "Not available in your area". This is because an American's IP would be from a banned IP range. IP banning can also be used by the government's to ban their population accessing websites on certain IP addresses.

The diagram above shows how two intranets can connect across the internet. If the computer in Intranet A with the IP address 192.168.1.2 wants to send a message to a computer in Intranet B, it will send its message through the Router connected to Intranet A (IP=172.8.18.100). This router will then route the message onto the internet, going from router to router until it reaches the router attached to Intranet B (IP=201.108.0.45). This router will then pass the message on to the correct machine in Intranet B. Notice that because each intranet is connected to the internet through a router, the computers on each intranet will appear as having the IP of their router when connected to the internet. If you share a house and someone commits a crime online, the finger might be pointed at the whole household! Using IP addresses this way was never the intention of the designers of TCP/IP, they would much prefer that each machine had a distinct IP address, however, with the shortage of IP addresses this isn't possible. What is needed is a system that has more addresses available.

 Extension: IPv6 As you might have noticed, there is a limit to the number of IPv4 addresses we can have, this limit is well below the current population of the world. If we were in the future to have every inhabitant of the planet connected to the internet, there wouldn't be enough IP Addresses for them to use! This problem is very current and IPv6 is being introduced to try and resolve it. IPv6 uses 128 bits for each address, meaning we have theoretically $2^{128}$ addresses available = $340,282,366,920,938,463,463,374,607,431,768,211,456$ different possible addresses. Decomposition of an IPv6 address from hexadecimal representation to its binary value. The IPv6 address has 128 bits split into: 64 bits for the network the first 16 bits are used for address type 16 bits for sub networks leaving 32 bits for main networks 64 bits for the interface addresses Why would we ever need this many you may ask? With so many addresses this will allow each person to have multiple devices connected to the internet, currently driven by the demand for internet on mobile phones. We are also looking at connecting lots of other devices to the internet that might not currently be connected. For example we could have fridges telling us when we are low on milk, ovens telling us when they need cleaning, bikes telling us when they need a service. The future is coming, watch this IPv6 space!
 Exercise: IP Addresses What is an IP address, give an example? Answer : Numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol 192.168.7.1 What is the IP address range for an internal network? Answer : 192.168.___.___ OR 172.16.___.___ - 172.31.___.___ 10.___.___.___ What IP address would an internal network machine appear to have when connecting to the internet? Answer : The address of the router Convert the following IP address into binary: 123.45.67.89 Answer : 01111011.00101101.01000011.01011001 Convert the following IP address into decimal: 01011110.01100010.10011011.00010000 Answer : 94.98.155.16 Why has IPv6 been introduced? Answer : IPv4 only has 32 bits, this means as more and more machines connect to the internet we will eventually run out of IP Addresses. IPv6 allows for more addresses to be used. For the following IP address can be split into two parts, label each: 192.168.23.2 Answer : $\underbrace{192 \cdot 168}_\text{network} \cdot \underbrace{23 \cdot 2}_\text{host}$

## Domain names

Domain Name - humanly-memorable names for Internet participants such as computers, networks, and services. One domain name can be connected to multiple IP addresses

Trying to remember IP addresses is as difficult as trying to remember people's phone numbers. Not many people do it well and you are far more likely to be using a domain name to access a website. A domain name allows us to link to servers and other computers using easily remembered names. The domain name also tells us a bit about the location we are visiting through the use of top level domain names.

Top level domain Description
.com Commercial
.gov US governmental organisations
.mil US military
.org Organisation
.uk United Kingdom, country specific website
.so Somalia, country specific website

Sometimes top level domain names might be joined by second level domains, chained together to tell you more detailed information:

bbc.com - there is a commercial organisation called bbc
bbc.co.uk - there is a United Kingdom commercial organisation called bbc.
tfl.gov.uk - there is a United Kingdom governmental organisation, called TFL.


Second level domain names tell you the company/organisation that owns the address. Finally you have the host or service name, which is the machine/service you are connecting to. For example:

en.wikipedia.org - an organisation, called Wikipedia, connecting to the English language host machine
www.ibm.com - an commercial organisation, called IBM, connecting to the www (World Wide Web) host/service machine

$\underbrace{windows}_\text{host} . \underbrace{microsoft}_\text{domain name} . \underbrace{com}_\text{top level domain}$
Diagram of how domain names are constructed

In the example above a client sends a request to a Domain Name Server for www.debian.com, but after that domain name lookup is hierarchical:

• a request for .com is first sent to a known root server which provides the address of the name server for .com.
• This is then queried for debian.com giving the address of another name server
• which finally provides the address for www.debian.com.

Results are remembered for a period of time to reduce the work load.

## Domain Name Server (DNS)

Domain Name Server - translates domain names into IP addresses

If you have a modern mobile phone it is very unlikely that you will type in the number of your friends each time you want to call or text them. You are far more likely to use the address book, typing in their name, then letting the phone find the number. This is exactly the same principle behind a Domain Name Server. A DNS translates domain names meaningful to humans (such as www.google.com) into IP Addresses for the purpose of locating and addressing these devices worldwide.

Domain names are far easier for humans to remember than an IP address. To see a domain name in action you can use the ping command, where pinging google, uses the DNS to find the IP address you want to send a ping packet to:

# ping www.google.com
Pinging www.l.google.com [209.85.229.99] with 32 bytes of data:


Or on Linux try dig

\$ dig www.google.com
-- Snip --


## Internet registries and Internet registrars

Internet Registrars - allow organisations and individuals to buy their own domain names

Internet registrars are responsible for allocating internet domains to anyone who wants one. If someone wanted to own their own website with a domain name, they would have to go to an internet registrar in order to buy the website name. These services require payment in order to maintain control over the name of the website. If you do not renew your website, then the internet registrars may sell it to other buyers.

 Extension: Travel back in domain name time In the early days of the World Wide Web, there were many instances of companies paying lots of money to buy their web domains from private individuals who were 'cyber-squatting'. Other organisations shared the same address and there were many legal fights and much cash exchanged to gain control of domain names. If you want to take a look at websites from the past take a look at http://web.archive.org and look at the following websites in the mid 1990s: www.itv.com www.michaeljackson.com

Internet Registries - hold domain names which are registered. They allow owners to link domain names to IP addresses. Well known domains usually have their own registry, such as .co, .com, .sch

Also big sites not only do geographic IP splitting but load balancing as well. This is when a domain name is undergoing heavy usage, and one particular IP address might be very busy, the domain name will then be pointed to other servers sitting at different IP addresses, balancing the 'load' of users accessing the site.

## Internet Service Providers (ISP)

Internet Service Providers - companies which offer customers access to the internet

Getting a direct connection to the internet is quite costly involving specialist hardware. Most people and organisations pay ISPs to link them to the internet. Examples of Internet Service Providers are : AOL, BT, Sky, TalkTalk and Virgin Media.

Getting a direct connection to the internet isn't straightforward which is why most people and companies use ISPs

## URIs

Uniform Resource Identifier (URI) - A character string identifying a resource on the internet

Resources such as documents, files and folders sitting on the internet need a method to identify them and access them. URIs provide a way to linking to these resources. There are two types of URI, but you only need to know URL for the exam:

• Uniform Resource Name (URN) - the name of a resource, but not its exact location.

e.g. urn:isbn:0486419266
The URN for R.U.R. (1921 play), identified by its book number.

• Uniform Resource Locator (URL) - the exact location of a resource.

The project gutenberg page for the R.U.R. book

Diagram of URI scheme categories. A Uniform Resource Name (URN) functions like a person's name, while a Uniform Resource Locator (URL) resembles that person's street address. In other words: the URN defines an item's identity, while the URL provides a method for finding it.

### Uniform Resource Locator (URL)

Uniform Resource Locator - A character string referring to the location of an internet resource

A URL is a URI that, "in addition to identifying a resource, provides a means of locating the resource by describing its primary access mechanism (e.g., its network location)"[1]. URLs allow us to specify the domain name and exact location of a resource on the internet. For example, the following links to a picture on wikicommons:

http://commons.wikimedia.org/wiki/File:George_Clausen_WWI_poster.jpg


We can break this down into its constituent parts:

$\underbrace{http://}_\text{protocol} \underbrace{commons.wikimedia.org}_\text{hostname} \underbrace{/wiki/File:George_{-}Clausen_{-}WWI_{-} poster.jpg}_\text{location on server}$

We can therefore summarise a URL as follows:

$protocol://hostname/location_-of_-file$
 Exercise: Uniform Resource Identifiers Describe the difference between a URN and a URL Answer : URN gives the name of a resource, but not necessarily its location URL gives the location of a resource Give the 3 parts that make up a URL Answer : the protocol the hostname the file location For the following address: http://www2.example.gov.uk/ describe the parts: http:// www2 gov.uk example Answer : http:// - the protocol being used www2 - the name of the host being used gov.uk - the domain name is registered in the uk, and is a governmental organisation example - the domain name of the government organisation

## References

1. Tim Berners-Lee, Roy T. Fielding, Larry Masinter. (January 2005). “Uniform Resource Identifier (URI): Generic Syntax”. Internet Society. RFC 3986; STD 66.

## Client server model

The history of computing started off with centralised computers (in many cases mainframes) or servers performing all the calculations. Client computers were then attached to these centralised computers (servers) and if you wanted to calculate something, you would have to wait for the central computer to respond. As computing power got cheaper client nodes became more powerful and the central computer less important. However, with the growth of the internet, there has been a shift back to a client server model. Powerful central computers store information such as emails, documents, music and videos or offer services such as file hosting, printing, game hosting and internet access; client computers fetch information and use services from these central servers. In the next few years you are likely to see more and more software moving away from running on your desktop to running on remote servers and you accessing it as a client, this is called software as a service.

the client-server model

As an example of modern client server model consider a video sharing website. The website, let's call it mutube, has a server that stores all the videos that are uploaded to the site. The website is used by millions of clients a day and each of them connects to the server to watch videos. When a client connects to mutube the server and asks for a particular video, the server loads the video into RAM from a large array of hard disks and mutube sends the video to the client. The client on receiving the video, presses play and watches the video.

Other examples of servers might be a shared printing service in a college. The print server will be hosted on a single computer, and when anyone in the building wants to print, the request is sent to the server. In this case the server will keep track of how much printing credit each user has and make sure that the print queue is dealt with properly.

Server - a computer program running to serve the requests of other programs, the "clients"

Servers are software programs that in most cases run off normal computing hardware. Server software includes:

• Printing
• File sharing
• Game hosting
• Websites
• Other web services

Client - an application or system that accesses a service made available by a server

Clients are software programs and processes that connect to servers, sending requests and receiving responses. Client examples include:

• Web browser page requests
• Chat systems on mobile phones
• Online games
 Exercise: Client Servers Give an example of where a server might be used: Answer : Serving websites, hosting games, file sharing, printer sharing What is a server and what is a client? Answer : Server - a computer program running to serve the requests of other programs, the "clients" Client - an application or system that accesses a service made available by a server Describe the process involved in a web server delivering a web page to a client: Answer : The Client sends a web request to the web server for a web page The server fetches the page items from secondary storage The server sends the page data back to the Client Describe a situation where having a single server and many client model might not work too well: Answer : When all the clients try to access the server at once, it will have too many requests and fail When the clients are a long distance from the server, meaning response times will be slow When the location housing the server suffers a power outage or other disruption, there is no other way for the client to get the data.

## Protocols

### Common Standard Protocols

Protocol - a set of rules governing the way that devices communicate with each other

With networks and the internet, we need to allow computers to talk to each other. To make sure that a computer talks to another in a way that the other understands, there are sets of rules governing modes of communication. These rules are called protocols. There are many different protocols out there, each defining rules for specific communication types.

### Port numbers

Port number - an application or process specific communication endpoint attached to an IP address

When you send and receive data from a client or server, you will be sending lots of different types of data. To make sure that the data is dealt with by the correct program, for example a website request is dealt with by the web server, you need to add a port number. Each application will have a port number associated with it. For example a web server is port 80 and a game of doom is port 666.

Combining an IP address with a port gives us a socket. This is a direct connection to a process or application on a machine. The following example is connecting to a webserver on 203.43.12.234.

$\underbrace{\underbrace{203 \cdot 43 \cdot 12 \cdot 234}_\text{IP address} : \underbrace{80}_\text{Port}} _\text{Socket}$

There are many well-known ports out there, here are a few of the ones you might need to know:

Port number Protocol that uses it
21 File Transfer Protocol (FTP)
25 Simple Mail Transfer Protocol (SMTP)
80 & 8080 HyperText Transfer Protocol (HTTP)
110 Post Office Protocol v3 (POP3)
143 Internet Message Access Protocol (IMAP)
443 HyperText Transfer Protocol over SSL/TLS (HTTPS)
666 Doom Multiplayer game
989 Secure FTP (SFTP)
23 Telnet
 Exercise: Port Numbers What is a port number? Answer : A port number is an application or process specific communication endpoint attached to an IP address What is the port number that a web server would use? Answer : 80 & 8080 Combined, what is an IP and port number called? Answer : Socket What sort of servers are the following referencing: 192.168.9.34:80 192.168.9.34:666 192.168.9.34:21 Answer : 192.168.9.34:80 (HTTP) 192.168.9.34:666 (Doom) 192.168.9.34:21 (FTP)

### Non-secure protocols

Several of the protocols used to transmit data across networks (including the internet) are not secure. This means that if you are one of the routers that is used to get data from one host to another, you can read the data being sent, this technique is called packet sniffing. Normally this isn't a problem as the data being transmitted isn't secret but reading other people's packets without their permission is a crime in the UK.

#### FTP

File Transfer Protocol (FTP) is a standard network protocol used to copy a file from one host to another over a TCP/IP-based network, such as the Internet. FTP is built on a client-server architecture. FTP users may authenticate themselves using a clear-text (unencrypted) sign-in protocol but can connect anonymously if the server is configured to allow it. FTP works on port 21.

Filezilla is a popular FTP Client and Server

The first FTP client applications were interactive command-line tools, implementing standard commands and syntax. Graphical user interface clients have since been developed for many of the popular desktop operating systems in use today.

#### HTTP

The Hypertext Transfer Protocol (HTTP) is a networking protocol behind the World Wide Web. HTTP allows for transmission of Hypertext documents and webpages. HTTP works on ports 80 and 8080.

An HTTP request made using telnet. The request, response headers and response body are highlighted.

#### Telnet

Telnet is a network protocol used on the Internet or a local area network to provide text-oriented communications between a server and remote clients. A client will connect to the server using a terminal (black and white command line console) and can then deliver commands to the server to perform things like remote software installation or system updates. Telnet works on several different ports.

telnet connections are often plain black and white text

Pros

You can telnet from simple clients with inexpensive hardware

Cons

Telnet doesn't allow you to use graphics
Telnet can be insecure, most remote connections are now handled by SSH

#### POP3, SMTP

Simple Mail Transfer Protocol (SMTP) is an Internet standard for sending electronic mail (e-mail) across Internet Protocol (IP) networks. SMTP is specified for outgoing mail transport and uses TCP port 25. The protocol for receiving mail is called the Post Office Protocol 3 and it uses port 110.

Note that SMTP sends mail and POP3 receives it

### Secure protocols

Sometimes we need to send data securely over networks. There are several protocols that allow you to do this. You can normally tell if a protocol is secure if it has the letter 'S' in its name. Examples include SSH, SFTP and HTTPS (SMTP is NOT secure!)

#### HTTPS

Hypertext Transfer Protocol Secure (HTTPS) is a combination of the Hypertext Transfer Protocol with the SSL/TLS protocol to provide encrypted communication and secure identification with a network web server.

HTTPS is often used when sensitive information is being sent over the internet, for example on internet banking webpages.

## TCP/IP protocol stack

MAC Address - a unique identifier assigned to network connections

IP addresses change, for example if you connect your laptop to the internet at home you get one IP address. If you were then to take it around a friends and connect there, you would be given another IP address. MAC addresses are unique to the device they are given to and every network interface has a MAC address, including mobile phones, games consoles and wireless cards. This is important when you consider that a computer can have more than one network interface. For example with a laptop you might have a cat-6 network card and a wireless card, one handling BitTorrent and the other web browsing. When you receive a message, which network interface should it be sent to? The MAC address would mean that messages can be directed to a particular network interface, namely the wireless card or the cat-6 card. In a moment you will see how we use MAC addresses with the TCP/IP stack.

Each networkable device has its own unique MAC address

### TCP/IP stack

The most common protocol on the internet is the Transmission Control Protocol/Internet Protocol (TCP/IP). To send data over a TCP/IP network requires four steps or layers:

Layer Name Description
Application Encodes the data being sent
Transport Splits the data into manageable chunks, adds port number information
Internet Adds IP addresses stating where the data is from and where it is going
Link Adds MAC address information to specify which hardware device the message came from, and which hardware device the message is going to
Successive encapsulation (wrapping) of application data descending through the protocol stack before transmission on the local network link

To show you how the TCP/IP stack works we going to use the following data as an example:

Matt, Mark, Luke, John


#### Application

The application layer makes sure that the data is sent in a format that will be understandable by the recipient. This will mean formatting data to be sent in a standard way applicable to that application, for example HTTP, FTP etc. In this case we are going to wrap each piece of data in XML tags.

<gospel>Matt</gospel><gospel>Mark</gospel><gospel>Luke</gospel><gospel>John</gospel>


#### Transport

The transport layer looks at the data to be sent and splits it into chunks that can fit into data packets. It then attaches a number to each, specifying that packet's order, this allows the recipient to place the data back together correctly at the other end. To each packet it then attaches a port number dependent on the application being used. For the example we'll send data to port 60

• Splits the data into chunks and adds order number
:60 | 1/4 <gospel>Matt</gospel>
:60 | 2/4 <gospel>Mark</gospel>
:60 | 3/4 <gospel>Luke</gospel>
:60 | 4/4 <gospel>John</gospel>

#### Network/Internet

The network layer attaches the IP address of the sender, so that the recipient will know who sent it and who to send a confirmation message to. It must also attach the IP address of the host that it is sending the data to so it doesn't get lost! In this case we are sending to 102.231.4.189 and sending from 98.1.232.99. Combined with the port number this creates a socket that data is being sent from and a socket that data is being sent to, namely 102.231.4.189:60

• Attaches destination IP address to create a socket
102.231.4.189
98.1.232.99
:60 | 1/4 <gospel>Matt</gospel>
102.231.4.189
98.1.232.99
:60 | 2/4 <gospel>Mark</gospel>
102.231.4.189
98.1.232.99
:60 | 3/4 <gospel>Luke</gospel>
102.231.4.189
98.1.232.99
:60 | 4/4 <gospel>John</gospel>

Finally the link layer attaches the MAC address of the sender and the recipient, allowing the packets to be directed to a specific network interface on the IP Address host machine. In this case the sender is using a wireless card with MAC address: 00-17-4F-08-5D-69 and the destination MAC address is: 11-22-33-44-55

11-22-33-44-55
00-17-4F-08-5D-69
102.231.4.189
98.1.232.99
:60 | 1/4 <gospel>Matt</gospel>
11-22-33-44-55
00-17-4F-08-5D-69
102.231.4.189
98.1.232.99
:60 | 2/4 <gospel>Mark</gospel>
11-22-33-44-55
00-17-4F-08-5D-69
102.231.4.189
98.1.232.99
:60 | 3/4 <gospel>Luke</gospel>
11-22-33-44-55
00-17-4F-08-5D-69
102.231.4.189
98.1.232.99
:60 | 4/4 <gospel>John</gospel>

These four packets can then be sent across the internet holding enough information for them to:

1. reach their destination (socket from the Network and Transport Layers)
2. find the correct network interface (MAC address from the Link Layer)
3. find the correct service(Port number from the Transport Layer)
4. be reassembled in the correct order (Order information from the Transport Layer)
5. deliver the intended message (data from the Application Layer)
 Extension: UDP TCP/IP does a great job of ensuring that the data you request is sent correctly and the data you send is received. However, as you have seen, sometimes data can get lost on the internet or packets can arrive in an order differing to the one you sent them in. With something like a computer game or telecommunications you can't wait for a slow packet to find its way across the internet. This would result in voice messages slowing down and computer games becoming unresponsive. There is another protocol called UDP that doesn't ask for a confirmation that data packets have been received. This protocol is used heavily in networked computer games and voice over IP, as losing a packet here and there won't impact too badly on the overall game experience or voice conversation. When you play computer games, you might see something that says "lost packets = xyz" or when having a web meeting the quality of voice or video might briefly degrade. This is packet loss in action and a result of using UDP.
Exercise TCP/IP Stack

Name and describe the four levels of the TCP/IP stack:

Layer Name Description
Application Encodes the data being sent
Transport Splits the data into manageable chunks, adds port number information
Internet Adds IP addresses stating where the data is from and where it is going
Link Adds MAC address information to specify which hardware device the message came from, and which hardware device the message is going to

Combined, the IP address and Port Number make up a what?

Socket

What is the MAC Address for in the TCP/IP stack?

A MAC address is a unique identifier assigned to a network device. It is used by the Link layer to direct messages to a particular network interface at the designated IP address

Show the steps involved in sending the following data:

• data = Hello (this will fit in one packet)
• from IP = 12.32.72.2 | MAC = 43.65.FF.23
• to IP = 98.125.43.88 | Port = 80 | MAC = A0.3D.EF.00

• Application
• "Hello"
• Transport
•  :80
• 1/1
• "Hello"
• Internet
• To=98.125.43.88
• From=12.32.72.2
•  :80
• 1/1
• "Hello"
• From MAC = 43.65.FF.23
• To MAC = A0.3D.EF.00
• To=98.125.43.88
• From=12.32.72.2
•  :80
• 1/1
• "Hello"

# Webpage Design

 Web design Web page construction Have practical experience of creating simple web pages containing hyperlinks using the tags listed in the Teacher Resource Bank. HTML & style sheets Know that HTML is used for structure only and that style sheets are used for style and layout of web pages (see the Teacher Resource Bank for list of style sheet type, class and ID selectors, properties and values)

## Web page construction

Web pages are now an essential part of how many people live their lives and perform their jobs. More and more computer functions are now moving to web based applications and it is important that you are familiar with this technology.

## Structure of a web page

You might have made some web sites at secondary school using WYSIWYG editors such as Front Page and Dreamweaver. For the A-Level Computing course we are going to take a look at the code that these editors produce, and how to structure webpages with code. Open this wikibook page in any browser and click CTRL+U in Firefox / Chrome or View -> Page Source in Internet Explorer, you should have the webpage code in front of you.

HTML - Hypertext Markup Language, the language used for building web pages

All web pages have the following basic structure:

• HTML - specifies that this is a web page
• Head - contains the title of the page with code and css includes
• Body - displays the main page content

Which can be represented in HTML code using the following Tags:

<html>
<title>...</title>

<body>...</body>
</html>


## Tags

Web pages are built out of tags. These tags define what is on the page and how it should be structured. There are two types of tags that you can use, and all tags should be written in lower case.

1. <h1>A Book About Computing</h1>

2. <hr />


On line one you can see the first type, it has an opening tag <h1> something in the middle "A book About Computing" and a closing tag</h1>. This tells us that everything between these tags should be treated as a level one heading (h1).

On line two you can see the second type of tag, there is no closing tag, the tag is entirely self contained. The <hr /> stands for a horizontal rule, a line across the page.

## Search Engine Optimisation

Some tags are supposed to be used in certain locations on a webpage and have special functions that may not result in any change to the content or layout of that page. There are special tags reserved to help a webpage get found and ranked by search engines. These tags live in the <head>...</head> section of a webpage.

• <title>Come to my site first</title> - this places a title on the top of the browser (NOT the top of a web page)
• <meta name="Description" content="Using the purest …."> - so that search engines can better categorise web pages, they know what the site is about
• <meta name="Keywords" content="premium …, bulk …., solid …, The …. Company"> - you used to be able to add keywords to tell search engines what a site was about. This was open to abuse as web site designers just chucked in all the words they could think of and this method isn't used much any more, however, you still need to know it.
Example: Drawing a website

Draw a web-browser display for the following:

<html>
<title>Kempoogle</title>
<meta name="Description" content="The best site in the world">
<body>hello world!</body>
</html>

Kempoogle

hello world!

Notice that the <title>Kempoogle</title> appears as the title of the browser window, but the <meta name="Description" content="The best site in the world"> is not visible to the user. It is merely there to help web search engines categorise the page.

 Exercise: Web Site Basics What are the top most level tags on a website: Answer : and Write the code to create a webpage that has the banner title of "Moogle - shopping site" and has a meta description of "The best site in the world": Answer :  Moogle - shopping site ...  How might you use the  section of a web page to increase the page's ranking in search engines? Answer : Adjust the   and   tags
 Extension: Teach Yourself HTML The web is full of free resources to skill yourself up and there is nothing to stop you becoming a top notch web designer. The questions here are suitable to get you through this course with some added elements. If you want to get really good at the vaste array of web technologies out there you should be looking to teach yourself. A great place to get started is the w3schools website where you can take courses in: HTML Javascript, the programming language behind interactive websites If you want to learn about the code that builds dynamic webpages, including Facebook, check out:

## Block-level tags

Block tags allow you give a tag attributes such as padding and margin. This allows you to insert tags into various parts of a page and rely on the other elements there to move to make space for it without worrying about overlap. The tags you need to know are:

• <h#></h#> - headings
• <hr /> - horizontal rules
• <p></p> - paragraphs
• <br /> - make a new
line,
• <ol></ol> - ordered lists
• <ul></ul> - unordered lists
• <li></li> - list items
• <div></div> - div

### Horizontal Rule

<hr /> - puts a horizontal line across the page where ever you are, useful for breaking up pages

<html>
<title>Examples of horizontal rule</title>
<body>
Normal Text
<hr />
Normal Text
<hr />
Normal Text
</body>
</html>


Examples of horizontal rule

Normal Text

Normal Text

Normal Text

<h#></h#> - heading tags make any text between the tags a heading, the higher the number (h#) the less significant the heading

<html>
<body>
Normal Text
</body>
</html>


The code above produces the following:

Normal Text

For all following examples the html, body and head tags have been left out. This doesn't mean they don't exist and if you code it you must include them.

Draw out what the following codes would produce:

  <h1>Years</h1>
<h2>Year 12</h2><hr />
<h2>Year 13</h2>
<h1>Staff</h1>


--

Years

Year 12

Year 13

Staff

  <h1>Introduction</h1>
<h2>My Life</h2>
<h2>My Cats</h2>
<h2>My Dogs</h2>
<h3>Barry</h3>
<h3>Aubrey</h3>
<h3>Rex</h3>
<h1>Theories</h1>
<h1>Conclusions</h1>


--

Introduction

My Life

My Cats

My Dogs

Barry

Aubrey

Rex

Theories

Conclusions

Write the code to produce the following headings:

--

Output Devices

Monitors

Speakers

  <h1>Output Devices</h1>
<h2>Monitors</h2>
<h2>Speakers</h2>

--

Team

Goalies

Defenders

Midfield

Strikers

Rooney

Socrates

Old Trafford

  <h1>Team</h1>
<h2>Goalies</h2>
<h2>Defenders</h2>
<h2>Midfield</h2>
<h2>Strikers</h2>
<h3>Rooney</h3>
<h3>Socrates</h3>
<h2>Old Trafford</h2>


### Lists

There are 2 types of list that you need to know, ordered lists (<ol></ol>) and unordered lists (<ul></ul>). Each has individual list items (<li></li>) that hold all the data.

• Unordered Lists <ol></ol>
• give you a list made up of bullet points
  <ul>
<li>apples</li>
<li>oranges</li>
<li>pears</li>
</ul>


the code above would give you:

Examples of unordered list
• apples
• oranges
• pears

  <ol>
<li>apples</li>
<li>oranges</li>
<li>pears</li>
</ol>


the code above would give you:

Examples of ordered list
1. apples
2. oranges
3. pears

As you can see above the individual list items are contained within the <li></li> brackets.

 Exercise: HTML Lists Write HTML to create the following lists: Geoffrey Bungle Zippy George Answer : 
• Geoffrey
• Bungle
• Zippy
• George
 Wittgenstein Augustine Heidegger Marcel Answer : 
1. Wittgenstein
2. Augustine
3. Heidegger
4. Marcel
 What would the following code output: 
• Kierkegaard
• Jaspers
• Frankl
• Rand
 Answer : Kierkegaard Jaspers Frankl Rand What is wrong with the following code to print an ordered list: 
• Kierkegaard
• Jaspers
• Frankl
• Rand
•  Answer : the following code is corrected with comments 
1. Kierkegaard
2. Jaspers
3. Frankl
4. Rand


### Breaking pages up

A Div element is used to divide a web page into sections <div></div> - this takes up space on a page and the page will appear larger the more of them you place in.

A Paragraph <p></p>, allows you to structure your text like you would if you were writing an essay.

A Break <br />, creates a new line.

## Inline tags

These don't take up any physical space on the page (they don't cause a new line) and can overlap each other. They are:

• <span></span> - break the page into sections but don't create new lines,
• <strong></strong> - make text bold,
• <em></em> - make text itallic,
• <a></a> - create a link or an anchor,
• <a href="http://www.google.com"> link </a> produces the following:link
• <img /> - add an image
• <img src="http://en.wikipedia.org/wiki/File:Googlelogo.png" />

produces the following:

Let's take a look at a quick example:

Example: HTML worked example
<h2>Ditty</h2>

I tell you naught for your comfort, <br /> Yea, naught for your
desire,<br /> Save that the sky grows <strong>darker</strong> yet <br /> And the sea rises <strong>higher</strong>

<hr />

- G.K.Chesterton, <em>The Ballad of the White Horse</em>(1911)


The output of the above is as follows:

Ditty

I tell you naught for your comfort,
Save that the sky grows darker yet
And the sea rises higher

- G.K.Chesterton, The Ballad of the White Horse (1911)

As you can see the layout of the HTML code doesn't always reflect how it will look on screen, remember even if your code looks like it has line breaks, if you don't use block-level tags such as <br /> or a <p> you won't get any breaks.

Now it's time to test your knowledge:

Exercise: Inline Tags

Write the code to produce the following output:

Hello how are you?

<em>Hello</em> <strong>how</strong> are <strong><em>you</em></strong>?

I'm fine
thank you

<strong>I'm</strong> <em>fine</em><br />
thank you

This is a link to the bbc website.

This is a <a href="http://www.bbc.co.uk">link</a> to the <em>bbc website</em>.


The Quick Brown Fox

Jumped over the Lazy Dog

<p>The <strong>Quick Brown Fox</strong></p>
<p>Jumped over the <em>Lazy Dog</em></p>


{apologies for the trick question!}

<ul>
<li><em>Bold</em></li>
</ul>


Write the code to create the following page linking an image called cat.jpg

Cat picture

This is a picture of a cat:

<html>
<title>Cat picture</title>
<body>
This is a picture of a <em>cat</em>:<br/>
<img src="cat.jpg">
</body>
</html>


Write the code to create the following page linking an image called dog.jpg to the page http://college.ac.uk

Dog picture

This picture of a dog links to my college's website:

<html>
<title>Dog picture</title>
<body>
This picture of a <strong>dog</strong> links to my college's website:<br/>
<a href="http://college.ac.uk"><img src="dog.jpg"></a>
</body>
</html>


What does the following code produce:

The invention<br />
of <strong>weights<strong> and <strong>measures</strong><br />
Makes robbery easier<br /><hr />
<em>- Chuang Tzu</em>


Quoted from: Merton, Thomas. (1969). The Way of Chuang Tzu. New York: New Directions.

The invention
of weights and measures
Makes robbery easier

- Chuang Tzu

<p><em>Modern art has taken the wrong turn in abandoning the
search for the <br /><strong>meaning of existence</strong></em>
<br /> in</p><p>order to affirm the value of the <strong>individual
</strong> for his own sake</p><p><em>- Andrei Tarkovsky</em></p>


Quoted from: Tarkovsky, Andrei (1989). Sculpting in Time. University of Texas Press

note that the line breaks at the end of each line of code has no effect, we only place line breaks with <br /> and <p>

Modern art has taken the wrong turn in abandoning the search for the
meaning of existence

in

order to affirm the value of the individual for his own sake

- Andrei Tarkovsky

Write the full html page code for the following webpage:

Car heaven

Car heaven

Welcome to the car site

• Cars
• Vans
• Bikes

This week 30% discount

<html>
<title>Car heaven</title>
<body>
<h1>Car heaven</h1>
<p>Welcome to <em>the</em> car site</p>
<ul>
<li>Cars</li>
<li>Vans</li>
<li>Bikes</li>
</ul>
<p>This week <strong>30%</strong> discount</p>
</body>
</html>


Write the full html page code for the following webpage, where the image address is: contempt.jpg with alt text of contempt and the web address is: http://bbc.co.uk

Education

Contempt

without a gentle contempt for education,
no gentleman's education is complete

<html>
<title>Education</title>
<body>
<h1>Contempt</h1>
<p>without a gentle <strong>contempt</strong> for education,<br /> no gentleman's education is complete</p>
<img src="contempt.jpg" alt="contempt">
</body>
</html>


Sometimes you want to write something in the HTML code of a webpage to help you understand the code better. This is called a comment and is an ubiquitous feature in any computing language. Comments don't perform any computing function and don't display on a finished Web page, they are merely there for the web designer to use so that they can understand the page better. For HTML we use the following tags:

<html>
<title>Love</title>
<body>
<h1>What Love is</h1>

"Love means to love that which is unlovable; or it is no virtue at all."

<!--Quote from G. K. Chesterton (1874-1936)-->
</body>
</html>


In the example above, the line starting with the <!−− and ending in −−> is a comment. A comment block start with <! and ends with > and you can have as many comments as you like between those tags, as long as they start and end with −−. Everything in between these comment tags will not be displayed on the screen, producing this:

Love

What Love is

"Love means to love that which is unlovable; or it is no virtue at all."

For the following code sketch what it outputs:

<html>
<title>Friendship</title>
<body>
<h1>Hello</h1>
<ol>
<li>Yes</li>
<li>No</li>
<!--<li>Maybe</li>-->
</ol>
<!--What a horrible question.-->
</body>
</html>


Friendship

Hello

1. Yes
2. No

 Extension: HTML 5 What we have been learning so far are the very basics of web design. If you like what you've been doing you better check out HTML5. HTML5 is starting to make websites fully interactive with the ability to quickly embed videos and interact with web pages. Over the next few years you'll increasingly see applications moving over to this new technology, so get with the program and start learning at w3schools.

## HTML & style sheets

Style sheet - a collection of rules about how to present an HTML document

In HTML it is possible to add colours, fonts and other styles to the web pages that you build, however this is not recommended and HTML should be used for structure only. To add colours, fonts, etc. we will use Cascading Style Sheets, also known as CSS.

## Style rule

A style sheet is made up of Style Rules. Each Style Rule has three parts, a selector, a property and a value:

selector {property : value}

For multiple properties you separate them using a semicolon;

selector {property1 : value1; property2 : value2}

## Selectors

selectors - "select" the elements on an HTML page that are affected by the style rule(s)

selector {property : value} You need to know three types of selector:

• type, selects all elements of a certain type on the page e.g. h1 { color : green} selects all the heading 1s and turns them green
• class, selects all elements of the class you have specified and applies the style to only those elements .classname { color : red}
• ID, selects the item with the single ID that you have specified #idname { color : blue }. You can only apply an ID once in an HTML document
CSS Property Description CSS Values Example for Heading 1 Output
font-style: Changes the font style of text elements normal, italic, oblique h1 { font-style : italic } Hello
font-weight: Define how bold text is bold, normal, 400 h1 { font-weight : bold } Hello
background-color: Define page or item background colour green, brown, yellow h1 { background-color : yellow } Hello
text-align: horizontal position of text center, left, right h1 { text-align : center }
Hello
font-family: define the font of page text "Times New Roman", Arial, Helvetica h1 { font-family : "Times New Roman" } Hello
font-size: define the size of page text 100%, 250%, 50% h1 { font-size : 250% } Hello
color: changes the foreground colour of an element green, brown, orange h1 { color : green } Hello
(EXTENSION) text-decoration: Allows for underlining, strikethrough etc. overline, underline, line-through h1 { text-decoration : underline } Hello
 Exercise: CSS rules Write CSS rules to do the following: Turn all heading 3s blue: Answer : h3 { color : blue}  Turn all paragraphs red and itallic: Answer : p { color : red; font-style : italic}  Turn all class=bbold: bold and blue Answer : .bbold { color : blue; font-weight: bold}  Turn all class=uit: underlined and italic Answer : .uit { text-decoration : underline; font-style : italic }  Name the three components of a CSS style rule: Answer : selector {property: value}  Name the three different types of selector and describe each: Answer : type, selects all elements of a certain type on the page e.g. h1 { color : red} class, selects all elements of the class you have specified and applies the style to only those elements .classname { color : white} ID, selects the item with the single ID that you have specified #idname { color : blue} Describe the difference between HTML and CSS: Answer : HTML - Used for page structure CSS - a collection of rules about how to present an HTML document

### Type

Type rules - select all elements of a certain type on the page and apply styles to them

 h1 { color : green }


Take the HTML behind a simple website:

<html>
<title>My Website</title>
<body>
<h1>Welcome</h1>

<p>This is my amazing website, look how great it is!</p>

<p>I doubt you could find a better one anywhere on the web.</p>

<p>Seriously!</p>

</body>
</html>


As we probably know, this would build the following page:

My Website

Welcome

This is my amazing website, look how great it is!

I doubt you could find a better one anywhere on the web.

Seriously!

You might think my claims are a little over the top, but we could try to make the site better by adding some colour to the title using the following CSS rules:

h1 { color : green }
p { color : red; font-style : italic }


We can't just place this directly into the page, we have to create a new section inside the <head> </head> tags, this is called embedding CSS, we'll look at another method, External Style Sheets later:

<html>
<title>My Website</title>
<style TYPE="text/css">
<!--
h1 { color : green }
p { color : red; font-style : italic }
-->
</style>
<body>
<h1>Welcome</h1>

<p> This is my amazing website, look how great it is!</p>

<p>I doubt you could find a better one anywhere on the web.</p>

<p>Seriously!</p>

</body>
</html>


What this will do is change the heading to green, and change each paragraph to red and italic:

My Website

Welcome

This is my amazing website, look how great it is!

I doubt you could find a better one anywhere on the web.

Seriously!

Exercise: CSS Type Selectors

For the HTML code below, show what the output would be for each set of CSS rules:

<html>
<title>My Website2</title>
<body>
<h1>Contact Details</h1>
<p>Please use the details below to get in contact</p>
<h2>Telephone</h2>
<p>Home: 0101010101010<br />
Mobile: 1010101010101<br />
</p>
<h2>Email</h2>
<p>1010101@10100101.com</p>
</body>
</html>


What would these two rules produce?

h2 { color : red }
h1 { color : blue; text-decoration : underline }


My Website2

Contact Details

Telephone

Please use the details below to get in contact
Home: 0101010101010
Mobile: 1010101010101

Email

1010101@10100101.com

What would these two rules produce?

p { font-weight : bold }
h1 { font-style : italic }


My Website2

Contact Details

Telephone

Please use the details below to get in contact
Home: 0101010101010
Mobile: 1010101010101

Email

1010101@10100101.com

Write rules to produce the following output:

My Website2

Contact Details

Telephone

Home: 0101010101010
Mobile: 1010101010101

Email

1010101@10100101.com

h1 { color : red; }
h2 { text-decoration : underline}


Write rules to produce the following output:

My Website2

Contact Details

Telephone

Home: 0101010101010
Mobile: 1010101010101

Email

1010101@10100101.com

h1 { background-color : yellow; }
h2 { text-decoration : underline }
p { background-color : red}


### Class

Class rules - select all elements of the class you have specified and applies the style to only those elements

.classname {property1 : value1; property2 : value2}


Take another look at the HTML behind a simple website:

<html>
<title>My Website</title>
<body>
<h1 class="textb">Welcome</h1>
<p class="textb">This is my amazing website, look how great it is!

<p class="texts">I doubt you could find a better one anywhere on the web.

<p class="textb">Seriously!

</body>
</html>


As you can see there are classes attached to some of the HTML tags, namely the 'textb' and 'texts' classes. On their own they don't do anything, we need to write some CSS style rules to make them come to life, remember that a class selector starts with a (.).

.textb { color : red; text-decoration : underline }
.texts { font-style : italic }

My website2

Welcome

This is my amazing website, look how great it is!

I doubt you could find a better one anywhere on the web.

Seriously!

Exercise: CSS Class Selectors

For the HTML code below, show what the output would be for each set of the CSS rules:

<html>
<title>My Website3</title>
<body>
<h1 class="txtt">Contact Details</h1>
<p>Please use the details below to get in contact</p>
<h2 class="txtg">Telephone</h2>
<p class="txtt">Home: 0101010101010<br />
Mobile: 1010101010101<br />
</p>
<h2>Email</h2>
<p class="txtg">1010101@10100101.com</p>
</body>
</html>


What would these two rules produce?

.txtg { color : blue }


note that class="txtt" does nothing as the CSS doesn't define it.

My Website3

Contact Details

Telephone

Home: 0101010101010
Mobile: 1010101010101

Email

1010101@10100101.com

.txtg { color : red }
.txtt { text-decoration : underline; color : green }


My Website3

Contact Details

Telephone

Home: 0101010101010
Mobile: 1010101010101

Email

1010101@10100101.com

### ID

ID rules - select the item with the single ID that you have specified. You can only apply an ID once in an HTML document.

#idname { color : blue }


Take yet another look at the HTML behind a simple website:

<html>
<title>A Website</title>
<body>
<h1 class="textb">Welcome</h1>
<p id="para1">This is my amazing website, look how great it is!

<p id="para2">I doubt you could find a better one anywhere on the web.

<p id="para3">Seriously!

</body>
</html>


As you can see, I have assigned an id to each of the paragraphs, this means that I can now style them separately from each other. Remember that an ID selector starts with a #.

#para1 { color : red }
#para2 { color : white }
#para3 { color : blue }

A Website

Welcome

This is my amazing website, look how great it is!

I doubt you could find a better one anywhere on the web.

Seriously!

Each id rule applies to a different paragraph, unfortunately I set #para2 to white, so you can't see it!

Exercise: CSS ID Selectors

For the HTML code below, show what the output would be for each set of the CSS rules:

<html>
<title>My Website3</title>
<body>
<h1 id="main">Contact Details</h1>
<p>Please use the details below to get in contact</p>
<h2>Telephone</h2>
<p>Home: 0101010101010<br />
Mobile: 1010101010101<br />
</p>
<h2>Email</h2>
<p id="txthighlight">1010101@10100101.com</p>
</body>
</html>


What would these two rules produce?

#main{ color : green }
#txthighlight{ background-color : yellow }


My Website3

Contact Details

Telephone

Home: 0101010101010
Mobile: 1010101010101

Email

1010101@10100101.com

Write the CSS to produce the following:

My Website3

Contact Details

Telephone

Home: 0101010101010
Mobile: 1010101010101

Email

1010101@10100101.com

#main{ font-style : italic }
#txthighlight{ text-align : center }


## Style sheets (Cascading Style Sheets or CSS)

You should be pretty comfortable with the use of CSS rules, we are now going to look how these rules are linked with the HTML. As we know the style (CSS) of a web page’s contents should to be separated from its structure (HTML), and when these two things come together, it creates the page that you see in your web browser. There are two methods of linking style to structure that you need to know:

• Embedded style, blocks of CSS information inside the HTML document
• External style sheets, i.e., a separate CSS file referenced from the HTML document

### Embedded style

Blocks of CSS information inside the HTML document. You can see that inside the head tag we have a block of CSS that applies to the HTML below it:

<html>
<title>My Website</title>
<style type="text/css">
<!--
h1 { font-weight : 900 }
.highlight {color : yellow }
-->
</style>
<body>
<h1>Welcome</h1>

This is my amazing website, look how great it is!

I doubt you could find a better one anywhere on the web.

Seriously!

</body>
</html>


### External style sheets

External style sheets use a separate file to store the style information (a .css file) and link the file from inside the HTML document.

home.html

<html>
<title>My Website</title>
<body>
<h1>Welcome</h1>

This is my amazing website, look how great it is!

I doubt you could find a better one anywhere on the web.

Seriously!

</body>
</html>


style.css

h1 { font-weight : 900 }
.highlight {color : yellow }


As you can see above the HTML file links to the CSS file through the line:

<link href="style.css" rel="stylesheet" type="text/css">


. You could get an HTML page to link to multiple CSS files and link a CSS file from multiple HTML files.

External style sheets are a better way of linking CSS to HTML than embedding CSS in HTML as you can:

Link one CSS file to many HTML files to reuse the same style without needing to retype it
When changing the style of a website you only need to change the style information in one location and it'll filter through to all pages

 Exercise: Types of style sheet Name the two different style sheets: Answer : external embedded (there is also inline but it's not pretty to use and not in the syllabus) Why might you prefer to use external style sheets on a large web site? Answer : You can link the same style sheet from multiple pages and changes to the site style would only require changes to that one style sheet
 Extension:CSS3 There is an awful lot more to learn about CSS and a new version is currently being released alongside HTML5. Don't get left behind, learn all about CSS2 and CSS3 at w3schools.

## Design decisions

Web page design is an art and there is no way of guaranteeing your website will look fantastic, however there are some rules that you can stick to when attempting to make a professional looking website:

### The rule of thirds

There is an artistic theory that states when you split an image into thirds aligning the main components in this format then it looks better.

This photograph of a sunset taken in the Thousand Islands region demonstrates the principles of the rule of thirds

This theory has been adopted into web design and many websites you use will utilise this rule of thirds, splitting the information into 3 columns, or 1 column and another column taking up two thirds.

### Colour schemes

Three web page colour schemes you need to know are: monochromatic, analogous, complementary colour

#### Monochromomatic

Monochromatic color schemes are derived from a single base colour, and extended using its shades, tones and tints (that is, a hue modified by the addition of black, grey (black + white) and white. Monochromatic color schemes may be considered boring unless there is diversity within the design

Red monochromatic image

#### Analogous

Analogous colors are colors that are adjacent to each other on a color wheel. Some examples are green, yellow green, and yellow or red, red violet and violet. Analogous color schemes are often found in nature and are pleasing to the eye.

Analogous color scheme on a colour wheel

#### Complementary

In color theory, two colors are called complementary if, when mixed in the proper proportion, they produce a neutral color (grey, white, or black). In the diagram below they are the colours that are opposite each other. Examples of complementary colours include:

• red and green
• blue and orange
• yellow and violet
a Blue-Yellow-Red color wheel. Opposite colors are called complementary
 Page Design Explain the rule of thirds: Answer : Separate the main components of your website into three columns and/or rows Name the three colour models that could be used on a webpage: Answer : Monochromatic Analogous Complementary

# Legal and ethical issues

With the growth of Information Technology a host of legal and ethical issues have arisen. These range from the laws that protect the work people create using computers, to the ethical and legal problems brought about by the use of robots in modern warfare.

Autonomous and remote controlled drones are now a common sight in a war zone

## Legislation

The way you use data and computers is subject to the law of the country you are living in. Across the world different countries have different laws, for the exam you only need to learn about the laws that effect the United Kingdom.

You must be familiar with the following legislation:

### Health and Safety (Display Screen Equipment) Regulations 1992

The Health and Safety Act was passed in 1992 and set out to promote excellence in managing health and safety in the work place. There are strict guidelines on how a desk is set up including provision for monitor positioning, adjustable chairs etc. Health and Safety is paramount when using computers for prolonged periods of time. Sitting in front of a computer screen typing and/or using a mouse is not a natural act for a human being and may result in health problems such as Repetitive Strain Injury (RSI), back and eye issues.

An example of a sensibly laid out work place

The Health and Safety (Display Screen Equipment) Regulations 1992 state that an employer must:

• make sure screens are adjustable and have anti glare filters
• provide supportive chairs that are adjustable
• provide foot supports
• provide breaks in computer work routine
• pay for eye treatment if necessary

Any employer failing to do this may be subject to a criminal investigation.

### Copyright, Design and Patents Act 1988

The Copyright, Design and Patents Act 1988 effects how people can acquire, use and share ideas, software and media.

#### Patent

A patent is a form of intellectual property which an individual or organisation owns the right to for a fixed period of time, allowing them to charge people for the use of it. After that time has expired the idea is in the public domain. Patents include the design of the lightbulb (1841) and the ejector seat (1916).

Growth of software patents in US

Computing has seen patents in hardware and more recently in software. There are many people who believe that software patents are damaging to Computer Science, as they stop innovation and stifle creativity. A famous case was BT trying to patent the hyperlink. If this had been successful, then every time a hyperlink was used (every page on the World Wide Web), someone might have had to pay money to BT for the privilege. Other people see software patents as important in defending the intellectual property of inventors, if someone creates something new they should be rewarded for it. Other software patents include: the MP3 and GIF. Countries such as India do not have software patents.

Software copyright refers to the law regarding the copying of computer software. Many companies and individuals write software and sell it for money, these products are copyrighted and you cannot copy the code or the program without the permission of the maker. This, they believe protects the work of the programmers, rewarding them for their efforts

 Copyright symbol Public domain symbol Copy-Left symbol

Other companies and individuals release software under Free and Open Source software (FOSS) licenses. These licenses allow users the right to use, study, change, and improve a program's design through the availability of its source code. Some adherents of FOSS believe it creates better software in the long term, and others believe that no software should be copyrighted. FOSS licensed products are heavily used in running the World Wide Web and in the creation of popular websites such as Facebook. Open Source licenses generally mean that if you create software that makes changes to open source code, and choose to release it, you must release your new code under the same Open Source license, this is called Copy-Left. Some free software is in the public domain, meaning that you can use it for whatever purpose you wish, if you make a software product involving changes to public domain sources code, you don't have to release your code into the public domain.

Copyright in most works lasts until 70 years after the death of the creator if known, otherwise 70 years after the work was created or published (fifty years for computer-generated works).

In summary the act specifies that users are not allowed to:

• use copyright material without permission
• use patented design without permission
• edit programs without permission
• copy or distribute software when you don't have permission

### Computer Misuse Act 1990

Personal Data - data that can be used to identify a living individual

The Computer Misuse Act 1990 deals with people who crack computer programs or systems. Crimes might include removing the Copyright protective measures from a commercial software product, breaking into a school database to change grades, hacking into a companies' website and stealing customer credit card details, creating viruses and trojans, and so on. It was recognised in the late 1980s that the increase in business and home use of computers required legislation in order to protect against their exploitation. To this end, in 1990 the Computer Misuse Act was established.

Under the act, three new offences were created:

It prohibits:

It must be shown that the perpetrator accessed the data, and that he was unauthorised, they knew they were unauthorised.
• unauthorised access with intent to commit or facilitate commission of further offences
To prove ulterior intent, it must be shown that they wished to use the information in order to commit a further offence.
• unauthorised modification of computer material
Unauthorised modification also includes deliberate introduction of a virus onto a computer system.

"Obtaining access" means; "Causing the computer to perform any action the results in it": Copying/moving data, Erasing/altering data, Using a program; or Causing the computer to output programs or data.

A difficulty with computer crime is that it can cross physical and national borders, the Computer Misuse Act recognises this fact and gives British Courts the jurisdiction where a "significant link" with Britain can be demonstrated in instances of computer-related crime. America has its own Computer Fraud and Abuse Act.

### Data Protection Act 1998

The Data Protection Act 1998 controls the way that companies, organisations and individuals handle personal data. It states that:

1. Data may only be used for the specific purposes for which it was collected.
2. Data must not be disclosed to other parties without the consent of the individual whom it is about, unless there is legislation or other overriding legitimate reason to share the information (for example, the prevention or detection of crime). It is an offence for Other Parties to obtain this personal data without authorisation.
3. Individuals have a right of access to the information held about them, subject to certain exceptions (for example, information held for the prevention or detection of crime).
4. Personal information may be kept for no longer than is necessary and must be kept up to date.
5. Personal information may not be sent outside the European Economic Area unless the individual whom it is about has consented or adequate protection is in place, for example by the use of a prescribed form of contract to govern the transmission of the data.
6. Subject to some exceptions for organisations that only do very simple processing, and for domestic use, all entities that process personal information must register with the Information Commissioner's Office.
7. The departments of a company that are holding personal information are required to have adequate security measures in place. Those include technical measures (such as firewalls) and organisational measures (such as staff training).
8. Subjects have the right to have factually incorrect information corrected (note: this does not extend to matters of opinion)

## Regulation of Investigatory Powers Act 2000

The Regulation of Investigatory Powers Act was passed in 2000, and introduces the power to intercept communications with the aim of taking into account the growth of the Internet. It regulates the manner in which certain public bodies may conduct surveillance and access a person's electronic communications. Supporters of the act claimed this was an excuse to introduce new measures, some of these included being able to force someone to reveal a cryptographic key for their data, with failure to do so resulting in up to 2 years imprisonment. As we have seen in packet switching, data can be read in transit between hosts. However, the act goes further than allowing this:

• enables certain public bodies to demand that an ISP provide access to a customer's communications in secret;
• enables mass surveillance of communications in transit;
• enables certain public bodies to demand ISPs fit equipment to facilitate surveillance;
• enables certain public bodies to demand that someone hand over keys to protected information;
• allows certain public bodies to monitor people's internet activities;
• prevents the existence of interception warrants and any data collected with them from being revealed in court.

## Code of conduct

A Code of Conduct is not law, but it is a set of rules that apply when you are in an organisation such as your college. Examples might include "Don't look at pornography at work". This would be legal at home, but if you did it at work you could be sacked. In addition, a code of conduct may contain laws such as "Don't install pirated software".

The British Computer Society has produced a list of standards for the training and development of Information Technology workers.

It covers the following issues:

• The Public Interest - safeguarding public health; respecting rights of 3rd parties, applying a knowledge of relevant regulation.
• Duty to employers and clients - carrying out work according to the requirements, and not abusing employers' or clients' trust in any way.
• Professional duty - uphold the reputation of the profession through good practice, support fellow members in professional development
• Professional Integrity and Competence - maintain standards of professional skill and practice, accepting responsibility for work done, avoiding conflicts of interest with clients.

An example of a code of conduct in use in an office is as follows:

• Don't play games
• Don't look at pornography
• Don't gamble
• Don't install software on work machines without permission

Each of these might be perfectly legal at home, but they might get you sacked at work

 Exercise: Laws and Codes of Conduct What is the difference between a Code of Conduct and a Law? Answer : A Law is applicable in all and every situation. A Code of Conduct is relevant only within the confines of an office, organisation or school. In a work place which of the following would be code of conduct rules only and which are laws. If a law name the law applicable: Don't look at pornography Don't download commercial MP3s from pirate websites Don't use email for personal messages Don't look at pirate software websites Don't use other company's logo on your work without permission Don't copy other company's ideas Don't give friends copies of CVs that have been sent to you Answer : Don't look at pornography (Code of Conduct) Don't download commercial MP3s from pirate websites (Law) Don't use email for personal messages (Code of Conduct) Don't look at pirate software websites (Code of Conduct) Don't use other company's logo on your work without permission (Law) Don't copy other company's ideas (Law) Don't give friends copies of CVs that have been sent to you (Law)

## Hacking

The term hacking can have two meanings:

1. The term might mean that you have taken some existing code and hacked it to do what you want it to. For example you take pre-existing open-source game code and use it to make your own game with. This is legal.
2. The other meaning is the more common, this is the idea that you break through some security system, bypass a copy protection, get access to data you shouldn't have access to etc. All this is illegal and sometimes termed cracking. Online financial and identity thefts are growing massively around the world.
 Richard Stallman is an example of an early day hacker, in the legal sense of the word Gary McKinnon is an example of a cracker, having hacked into the US Military
 Hacking Hats Within the hacking community, in the second sense of the term, there are two main groups. The term white hat in Internet slang refers to an ethical hacker, or a computer security expert who specializes in ensuring the security of an organization's information systems.[1] White hats may flag up security vulnerabilities on corporate websites and bring them to the attention of companies or organisations before the bad guys can make use of them. Recently companies have recognised the use of white hats, with companies such as Facebook and google offering bug bounty for people who can bring their attention to security flaws in their products A black hat is a hacker who "violates computer security for little reason beyond maliciousness or for personal gain"[2] Black Hat Hackers are what the media will often talk about when talking about 'hackers'. Black Hats break into secure networks to destroy data or make the network unusable for those who are authorized to use the network. Examples include the Lulzsec hacking group that hacked corporate websites for the 'lulz', releasing thousands of user account details of companies such as Sony.

## References

1. Tim Berners-Lee, Roy T. Fielding, Larry Masinter. (January 2005). “Uniform Resource Identifier (URI): Generic Syntax”. Internet Society. RFC 3986; STD 66.

## Digital rights management

With the emergence of digital technology and the internet, it has become easier than ever to make exact copies of data or use other peoples work in your own work. This might involve copying files, images, games, music and videos; it might involve using well known songs in videos you make; it might involve using images you find on the web in your own work. For all of this there are legal issues you must consider.

• Is it fair to give a copy of an MP3 to a friend when they haven't paid for it?
• Will piracy kill the film and music industries?
• Is taking images off the internet fair use, shouldn't we reward people for their work?
• Does Piracy actually aid some forms of media, as it increases the audience reach of that artist, making it more likely for them to buy it officially?

A way that companies try to control the use of media and programs is through the use of digital rights management systems. These systems

 Exercise: Digital Rights Management Give the arguments for and against using Digital Rights Management: Answer : Defends the intellectual property rights of creators Users are not able to use purchased products in the ways they might wish People who download illegally are more likely to buy a product in the long run

## Robotics

Robot - a mechanical or virtual intelligent agent that can perform tasks automatically or with guidance, typically by remote control

Robots are becoming an increasingly important part of modern society. They work in factories, fight wars and might one day nurse you in your old age.

## Artificial intelligence

Artificial intelligence - a science concerned with the general study of intelligence in all its manifestations, both in living organisms and in present and future machines

A large and important field of computer science is Artificial Intelligence (AI), the study of making intelligent machines. Many robots and computer programs are said to have Artificial Intelligence (AI). AI can be summarised by the definition above, with explicit examples of it including:

Trying to get machines to perform very speciﬁc tasks, e.g.

• recognition of faces or other things in pictures
• automatic translation of written or spoken words from one language to another
• controlling processes like landing aeroplanes, optimising a chemical plant or power station
• vacuuming rooms
• computer opponents in video games
• building things in factories

You might even have some ideas for how AI can be used for your A2 project next year.

Factory automation with industrial robots for material handling in flat glass industry

The 'thinky' AI can even learn from experience, meaning that you don't have to program them how to explicitly respond to each and every situation. This AI starts to pose some very big questions for humanity. Is there really a difference between the intelligence of a human being and that of a program? We'll look into this a little below:

## What are machines good and bad at, in comparison to humans?

1. Machines are good at doing tasks repeatedly (think about car manufacturing robots), as they don't get tired or make mistakes.
2. Machines are seen to be bad at making judgements which they haven't been built to make, sympathy, inventing things. etc. But if we built machines smart enough, couldn't we build these capabilities in?

## What can this tell us about the way that the human mind works?

There are many scientists and philosophers who believe that computers will one day become as intelligent as humans. But there is a question about what 'intelligence' really means. If it is just performing tasks well, then there are computers that can compose music, or sweep a road, or fly a plane, or solve maths equations better than most humans. We can even get computers to display emotions such as sympathy and anger. Does this mean that we can fully recreate how the mind works?

In 1950 Alan Turing, an early pioneer in computer science, proposed a test for machine intelligence. If you could have a conversation with a panel of human beings and with a computer AI program, and be unable to tell the difference between whether you were speaking to a human or a computer, then the computer could be seen to be as intelligent as a human. This is known as the Turing Test.

Player C, the interrogator, is tasked with trying to determine which player - A or B - is a computer and which is a human. The interrogator is limited to only receiving written responses in order so that they can't judge on appearance.

In 1980 the philosopher John Searle posed a thought experiment that some see as proving machines cannot understand what they are doing. The Chinese Room is a box in which a man sits. He does not speak Chinese at all, but is passed Chinese characters under the door. He has a book of Chinese characters and their matching responses. On receiving a character he looks for it in the book and sends the corresponding character in reply. At no point does he understand what he is doing, he just follows the instructions. AI can be considered to be just like this, however complex the code, all it is doing is responding to inputs with set outputs, there is no understanding present.

If you can carry on an intelligent conversation with an unknown partner, does this imply your statements are understood?

A similar argument was made by Stanley Jaki in 1969, where he proposed that AI is a little like a drain pipe, where two water droplets roll down, at the bottom they combine to form a larger droplet, but at no point does the drainpipe understand what has happened. He argues that human beings possess this understanding, whilst machines do not.

However, many philosophers and scientists see intelligence and understanding as nothing more than complex algorithms responding to stimuli. Is there really a 'me' that 'understands' and what exactly is it? Could our mind be reduced to a set of algorithms?

## What can we learn from machines

As machines are expendable they allow us to experiment and simulate human beings without worrying about their safety. For example machines are used by the army to simulate the damage received by a human being from the detonation of an Improvised Explosive Device. This allows us to design vehicles and clothing better able to protect soldiers.

Testing on machines allows us to better prepare for dangerous situations

## What are the limitations of using machines as tools?

If you create a machine without emotions and without the ability to acquire emotions, for example a car manufacturing robot, then there are some important limitations about how they can be used.

If you were to work next to a robot in a factory and to not feel very well. The machine would be very unlikely to be programmed to feel any sympathy, and would most probably not change its work routine to accommodate your changing circumstances.

Articulated industrial robot operating in a foundry

Machines in most cases lack the ability to adapt to new situations, being stuck with the code they have been given, and unable to see safety problems when carrying out their routine. The first robot-caused death was in 1979 when a robotic arm struck Robert Williams, a worker at a metal casting plant in the USA.

There might also be problems on the horizon if AI produces machines as 'intelligent' as us. In this situation they would have no limitations, they would be just like us. Isaac Asimov saw this problem and defined three laws of robotics to make sure that robots and humans can live together in peace.

1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.
2. A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.
3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws
 Exercise: Robotics Name a task that a robot would be suitable to do Answer : Building cars - don't get tired doing repetitive tasks, don't make mistakes Arial Attack drones - doesn't matter if they are shot down, can fly for longer without making mistakes NOT calculators, doing maths, hosting websites, etc. Why do you need a robot for that?! Surely a calculator or computer program would suffice? What are robots better at than humans, why? Answer : Repeated tasks, they don't get tired or make mistakes Do you believe that robots can ever be as intelligent as humans? Answer : This is an essay question that I'd like you to give some serious consideration to What limitations might a machine have when used to perform a task? Give an example of where something might go wrong Answer : It might not have been programmed to deal with a scenario it comes up against. robotic arm not realising someone is within its danger zone and getting crushed by it

## Emerging technologies

Technology impacts on many aspects of our lives, but the world hasn't always been this way. Over the course of the last 70 years the working practices of most professions have changed beyond belief. The rate of change shows no sign of stopping and the future looks like it will be ever more dominated by Information Technology. This section will be looking at a few of the issues around these emerging technologies and asking whether all this change is for the good.

## Computing timeline

The history of computing is short and spectacular. Many of the technologies that you may take for granted today might not have existed ten years ago.

The Colossus was an computer that helped shorten the Second World War
Date Place Event
1822 UK Charles Babbage designed his first mechanical computer, the Difference Engine
1848 UK George Boole developed binary algebra (Boolean algebra)
1938 Germany Konrad Zuse, completed the 'Z1', the first mechanical binary programmable computer. It was based on Boolean Algebra and had most of the basic ingredients of modern machines.
1943 UK The Colossus was built, by Dr Thomas Flowers at The Post Office Research Laboratories in London, to crack the German Lorenz (SZ42) cipher. 10 Colossus machines were used at Bletchley Park during World War II, most were destroyed immediately after they had finished their work to maintain secrecy.
1945 Germany Konrad Zuse developed Plankalkül, the first higher-level programming language
1947 USA Invention of the transistor at Bell Laboratories
1948 UK Academics at the Victoria University of Manchester created the first stored program computer, the SSEM. The first program it executed ran at roughly 1,000 Instructions per second.
1949 USA "Computers in the future may weigh no more than 1.5 tons" - Popular Mechanics, forecasting the relentless march of science
1950 UK Alan Turing published a paper describing the potential development of human and computer intelligence and communication. The paper would come later to be called the Turing Test
1951 UK J Lyons, a food company famous for its tea, ran the first business application on an electronic computer.
1951 UK The oldest known recordings of computer generated music were played by the Ferranti Mark 1 computer.
1953 World Estimate that there are 100 computers in the world.
1959 USA COBOL (COmmon Business-Oriented Language) developed by Grace Murray Hopper, finished in 1961.
1962 USA Spacewar!, the first computer game is written by MIT student Steve Russell
1963 USA Computer Mouse invented. It did not become popular until 1983 with Apple Computer's Macintosh
1965 USA Packet switching, funded by ARPA was developed. This makes reliable computer networking possible.
1969 USA Unix is released, its design has influenced many other operating systems including Linux, OS/X and Android
1971 USA First microprocessor, the 4004.
1972 USA The C programming language was developed by Dennis Ritchie. It is one of the most popular programming languages in history and along with its successor, C++, has been used to create system such as Unix, Linux and Windows.
1973 USA Development of the TCP/IP protocol suite.
1981 USA IBM announced their IBM Personal Computer. It becomes the basis for most of the modern personal computer industry.
1983 USA DNS introduced
1985 Japan / Netherlands CD-ROMs invented by Philips and produced in collaboration with Sony
1985 USA The first version of Microsoft Windows
1989 Switzerland World Wide Web, invented by Tim Berners-Lee
1991 Finland Linux created by Linus Torvalds
1993 USA Archie, the world's first search engine is released
1992 USA "Windows NT addresses 2 Gigabytes of RAM which is more than any application will ever need" — Microsoft on the development of Windows NT.
1993 USA Mosaic, the world's first web browser is released
1993 Worldwide Businesses allowed to sell internet connections to consumers
1995 Japan Sony releases its first PlayStation
1996 USA Hotmail is launched
2001 USA Microsoft releases Windows XP
2002 Canada RIM released the first BlackBerry smartphone.
2004 USA Mark Zuckerberg launches the Facebook website
2010 USA Apple releases the iPad

## Hope

The internet has brought the world closer together, it is now possible to talk directly to friends, family, colleagues and strangers on the other side of the world for free. As the internet has no central controlling body it allows for free speech on a global scale and the prevalence of social networking technologies have been seen as a catalyst for uprisings in the Middle East, where the people used Facebook and Twitter to call for greater freedom and democracy.

Tunisian protests January 2011

Much of the information held on the internet is free, with projects such as Wikipedia bringing about global collaboration to give uninhibited access to information and education. With free access to knowledge people should be able to make more informed choices about how they live, and this information should help them take control of their own destinies. Collaboration over the internet has allowed computer experts to write software, scientists to share and discuss findings, artists to create shared works and it has even let teachers write textbooks.

As of 2011, the English version of Wikipedia had nearly 4 million articles

Technology has impacted on health care massively, with computer systems assisting in the diagnosis of illness, computer programs modelling viruses and disease, and GPS helping ambulances reach their destinations faster. In countries possessing advanced technologies the life expectancy is above that of those that don't have this technology. The future of medicine could well see swarms of robots moving around the body helping to keep you healthy, surgery conducted by machines and gene therapy automated by computer programs.

Computers are used to analyse brain scans and model solutions

Technologies have touched on almost every part of our lives, simplifying or automating much of what we do. Cars are more fuel efficient and safer, food is cheaper to produce, you can buy products from the other side of the world. To live without a mobile phone or the internet would be unthinkable for some. What the future holds and how our lives will change is an unknown, but it is likely our lives will become ever more intertwined with technology and we will see Artificial Intelligence coming to the fore.

## Despair

George Orwell wrote the book 1984 about a dystopian world where people were constantly under surveillance. He wrote this book in 1949 and the real world of 1984 was very different to the one in the book, however, with surveillance becoming easier for governments to conduct his world no longer seems so far fetched. Governments now have the technology to read your digital correspondence without you even knowing, they have software that can recognise you just from a picture of your face. Several countries have punished free speech on the internet with prison. Throw away comments that would previously have been forgotten are now permanently remembered on the internet, and people find it harder and harder to escape their past indiscretions.

Facial recognition software will allow for easier photo tagging but higher levels of surveillance

In 1984 a film called The Terminator was released. It talks of a world where the military have created robots to fight wars, in a fictional 2009 they rebel against their makers. This didn't happen in 2009, but many of the things that the film referenced are becoming a reality. Military organisations around the world are building Unmanned Aerial Vehicles, these 'planes' do not have a pilot inside them so are 'expendable' and can fly for far longer than a manned plane could.

Predator drone launching a Hellfire missile

They have been used heavily in the Afghan War and around the world, with human controllers often sat thousands of miles away, pressing buttons like a computer game to fire and kill targets. Software is being developed allowing the planes and their ground equivalent to pick and recommend their own targets, keeping the human controller to give the go-ahead. But what is to stop them being fully automatic, like in the Terminator?

Fossil fuel use leads to global warming

Modern technology is powered by electricity, and the more we use technology, the more energy we require. This has resulted in an increase in the use of fossil fuels, but also companies like Google investing in renewable resources. The creation of new devices and the manufacturing processes involved have resulted in the use of dangerous chemicals, and rubbish dumps full of abandoned technology. The pursuit of rare metals needed for the production of mobile phones and laptops has led to conflicts in such countries as the Democratic Republic of the Congo.

With people's increasing reliance on using computers for financial transactions, criminals have adapted to the new technologies quickly, offering them the ability to steal money and identities remotely and anonymously. With business and Governmental activities being ever more interconnected it is now a very real threat that terrorists and foreign forces could bring down the infrastructure of a country through viruses and hacking, without ever having the need to fire a single bullet. However, police forces are also making use of new technologies such as GPS, CCTV and face recognition to help them solve crimes.

 Exercise: Hope vs Despair Should we welcome free speech on the internet? Answer : Yes to those wanting democracy and freedom. No to those spreading hate and lies. Is tolerating one and not the other a sign of intolerance? Should we be grateful for the recent advances of technology? Answer : Yes Health care and longer life expectancy Free access to information and communication The spread of democracy and free speech Cheaper food No New types of crime The threat of terrorism Increased surveillance of what we do Inability to escape your mistakes

## Digital divide

Digital Divide - the disparity between groups when accessing information and communication technologies

With technology becoming more and more important to how we conduct our daily lives it must be noted that not all people have equal access to technologies for a variety of reasons. For example if you live in the countryside your internet connection probably won't be as fast as a person living in a city. If you live in sub-Saharan Africa it is far less likely that you'll have the same technologies as someone living in Europe. If you have more money than your friends you might have the latest software to complete your homework whilst your friends have to go without. If you are very old then you didn't grow up with smart phones and you may never have learned to use them. There are a variety of reasons for the digital divide:

• Age
• Wealth
• Education
• Culture
• Location

But why is a disparity of access to information and communication technologies an issue? It should be pretty obvious, a person who is well educated with the correct skill set is able to access modern society and a larger selection of jobs. Without a proper education and exposure to these technologies then a person will find themselves less employable and less able to engage with the society in which we live.

### How can we fix it?

There are many schemes in place at the moment to try and help bridge the digital divide. As technology becomes cheaper, more people can access it, there are also schemes such as the One Laptop Per Child organisation, which aim to deliver cheap hardware to developing countries.

The OLPC is a robust peive of hardware designed for use in the third world

Free and Open Source Software (FOSS) is getting increasingly popular, offering industry standard technologies for free. Governments and charities are investing heavily in providing education to the elderly and technology to those in remote areas.

### Is the Digital Divide bad?

You might be familiar with elderly relatives who know little about technology and maybe care even less, should we feel sorry for them?

There are some people who would argue that our constant striving for better technology is damaging the world around us. The manufacture of modern technology is very polluting adding to greenhouse gases and the destruction of natural habitats. Cobalt and other rare earths are used heavily in the manufacture of many of the phones and computer systems we take for granted. Unfortunately much of this metal is acquired through the use of questionable labour practice, and have the market for them has been seen to fuel ongoing conflicts in countries such as the Democratic Republic of Congo. Many products are manufactured in countries with looser employment laws than our own so we might be indirectly responsible for child or even slave labour. Should those without technology feel sorry for those with it as they could well be taking a more moral position? Can we make sure that all the technology we use is ethical?

The Amish reject technologies such as cars

Other groups such as the Amish don't see the benefits that modern technology brings. They reject things such as computers and the internet, some even reject electricity. Are their lives impoverished as a result? Should we force them to conform? Some might claim that we live far more efficient and longer lives due to technology, but others might respond that making everything easier doesn't necessarily make for happier people, we need struggle to find meaning in our lives and lives without struggle lose meaning:

 “ And if we haven't had our misfortunes, we wouldn't have been better off. It would have been worse. Because in that case, there wouldn't have been any happiness. And there wouldn't have been any hope - Tarkovsky A. Stalker 1979 ”

In Amish culture it is also notable that the elders are not seen as useless, their experience is relevant to the youth as they have lived the same lives. In modern society many elderly are seen as useless (not necessarily correctly!) when measured against the skill set needed to live and the advice they can pass on.

 Exercise: Digital Divide Explain what the Digital Divide is: Answer : the disparity between groups when accessing information and communication technologies Name 3 factors that cause the Digital Divide: Answer : Age Wealth Location Education Give two ways that people are trying to address the Digital Divide: Answer : Free and Open Source Software Cheaper technologies provided to the developing world Education for elderly Evaluate whether advancing technology is for the best: Answer : For: It makes people's lives easier It prolongs our lives It gives us more leisure time It gives us fast and cheap access to communication and information Against: It damages the planet Its creation can support child and slave labour Its creation can fuel wars It makes old folks useless

## References

1. What is white hat? - a definition from Whatis.com
2. R. Moore, Cybercrime: Investigating High Technology Computer Crime, 2005, Matthew Bender & Company, p258