Boolean algebra and logic circuits · A level · OCR H446 1.4.3, AQA 7517 4.6.4.1, Eduqas A500QS 1.2 · about 30 min
From a rule table to a Karnaugh map, a simplified expression, a proof and a robot that stops for the right reasons.
[1 mark]A rule has four inputs. How many rows does its truth table have?
[1 mark]With rows numbered 8C + 4K + 2L + D, which row number is C = 1, K = 0, L = 1, D = 1?
[1 mark]Put the stages of designing a logic rule in order.
Number the lines 1 to 6 to put them in the right order.
Write the simplified expressionDraw the circuit or write the codeWrite the truth tableName each input with a letterCheck it against the truth tableDraw the Karnaugh map and group the 1s[1 mark]Two groups on a map give (¬K ∧ D) ∨ (¬K ∧ ¬C ∧ ¬L). Which law turns this into ¬K ∧ (D ∨ (¬C ∧ ¬L))?
[1 mark]Which expression is equal to ¬C ∧ ¬L?
The starter gives GO_ROWS, the truth table rows (numbered 8C + 4K + 2L + D) where G = 1, and draft(c, k, l, d), which takes four bits and returns 1 on those rows and 0 otherwise.
1. Write go(c, k, l, d), taking four bits, as a single return line using at most six of and, or and not in total. It may not use GO_ROWS or call draft. Any true result means drive.
2. Check go against draft on all sixteen combinations, treating a true result as 1 and a false one as 0, and print matches: True if they agree on every one, or matches: False if not.
3. Drive the robot. Set docking = 0. In a loop, read close (1 if distance() is under 20, else 0), hit (1 if bumped(), else 0) and low (1 if battery() is under 20, else 0), and call go(close, hit, low, docking). While it is true, drive forward. When it is false, stop, print one line in exactly the form stopped: C=1 K=0 L=0 D=0 using the values that stopped it, and end the loop. The robot must finish in the band before the wall without touching it.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
GO_ROWS = [0, 1, 3, 9, 11]
def draft(c, k, l, d):
return 1 if 8 * c + 4 * k + 2 * l + d in GO_ROWS else 0
def go(c, k, l, d):
return 0Plan your program here, then type it in and press Run.
go expression using AND, OR and NOT gates. How many gates does it need, compared with the sum of products?