1 / 21

CSE111: Great Ideas in Computer Science

CSE111: Great Ideas in Computer Science. Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:50 645-4739 alphonce@buffalo.edu. Announcements. Recitations have started this week! You have this week and next to complete HW1. cell phones off (please). Agenda.

wylie
Download Presentation

CSE111: Great Ideas in Computer Science

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. CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:50 645-4739 alphonce@buffalo.edu

  2. Announcements • Recitations have started this week! • You have this week and next to complete HW1.

  3. cell phones off (please)

  4. Agenda • Review from last class • fixed-width representations • two’s complement • Today’s topics • two’s complement • Underlying hardware

  5. Fixed-width encodings • Suppose we have a four-bit wide representation. • We then have 24 = 2*2*2*2 = 16 distinct bit patterns:

  6. Overflow • Compute the following sums, in a four-bit wide base 2 representation: 5 + 1 = 6 8 + 8 = 16 10 + 12 = 22 101 1000 1010 + 001+ 1000+ 1100 110 0000 0110

  7. How about negative and non-negative numbers? • How can we assign the bit strings from 0000 to 1111 to numbers, including negative numbers? • There are many ways to do this, but some ways are better than others. • Keep in mind, we only have the symbols ‘0’ and ‘1’ to use.

  8. Desirable properties of our representation X – Y = X + (-Y) X + (-X) = 0 0 = - 0 - (-X) = X

  9. 4-bit two’s complement

  10. How does it work? • Given representation for x, compute representation of –x as follows: • First compute the 1’s complement by inverting all the bits (change 0 to 1, and 1 to 0) • Then compute the 2’s complement by adding 1, and ignoring any overflow carry bit.

  11. Examples • Compute the representation of -1: 0001  original representation 1110  one’s complement 1111  two’s complement • Representation of -1 is 1111.

  12. Check: x + (–x) = 0 0001 + 1111 0000 • Remember, representation is 4 bits wide, and we discard any overflow carry bit.

  13. Check other properties too!(done on board) X – Y = X + (-Y) X + (-X) = 0 0 = - 0 - (-X) = X

  14. Gates • Basic building blocks of computers are gates… • and • or • not • …and wires to connect them to each other.

  15. Gate images http://upload.wikimedia.org/wikipedia/commons/5/5d/Logic-gate-and-us.png http://upload.wikimedia.org/wikipedia/commons/c/c8/Logic-gate-or-us.png http://upload.wikimedia.org/wikipedia/commons/d/d0/Logic-gate-inv-us.png

  16. AND gate

  17. OR gate

  18. NOT gate

  19. 4-bit one’s complement A A’ B B’ C C’ D D’

  20. Flip-flophttp://commons.wikimedia.org/wiki/File:RS_Flip-flop_(NOR).svgFlip-flophttp://commons.wikimedia.org/wiki/File:RS_Flip-flop_(NOR).svg

  21. Questions?

More Related