0% found this document useful (0 votes)
8 views68 pages

Lecture 1

Uploaded by

sjsksjdjd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views68 pages

Lecture 1

Uploaded by

sjsksjdjd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68



















Assembly Language

Processors
Arithmetic Finite State
Logic Units Machines

Devices Flip-flops

Circuits
Logic Gates







What is a computer?

do you need
electricity for a
computer?
CSCB58 Asks the Big Questions
▪ What is a computer?
▪ What is memory? How does a computer
store information
▪ Why do computers work in binary?
▪ how does a computer actually…
compute?
▪ How does the code we write in
Python/Java/C++/etc actually translate
into things happening?
Why take CSCB58?
▪ To better understand computers!
▪ See what's going on "under the hood"
▪ Open the black box, get rid of the mystery
▪ Understand the whole pipeline, from
atoms to assembly
 Everything above assembly is virtualization
and abstraction
 Everything else is an illusion!
▪ Build a cool software-based project!
CSCB58 Course Goals
▪ Learn to build computers…
 Understand and design the underlying
architecture of computer systems.
▪ … and how they work.
 How programs use digital structures to do
computation.
▪ Learn engineering.
 Build systems from components, understand
abstractions, make tradeoffs.
▪ Learn there is no magic!
 There is nothing you cannot understand.
CSCB58 Course Goals

▪ By the end of this course, you will be able to


build a computer from the atomic level upwards*
 Build circuits from logic gates
 Build memory/computational units from circuits
 Build a computer from memory/computational units

(* Given an infinite amount of time, and the ability to manipulate individual


atoms.)
Build a Computer!
▪ …from LEGO

▪ …in Minecraft

▪ …from living crabs*


* Do not build a computer from live
crabs. It is unethical.

▪ …inside an iMessage
to break into iPhones**
** also unethical.
https://villains.fandom.com/wiki/Vogons








































































This week

Assembly Language

Processors
Arithmetic Finite State
Logic Units Machines

Devices Flip-flops

Circuits
Logic Gates

Transistors
You already know some important concepts…
Boolean Logic from CSCA67
▪ Example: Create an expression that is true if
both variables A and B are true, or if both C and
D are true.
G = A & B | C & D

▪ Now create a circuit that does the same thing:

A
B
G
C
D
Logic Gates
▪ If you know how to create A
Y
B
simple logical expressions,
you already know the basics A
Y
B
of putting logic gates
together to form simple
A Y
circuits.
▪ Just need to know which
A
Y
logic operations are B

represented by which gate!


AND Gate

A
Y
B

inputs outputs
truth table A B Y
For every
combination of 0 0 0
inputs, what are 0 1 0 If the truth table
the outputs? for two circuits is
1 0 0 the same, they
1 1 1 are equivalent
OR Gate

A
Y
B

A B Y
0 0 0
0 1 1
1 0 1
1 1 1
NOT Gates
Bubble signifies
‘NOT’

A Y

A Y
0 1
1 0
XOR Gates

A
Y
B

A B Y
0 0 0
0 1 1
1 0 1
1 1 0
NAND Gates
Bubble signifies
‘NOT’

A
Y
B

A B Y
0 0 1
0 1 1
1 0 1
1 1 0
NOR Gates

A
Y
B

A B Y
0 0 1
0 1 0
1 0 0
1 1 0
Buffer

A Y

This is not as silly as A Y

you might think now, 0 0


as we’ll see later… 1 1
Circuit Design?
▪ Creating circuit logic can be similar to
creating Boolean logic in Python, C or Java:
Y = (!A and !B and !C) or
(!A and B and C) or
(A and B and C)
A ¬A
¬B
¬C
¬A
B Y
C
A
B
C
The real challenge in circuit design…

▪ Given a truth table or A B C Y


description… 0 0 0 1
▪ …find a circuit that 0 0 1 0
implements it. 0 1 0 0
▪ Many ways of tackling 0 1 1 1
the problem 1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1
You are here

Assembly Language

Processors
Arithmetic Finite State
Logic Units Machines
Devices Flip-flops
Circuits
Gates

Transistors
Making logic with gates
▪ Logic gates create an output value, based on
one or more input values.
▪ These correspond to Boolean logic that we’ve
seen before in CSCA08/A48/A67:
AND OR NOT
A Y A
Y A Y
B B

A B Y A B Y A Y
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1
1 1 1 1 1 1
Other gates
XOR NAND NOR

