Solutions for Appendix C Exercises

Similar documents
Chapter 5 Arithmetic Circuits

Binary addition by hand. Adding two bits

L8/9: Arithmetic Structures

CS 140 Lecture 14 Standard Combinational Modules

CSE140: Components and Design Techniques for Digital Systems. Decoders, adders, comparators, multipliers and other ALU elements. Tajana Simunic Rosing

Binary addition (1-bit) P Q Y = P + Q Comments Carry = Carry = Carry = Carry = 1 P Q

Hardware Design I Chap. 4 Representative combinational logic

Midterm Exam Two is scheduled on April 8 in class. On March 27 I will help you prepare Midterm Exam Two.

Adders, subtractors comparators, multipliers and other ALU elements

14:332:231 DIGITAL LOGIC DESIGN. 2 s-complement Representation

UNIT 8A Computer Circuitry: Layers of Abstraction. Boolean Logic & Truth Tables

Carry Look Ahead Adders

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING UNIT 3 - ARITMETHIC-LOGIC UNIT JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

Boolean Algebra and Digital Logic 2009, University of Colombo School of Computing

CprE 281: Digital Logic

ARITHMETIC COMBINATIONAL MODULES AND NETWORKS

EECS150 - Digital Design Lecture 24 - Arithmetic Blocks, Part 2 + Shifters

CSE 140 Spring 2017: Final Solutions (Total 50 Points)

Linear Feedback Shift Registers (LFSRs) 4-bit LFSR

Adders, subtractors comparators, multipliers and other ALU elements

Binary Multipliers. Reading: Study Chapter 3. The key trick of multiplication is memorizing a digit-to-digit table Everything else was just adding

Logic and Computer Design Fundamentals. Chapter 5 Arithmetic Functions and Circuits

Chapter 03: Computer Arithmetic. Lesson 03: Arithmetic Operations Adder and Subtractor circuits Design

3. Combinational Circuit Design

Lecture 5: Arithmetic

EC 413 Computer Organization

Overview. Arithmetic circuits. Binary half adder. Binary full adder. Last lecture PLDs ROMs Tristates Design examples

EECS150 - Digital Design Lecture 23 - FSMs & Counters

BOOLEAN ALGEBRA. Introduction. 1854: Logical algebra was published by George Boole known today as Boolean Algebra

Review Problem 1. should be on. door state, false if light should be on when a door is open. v Describe when the dome/interior light of the car

Appendix B. Review of Digital Logic. Baback Izadi Division of Engineering Programs

EECS150 - Digital Design Lecture 11 - Shifters & Counters. Register Summary


Chapter 1: Solutions to Exercises

Chapter 4. Combinational: Circuits with logic gates whose outputs depend on the present combination of the inputs. elements. Dr.

ECE 2300 Digital Logic & Computer Organization

Arithmetic and Logic Unit First Part

Parity Checker Example. EECS150 - Digital Design Lecture 9 - Finite State Machines 1. Formal Design Process. Formal Design Process

CSE 140 Midterm 3 version A Tajana Simunic Rosing Spring 2015

Chapter 5. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 5 <1>

Systems I: Computer Organization and Architecture

CHAPTER 7. Exercises 17/ / /2 2 0

EECS 270 Midterm Exam 2 Fall 2009

Module 2. Basic Digital Building Blocks. Binary Arithmetic & Arithmetic Circuits Comparators, Decoders, Encoders, Multiplexors Flip-Flops

Total time is: 1 setup, 2 AND, 3 XOR, 1 delay = (1*1) + (2*2) + (3*3) + (1*1) = 15ns

CSE 20 Discrete Math. Algebraic Rules for Propositional Formulas. Summer, July 11 (Day 2) Number Systems/Computer Arithmetic Predicate Logic

UNIVERSITI TENAGA NASIONAL. College of Information Technology

Models for representing sequential circuits

Computer Architecture. ESE 345 Computer Architecture. Design Process. CA: Design process

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

Design of Sequential Circuits

Numbers and Arithmetic

CprE 281: Digital Logic

Module half adder module half_adder(output S,C,input x,y); xor(s,x,y); and(c,x,y); endmodule

Total Time = 90 Minutes, Total Marks = 50. Total /50 /10 /18

CS61C : Machine Structures

Computer Architecture. ECE 361 Lecture 5: The Design Process & ALU Design. 361 design.1

ECE/Comp Sci 352 Digital Systems Fundamentals. Charles R. Kime Section 2 Fall Logic and Computer Design Fundamentals

CSEE 3827: Fundamentals of Computer Systems. Combinational Circuits

Combinational Logic. Mantıksal Tasarım BBM231. section instructor: Ufuk Çelikcan

