10
A-Level Computing#BristolMet Session Objectives#6 MUST understand and produce simple logic diagrams using the operations NOT, AND and OR SHOULD explain why data is represented in computer systems in binary COULD construct a truth tables from a given logic diagram Create a program in yousrc to calculate gcse grades.

Session Objectives #6

  • Upload
    miyo

  • View
    25

  • Download
    0

Embed Size (px)

DESCRIPTION

Session Objectives #6 . Binary Logic. Starter: A lily pad doubles in size everyday. It takes 30 whole days to fill up the whole pond, how many days did it take to fill half the pond? Prove your answer... . Binary Logic. - PowerPoint PPT Presentation

Citation preview

Page 1: Session  Objectives #6

A-Level Computing#BristolMet

Session Objectives#6

MUST understand and produce simple logic diagrams using the operations NOT, AND and OR

SHOULD explain why data is represented in computer systems in binary

COULD construct a truth tables from a given logic diagram

Create a program in yousrc to calculate gcse grades.

Page 2: Session  Objectives #6

A-Level Computing#BristolMet

Binary LogicStarter:

A lily pad doubles in size everyday. It takes 30 whole days to fill up the whole pond, how many days did it take to fill half the pond? Prove your answer...

Page 3: Session  Objectives #6

A-Level Computing#BristolMet

Binary LogicWe know that from von Neumann and the principle that all modern computers, data and instructions are based on the binary system (base 2). This is due to the ease in which 2 states can recognised – 0 and 1, on and off, true or false – by using simple transistors and capacitors.

transistor capacitorMemory uses very small transistors and capacitors which can be linked together to make simple logical calculations: e.g are both inputs 1? or is only one input 1? These simple circuits are called Logic Gates.

Page 4: Session  Objectives #6

A-Level Computing#BristolMet

Logic GatesThere main gates are as follows:

1. NOT gate – it outputs the opposite of the input i.e input = 1, then output = 0, and vice versa.

Truth Tables are used to express the relationship between input and output. (Algebraic values are used, ABC etc for input and PQR for output)

A P

0 1

1 0

Input Output

Page 5: Session  Objectives #6

A-Level Computing#BristolMet

Logic Gates

2. AND gate – this tells us if both inputs are 1 by outputting 1, otherwise the output will be 0

e.g

3. OR gate – shows that either 1 OR 2 inputs are on by outputting 1, otherwise output is 0.

e.g

A B P0 0 00 1 01 0 01 1 1

A B P0 0 00 1 11 0 11 1 1

Page 6: Session  Objectives #6

A-Level Computing#BristolMet

Logic Gate DiagramsEach gate is represented by a different symbol:

NOT gate

AND gate

OR gate

INPUT OUTPUT

Page 7: Session  Objectives #6

A-Level Computing#BristolMet

Logic CircuitsLogic gates can be joined together to make more complex logic circuits.

A common combination is the NAND circuit (Not AND) which frustratingly is a AND followed by a NOT gate. Similarly a NOR is an OR followed by a NOT.

NAND – basically toggles the AND so that if both inputs are 1 then 0 will be output, otherwise 1 is output.

Output R

Output P

A B R= A AND B P=NOT R0 0 0 1

0 1 0 1

1 0 0 1

1 1 1 0

Page 8: Session  Objectives #6

A-Level Computing#BristolMet

Logic Circuits

This example has 3 inputs, 2 in the AND (A&B), outputting to an OR at P, and 1 directly into the OR.

The resulting truth table is calculated:

P

A B C P=A AND B Q = P OR C

0 0 0 0 0

0 0 1 0 1

0 1 0 0 0

0 1 1 0 1

1 0 0 0 0

1 0 1 0 1

1 1 0 1 1

1 1 1 1 1

Page 9: Session  Objectives #6

A-Level Computing#BristolMet

Boolean AlgebraThese logic circuits can be written down using mathematical expersions called Boolean algebra (named after Mathematician George Boole).

i.e Q = (A AND B) OR C

TASKS – Draw logic circuits and truth tables for the following

a) P=NOT(A AND B)b) P=NOT(A OR B)c) P=A AND NOT (B)d) A AND NOT(B OR C)

Page 10: Session  Objectives #6

A-Level Computing#BristolMet

Boolean ProgrammingBoolean algebra is used in programming to perform many instruction. For example IF statements and While loops

IF x >10 then...

ELSE....__________________

WHILE x < 10 AND NOT (end of file) DO

Now try some simple programming using Ifs and Loops in Yousrc.