Learn IT with Davo
  • Mr Davidson's Blog
  • Twitter
  • A Level CS
    • A Level Exam Technique
    • Lessons
    • Unit 3 - Coursework Guidance
  • OLD GCSE CS - J276
    • All GCSE Questions
    • GCSE Exam Technique
    • Lessons
    • Glossary of Terms
    • Unit 1 Revision >
      • 1.1 - Systems Architecture
      • 1.2 - Memory
      • 1.3 - Storage
      • 1.4 - Wired and Wireless Networks
      • 1.5 - Topologies, Protocols and Layers
      • 1.6 - System Security
      • 1.7 - Systems Software
      • 1.8 - Ethics and Law
    • Unit 2 Revision >
      • 2.1 - Computational Thinking
      • 2.1 - Searching and Sorting Algorithms
      • 2.1 and 2.2 - Writing Algorithms/Programming Techniques
      • 2.2 - SQL and Database Structure
      • 2.3. Robust Code
      • 2.4. Logic
      • 2.5. Translators and Facilities
      • 2.6. Data Representation
  • NEW GCSE CS - J277
    • Glossary of Terms
    • Exam Technique
    • Lessons >
      • Unit 1 - Computer Systems
  • GCSE Business - J204
    • Lessons >
      • Unit 1 - Business Activity, Marketing and People
      • Unit 2 - Operations, Finance and Influences
    • Exam Technique
  • Contact

2.4 - Logic

In this section (click to jump):
  • Why data is represented in Binary form
  • Logic Gates and Truth Tables
  • Simple Circuits

Why data is represented in binary form

Picture
I have a confession. I used to have these exact sideburns. No, really, I did.
This is George Boole. You've probably only ever heard of him when I've been rambling on about him in class, but all of our futures were changed by this man in 1854 when he published a paper which contained "Boolean Logic." The rules he proposed became the "basis of all reasoning" in our computer systems and yet they are based on nothing more than (loosely) AND means multiply and OR means add together. How, er, logical!

Now you've all heard of the Boolean data type - True or False. Boolean logic takes this idea and creates some rules that take one or two inputs and tells you exactly what the "result" of combining these inputs together are. The output is always True or False. (Richtig oder Falsch in German, I always did love those words.)

That sounds complicated, but really it isn't. The complicated part is remembering them off the top of your head - but don't worry, there's a technique for that.

Each Boolean rule is written out in a table form, these are called "truth tables." Cos they is the truth - bare mans swear down, bruv.

These truth tables represent one boolean operation - AND, OR and NOT. Each of these can be represented by a symbol which, in turn is often called a "logic gate". Why a gate? Well they kind of operate like a really weird bouncer at an exceptionally furry toothed geek convention. If you arrive in the right order, they'll let you in, otherwise they won't. 

This leads us to why computers only understand data represented in binary form...

The reason we use these truth tables or logic gates is because they are 100% predictable. We know exactly what we're going to get in any situation. This is incredibly important, literally life or death important in modern computer systems. So we use boolean logic because:
  • We know the result for any given input
  • We know how the circuit will behave in all circumstances - there are no hidden surprises.
  • We can combine these rules together to perform complex operations (make circuits that do things we want)
  • We can use further logic to simplify our designs and save lots of money in manufacturing costs
  • We can prove, with 100% certainty, that a circuit does what we say it will using Logical Proofs. You won't need to do this. Probably ever, and if you do you won't be worried because you'll be minted.

And this (starting a sentence with and? Your English teachers are crying out in anguish) is why we use binary in computer systems. Not because its fun, not to satisfy the sadistic needs of weird, pale looking geeks, but because it works and we can prove it. Oh and we can make everything out of switches. That too. That really helps.

So, let's finish with an exam style definition:

Computers represent (or require) data in binary form as they are electronic devices. This is because their circuits are made up of transistors, which are switches that use electric current to change states. A switch can only be in one of two states - on or off. Therefore, all data in a computer is represented as a series of switches in an on or off position, which we interpret as 1 or 0. 

Picture
"See, honey, the formula for a perfect relationship actually turns out to be very simple!"
"But this just says 'IF woman != right THEN woman = right.'...??"
"See! Isn't logic beautiful..."

Logic Gates/Truth Tables

Lets be clear before we start:

TRUE = 1
FALSE = 0


These terms are interchangeable and you should be comfortable with either. So sometimes I may say "true" and others "1."  Confused? Good. In all seriousness, OCR have a habit of using either words or numbers in truth tables and the like so you need to understand both.

NOT

Picture
What does it do? Inverts the input, flips it, turns it over, gives it an identity crisis.

Remember it like this: "The output is NOT the input."

