A Level Computer Science Homework
A Level Computer Science Homework
1. Introduction
Source: https://www.quora.com/How-are-electricity-and-computers-related
Electricity flows through these logic gates and represents signals we need to act on
In computers we need to
Computers work on a Binary or base 2 system, where values are on or off (AKA true or false, yes or no, 0 or 1).
It makes sense to create the circuits we need based on a similar ON/OFF, TRUE or FALSE, 0 or 1 system.
In the computer’s case the circuits take in signals (voltages) representing 0 or 1 and produce ouputs signals
(voltages) representing 0 or 1.
The results therefore depend on what you put in and what you designed the circuit to do logically to give you
the output you want.
For example
An interior light in a two-door car is controlled by two switches that the driver can turn on or off
and two sensors, one per door. The switches are named A and B.
The door sensors are named C and D. The interior light is named L.
If a door is open the output of its sensor is on(C or D = TRUE).
If a door is closed the output of its sensor is off (C or D = FALSE).
• If both switches A and B are off then the light L is always off.( A and B = FALSE)
• If switch A is on the light L is always on.(A= TRUE)
• If switch B is on and switch A is off then:
○ the light L turns on if one or more of the car doors is opened B = TRUE and C OR
D = true)
○ the light L turns off if both of the doors are closed. (C OR D OR BOTH = FALSE)
Start
True (Y)
This is a decision – is it
It is
raining? Do not go to school
raining
No (F)
Go to school
Example: If it is raining AND I have to walk the dog then I will not go to school.
A truth table shows all possible input combinations and the answer for each of combination of
questions.
e.g. 1 question = 2 results,
2 questions = 4 results and so on
a. AND
b. OR
c. NOT
d. XOR
An operator takes at least one and usually 2 or more input values and produces an output
XOR Exclusive
Dysjunction
NOT Negation
NAND,
NOR and
NXOR.
If it is raining and I have to walk the dog then I will not go to school
can be divided into three parts - two expressions (questions if you like) and a result based on whether the
questions are answered as True or False
By replacing the questions with letters we simplify the problem to an algebraic form . this is a truth table
e.g.
A B R
F F F
F T F
T F F
T T T
This gives us an expression of R = A AND B (this can also be written as R = A.B or R= A^B)
TASK:
Fill in the truth table below for the following problem
If it is sunny (A) or I am happy (B), then I will go out for the day (R)
What are the possible values for A and B? What is the possible result in each case for R?
R=
…………………………………………………………….
To represent these circuits, we use LOGIC GATE diagrams which have a number of input lines and an
output line. Each logical operator has a logic gate shape for it
A logical algebra expression is converted to a logic circuit by substituting in an appropriate logic gate
for each part of the logical algebra expression
Example 1: the logical algebra expression A.B becomes a single AND gate.
Example 2: the logical algebra expression Z= (A OR B) AND (not(B) OR C) becomes the following
circuit diagram
We can create the circuit in a simulator and test it to see if it gives the correct results.
The link allows you to create and test logic circuits the http://www.neuroproductions.be/logic-lab/
The software is drag and drop so drag out the components, drop them on the screen then link together from
the contact points (when these go green then drag to the next point to link the components together
Task: Use the inputs, logic ports and output sections to build solutions to the following problems.
This shows the circuit built from the expression A and B. Click on the switches to see it work
Task: Try building the circuit for the extended ice cream problem
INPUT A = LYNN likes chocolate ice cream ( can be true or false)
INPUT B = LYNN likes vanilla ice cream ( can be true or false)
INPUT C = LYNN does not like ginger ice cream
RESULT R = is true if Lynn likes chocolate ice cream(A= T) OR likes vanilla ice
cream(B=T) AND dislikes ginger ice cream (C =T)
Task: Given the diagram below, try building and testing the circuit for it
TASK: here are a range of logical algebra expressions. Build and test the circuit for each one
1. A XOR B XOR C
2. (A XOR C) OR B
3. A OR (not(B))
4. A AND not(C OR B)
5. Not(A AND B AND C)
TASK: Using the http://www.neuroproductions.be/logic-lab/ link, build and test the following circuit
diagrams
You will need to create a truth table for each circuit to prove that your answer is correct
TRUTH TABLE
A Not(A) B Not(B) C= B and not(A) E = A and not(B) D= Not(C or D)
0 0
0 1
1 0
1 1
TRUTH TABLE
D Clk Q Not Q
0 0 0
0 1 0
1 0 0
1 1 1
4. Multiplexor A multiplexer performs the function of selecting the input on any one of 'n'
input lines and feeding this input to one output line. The diagram below is a 2 to 1
multiplexer
TRUTH TABLE
A B X Not(X) A and not(X) B and not(X) Y
TASK: Extension
Can you join the adder and flipflop together so that the results of the adder (the sum(S) and the carry(C)) get
stored ( S goes into one flip flop, C goes into another!)
• a door sensor D that outputs TRUE when the door is open and FALSE when the door is
shut
• a pressure mat sensor M that outputs TRUE while a weight is detected on it and FALSE
when no weight is detected on it.
The alarm also has a key K that turns the alarm on and off. K outputs a TRUE signal when the
alarm is switched on and FALSE when the alarm is off.
(a) In the space below, draw a logic circuit that will behave as described above for the
inputs D, M and K and the output A.
(2)
(b) Write a Boolean expression to represent the logic of this alarm system.
A=...................................................................................................................
http://pigofminecraft.blogspot.com/2011/07/xor-gates-how-and-why.html
https://learn.sparkfun.com/tutorials/logicblocks-experiment-guide/7-2-to-1-multiplexer