A A A
Y Y Y
B B B

A B Y A B Y A B Y
0 0 0 0 0 1 0 0 1
0 1 1 0 1 1 0 1 0
1 0 1 1 0 1 1 0 0
1 1 0 1 1 0 1 1 0
Aside: notation
▪ While we’re talking about notation…
 AND operations are denoted in these expressions by
the multiplication symbol.
 e.g. A·B·C or ABC or A*B*C  A˄B˄C
 OR operations are denoted by the addition symbol.
 e.g. A+B+C  A˅B˅C
 NOT is denoted by multiple symbols.
 e.g. !A or ~A or A or A’ or ¬A
 XOR occurs rarely in circuit expressions.
 e.g. A  B
Making Boolean expressions
▪ So how would you represent boolean
expressions using logic gates?

Y = (A or B) and (not A or not B) or C

▪ Like so: A
B
A
B

C
Now you are here

Assembly Language

Processors
Arithmetic Finite State
Logic Units Machines
Devices Flip-flops
Circuits
Gates

Transistors
Creating complex circuits
▪ What do we do in the case of more complex
circuits, with several inputs and more than
one output?
 If you’re lucky, a truth
table is provided to
express the circuit.
 Usually the behaviour of
the circuit is expressed in
words, and the first step
involves creating a truth
table that represents the
described behaviour.
Circuit example
▪ The circuit on the
right has three A X
B
Logic
inputs (A, B and C) Circuit Y
and two outputs C
(X and Y).
▪ What logic is needed to set X high when all
three inputs are high?
▪ What logic is needed to set Y high when the
number of high inputs is odd?
Combinational circuits
▪ Small problems can be solved easily.
A A
B B
X Y
C C

▪ Larger problems require a more systematic approach.


 Example: Given three inputs A, B, and C, make output Y high in the
case where all of the inputs are low, or when A and B are low and C is
high, or when A and C are low but B is high, or when A is low and B
and C are high.
Creating complex logic
▪ How do we approach
problems like these (and
circuit problems in general)?
▪ Basic steps:
1. Create truth tables.
2. Express as Boolean expression.
3. Convert to gates.
▪ The key to an efficient design?
 Spending extra time on Step #2.
Example truth table
▪ Consider the following A B C Y
0 0 0 0
example: 0 0 1 1

 “Given three inputs A, B, and C, 0 1 0 1


0 1 1 1
make output Y high wherever any
1 0 0 1
of the inputs are low, except when 1 0 1 0
all three are low or when A and C 1 1 0 1
are high.” 1 1 1 0

 This leads to the truth table on


the right.
 Is there a more compact way
to describe this function?
Warm-Up Exercise
For each of the following logic expressions, what are the
A, B, C values that make the expression evaluate to 1 ?

A’B’C’

ABC

A’BC

ABC’

51
Answers to Warm-Up Exercise
For each of the following logic expressions, what are the
A, B, C values that make the expression evaluate to 1 ?

A’B’C’
▪ A=0, B=0, C=0 , and only this!
ABC
▪ 111 and only this!
A’BC
▪ 011 and only this!
ABC’
▪ 110 and only this!

52
Maxterms, informally
▪ Assume a standard truth table format.
 Sort rows as if input ABC is binary number.
▪ Maxterms tell us which rows have low output.
 These rows are referred to as maxterms.
▪ Express circuit behaviour by listing those rows.
 In this example, we only need maxterms M0 M5 M7

Row index A B C Y Maxterm Y


0 0 0 0 0 M0 0
1 0 0 1 1 M1 1
2 0 1 0 1 M2 1
3 0 1 1 1 M3 1
4 1 0 0 1 M4 1
5 1 0 1 0 M5 0
6 1 1 0 1 M6 1
7 1 1 1 0 M7 0
Minterms, informally
▪ A more popular alternative:
list which input rows cause high output.
 These rows are referred to as minterms.
 In this case we have the minterms m1 m2 m3 m4 m6

Row index A B C Y Minterm Y


0 0 0 0 0 m0 0
1 0 0 1 1 m1 1
2 0 1 0 1 m2 1
3 0 1 1 1 m3 1
4 1 0 0 1 m4 1
5 1 0 1 0 m5 0
6 1 1 0 1 m6 1
7 1 1 1 0 m7 0
Minterms and maxterms
▪ A more formal description:
 minterm = an AND expression with every input
