Professional Documents
Culture Documents
solutions for
chapter 2
a) The truth table for a + b c is
solution 2.1
a
a+bc
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
0
1
0
1
1
1
1
xyz
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
1
0
1
0
0
1
b
0
0
0
0
1
1
1
c
0
0
1
1
0
0
1
d
0
1
0
1
0
1
0
a+b
0
0
0
0
1
1
1
c+d
1
0
0
0
1
0
0
(a + b) (c + d)
0
0
0
0
1
0
0
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
a
0
1
1
1
1
1
1
1
1
b
1
0
0
0
0
1
1
1
1
solution 2.2
c
1
0
0
1
1
0
0
1
1
d
1
0
1
0
1
0
1
0
1
a+b
1
1
1
1
1
1
1
1
1
c+d
0
1
0
0
0
1
0
0
0
a
b
c
b) The schematic diagram for x y z is:
x
y
z
c) The schematic diagram for ( a + b ) ( c + d ) is:
a
b
c
d
solution 2.3
(a + b) (c + d)
0
1
0
0
0
1
0
0
0
f = abc+abc+abc
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
solution 2.4
b
c
solution 2.5
x
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
0
1
1
1
0
0
1
solution 2.6
circuit is:
f = x y + (y z)
The Boolean equation in the form of a sum of minterms is:
f = xyz+xyz+xyz+xyz
The truth table is
solution 2.7
a
0
0
0
0
0
1
0
1
0
0
0
0
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
0
1
1
1
1
1
0
0
1
1
1
0
1
0
1
1
0
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
x (y z)
0
0
0
0
1
1
1
0
xy+xz
0
0
0
0
1
1
1
0
b) The truth table for x y and x y is shown below. Since the values
in each row for the two expressions are the same, the expressions are
equivalent.
x
0
0
1
1
y
0
1
0
1
xy
1
0
0
1
xy
1
0
0
1
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
solutions for chapter 2
solution 2.9
solution 2.10
x
0
0
1
y
0
1
solution 2.11
f0
f1
f2
f3
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
1
0
0
1
0
0
0
1
1
0
0
1
0
1
0
1
1
0
0
1
0
0
1
1
1
0
0
1
0
1
1
1
1
0
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
10
s o l u t i o n 2 . 1 2 In the following, the top two circuits are equivalent, and the bottom two circuits are equivalent:
x
y
z
x
y
x
z
x
y
z
x
y
x
z
solution 2.13
x+1
= x+x+x
= (x + x) 1 + x
= (x + x) (x + x) + x
= x + (x x) + x
= x+0+x
= x+x
=1
= x 1 + (x y)
= x (1 + y)
= x (y + 1)
= ...
= x1
=x
(w + y) (x + z) = (w y) (x + z)
= wyx+wyz
DeMorgan Law
Distributive Law
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
solutions for chapter 2
solution 2.15
abc+abc+abc+abc
= abc+abc+abc+abc+abc+abc
Idempotence twice
= abc+abc+abc+abc+abc+abc
Commutative
= abc+abc+bac+bac+cab+cab
Commutative
= (a + a) b c + (b + b) a c + (c + c) a b
Distributive
Complement
Identity
Commutative
= 1bc+1ac+1ab
= bc+ac+ab
ab+bc+ac
solution 2.16
11
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
12
solution 2.18
off_hook,
p );
p[0] |
~p[0] |
p[0] |
~p[0] |
p[0];
s o l u t i o n 2 . 2 1 The equations for green and yellow are unchanged, since they only activate the respective lights on valid one-hot
code words. The equation for red must be revised to include only the first
term that activates the red light on the valid one-hot code word for red.
The equations are:
green = s_red s_yellow s_green
yellow = s_red s_yellow s_green
red = s_red s_yellow s_green
s o l u t i o n 2 . 2 2 Since odd parity is the logical negation of even
parity, we can form the parity trees for odd parity by negating the output
of the parity trees for even parity. We can do this by substituting an
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
13
XNOR gate for the XOR gate that produces the output of the tree. The
odd-parity generator (left) and checker (right) are:
a0
a1
a2
a3
a4
a5
a6
a7
a0
a1
a2
a3
a4
a5
a6
a7
p
s o l u t i o n 2 . 2 3 Suppose we have a code word 00000000. Augmenting this with an even parity bit gives 000000000 and with an odd
parity bit gives 00000001. (The parity bit is the rightmost bit in both cases.) Now suppose the leftmost two bits of each augmented code word are
flipped. The corrupted code words are 110000000 and 110000001,
which have even and odd parity, respectively, as expected for uncorrupted
code words. Thus, the errors are not detected.
s o l u t i o n 2 . 2 4 For an encoded 3-bit input signal, (i2, i1, i0), the
Boolean equations for the decoded outputs are:
z1 = i2 i1 i0
z2 = i2 i1 i0
z3 = i2 i1 i0
z4 = i2 i1 i0
z5 = i2 i1 i0
z6 = i2 i1 i0
z7 = i2 i1 i0
z8 = i2 i1 i0
solution 2.25
[1:8] z,
[2:0] i );
& ~i[0];
& i[0];
& ~i[0];
error
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
14
assign z[4]
assign z[5]
assign z[6]
assign z[7]
assign z[8]
endmodule
s o l u t i o n 2 . 2 6 The Boolean equations to produce a 3-bit encoded signal (c2, c1, c0) are:
c 2 = yellow light_cyan light_magenta
c 1 = cyan magenta light_magenta
c 0 = black magenta light_cyan
For pairs of inputs both being 1, the resulting code words are:
black and cyan: (0, 1, 1) = magenta
black and magenta: (0, 1, 1) = magenta
black and yellow: (1, 0, 1) = light_cyan
black and light_cyan: (1, 0, 1) = light_cyan
black and light_magenta: (1, 1, 1) = illegal code word
cyan and magenta: (0, 1, 1) = magenta
cyan and yellow: (1, 1, 0) = light_magenta
cyan and light_cyan: (1, 1, 1) = illegal code word
cyan and light_magenta: (1, 1, 0) = light_magenta
magenta and yellow: (1, 1, 1) = illegal code word
magenta and light_cyan: (1, 1, 1) = illegal code word
magenta and light_magenta: (1, 1, 1) = illegal code word
yellow and light_cyan: (1, 0, 1) = light_cyan
yellow and light_magenta: (1, 1, 0) = light_magenta
light_cyan and light_magenta: (1, 1, 1) = illegal code word
s o l u t i o n 2 . 2 7 Since no priority ordering is specified, we assume the following order, from highest to lowest priority: black, cyan,
magenta, yellow, light cyan, light magenta. For the inputs, color[1] is
black, color[2] is cyan, etc.
module ink_encoder (output [2:0] encoded_color,
output
valid,
input [1:6] color);
assign encoded_color = color[1]
color[2]
color[3]
color[4]
color[5]
?
?
?
?
?
3'b001
3'b010
3'b011
3'b100
3'b101
:
:
:
:
:
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
solutions for chapter 2
color[6] ? 3'b110 :
3'b000;
assign valid = color[1] | color[2] | color[3] |
color[4] | color[5] | color[6];
endmodule
s o l u t i o n 2 . 2 8 For a 4-bit BCD input signal, (i3, i2, i1, i0), the
Boolean equations for the decoded outputs are:
y0 = i3 i2 i1 i0
y1 = i3 i2 i1 i0
y2 = i3 i2 i1 i0
y3 = i3 i2 i1 i0
y4 = i3 i2 i1 i0
y5 = i3 i2 i1 i0
y6 = i3 i2 i1 i0
y7 = i3 i2 i1 i0
y8 = i3 i0
y9 = i3 i0
We assume here that invalid input code words cannot occur, and so we
have simplified the equations for y8 and y9. A circuit for the decoder is:
15
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
16
i0
i1
i2
i3
y0
y1
y2
y3
y4
y5
y6
y7
y8
y9
solution 2.29
y[0]
y[1]
y[2]
y[3]
y[4]
y[5]
y[6]
y[7]
y[8]
y[9]
endmodule
=
=
=
=
=
=
=
=
=
=
~i[3]
~i[3]
~i[3]
~i[3]
~i[3]
~i[3]
~i[3]
~i[3]
i[3]
i[3]
&
&
&
&
&
&
&
&
~i[2]
~i[2]
~i[2]
~i[2]
i[2]
i[2]
i[2]
i[2]
&
&
&
&
&
&
&
&
~i[1]
~i[1]
i[1]
i[1]
~i[1]
~i[1]
i[1]
i[1]
&
&
&
&
&
&
&
&
&
&
~i[0];
i[0];
~i[0];
i[0];
~i[0];
i[0];
~i[0];
i[0];
~i[0];
i[0];
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
solutions for chapter 2
s o l u t i o n 2 . 3 0 For a multiplexer with data inputs a0 and a1, select input s, and data output y, the Boolean equation is:
y = s a0 + s a1
A circuit to implement a multiplexer is:
a0
y
a1
s
solution 2.31
The circuit is
x
y
a
b
c
enable
sel
solution 2.32
0
1
17
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
18
solution 2.33
0
1
2
3
z(0)
0
1
2
3
z(1)
0
1
2
3
z(2)
sel(1...0)
solution 2.34
=
=
=
=
a0;
a1;
a2;
a3;
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
solutions for chapter 2
solution 2.35
>30C
vat 0
>25C
low level
0
buzzer
>30C
+V
vat 1
select vat 1
>25C
select vat 0
low level
solution 2.36
module vat_buzzer_n_struct
( output buzzer_n,
input above_25_0, above_30_0, low_level_0_n,
input above_25_1, above_30_1, low_level_1_n,
input select_vat_1 );
wire low_level_0, below_25_0, temp_bad_0, wake_up_0;
wire low_level_1, below_25_1, temp_bad_1, wake_up_1;
wire buzzer;
// components for vat 0
not inv_0a (low_level_0, low_level_0_n);
not inv_0b (below_25_0, above_25_0);
or or_0a (temp_bad_0, above_30_0, below_25_0);
or or_0b (wake_up_0, temp_bad_0, low_level_0);
// components for vat 1
not inv_1a (low_level_1, low_level_1_n);
not inv_1b (below_25_1, above_25_1);
or or_1a (temp_bad_1, above_30_1, below_25_1);
or or_1b (wake_up_1, temp_bad_1, low_level_1);
mux2 select_mux (buzzer,
select_vat_1, wake_up_0, wake_up_1);
19
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
20
not
inv_out
(buzzer_n, buzzer);
endmodule
solution 2.37
in Example 1.5 is:
`timescale 1ms/1ms
module vat_buzzer_testbench;
wire buzzer;
reg above_25_0, above_30_0, low_level_0,
above_25_1, above_30_1, low_level_1,
select_vat_1;
task apply_test
( input above_25_0_test, above_30_0_test,
low_level_0_test,
above_25_1_test, above_30_1_test,
low_level_1_test,
select_vat_1_test );
begin
above_25_0
= above_25_0_test;
above_30_0
= above_30_0_test;
low_level_0 = low_level_0_test;
above_25_1
= above_25_1_test;
above_30_1
= above_30_1_test;
low_level_1 = low_level_1_test;
select_vat_1 = select_vat_1_test;
#1000;
end
endtask
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
solutions for chapter 2
21
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog 21 September 2007.
2007 by Elsevier Inc. Reproduced with permission from the publisher.
22
The testbench for the behavioral design in Example 1.6 is the same, except
that the module name vat_buzzer_struct is replaced by
vat_buzzer_behavior in the instantiation of the design under verification.