1 / 11

Signed Addition

מבנה המחשב + מבוא למחשבים ספרתיים תרגול 9#. Signed Addition. Example: The sign of the sum z is not signaled correctly by S[ n-1 ]. Set:. Proof: NEG = XOR(OVF,S[ n-1 ]). (1). (2). By substituting (2) in (1) ,. Correctness of S-ADDER( 2n ).

temima
Download Presentation

Signed Addition

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. מבנה המחשב + מבוא למחשבים ספרתייםתרגול 9# Signed Addition

  2. Example: The sign of the sum z is not signaled correctly by S[n-1]. Set:

  3. Proof: NEG = XOR(OVF,S[n-1]) (1) (2) By substituting (2) in (1),

  4. Correctness of S-ADDER(2n) We assume the correctness of S-ADDER(n) implementation in Figure 8.2 in chapter 8 of the lecture notes:

  5. S-ADDER(n)

  6. Negation circuit The circuit is correct when no overflow occurs: “C[n]” “A[n-1]” “B[n-1]” “S[n-1]”

  7. A wrong implementation of ADD-SUB(n) The circuit errs ⇔ the “negation” of B errs

  8. OVF and NEG flags in high level programming unsigned int lastBit( unsigned int num) { return num >> (8*sizeof(int) – 1); } unsigned int negBit( unsignedint bit) { return 1-bit; } void main() { //... suppose S = A ±B; int ovf = ( lastBit(A) & lastBit(B) & negBit(lastBit(S)) ) | ( negBit(lastBit(A)) & negBit(lastBit(B)) & lastBit(S) ); int neg = ovf ^ lastBit(S); }

  9. Note: Short segments of low level language (Assembly) can be integrated in C programs using inline assembly. __asm { //assembly code// } Overflow and Negative result are indicated by flags: OF – Overflow flag which is set if an overflow occurs. SF – Sign flag which is a copy of the high-order bit of a result. Testing for overflow: jo target - jumps to “target” if OF = 1 jno target - jumps to “target” if OF = 0 Testing for sign: js target - jumps to “target” if SF = 1 jns target - jumps to “target” if SF = 0

  10. Bi-directional cyclic shifting A reduction of right cyclic shifting to left cyclic shifting.

  11. XOR(k) Bi-directional cyclic shifting – Cont’

More Related