present in true or complemented form.
 maxterm = an OR expression with every input present
in true or complemented form.
▪ For example, given four inputs (A, B, C, D):
 Valid minterms:
 A·B·C·D, A·B·C·D, A·B·C·D
 Valid maxterms:
 A+B+C+D, A+B+C+D, A+B+C+D
 Neither minterm nor maxterm:
 A·B+C·D, A·B·D, A+B
Naming
▪ Given n inputs, there are 2n minterms and
maxterms possible (same as rows in a truth table).
▪ minterms are labeled as mx
maxterms are labeled as Mx
 The x subscript indicates the row in the truth table.
 x starts at 0 and ends with n-1.
▪ Minterms are about when output is 1:
 From m0 for A·B·C to m7 for A·B·C
n=3
▪ Maxterms are about when output is 0:
 M0 (A+B+C) to M7 (A+B+C)
m0 vs M0

▪ Minterm m0 is A and B and C


 m0 = 1 if and only if: A = B = C = 0 (row 0)
▪ Maxterm M0 is A or B or C
 M0 = 0 if and only if: A = B = C = 0 (row 0)
▪ Minterms tell us when the output is 1
▪ Maxterms tell us when the input is 0
Examples
For example, given four inputs (A, B, C, D):
▪ Valid minterms: m (because 1101 = 13)
13
 A·B·C·D
 A·B·C·D m10 (because 1010 = 10)
 A·B·C·D m15 (because 1111 = 15)
▪ Valid maxterms: (because 0010 = 2)
 A+B+C+D
M2
 A+B+C+D M5 (because 0101 = 5)
 A+B+C+D M0 (because 0000 = 0)
▪ Neither minterm nor maxterm:
 A·B+C·D mixes AND and OR
 A·B·D
 A+B missing some of the inputs
Quick Exercises
▪ Given 4 inputs A, B, C and D write:
 m9 => A·B·C·D
 m15 => A·B·C·D
 m16 => N/A for four inputs we go up to m15
 M2 => A+B+C+D

▪ Which minterm is this?


 A·B·C·D => m4

▪ Which maxterm is this?


 A+B+C+D => M1
What is This For?
▪ Recap:
 Minterms and maxterms are a shorthand to refer
to rows of the truth table.
 minterms describe rows where output is high.
 maxterms describe rows where output is low.
▪ Use minterms and maxterms to go from truth
table to logic expression
 Define output by OR-ing minterms or AND-ing
maxterms.
 Don’t mix them both
Using minterms and maxterms
Row index A B C D m2
▪ What are minterms 0 0 0 0 0 0
1 0 0 0 1 0
used for? 2 0 0 1 0 1

 A single minterm 3 0 0 1 1 0
4 0 1 0 0 0
indicates a set of inputs 5 0 1 0 1 0
that will make the 6 0 1 1 0 0

output go high. 7 0 1 1 1 0
8 1 0 0 0 0
 Example: m2 9 1 0 0 1 0

 Output only goes high 10 1 0 1 0 0


11 1 0 1 1 0
in third row of truth 12 1 1 0 0 0
table. 13 1 1 0 1 0
14 1 1 1 0 0
15 1 1 1 1 0
Using minterms and maxterms
A B C D m2 m8 m2+m8
0 0 0 0 0 0 0 0
▪ What happens when 1 0 0 0 1 0 0 0

you OR two minterms? 2 0 0 1 0 1 0 1


3 0 0 1 1 0 0 0
▪ Result is output that 4 0 1 0 0 0 0 0
0 1 0 1 0 0 0
goes high in both 5
6 0 1 1 0 0 0 0
minterm cases. 7 0 1 1 1 0 0 0
8 1 0 0 0 0 1 1
▪ For m2+m8, both third 9 1 0 0 1 0 0 0

and ninth rows of truth 10 1 0 1 0 0 0 0


11 1 0 1 1 0 0 0
table result in high 12 1 1 0 0 0 0 0

output. 13 1 1 0 1 0 0 0
14 1 1 1 0 0 0 0
15 1 1 1 1 0 0 0
Creating Boolean expressions
▪ Two canonical forms of Boolean expressions:
▪ Sum-of-Minterms (SOM):
 Since each minterm corresponds to a single high
output in the truth table, the combined high outputs
are a union of these minterm expressions.
 Also known as: Sum-of-Products.
