Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.

Slides:



Advertisements
Similar presentations
//HDL Example 4-10 // //Gate-level description of circuit of Fig. 4-2 module analysis (A,B,C,F1,F2); input.
Advertisements

Figure 4.1. The function f (x1, x2, x3) =  m(0, 2, 4, 5, 6).
Lecture Adders Half adder.
Arithmetic Operations and Circuits
Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design.
ECE 331 – Digital System Design
Lecture 9 Sept 28 Chapter 3 Arithmetic for Computers.
1 COMP541 Arithmetic Circuits Montek Singh Mar 20, 2007.
ECE 301 – Digital Electronics
ECE 301 – Digital Electronics
ECE 301 – Digital Electronics
ECE 331 – Digital System Design
Chapter 7 Arithmetic Operations and Circuits Hexadecimal Arithmetic 4 binary bits represent a single hexadecimal digit Addition –Add the digits.
Arithmetic Operations and Circuits
CS 105 Digital Logic Design
Calculator Lab Overview Note: Slides Updated 10/8/12
Combinational Logic in Verilog
Outline Analysis of Combinational Circuits Signed Number Arithmetic
Figure 6.1. A 2-to-1 multiplexer.
Arithmetic Chapter 4.
Digital Arithmetic and Arithmetic Circuits
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
1 Chapter 4 Combinational Logic Logic circuits for digital systems may be combinational or sequential. A combinational circuit consists of input variables,
Chapter 6-1 ALU, Adder and Subtractor
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
Figure 5.1 Conversion from decimal to binary. Table 5.1 Numbers in different systems.
1 Adders & Subtractors Adders –An adder is a combinational logic circuit that performs the addition of 2 binary numbers (A & B) to generate the sum (S)
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Digital System Ch4-1 Chapter 4 Combinational Logic Ping-Liang Lai ( 賴秉樑 ) Digital System 數位系統.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
EEE2243 Digital System Design Chapter 3: Verilog HDL (Combinational) by Muhazam Mustapha, January 2011.
Computer Organization Department of CSE, SSE Mukka Chapter 6 : ARITHMETIC | Website for students | VTU NOTES.
Use of HDLs in Teaching of Computer Hardware Courses Zvonko Vranesic and Stephen Brown University of Toronto.
1 CS 151: Digital Design Chapter 4: Arithmetic Functions and Circuits 4-1,2: Iterative Combinational Circuits and Binary Adders.
Number Systems and Circuits for Addition Lecture 5 Section 1.5 Thu, Jan 26, 2006.
Topics covered: Arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Digital Design Module –II Adders Amit Kumar Assistant Professor SCSE, Galgotias University, Greater Noida.
ECE 331 – Digital System Design Multi-bit Adder Circuits, Adder/Subtractor Circuit, and Multiplier Circuit (Lecture #12)
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 5: Arithmetic Circuits Chapter 5 (minus 5.3.4)
C-H1 Lecture Adders Half adder. C-H2 Full Adder si is the modulo- 2 sum of ci, xi, yi.
Logic Design CS221 1 st Term combinational circuits Cairo University Faculty of Computers and Information.
Number Systems and Circuits for Addition – Binary Adders Lecture 6 Section 1.5 Fri, Jan 26, 2007.
Verilog hdl – II.
Number Representation and Arithmetic Circuits
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
CS151 Introduction to Digital Design Chapter 4: Arithmetic Functions and HDLs 4-1: Iterative Combinational Circuits 4-2: Binary Adders 1Created by: Ms.Amany.
Electrical Engineering Engineering the Future Digital Circuits Fundamentals Hands-on Full-Adder Simulation (afternoon)
Logic Design (CE1111 ) Lecture 4 (Chapter 4) Combinational Logic Prepared by Dr. Lamiaa Elshenawy 1.
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
1 Digital Logic Design (41-135) Chapter 5 Number Representation & Arithmetic Circuits Younglok Kim Dept. of Electrical Engineering Sogang University Spring.
Gunjeet Kaur Dronacharya Group of Institutions. Binary Adder-Subtractor A combinational circuit that performs the addition of two bits is called a half.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Supplement on Verilog adder examples
Lecture 2 Supplement Verilog-01
Reference: Moris Mano 4th Edition Chapter 4
ECE 331 – Digital System Design
FIGURE 4.1 Block diagram of combinational circuit
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Chapter 5 – Number Representation and Arithmetic Circuits
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Supplement on Verilog adder examples
EEE2243 Digital System Design Chapter 1: Verilog HDL (Combinational) by Muhazam Mustapha, February 2012.
Introduction to Verilog – Part-2 Procedural Statements
Lecture 2 Adders Half adder.
Presentation transcript:

Figure 5.1. Conversion from decimal to binary.

Table 5.1. Numbers in different systems.

Figure 5.2. Half-adder. Please see “portrait orientation” PowerPoint file for Chapter 5

Figure 5.3. An example of addition.

Figure 5.4. Full-adder. Please see “portrait orientation” PowerPoint file for Chapter 5

Figure 5.5. A decomposed implementation of the full-adder circuit. HA s c s c c i x i y i c i1+ s i c i x i y i c i1+ s i (a) Block diagram (b) Detailed diagram

Figure 5.6. An n-bit ripple-carry adder. FA x n –1 c n c n1” y n1– s n1– FA x 1 c 2 y 1 s 1 c 1 x 0 y 0 s 0 c 0 MSB positionLSB position

Figure 5.7. Circuit that multiplies an 8-bit unsigned number by 3. Please see “portrait orientation” PowerPoint file for Chapter 5

Figure 5.8. Formats for representation of integers. b n1– b 1 b 0 Magnitude MSB (a) Unsigned number b n1– b 1 b 0 Magnitude Sign (b) Signed number b n2– 0 denotes 1 denotes + –MSB

Table 5.2. Interpretation of four-bit signed integers.

Figure 5.9. Examples of 1’s complement addition () 5–  3-  + 5–  7–  + 2–  5+ () 2+ () 7+ () + 5+ () 3+ () + 2– 

Figure Examples of 2’s complement addition ignore 5+ () 2+ () 7+ () + 5+ () 3+ () + 2–  2+ () 5–  3–  + 5–  7–  + 2– 

Figure Examples of 2’s complement subtraction. – () 2+ () 3+ () – 1 ignore – – 1 ignore – () 7+ () – –  7–  2+ () 2–  – – –  5–  3– 

Figure Graphical interpretation of four-bit 2’s complement numbers – – 3– 4– 5– 6– 7– 8– 0

Figure Adder/subtractor unit. s 0 s 1 s n1– x 0 x 1 x n1– c n n-bit adder y 0 y 1 y n1– c 0 Add  Sub control

Figure Examples of determination of overflow () 2+ () 9+ () () 5+ () + 2–  11 c 4 0= c 3 1= c 4 0= c 3 0= c 4 1= c 3 1= c 4 1= c 3 0= 2+ () 7–  5–  + 7–  9–  +2– 

x 1 y 1 g 1 p 1 s 1 Stage 1 x 0 y 0 g 0 p 0 s 0 Stage 0 c 0 c 1 c 2 Figure A ripple-carry adder with generate/propagate signals.

Figure The first two stages of a carry-lookahead adder. x 1 y 1 g 1 p 1 s 1 x 0 y 0 s 0 c 2 x 0 y 0 c 0 c 1 g 0 p 0

Figure A hierarchical carry-lookahead adder with ripple-carry between blocks. Block x 3124– c 32 c 24 y 3124– s 3124– x 158– c 16 y 158– s 8– c 8 x 70– y 70– s 70– c 0 3 Block 1 0

Figure A hierarchical carry-lookahead adder. Block x 158– y 8– x 70– y 70– 3 Block 1 0 Second-level lookahead c 0 s 70– P 0 G 0 P 1 G 1 P 3 G 3 s 158– s 3124– c 8 c 16 c 32 x 3124– y 3124– c

Figure An alternative design for a carry-lookahead adder. x 1 y 1 g 1 p 1 s 1 s 0 c 2 x 0 y 0 c 0 c 1 g 0 p 0

Figure Schematic using an LPM adder/subtractor module.

Figure Simulation results for the LPM adder optimized for cost.

Figure Simulation results for the LPM adder optimized for speed.

Figure Verilog code for the full-adder using gate level primitives. module fulladd (Cin, x, y, s, Cout); input Cin, x, y; output s, Cout; xor (s, x, y, Cin); and (z1, x, y); and (z2, x, Cin); and (z3, y, Cin); or (Cout, z1, z2, z3); endmodule

Figure Another version of Verilog code from Figure module fulladd (Cin, x, y, s, Cout); input Cin, x, y; output s, Cout; xor (s, x, y, Cin); and (z1, x, y), (z2, x, Cin), (z3, y, Cin); or (Cout, z1, z2, z3); endmodule

Figure Verilog code for the full-adder using continuous assignment. module fulladd (Cin, x, y, s, Cout); input Cin, x, y; output s, Cout; assign s = x ^ y ^ Cin; assign Cout = (x & y) | (x & Cin) | (y & Cin); endmodule

Figure Another version of Verilog code from Figure module fulladd (Cin, x, y, s, Cout); input Cin, x, y; output s, Cout; assign s = x ^ y ^ Cin, Cout = (x & y) | (x & Cin) | (y & Cin); endmodule

Figure Verilog code for a four-bit adder. module adder4 (carryin, x3, x2, x1, x0, y3, y2, y1, y0, s3, s2, s1, s0, carryout); input carryin, x3, x2, x1, x0, y3, y2, y1, y0; output s3, s2, s1, s0, carryout; fulladd stage0 (carryin, x0, y0, s0, c1); fulladd stage1 (c1, x1, y1, s1, c2); fulladd stage2 (c2, x2, y2, s2, c3); fulladd stage3 (c3, x3, y3, s3, carryout); endmodule module fulladd (Cin, x, y, s, Cout); input Cin, x, y; output s, Cout; assign s = x ^ y ^ Cin, assign Cout = (x & y) | (x & Cin) | (y & Cin); endmodule

Figure A four-bit adder using vectors. module adder4 (carryin, X, Y, S, carryout); input carryin; input [3:0] X, Y; output [3:0] S; output carryout; wire [3:1] C; fulladd stage0 (carryin, X[0], Y[0], S[0], C[1]); fulladd stage1 (C[1], X[1], Y[1], S[1], C[2]); fulladd stage2 (C[2], X[2], Y[2], S[2], C[3]); fulladd stage3 (C[3], X[3], Y[3], S[3], carryout); endmodule

Figure A generic specification of a ripple-carry adder. module addern (carryin, X, Y, S, carryout); parameter n=32; input carryin; input [n-1:0] X, Y; output [n-1:0] S; output carryout; reg [n-1:0] S; reg carryout; reg [n:0] C; integer k; or Y or carryin) begin C[0] = carryin; for (k = 0; k < n; k = k+1) begin S[k] = X[k] ^ Y[k] ^ C[k]; C[k+1] = (X[k] & Y[k]) | (X[k] & C[k]) | (Y[k] & C[k]); end carryout = C[n]; end endmodule

