1 / 25

Real number : X Machine representation: X M Due to limited digits Let ulp= unit of least position

Machine Representation. Real number : X Machine representation: X M Due to limited digits Let ulp= unit of least position Then X M  X  X M +ulp Error exists: e= X M  X < ulp Overflow or Underflow. Number System. Positive binary number system:

luisa
Download Presentation

Real number : X Machine representation: X M Due to limited digits Let ulp= unit of least position

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Machine Representation • Real number : X • Machine representation: XM • Due to limited digits • Let ulp= unit of least position • Then XM  X  XM +ulp • Error exists: e= XM X < ulp • Overflow or Underflow

  2. Number System • Positive binary number system: • X=(xn-1, xn-2, …, x0)=xi2i, xi0,1 • Signed-magnitude: • xn-1 sign bit, others magnitude • Complement • 2’s Complement • 1’s Compelement

  3. Complement Representation • Let R= givenconstant, Y: n-bit • Complement of Y = RY • Check if (Y) = RY • then ((Y))=R (R Y)=Y O.K. • Complement • 2’s (Radix) Complement: R= 2n • 1’s (Diminished-Radix) Complement: R=2n ulp

  4. Radix Complement • 2’s Complement • R= 2n, Y: n-bit, Y= 2n Y=Y’+1 • Y’= (1,1, …,1)  Y • Example: Y=(0110), Y=(1010) • X=(xn-1, xn-2, …, x0) =  xn-12n-1 + xi2i for i= 0, 1, …, n-2

  5. Diminished-Radix Complement • 1’s Complement • R= 2n 1, Y= 2n Y  1=Y’ • Y’= (1,1, …,1)  Y • Example: Y=(0110), Y=(0101) • X=(xn-1, xn-2, …, x0) =  xn-1 (2n-1 1)+ xi2i for i= 0, 1, …, n-2

  6. Example

  7. Ranges • SM: (2n1 1)  Y  (2n 1 1) • Two Zeros: (00…0) & (10…0) • 1’s C: (2n1 1)  Y  (2n 1 1) • Two Zeros:(00…0) & (11…1) • 2’s C: (2n1 1)  Y  2n 1

  8. Addition/Subtraction • Operations: • ADD (M=0); SUB (M=1) • SM: Sign-bit (SA), Overflow (=OV), End-around-carry (=C), magnitude >0 • 1’s C: Overflow, End-around-carry • 2’s C: Overflow • Complement  Using XOR gate

  9. 2’C ADD/SUB (1) • Ex 1: A +B=2+1= (010)+(001)=3 • (010)+(001)M+M=(010)+(001)+0= (011) • Ex2: A  B=21= (0010)(0001)= 1 • (010)+(001)M+M = (010) + (110) + (001) = 1(001) • Ex3 A +B=2+2= 4=OV • (010)+(010)M+M = (100)= 4

  10. 2’C ADD/SUB Overflow • Occurs when Sign bits: • P add P = N • N add N = P • OV=Cn  Cn-1

  11. 2’C ADD/SUB Proof(1) • Only consider A+B case: A  B=A+( B) • Let |A|=E & |B|=F 2n-1> E, F 0 • Case 1: A, B 0  2n> E+F 0 • IF E+F  2n-1 OV=1 (Chk OV) • Case 2: A,B <0 A= 2n E, B = 2n F • A+B=2n+2n (E +F)  Cn=1 (neglect) • neglect Cn  A+B= 2n (E +F)  Chk OV

  12. 2’C ADD/SUB Proof(2) • Case 3: A  0, B<0 B = 2n F • A+B= 2n +(EF)= 2n  (F E) • E  F  Cn=1 (neglect) & Sign bit=0 • F  E  Cn=0 & Sign bit=1 • Case 4: B  0, A <0 Similar to Case 3 • A+B= 2n (EF)= 2n + (F E) • E  F  Cn=0 & Sign bit=1 • F  E  Cn=1 (neglect) & Sign bit=0

  13. 2’C ADD/SUB Circuit

  14. 1’C ADD/SUB (1) • Ex 1: A +B=2+1= (010)+(001)=3 • (010)+(001)M+C=(010)+(001)+0= (011) • Ex2: A  B=21= (010)(001)= 1 • (010)+(001)M+C = (010) + (110) =1(000) = (000)+(001)=(001) • Ex3 A +B=2+2= 4=OV • (010)+(010)M+C = (100)= 3

  15. 1’C ADD/SUB Overflow • Same as 2’C • OV occurs when Sign bits: • P add P = N • N add N = P • OV=Cn  Cn-1

  16. 1’C ADD/SUB Proof(1) • Only consider A+B case: A  B=A+( B) • Let |A|=E & |B|=F 2n-1> E, F 0 • Case 1: A, B 0  Same as 2’C • IF E+F  2n-1 OV=1 (Chk OV) • Case 2: A,B <0 A= 2n E 1, B = 2n F 1 • A+B=2n+2n (E +F)  2  Cn=C=1 (neglect) • Add end-around carry A+B= 2n (E +F) 1 •  Chk OV

  17. 1’C ADD/SUB Proof(2) • Case 3: A  0, B<0 B = 2n F  1 • A+B= 2n +(EF)  1= 2n  (F E) 1 • E >F  C=1 (neglect 2n ,1) & A+B=E  F>0 • F  E  C=0 & Sign bit=1 (may have 0) • Case 4: B  0, A <0 Similar to Case 3 • A+B= 2n (EF)  1= 2n + (F E) 1 • E  F  C=0 & Sign bit=1 • F > E  C=1 (neglect 2n ,1) & A+B= F E

  18. 1’C ADD/SUB Circuit

  19. End-Around-Carry Oscillation?

  20. SM ADD/SUB (1) • Ex 1: A  B=21= (0010)(0001)= 1 • Init. Sign P= SA (SBM)=01=1 • Mag. (010)+(001)P=(010)+(110)=1(000) • Add C (end-arnd-crry): (000)+(001)=(001) • Final Mag. Indicator Q=P(C)’=0 • Final Sign S= (SA C)v((SBM)C’)= 0v0 =0 • Answer= (S, (Mag)  Q)=(0001)

  21. SM ADD/SUB (2) • Ex 2: A  B=12= (0001)(0010)= 1 • Init. Sign P= SA (SBM)= 01=1 • Mag. (001)+(010)P=(001)+(101)=0(110) • Add C (end-arnd-crry): (110)+(000)=(110) • Final Mag. Indicator Q=P(C)’=1 • Final Sign S= (SAC)v((SBM)C’)= 0 v 1 =1 • Answer= (S, (Mag)  Q)=(1001)

  22. SM ADD/SUB (3) • Ex 3: (0010)+(0111)= 2+7=9= OV • Init. Sign P=00=0 • Mag. (010)+(111)P=(010)+(111)=1(001) • Add C (end-arnd-crry): (001)+(001)=(010) • OV=P’C=1

  23. SM ADD/SUB Proof(1) • A  B=A+( B)  need (n-1)-bit Adder • Init Sign P=0 for (SA=(SBM)); P=1 otherwise • OV occurs only at P=0 • Let |A|=E and |B|=F (mag. E, F 0) C • Case 1: P=0, • If (E+F P)=E+F < 2n1  C=0, No OV • Otherwise C=1 and OV  OV=P’C=1

  24. SM ADD/SUB Proof(2) • Case 2: P=1, then • E+(FP)= E+F’= E+(2n F1)=2n+(EF)1 • if E > F  C=1  Sign=SA • (EF)1+C= (E F); Neglect 2n =C=1 • otherwise (F E, Sign =(SBM)) C=0 Q=PC’=1 • 2n+(EF)1+C= 2n(F E) 1 • (Mag)  Q= 2n (2n(F E) 1 ) 1= (F E)

  25. SM ADD/SUB Proof(3) • Sign= SAC v (SBM)C’

More Related