▪ Product-of-Maxterms (POM):
 Since each maxterm only produces a single low output
in the truth table, the combined low outputs are an
intersection of these maxterm expressions.
 Also known as Product-of-Sums.
Y = m2 + m6 + m7 + m10 (SOM)
A B C D m2 m6 m7 m10 Y
0 0 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 0 0 0
2 0 0 1 0 1 0 0 0 1
3 0 0 1 1 0 0 0 0 0
4 0 1 0 0 0 0 0 0 0
5 0 1 0 1 0 0 0 0 0
6 0 1 1 0 0 1 0 0 1
7 0 1 1 1 0 0 1 0 1
8 1 0 0 0 0 0 0 0 0
9 1 0 0 1 0 0 0 0 0
10 1 0 1 0 0 0 0 1 1
11 1 0 1 1 0 0 0 0 0
12 1 1 0 0 0 0 0 0 0
13 1 1 0 1 0 0 0 0 0
14 1 1 1 0 0 0 0 0 0
15 1 1 1 1 0 0 0 0 0
Y = m2 + m6 + m7 + m10 (SOM)
A B C D m2 m6 m7 m10 Y
0 0 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 0 0 0
2 0 0 1 0 1 0 0 0 1
3 0 0 1 1 0 0 0 0 0
4 0 1 0 0 0 0 0 0 0
5 0 1 0 1 0 0 0 0 0
6 0 1 1 0 0 1 0 0 1
7 0 1 1 1 0 0 1 0 1
8 1 0 0 0 0 0 0 0 0
9 1 0 0 1 0 0 0 0 0
10 1 0 1 0 0 0 0 1 1
11 1 0 1 1 0 0 0 0 0
12 1 1 0 0 0 0 0 0 0
13 1 1 0 1 0 0 0 0 0
14 1 1 1 0 0 0 0 0 0
15 1 1 1 1 0 0 0 0 0
Y = M3· M5· M7· M10· M14 (POM)
A B C D M3 M5 M7 M10 M14 Y
0 0 0 0 1 1 1 1 1 1
0 0 0 1 1 1 1 1 1 1
0 0 1 0 1 1 1 1 1 1
0 0 1 1 0 1 1 1 1 0
0 1 0 0 1 1 1 1 1 1
0 1 0 1 1 0 1 1 1 0
0 1 1 0 1 1 1 1 1 1
0 1 1 1 1 1 0 1 1 0
1 0 0 0 1 1 1 1 1 1
1 0 0 1 1 1 1 1 1 1
1 0 1 0 1 1 1 0 1 0
1 0 1 1 1 1 1 1 1 1
1 1 0 0 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 0 0
1 1 1 1 1 1 1 1 1 1
Y = M3· M5· M7· M10· M14 (POM)
A B C D M3 M5 M7 M10 M14 Y
0 0 0 0 1 1 1 1 1 1
0 0 0 1 1 1 1 1 1 1
0 0 1 0 1 1 1 1 1 1
0 0 1 1 0 1 1 1 1 0
0 1 0 0 1 1 1 1 1 1
0 1 0 1 1 0 1 1 1 0
0 1 1 0 1 1 1 1 1 1
0 1 1 1 1 1 0 1 1 0
1 0 0 0 1 1 1 1 1 1
1 0 0 1 1 1 1 1 1 1
1 0 1 0 1 1 1 0 1 0
1 0 1 1 1 1 1 1 1 1
1 1 0 0 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 0 0
1 1 1 1 1 1 1 1 1 1
Using Sum-of-Minterms
▪ Sum-of-Minterms is a way of expressing which inputs cause the
output to go high. Product-of-Maxterms is a way of expression
which inputs cause the output to go low.
 Assumes that the truth table columns list the inputs according to some
logical or natural order.
▪ Minterm and maxterm expressions are used for efficiency reasons:
 More compact that displaying entire truth tables.
 Sum-of-minterms (SOM) are useful when very few input combinations that
produce high output.
 Product-of-maxterms (POM) useful when expressing truth tables that have
very few low output cases.
Converting SOM to gates
▪ Once you have a Sum-of-Minterms expression, it is easy to
convert this to the equivalent combination of gates:

¬A
¬B
¬C
m0 + m1 + m2 + m3 =
¬A
¬B
C
A·B·C + A·B·C + ¬A Y
A·B·C + A·B·C = B
¬C
¬A
B
C

You might also like