Tree and Array Multipliers Ivor Page 1

Binary addition example worked out

Sequential Logic Worksheet

Combinational Logic Design Arithmetic Functions and Circuits

EECS150. Arithmetic Circuits

Digital Integrated Circuits A Design Perspective. Arithmetic Circuits. Jan M. Rabaey Anantha Chandrakasan Borivoje Nikolic.

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec 09 Counters Outline.

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

Digital Design for Multiplication

Chapter 2 Basic Arithmetic Circuits

Number representation

ALU (3) - Division Algorithms

ECE 545 Digital System Design with VHDL Lecture 1. Digital Logic Refresher Part A Combinational Logic Building Blocks

IT T35 Digital system desigm y - ii /s - iii

EECS150 - Digital Design Lecture 25 Shifters and Counters. Recap

Lecture 12: Adders, Sequential Circuits

ELEN Electronique numérique

For smaller NRE cost For faster time to market For smaller high-volume manufacturing cost For higher performance

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

Lecture 10: Synchronous Sequential Circuits Design

EECS Components and Design Techniques for Digital Systems. FSMs 9/11/2007

1 Short adders. t total_ripple8 = t first + 6*t middle + t last = 4t p + 6*2t p + 2t p = 18t p

Hakim Weatherspoon CS 3410 Computer Science Cornell University

COE 202: Digital Logic Design Combinational Circuits Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

This Unit: Arithmetic. CIS 371 Computer Organization and Design. Pre-Class Exercise. Readings

EXPERIMENT Bit Binary Sequential Multiplier

9. Datapath Design. Jacob Abraham. Department of Electrical and Computer Engineering The University of Texas at Austin VLSI Design Fall 2017

CS61c: Representations of Combinational Logic Circuits

CSC 322: Computer Organization Lab

Problem Set 6 Solutions

Chapter 5. Digital systems. 5.1 Boolean algebra Negation, conjunction and disjunction

EECS150 - Digital Design Lecture 16 Counters. Announcements

Department of Electrical and Computer Engineering University of Wisconsin - Madison. ECE/CS 352 Digital System Fundamentals.

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec09 Counters Outline.

CMPUT 329. Circuits for binary addition

Class Website:

hexadecimal-to-decimal conversion

Numbers and Arithmetic

CPE100: Digital Logic Design I

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

Transcription:

C Solutions for Appix C Exercises 1 Solutions for Appix C Exercises C.1 A B A B A + B A B A B A + B 0 0 1 1 1 1 1 1 0 1 1 0 0 0 1 1 1 0 0 1 0 0 1 1 1 1 0 0 0 0 0 0 C.2 Here is the first equation: E = (( A B) + ( A +( ) ( A. Now use DeMorgan s theorems to rewrite the last factor: E = (( A B) + ( A +( ) ( A+ B+ Now distribute the last factor: E = (( A B) ( A+ B+ ) + (( A ( A+ B+ ) +( ( ( A+ B+ ) Now distribute within each term; we show one example: (( A B) ( A+ B+ ) = ( A A) + ( A B) + ( A = 0+ 0+( A (This is simply A C.) Thus, the equation above becomes E = ( A + ( A +( A, which is the desired result.

CCC 2 Solutions for Appix C Exercises C.7 Four inputs & F (O/P) = 1 if an odd number of 1s exist in A. F 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 C.8 F = + + ' + + + + + Note: F = XOR XOR XOR. Another question can ask the students to prove that.

Solutions for Appix C Exercises 3 F

4 Solutions for Appix B Exercises C.9 OR Plane C.10 No solution provided.

Solutions for Appix C Exercises 5 C.11 x2 x1 x0 F1 F2 F3 F4 0 0 0 0 0 1 0 0 0 1 0 1 1 0 0 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 0 0 1 0 1 1 0 1 1 0 0 1 1 1 0 1 0 0 1 1 1 1 0 1 0 1 F1 = X2 X1 X0 + X2 X1 X0 + X2 X1 X0 F2 = X2 X1 X0 + X2 X1 X0 + X2 X1 X0 + X2 X1 X0 = (A XOR B XOR F3 = X2 F4 = X2 (= F3 )

6 Solutions for Appix C Exercises C.12 X0 X1 X2 F1 F2 F3 F4

Solutions for Appix C Exercises 7 C.13 x2y2 + x2y2x1y1 + x2y2x1y1x0y0 + x2y2x1y1 + x2y2x1y1x0y0 + x2y2x1y1x0y0 + x2y2x1y1x0y0 + x2y2x1y1x0y0 x2y2 + x2y2x1y1 + x2y2x1y1x0y0 + x2y2x1y1 + x2y2x1y1x0y0 + x2y2x1y1x0y0 + x2y2x1y1x0y0 ( x2y2 + x2y2) ( x1y1 + x1y1) ( x0y0 + x0y0) C.14 B A 0 Mu x 1 C A B 0 Mu x 1 D S C.15 Generalizing DeMorgan s theorems for this exercise, if A+ B = A B, then A+ B+ C = A+ ( B + = A ( B+ = A ( = A C. Similarly, A C = A ( = A + B C = A ( B + = A + B + C. Intuitively, DeMorgan s theorems say that (1) the negation of a sum-of-products form equals the product of the negated sums, and (2) the negation of a productof-sums form equals the sum of the negated products. So, E = E = ( A + ( A C B) +( C A) = ( A ( A C B) ( C A) ; first application of DeMorgan s theorem = ( A+ B+ ( A+ C+ B) ( B+ C+ A) ; second application of DeMorgan s theorem and product-of-sums form C.16 No solution provided.

8 Solutions for Appix C Exercises C.18 2-1 multiplexor and 8 bit up/down counter. C.19 module LATCH(clock,D,Q,Qbar) input clock,d; reg Q; wire Qbar; assign Qbar = ~Q; always @(D,clock) //senstivity list watches clock and data begin if(clock) Q = D; module C.20 module decoder (in, out, enable); input [1:0] in; input enable output [3:0] out; reg [3:0] out; always @ (enable, in) if (enable) begin out = 0; case (in) 2'h0 : out = 4'h1; 2'h1 : out = 4'h2; 2'h2 : out = 4'h4; 2'h3 : out = 4'h8; case module

Solutions for Appix C Exercises 9 C.21 module ACC(Clk, Rst, Load, IN, LOAD, OUT); input Clk, Rst, Load; input [3:0] IN; input [15:0] LOAD output [15:0] OUT; wire [15:0] W; reg [15:0] Register; initial begin Register = 0; assign W = IN + OUT; always @ (Rst,Load) begin if Rst begin Register = 0; if Load begin Register = LOAD; always @ (Clk) begin Register <= W; module

10 Solutions for Appix C Exercises C.22 We use Figure 3.5 to implement the multiplier. We add a control signal "load" to load the multiplicand and the multiplier. The load signal also initiates the multiplication. An output signal "done" indicates that simulation is done. module MULT(clk, load, Multiplicand, Multiplier, Product, done); input clk, load; input [31:0] Multiplicand, Multiplier; output [63:0] Product; output done; reg [63:0] A, Product; reg [31:0] B; reg [5:0] loop; reg done; initial begin done = 0; loop = 0; always @(posedge clk) begin if (load && loop ==0) begin done <= 0; Product <=0; A <= Multiplicand; B <= Multiplier; loop <= 32; if(loop > 0) begin if(b[0] == 1) Product <= Product + A; A <= A << 1; B <= B >> 1; loop <= loop -1; if(loop == 0) done <= 1; module

Solutions for Appix B Exercises 11 C.23 We use Figure 3.10 for divider implementation, with additions similar to the ones listed above in the answer for Exercise B.22. module DIV(clk, load, Divisor, Divid, Quotient, Remainder, done); input clk, load; input [31:0] Divisor; input [63:0] Divid; output [31:0] Quotient; input [31:0] Remainder; output done; reg [31:0] Quotient; reg [63:0] D, R; reg [6:0] loop; reg done; //Quotient //Divisor, Remainder //Loop counter initial begin done = 0; loop = 0; assign Remainder = R[31:0]; always @(posedge clk) begin if (load && loop ==0) begin done <= 0; R <=Divid; D <= Divisor << 32; Quotient <=0; loop <= 33; if(loop > 0) begin if(r D >= 0) begin Quotient <= (Quotient << 1) + 1; R <= R D; else begin Quotient <= Quotient << 1; D <= D >> 1; loop <= loop 1;

12 Solutions for Appix C Exercises if(loop == 0) done <= 1; module Note: This code does not check for division by zero (i.e., when Divisior = = 0) or for quotient overflow (i.e., when Divisior < = Dividi [64:32]). C.24 The ALU-supported set less than (slt) uses just the sign bit. In this case, if we try a set less than operation using the values 7 ten and 6 ten, we would get 7 > 6. This is clearly wrong. Modify the 32-bit ALU in Figure 4.11 on page 169 to handle slt correctly by factor in overflow in the decision. If there is no overflow, the calculation is done properly in Figure 4.17 and we simply use the sign bit (Result31). If there is overflow, however, then the sign bit is wrong and we need the inverse of the sign bit. Overflow Result31 LessThan 0 0 0 0 1 1 1 0 1 1 1 0 LessThan = Overflow Result31 Overflow Result31 LessThan Overflow Result31 LessThan 0 0 0 0 1 1 1 0 1 1 1 0

Solutions for Appix C Exercises 13 C.25 Given that a number that is greater than or equal to zero is termed positive and a number that is less than zero is negative, inspection reveals that the last two rows of Figure 4.44 restate the information of the first two rows. Because A B = A + ( B), the operation A B when A is positive and B negative is the same as the operation A + B when A is positive and B is positive. Thus the third row restates the conditions of the first. The second and fourth rows refer also to the same condition. Because subtraction of two s complement numbers is performed by addition, a complete examination of overflow conditions for addition suffices to show also when overflow will occur for subtraction. Begin with the first two rows of Figure 4.44 and add rows for A and B with opposite signs. Build a table that shows all possible combinations of Sign and CarryIn to the sign bit position and derive the CarryOut, Overflow, and related information. Thus, Sign A Sign B Carry In Carry Out Sign of result Correct sign of result Overflow? Carry In XOR Carry Out Notes 0 0 0 0 0 0 No 0 0 0 1 0 1 0 Yes 1 Carries differ 0 1 0 0 1 1 No 0 A < B 0 1 1 1 0 0 No 0 A > B 1 0 0 0 1 1 No 0 A > B 1 0 1 1 0 0 No 0 A < B 1 1 0 1 0 1 Yes 1 Carries differ 1 1 1 1 1 1 No 0 From this table an Exclusive OR (XOR) of the CarryIn and CarryOut of the sign bit serves to detect overflow. When the signs of A and B differ, the value of the CarryIn is determined by the relative magnitudes of A and B, as listed in the Notes column. C.26 C1 = c4, C2 = c8, C3 = c12, and C4 = c16. c4 = G 3,0 + (P 3,0 c0). c8 is given in the exercise. c12 = G 11,8 + (P 11,8 G 7,4 ) + (P 11,8 P 7,4 G 3,0 ) + (P 11,8 P 7,4 P 3,0 c0). c16 = G 15,12 + (P 15,12 G 11,8 ) + (P 15,12 P 11,8 G 7,4 ) + (P 15,12 P 11,8 P 7,4 G 3,0 ) + (P 15,12 P 11,8 P 7,4 P 3,0 c0).

14 Solutions for Appix C Exercises C.27 The equations for c4, c8, and c12 are the same as those given in the solution to Exercise 4.44. Using 16-bit adders means using another level of carry lookahead logic to construct the 64-bit adder. The second level generate, G0, and propagate, P0, are G0 = G 15,0 = G 15,12 + P 15,12 G 11,8 + P 15,12 P 11,8 G 7,4 + P 15,12 P 11,8 P 7,4 G 3,0 and P0 = P 15,0 = P 15,12 P 11,8 P 7,4 P 3,0 Using G0 and P0, we can write c16 more compactly as and c16 = G 15,0 + P 15,0 c0 c32 = G 31,16 + P 31,16 c16 c48 = G 47,32 + P 47, 32 c32 c64 = G 63,48 + P 63,48 c48 A 64-bit adder diagram in the style of Figure B.6.3 would look like the following:

Solutions for Appix C Exercises 15 CarryIn a0 b0 a1 b1 a2 b2 a3 b3 CarryIn ALU0 P0 G0 C1 pi gi ci + 1 Result0 3 Carry-lookahead unit a4 b4 a5 b5 a6 b6 a7 b7 CarryIn ALU1 P1 G1 C2 pi + 1 gi + 1 ci + 2 Result4 7 a8 b8 a9 b9 a10 b10 a11 b11 CarryIn ALU2 P2 G2 C3 pi + 2 gi + 2 ci + 3 Result8 11 a12 b12 a13 b13 a14 b14 a15 b15 CarryIn ALU3 P3 G3 C4 pi + 3 gi + 3 ci + 4 Result12 15 CarryOut FIGURE C.6.3 Four 4-bit ALUs using carry lookahead to form a 16-bit adder. Note that the carries come from the carry-lookahead unit, not from the 4-bit ALUs.

16 Solutions for Appix C Exercises C.28 No solution provided. C.29 No solution provided. C.30 No solution provided. C.31 No solution provided. C.32 No solution provided. C.33 No solution provided. C.34 The longest paths through the top (ripple carry) adder organization in Figure B.14.1 all start at input a0 or b0 and pass through seven full adders on the way to output s4 or s5. There are many such paths, all with a time delay of 7 2T = 14T. The longest paths through the bottom (carry save) adder all start at input b0, e0, f0, b1, e1, or f1 and proceed through six full adders to outputs s4 or s5. The time delay for this circuit is only 6 2T = 12T.