Figure Specification of an n-bit adder using arithmetic assignment. module addern (carryin, X, Y, S); parameter n = 32; input carryin; input [n-1:0] X, Y; output [n-1:0] S; reg [n-1:0] S; or Y or carryin) S = X + Y + carryin; endmodule

Figure An n-bit adder with carry-out and overflow signals. module addern (carryin, X, Y, S, carryout, overflow); parameter n = 32; input carryin; input [n-1:0] X, Y; output [n-1:0] S; output carryout, overflow; reg [n-1:0] S; reg carryout, overflow; or Y or carryin) begin S = X + Y + carryin; carryout = (X[n-1] & Y[n-1]) | (X[n-1] & ~S[n-1]) | (Y[n-1] & ~S[n-1]); overflow = carryout ^ X[n-1] ^ Y[n-1] ^ S[n-1]; end endmodule

Figure An alternative specification of an n-bit adder with carry-out and overflow signals. module addern (carryin, X, Y, S, carryout, overflow); parameter n = 32; input carryin; input [n-1:0] X, Y; output [n-1:0] S; output carryout, overflow; reg [n-1:0] S; reg carryout, overflow; reg [n:0] Sum; or Y or carryin) begin Sum = {1'b0,X} + {1'b0,Y} + carryin; S = Sum[n-1:0]; carryout = Sum[n]; overflow = carryout ^ X[n-1] ^ Y[n-1] ^ S[n-1]; end endmodule

