# CS/ECE 252 Introduction to Computer Engineering

Spring 2013 Section 1 & 2
Instructors Mark D. Hill and Guri Sohi
TAs Preeti Agarwal, Mona Jalal, Rebecca Lam, Pradip Vallathol

URLs: http://www.cs.wisc.edu/~markhill/cs252/Spring2013/ and http://www.cs.wisc.edu/~sohi/cs252/Spring2013/

## Homework 3 [Due at lecture on Wed, Feb 20]

Primary contact for this homework: Rebecca Lam rjlam@cs.wisc.edu

You must work in groups of two for this homework. Please write the full name (as it appears on Learn@UW) and the student ID of each group member on every page and staple multiple pages together.

### Problem 1 (2 points)

Convert the following string (only the characters within the quotes) into its ASCII representation: "T4k*". Represent each character in hexadecimal. Assume that the string is null terminated.

T=0x54 4=0x34 k=0x6B *=0x2A null=0x00
"T4k*"=0x54 34 6B 2A 00

### Problem 2 (6 points)

Given the following transistor level circuit:

1. (2 points) Fill out the truth table for Z.
 A B Z 0 0 1 0 1 0 1 0 1 1 1 1
2. (2 points) Give the equation for Z in terms of A and B.

Z = [NOT (A) AND NOT(B)] OR [A AND NOT(B)] OR [A AND B] (full expression)
Z = NOT( NOT(A) AND B) = A OR NOT(B) (reduced exp.)

3. (2 points) Draw the gate-level circuit for Z using 2-input AND/OR gates and NOT gates.

### Problem 3 (4 points)

Given the logic equation Z = (NOT A) OR ( NOT( A AND ( NOT(B) ) ) )

1. (2 points) Fill out the truth table for Z.
 A B Z 0 0 1 0 1 1 1 0 0 1 1 1
2. (2 points) Draw the gate-level circuit for Z using 2-input AND/OR gates and NOT gates.

Z = [NOT (A) AND NOT (B)] OR [NOT(A) AND B] OR [A AND B] (full exp)
Z = NOT (A) OR B (reduced exp)

### Problem 4 (6 points)

Given the logic equation Z = NOT( NOT (A AND B) OR ( NOT( B AND A ) ) )

1. (2 points) Fill out the truth table for Z
 A B Z 0 0 0 0 1 0 1 0 0 1 1 1
2. (2 points) Draw the gate-level circuit for Z using 2-input AND/OR gates and NOT gates.

3. (2 points) Draw the transistor-level equivalent of the circuit from part b.

### Problem 5 (6 points)

Suppose A, B, and C are inputs to logic function Z with the following truth table:

 A B C Z 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1
1. (4 points) Draw the gate-level circuit using NOT gates and 3-input AND/OR gates.

Z = [NOT (A) AND NOT(B) AND C] OR [A AND NOT (B) AND C] OR [A AND B AND C]

2. (2 points) Convert the circuit of part a into one that uses only NAND gates. (Hint: DeMorgan's law)

### Problem 6 (6 points)

Assume that A, B, and C are 3 bits that represent an unsigned integer, where A is the highest bit and C is the lowest bit (e.g. 310 = 0112=ABC where A=0, B=1, C=1). Suppose A, B, and C are inputs to a logic function that outputs Z = 1 when the number represented by ABC is a prime number greater than 1.

1. (4 points) Fill out the truth table for Z
 A B C Z 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1
2. (2 points) Write the logic expression for Z in terms of A, B, and C

Z = [NOT (A) AND B AND NOT(C)] OR [NOT (A) AND B AND C] OR [A AND NOT (B) AND C] OR [A AND B AND C] (full expression)
Z = [NOT (A) AND B] OR [A AND C] (reduced)

Computer Sciences | UW Home
 Page last modified: Thursday, 21-Feb-2013 08:18:42 CST Feedback or content questions: send email to sohi@cs.wisc.edu Technical or accessibility issues: lab@cs.wisc.edu Copyright © 2002, 2003 The Board of Regents of the University of Wisconsin System.