CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The...
-
Upload
naomi-caldwell -
Category
Documents
-
view
219 -
download
0
Transcript of CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The...
![Page 1: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/1.jpg)
CS1Q Computer SystemsLecture 7
Simon Gay
![Page 2: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/2.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 2
ParityThe parity of a binary word is determined by the number of 1s in it:if it contains an odd number of 1s then the parity is 1 (or odd);if it contains an even number of 1s then the parity is 0 (or even).
(Mathematically the parity of a number is sometimes said to be odd for odd numbers and even for even numbers. But for binary words,parity is based on the number of 1s.)
Example: 1010 has even parity. 1101 has odd parity. 11111111 has even parity. 00101010 has odd parity.
![Page 3: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/3.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 3
ParityThe parity function for a 3 bit word xyz is defined by the followingtruth table, which also shows the minterm for each row.
y zx p0 00 00 10 11 00 11 10 00 01 10 11 01 01 01 11 1
zyxzyxzyxzyxzyxzyxzyxzyx
The formula for p is the OR of thefour minterms corresponding to therows in which p = 1.
xyzzyxzyxzyxp
![Page 4: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/4.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 4
Exercises1. Draw a circuit for the parity function, in the same way that we didfor majority voting.
2. Find an equivalent circuit, which uses just two XOR gates. Provethat it is equivalent, both by truth tables and by using the laws ofboolean algebra.
![Page 5: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/5.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 5
Exercise Solution
xyzzyxzyxzyxp
The parity function for a 3 bit word xyz:
The question was to find a way of expressing this function with twoXOR gates, and prove that it is equivalent.
There is only one sensible circuit we can make out of two XOR gates:
xxor2 xor2y
zp
So we get:zyxzyxp )(
![Page 6: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/6.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 6
Exercise SolutionTo prove that this expression for p is equivalent to the first one,either use truth tables or the following calculation:
xyzzyxzyxzyxp
zyxyxzxyyx )()(
zyxzyx )()(
zyx )(
This expression for p suggests that the parity function is a 3-inputXOR operation. Indeed, we can see that XOR is the parity functionfor a 2 bit word.
![Page 7: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/7.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 7
Simplifying CircuitsWe have two different logical expressions for the majority votingfunction:
xyzzxyzyxyzxr
zxyzxyr
They are equivalent, but the first is simpler: easier to understand, perhaps more efficient to implement.
The more complex expression came from our systematic designtechnique. So we need a systematic simplification technique as well.
We’ll look at systematic simplification in a moment. But first,here’s a non-systematic approach.
![Page 8: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/8.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 8
Simplifying with Boolean Algebra
xyzzxyzyxyzxr xyzxyzxyzzxyzyxyzx xyzzxyxyzzyxxyzyzx xyzzxyxzyyxzyzxxyz
)()()( zzxyyyxzxxyz 111 xyxzyz
zxyzxy
. osimplify t ),( as factorize ,spot :Method xyzzxyxyzzxy
![Page 9: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/9.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 9
Karnaugh MapsA Karnaugh map, or K-map, is an alternative representation of atruth table, which makes it easy to spot when expressions of theform can be eliminated.xx
Example: consider the function yxyr and lay out its truth table as a 2 by 2 grid.
x y r0 0 00 1 11 0 01 1 1
0 10 1
1
10
0
xx
y y
This grid is the Karnaugh map for r.
![Page 10: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/10.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 10
Karnaugh MapsIn the Karnaugh map, each square corresponds to one of the fourcombinations of values of x and y. The values of x and y are shownat the left hand side and along the top.
0 10 1
1
10
0
xx
y yx y r0 0 00 1 11 0 01 1 1
![Page 11: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/11.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 11
Karnaugh MapsIn the Karnaugh map, each square corresponds to one of the fourcombinations of values of x and y. The values of x and y are shownat the left hand side and along the top.
0 10 1
1
10
0
xx
y yx y r0 0 00 1 11 0 01 1 1
![Page 12: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/12.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 12
Karnaugh MapsIn the Karnaugh map, each square corresponds to one of the fourcombinations of values of x and y. The values of x and y are shownat the left hand side and along the top.
0 10 1
1
10
0
xx
y yx y r0 0 00 1 11 0 01 1 1
![Page 13: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/13.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 13
Karnaugh MapsIn the Karnaugh map, each square corresponds to one of the fourcombinations of values of x and y. The values of x and y are shownat the left hand side and along the top.
0 10 1
1
10
0
xx
y yx y r0 0 00 1 11 0 01 1 1
![Page 14: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/14.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 14
Karnaugh MapsIn the Karnaugh map, each square corresponds to one of the fourcombinations of values of x and y. The values of x and y are shownat the left hand side and along the top.
0 10 1
1
10
0
xx
y yx y r0 0 00 1 11 0 01 1 1
![Page 15: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/15.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 15
Karnaugh MapsIn the Karnaugh map, each square corresponds to one of the fourcombinations of values of x and y. The values of x and y are shownat the left hand side and along the top.
0 10 1
1
10
0
xx
y yx y r0 0 00 1 11 0 01 1 1
The rows are labelled with and , and the columns with and ,to show which axis corresponds to which variable and also to indicatewhich minterm corresponds to which square in the grid.
x x y y
![Page 16: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/16.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 16
Karnaugh MapsIn the Karnaugh map, each square corresponds to one of the fourcombinations of values of x and y. The values of x and y are shownat the left hand side and along the top.
0 10 1
1
10
0
xx
y yx y r0 0 00 1 11 0 01 1 1
The rows are labelled with and , and the columns with and ,to show which axis corresponds to which variable and also to indicatewhich minterm corresponds to which square in the grid.
x x y y
minterm
yx
![Page 17: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/17.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 17
Karnaugh MapsIn the Karnaugh map, each square corresponds to one of the fourcombinations of values of x and y. The values of x and y are shownat the left hand side and along the top.
0 10 1
1
10
0
xx
y yx y r0 0 00 1 11 0 01 1 1
The rows are labelled with and , and the columns with and ,to show which axis corresponds to which variable and also to indicatewhich minterm corresponds to which square in the grid.
x x y y
minterm
yx
![Page 18: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/18.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 18
Karnaugh MapsIn the Karnaugh map, each square corresponds to one of the fourcombinations of values of x and y. The values of x and y are shownat the left hand side and along the top.
0 10 1
1
10
0
xx
y yx y r0 0 00 1 11 0 01 1 1
The rows are labelled with and , and the columns with and ,to show which axis corresponds to which variable and also to indicatewhich minterm corresponds to which square in the grid.
x x y y
minterm
yx
![Page 19: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/19.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 19
Karnaugh MapsIn the Karnaugh map, each square corresponds to one of the fourcombinations of values of x and y. The values of x and y are shownat the left hand side and along the top.
0 10 1
1
10
0
xx
y yx y r0 0 00 1 11 0 01 1 1
The rows are labelled with and , and the columns with and ,to show which axis corresponds to which variable and also to indicatewhich minterm corresponds to which square in the grid.
x x y y
mintermyx
![Page 20: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/20.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 20
Karnaugh Maps
0 10 1
1
10
0
xx
y y
From the Karnaugh map, we can write down a formula for r byOR-ing together the minterms corresponding to the squareswhich contain 1. xyyxr This can be factorised as
yxxr )(
and therefore simplifies to yr
This is just what we did for the majority voting function, but nownotice that the presence of in the formula has a visualinterpretation: there are two adjacent 1s in the y column, coveringboth the and squares.x x
xx
![Page 21: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/21.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 21
ExerciseDraw a Karnaugh map for the function
yxxr
x y r0 0 10 1 01 0 11 1 1
1 01 1
1
10
0
xx
y y
![Page 22: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/22.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 22
Simplification with K-MapsEach square in the K-map corresponds to a minterm. Each 1 by 2rectangle (either horizontal or vertical) corresponds to one of thevariables, either negated or non-negated.
Any collection of squares and rectangles which cover all the 1s,corresponds to a logical formula for the function defined by the K-map.
By choosing a covering in which the rectangles are as large aspossible (maybe overlapping), we obtain the simplest formula.
(What do we mean by “simplest”? We are trying to minimise thenumber of terms OR-ed together, and minimise the complexity ofeach term. This simplification process is often called minimisation.)
![Page 23: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/23.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 23
Simplification with K-MapsExample: the function yxxr has this K-map:
0 11 1
1
10
0
xx
y y
Different coverings of the 1s give different formulae.
![Page 24: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/24.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 24
Simplification with K-MapsExample: the function yxxr has this K-map:
0 11 1
1
10
0
xx
y y
Different coverings of the 1s give different formulae.
Three squares: yxxyyxr
![Page 25: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/25.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 25
Simplification with K-MapsExample: the function yxxr has this K-map:
0 11 1
1
10
0
xx
y y
Different coverings of the 1s give different formulae.
Three squares: yxxyyxr Square and horizontal rectangle: yxxr
![Page 26: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/26.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 26
Simplification with K-MapsExample: the function yxxr has this K-map:
0 11 1
1
10
0
xx
y y
Different coverings of the 1s give different formulae.
Three squares: yxxyyxr Square and horizontal rectangle: yxxr
Square and vertical rectangle: yxyr
![Page 27: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/27.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 27
Simplification with K-MapsExample: the function yxxr has this K-map:
0 11 1
1
10
0
xx
y y
Different coverings of the 1s give different formulae.
Three squares: yxxyyxr Square and horizontal rectangle: yxxr
Square and vertical rectangle: yxyr Horizontal and vertical rectangles: yxr
![Page 28: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/28.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 28
K-Maps for 3 VariablesThe Karnaugh map for a function of 3 variables consists of a grid of8 squares. Here is the K-map for the majority voting function.
0 00 1x
xy y
1 01 1
y y
z z z z
The 0s and 1s around the edges havebeen omitted. Remember that anegated label corresponds to 0 and anon-negated label to 1.
Notice that the negated ys appear in a different pattern from thenegated zs. This means that again each square corresponds to oneof the 8 minterms.
The three rectangles of 1s correspond to xy, yz and xz.
![Page 29: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/29.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 29
K-Maps for 3 VariablesThe Karnaugh map for a function of 3 variables consists of a grid of8 squares. Here is the K-map for the majority voting function.
0 00 1x
xy y
1 01 1
y y
z z z z
The 0s and 1s around the edges havebeen omitted. Remember that anegated label corresponds to 0 and anon-negated label to 1.
Notice that the negated ys appear in a different pattern from thenegated zs. This means that again each square corresponds to oneof the 8 minterms.
The three rectangles of 1s correspond to xy, yz and xz.
xy
![Page 30: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/30.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 30
K-Maps for 3 VariablesThe Karnaugh map for a function of 3 variables consists of a grid of8 squares. Here is the K-map for the majority voting function.
0 00 1x
xy y
1 01 1
y y
z z z z
The 0s and 1s around the edges havebeen omitted. Remember that anegated label corresponds to 0 and anon-negated label to 1.
Notice that the negated ys appear in a different pattern from thenegated zs. This means that again each square corresponds to oneof the 8 minterms.
The three rectangles of 1s correspond to xy, yz and xz.
yz
![Page 31: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/31.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 31
K-Maps for 3 VariablesThe Karnaugh map for a function of 3 variables consists of a grid of8 squares. Here is the K-map for the majority voting function.
0 00 1x
xy y
1 01 1
y y
z z z z
The 0s and 1s around the edges havebeen omitted. Remember that anegated label corresponds to 0 and anon-negated label to 1.
Notice that the negated ys appear in a different pattern from thenegated zs. This means that again each square corresponds to oneof the 8 minterms.
The three rectangles of 1s correspond to xy, yz and xz.
xz
![Page 32: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/32.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 32
K-Maps for 3 VariablesThe Karnaugh map for a function of 3 variables consists of a grid of8 squares. Here is the K-map for the majority voting function.
0 00 1x
xy y
1 01 1
y y
z z z z
The 0s and 1s around the edges havebeen omitted. Remember that anegated label corresponds to 0 and anon-negated label to 1.
Notice that the negated ys appear in a different pattern from thenegated zs. This means that again each square corresponds to oneof the 8 minterms.
The three rectangles of 1s correspond to xy, yz and xz. OR-ing themtogether gives the simplified formula for majority voting:
zxyzxy
![Page 33: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/33.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 33
Labelling 3 Variable K MapsIt is essential to label the rows and columns correctly, otherwise thetechnique of finding overlapping rectangles does not work.
xx
y y y y
z z z z
It must be the case that any two adjacent squares (including “wrappinground” from top to bottom) have labels which differ by negation ofexactly one variable. There are several labelling schemes which havethis property, but for safety you should memorise the labelling whichis used in the lecture notes.
![Page 34: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/34.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 34
Another ExampleWe will use a Karnaugh map to minimise the formula
zyxyzzyxzx First we fill in the K-map. The terms with two variables correspond to2 by 1 rectangles, and the other terms are just squares.
1 1xx
y y y y
z z z z
zx
![Page 35: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/35.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 35
Another ExampleWe will use a Karnaugh map to minimise the formula
zyxyzzyxzx First we fill in the K-map. The terms with two variables correspond to2 by 1 rectangles, and the other terms are just squares.
1 1xx
y y11
y y
z z z z
yz
![Page 36: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/36.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 36
Another ExampleWe will use a Karnaugh map to minimise the formula
zyxyzzyxzx First we fill in the K-map. The terms with two variables correspond to2 by 1 rectangles, and the other terms are just squares.
11 1x
xy y
11
y y
z z z z
zyx
![Page 37: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/37.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 37
Another ExampleWe will use a Karnaugh map to minimise the formula
zyxyzzyxzx First we fill in the K-map. The terms with two variables correspond to2 by 1 rectangles, and the other terms are just squares.
11 1x
xy y
11 1
y y
z z z z
zyx
![Page 38: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/38.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 38
Another ExampleWe will use a Karnaugh map to minimise the formula
zyxyzzyxzx First we fill in the K-map. The terms with two variables correspond to2 by 1 rectangles, and the other terms are just squares.
0 11 1x
xy y
1 01 1
y y
z z z z
The remaining squares are 0.
![Page 39: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/39.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 39
Another Example
0 11 1x
xy y
1 01 1
y y
z z z zNow we can find collections of rectangles which cover the 1s.
![Page 40: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/40.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 40
Another Example
0 11 1x
xy y
1 01 1
y y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles:
![Page 41: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/41.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 41
Another Example
0 11 1x
xy y
1 01 1
y y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: zx
![Page 42: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/42.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 42
Another Example
0 11 1x
xy y
1 01 1
y y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: yxzx
![Page 43: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/43.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 43
Another Example
0 11 1x
xy y
1 01 1
y y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx
![Page 44: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/44.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 44
Another Example
0 11 1x
xy y
1 01 1
y y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares:
![Page 45: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/45.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 45
Another Example
0 11 1x
xy y
1 01 1
y y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares: y
![Page 46: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/46.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 46
Another Example
0 11 1x
xy y
1 01 1
y y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares: zyxy
![Page 47: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/47.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 47
Another Example
0 11 1x
xy y
1 01 1
y y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares: zyxzyxy
![Page 48: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/48.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 48
Another Example
0 11 1
xy y
1 01
y
1
y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares: zyxzyxy Combining the two 1 by 1 squares:
x
yxy
![Page 49: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/49.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 49
Another Example
0 11 1
xy y
1 01
y
1
y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares: zyxzyxy Combining the two 1 by 1 squares:
x
yxy 4 by 1 and 2 by 1 rectangles:
![Page 50: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/50.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 50
Another Example
0 11 1
xy y
1 01
y
1
y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares: zyxzyxy Combining the two 1 by 1 squares:
x
yxy 4 by 1 and 2 by 1 rectangles: x
![Page 51: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/51.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 51
Another Example
0 11 1
xy y
1 01
y
1
y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares: zyxzyxy Combining the two 1 by 1 squares:
x
yxy 4 by 1 and 2 by 1 rectangles: yxx
![Page 52: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/52.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 52
Another Example
0 11 1
xy y
1 01
y
1
y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares: zyxzyxy Combining the two 1 by 1 squares:
x
yxy 4 by 1 and 2 by 1 rectangles: yxx 4 by 1 rectangle and 2 by 2 square:
![Page 53: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/53.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 53
Another Example
0 11 1
xy y
1 01
y
1
y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares: zyxzyxy Combining the two 1 by 1 squares:
x
yxy 4 by 1 and 2 by 1 rectangles: yxx 4 by 1 rectangle and 2 by 2 square: x
![Page 54: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/54.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 54
Another Example
0 11 1
xy y
1 01
y
1
y
z z z zNow we can find collections of rectangles which cover the 1s.
Three horizontal 2 by 1 rectangles: xzyxzx 2 by 2 square and two 1 by 1 squares: zyxzyxy Combining the two 1 by 1 squares:
x
yxy 4 by 1 and 2 by 1 rectangles: yxx 4 by 1 rectangle and 2 by 2 square: yx (the simplest formula)
![Page 55: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/55.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 55
ExerciseIn the same way, minimise the expression
zyxzyxy
![Page 56: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/56.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 56
ExerciseIn the same way, minimise the expression
zyxzyxy
xy y y y
z z z zx
Draw the Karnaugh map:
![Page 57: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/57.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 57
ExerciseIn the same way, minimise the expression
zyxzyxy
1x
y y
1
y y
z z z zx
Draw the Karnaugh map:
xy
![Page 58: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/58.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 58
ExerciseIn the same way, minimise the expression
zyxzyxy
1x
y y1
1
y
1
y
z z z zx
Draw the Karnaugh map:
zy
![Page 59: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/59.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 59
ExerciseIn the same way, minimise the expression
zyxzyxy
11
xy y
11
y
1
y
z z z zx
Draw the Karnaugh map:
zyx
![Page 60: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/60.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 60
ExerciseIn the same way, minimise the expression
zyxzyxy
1 00 1
xy y
0 11
y
1
y
z z z zx
Draw the Karnaugh map:
Cover the 1s with the largest possible rectangles:
![Page 61: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/61.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 61
1
ExerciseIn the same way, minimise the expression
zyxzyxy
00 1
y y0 11
y
1
y
z z z zx
Draw the Karnaugh map:
Cover the 1s with the largest possible rectangles:
yx
x
![Page 62: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/62.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 62
1
ExerciseIn the same way, minimise the expression
zyxzyxy
00 1
y y0 11
y
1
y
z z z zx
Draw the Karnaugh map:
Cover the 1s with the largest possible rectangles:
xyyx
x
![Page 63: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/63.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 63
1
ExerciseIn the same way, minimise the expression
zyxzyxy
00 1
y y0 11
y
1
y
z z z zx
Draw the Karnaugh map:
Cover the 1s with the largest possible rectangles:
xzxyyx
x
![Page 64: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/64.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 64
1
ExerciseIn the same way, minimise the expression
zyxzyxy
00 1
y y0 11
y
1
y
z z z zx
Draw the Karnaugh map:
Cover the 1s with the largest possible rectangles:
)( zyxyxxzxyyx
x
![Page 65: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/65.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 65
1
ExerciseIn the same way, minimise the expression
zyxzyxy
00 1
y y0 11
y
1
y
z z z zx
Draw the Karnaugh map:
Cover the 1s with the largest possible rectangles:
)( zyxyxxzxyyx
x
Alternatively:xyyzxzyxyyx )(
![Page 66: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/66.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 66
K-Maps for 4 VariablesA Karnaugh map for a function of 4 variables x, y, z, w uses thefollowing grid.
xy y y y
z z z zxxx
ww
w
w
The left and right columns are adjacent. The top and bottom rowsare adjacent. Larger K-maps can be constructed (e.g. for 5 variables,take 2 copies of this K-map, one labelled v and the other labelled v )but are less useful because it is more difficult to spot rectangles.
![Page 67: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/67.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 67
Example: Gray CodeGray code is an alternative binary counting sequence. The Gray codesequence for 3 bits is as follows:
0 0 00 0 10 1 10 1 01 1 01 1 11 0 11 0 0
At each step, exactly one bit is changed, andit is the rightmost bit such that a change producesa word which has not already occurred.
Exercise: use this rule to work out the Gray codesequence for other numbers of bits.
We will design a circuit to calculate the next 3 bitGray code. Given a 3 bit input xyz, the 3 bit outputx’y’z’ is the word which follows xyz in the Graycode sequence. For input 100 the output is 000.
![Page 68: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/68.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 68
Gray Code Truth TablesBy combining three truth tables we can show x’, y’ and z’ as functionsof x, y and z.
0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1
x y z0 0 10 1 11 1 00 1 00 0 01 0 01 1 11 0 1
x’ y’ z’
![Page 69: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/69.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 69
1
Gray Code Karnaugh MapsFor each of x’, y’, z’ we can draw a Karnaugh map and find aminimised formula.
For x’:
0 10 1
xy y
0 01
y
1
y
z z z zx
For y’:
0 10 1
xy y
1 10
y
0
y
z z z zx
For z’:
00 1
y y0 11
y
0
y
z z z zx
xzzyx
zxzyy
yxxyz
x
![Page 70: CS1Q Computer Systems Lecture 7 Simon Gay. Lecture 7CS1Q Computer Systems - Simon Gay2 Parity The parity of a binary word is determined by the number.](https://reader030.fdocuments.net/reader030/viewer/2022033105/56649f315503460f94c4bebf/html5/thumbnails/70.jpg)
Lecture 7 CS1Q Computer Systems - Simon Gay 70
Gray Code CircuitNotice that the expression occurs twice, so we can reduce thesize of the circuit by only calculating it once. Also notice that , which means that if XOR gates are available then thecircuit can be simplified further.
zy
yxz