Figure Simplified complete specification of an n-bit adder. module addern (carryin, X, Y, S, carryout, overflow); parameter n = 32; input carryin; input [n-1:0] X, Y; output [n-1:0] S; output carryout, overflow; reg [n-1:0] S; reg carryout, overflow; or Y or carryin) begin {carryout, S} = X + Y + carryin; overflow = carryout ^ X[n-1] ^ Y[n-1] ^ S[n-1]; end endmodule

Figure Behavioral specification of a full-adder. module fulladd (Cin, x, y, s, Cout); input Cin, x, y; output s, Cout; reg s, Cout; or y or Cin) {Cout, s} = x + y + Cin; endmodule

Figure Multiplication of unsigned numbers. Please see “portrait orientation” PowerPoint file for Chapter 5

Figure A 4 x 4 multiplier circuit. Please see “portrait orientation” PowerPoint file for Chapter 5

Figure Multiplication of signed numbers. Please see “portrait orientation” PowerPoint file for Chapter 5

Figure IEEE standard floating-point formats. Sign 32 bits 23 bits of mantissa excess-127 exponent 8-bit 52 bits of mantissa11-bit excess-1023 exponent 64 bits Sign SM SM (a) Single precision (c) Double precision E + E 0 denotes – 1 denotes

Table 5.3. Binary-coded decimal digits.