Explanation: The NOT gate simply takes whichever bit you put in and gives you the opposite. It only takes one input, which can either be a 1 or a 0 (because we're working in binary, right, and one bit can be a 0 or 1?)

Other symbols: NOT can be written like this "¬A" or  with a line over the top of a letter.

Picture

AND

Picture
 What does it do? Tells you when two things are true, tells you when something is switched on or off, multiplies 2 bits.

Remember it like this: "one AND the other input must be true, to get true output"

Explanation: The AND gate will only give out a true (1)  if both of the inputs are also true. This is dead useful for finding out the state of switches in a system/circuit or for only doing something when two things are ready, or for... the list goes on

Other Symbols: AND can be written as a full stop - A.B means A AND B. You may also see this symbol being used: A ∧ B which looks a little like an upside down V and means the same thing - A AND B.

Picture

OR

Picture
What does it do? Tells you if one of the inputs is true or not. More importantly it forms the basis of addition in binary.

Remember it like this: "one OR the other input must be true, to get true output"

Explanation: The OR gate will give true if any of the inputs are true. This is the easiest rule to learn because all you have to remember is if there's a 1 anywhere, then you'll get a 1 out.

Other Symbols: Strangely, OR can be written using a + symbol, so A+B means A OR B. You may also see this symbol being used: A ∨ B which looks just like a V and means the same as before.

Picture

A few tips before we go any further...

We are going to draw many truth tables. Indeed, the truth tables for each individual logic gate is only the beginning.

A few things to remember/understand:
  • A logic gate is a circuit
  • A logic gate has a truth table
  • If we combine gates to make a circuit, then this whole circuit has a truth table too!
  • We must always include every possible input to a truth table, so we work out what the highest number those binary bits could represent and add one for the combination of 0:
    • 2 inputs = (1 + 2) + 1 = 4 possible input combinations (Just like AND and OR gates have)
    • 3 inputs = (1 + 2 + 4) + 1 = 8 possible input combinations
    • 4 inputs = (1 + 2 + 4 + 8) + 1 = 16 possible input combinations
  • You'll never do complicated circuits in the exam, but being able to draw the truth table for a circuit with up to 4 inputs would be an incredible help

Drawing Truth Tables

Picture
You should be as happy as Eduard if you've understood everything so far.
Drawing truth tables is actually really easy IF you break the problem down. If you're good at this and you've remembered all the rules you may well be thinking "don't be silly, I can do it in my head" and you probably can but remember, in an exam situation you want to be using techniques and methods that guarantee the marks, whether you're a genius or not. Also you will fail hard for any circuit with more than 2 inputs or 2 or 3 gates.

The rules for making circuit truth tables are:
  1. Write out all of the inputs (e.g. A, B, C)
  2. Write out all the possible inputs (all the combinations of 0 and 1 that they can be). This is trivial - just count up in binary from 0.
  3. Now identify all the points on the circuit where there is an output (after each symbol!) if it isn't marked with a letter, make one up yourself.
  4. Write out each of these points as a column on the table
  5. Now work your way through the circuit, using the outputs from previous columns as inputs wherever necessary.

That doesn't sound too simple, does it? Let's make a video!
Picture
If you get that then you truly are trolololol-ing


Powered by Create your own unique website with customizable templates.
  • Mr Davidson's Blog
  • Twitter
  • A Level CS
    • A Level Exam Technique
    • Lessons
    • Unit 3 - Coursework Guidance
  • OLD GCSE CS - J276
    • All GCSE Questions
    • GCSE Exam Technique
    • Lessons
    • Glossary of Terms
    • Unit 1 Revision >
      • 1.1 - Systems Architecture
      • 1.2 - Memory
      • 1.3 - Storage
      • 1.4 - Wired and Wireless Networks
      • 1.5 - Topologies, Protocols and Layers
      • 1.6 - System Security
      • 1.7 - Systems Software
      • 1.8 - Ethics and Law
    • Unit 2 Revision >
      • 2.1 - Computational Thinking
      • 2.1 - Searching and Sorting Algorithms
      • 2.1 and 2.2 - Writing Algorithms/Programming Techniques
      • 2.2 - SQL and Database Structure
      • 2.3. Robust Code
      • 2.4. Logic
      • 2.5. Translators and Facilities
      • 2.6. Data Representation
  • NEW GCSE CS - J277
    • Glossary of Terms
    • Exam Technique
    • Lessons >
      • Unit 1 - Computer Systems
  • GCSE Business - J204
    • Lessons >
      • Unit 1 - Business Activity, Marketing and People
      • Unit 2 - Operations, Finance and Influences
    • Exam Technique
  • Contact