Docsity

Binary Subtracters, BCD Adder-Boolean Algebra and Digital Logic Design-Lecture Slides, Slides of Digital Logic Design and Programming

Partial preview of the text

Download Binary Subtracters, BCD Adder-Boolean Algebra and Digital Logic Design-Lecture Slides and more Slides Digital Logic Design and Programming in PDF only on Docsity!

Overview of Last Lecture

  • Binary Adder‐Subtractor

– Half Adder

– Full Adder

– Binary Subtractor

  • Carry Lookahead Generator

Today’s Lecture

  • Binary Subtractor
  • BCD Adder

Binary Subtractor

  • The circuit for subtracting A – B consists of an adder with inverters placed between each data input B and the corresponding input of full adder
  • The input carry C 0 must be equal to 1 when performing subtraction
  • The operation thus performed becomes A, plus the 1 ’ s complement of B, plus 1 (A+1 ’ s complement of B +1). This is equal to A plus 2 ’ s complement of B (A +2 ’ s complement of B)
  • For unsigned numbers this gives A – B if A B or the 2 ’ s complement of (B – A) if A<B

Binary subtractor

  • The addition and subtraction operation can be combined into one circuit with one common binary adder
  • This is done by including an exclusive-OR gate with each full adder
  • The mode input M controls the operation. When M=0, we have B⊕0= B. The full adder receives the value of B, the input carry is 0 and the circuit performs A+B
  • When M=1, we have B⊕1= B’. The full adder receives the value of B’, the input carry C 0 is 1 and the circuit performs A plus the 2 ’ s complement of B. (A+1 ’ s complement of B+1).
  • The exclusive-OR with output V is for detecting an overflow (detail later, in overflow)

Overflow

  • When two numbers of n digits are added and sum occupies n+1 digits we say that an overflow occurred
  • Overflow is problem in digital computers because the number of bits that hold the number (limited storage) is finite and a result that contains n+1 can ’ t be accommodated.
  • The detection of an overflow after the addition of two binary numbers depends on whether the numbers are considered to be signed or unsigned
  • When two unsigned numbers are added an overflow is detected from the end carry out of the most significant position
  • In the case of signed numbers, the leftmost bit always represent the sign and negative numbers are in 2 ’ s complement form

Overflow

  • When two signed numbers are added, the sign bit is treated as part of the number and end carry doesn ’ t indicate an overflow
  • An overflow can ’ t occur after an addition if one number is positive and the other is negative, since adding a positive number to a negative number produces a result which is smaller than the larger of the two original numbers.
  • An overflow may occur if the two numbers added are both positive or both negative
  • For n-bit registers, the range of numbers (signed numbers) that each register can accommodate is from binary 2 n- -1 to binary – n- .

Overflow

  • If we just consider the 8-bit result from the last example, we go wrong as we - Add two positive numbers and obtain a negative number - Add two negative numbers and obtain a positive number
  • The carry out of sign bit position is taken as the sign bit of the result, then the 9-bit answer so obtained will be correct. This answer can’t be accommodated within 8-bits we say that an overflow has occurred
  • An overflow has occurred if carry into the sign bit position and carry out of the sign bit position are not equal. This can be found by applying the two carries to an exclusive-OR gate. 1 at the output of the gate indicates overflow - V=0, no overflow; V=1, overflow

Decimal Adder

  • Computers or calculators that perform arithmetic operation directly in the decimal number system represents decimal number in binary coded form
  • An adder for such a computer must employ aritmetic circuits that accepts coded decimal number and present results in the same code
  • To add two BCD's, we require
    • 9 inputs: eight inputs for two BCDs and one carry-in. Since four bits are required to code each decimal digit
    • 5 outputs: four outputs for one BCD and one carry-out