Figure Addition of BCD digits X Y Z carry X Y Z carry S = 2 S = 7

Figure Block diagram for a one-digit BCD adder.

modulebcdadd (Cin,X,Y,S, Cout); inputCin; input[3:0] X,Y; output[3:0] S; outputCout; reg[3:0] S; regCout; reg[4:0] Z; (X orYorCin) begin Z=X+Y+Cin; if(Z<10) {Cout,S}=Z; else {Cout,S}=Z+6; end endmodule Figure Verilog code for a one-digit BCD adder.

Figure Functional simulation of the Verilog code in Figure 5.41.

Figure Circuit for a one-digit BCD adder.

Figure P5.1. Circuit for problem 5.11.

Figure P5.2. The code for problem module problem5_17 (IN, OUT); input [3:0] IN; output [3:0] OUT; reg [3:0] OUT; if (IN == 4'b0101) OUT = 4'b0001; else if (IN == 4'b0110) OUT = 4'b0010; else if (IN == 4'b0111) OUT = 4'b0011; else if (IN == 4'b1001) OUT = 4'b0010; else if (IN == 4'b1010) OUT = 4'b0100; else if (IN == 4'b1011) OUT = 4'b0110; else if (IN == 4'b1101) OUT = 4'b0011; else if (IN == 4'b1110) OUT = 4'b0110; else if (IN == 4'b1111) OUT = 4'b1001; else OUT = 4'b0000; endmodule

Figure P5.3. Ternary half-adder