COMP 1321 Digital Infrastructure Richard Henson University of Worcester October 2017
Week 2: Binary Numbers and CPUs Objectives of session: Explain the CPU as the fundamental part of the computer Explain why binary numbers are fundamental to computing Convert between binary and hexadecimal numbers Explain the structure of typical CPU
Origins of the CPU All about processing data Needs a mechanism for adding data (input) removing processed data (output) storing data outside the CPU In early days (e.g. Bletchley Park) data input, output, movement, storage were all paper-based… very slow!
Binary Numbers Base 2… based on symbols 0 and 1 perfect fit with Boole & logic states (1850s) surprising no-one before Shannon (1930s) grasped this idea To represent binary in real world… need “on/off” switches mechanical… slow but gotta start somewhere… (!)
Electrical Storage of Binary? Possible using: Relays on – magnet has current/off – magnet no current binary numbers relay off = 0 relay on = 1
Shannon & Relays 1938: first scientist to use Boolean Logic with relays: on/off 1/0 realised binary numbers could replace decimal numbers & represent real data values Figured that relays could be wired together to create logic gates and do Boolean Algebra (!) problem… relays slow
A Fast Switch Electronic… But once working, it did work, and quickly… called valves, but actually glass tubes air taken out; near vacuum didn’t work until “warmed up” needed a lot of energy to work took up lots of space But once working, it did work, and quickly… Head of IBM (1950s) said that the world would only need four of these computers anyway (!)
More from Shannon (1948) Demonstrated the essential unity of all information media: text telephone signals radio waves pictures, film, etc… ALL could be encoded in the universal language of binary digits used term “bit” for a binary digit
Binary Logic and CPU Design Putting theory into practice… Data stored as blocks of ‘cells’ (effectively switches) voltage off/on in binary either “0” or “1” If memory and data binary… processing must be binary as well! 9
Number Systems (binary and others) Number of different symbols… “base” of number system many tried over the years Examples: base 2: binary (2 symbols) base 10: decimal (10 symbols) base 12: (inches in a foot, etc. flawed… only 10 symbols) base 16: hexadecimal (16, and 16 symbols) Nystrom (1859!)
Logic and Digital Logic “Logical”… through mental activity (human CPU?) https://www.youtube.com/watch?v=5_APSczipvo&t=18s (Mr Spock) “Emotional”… following gut feeling Now add “digital” specific type of logic required to program a CPU!
Some Definitions… binary digit bit 0 or 1 byte: a group of 8 bits (nibble: a group of 4 bits) “word”: a group of bits of a fixed length actual length of a word depends on the register size in a CPU 12
Number Theory: what does decimal 2314 mean? Thousands Hundreds Tens units 10x10x10 10x10 10 103 102 101 100 bracket form: (2 x 103) + (3 x 102) + (1 x 101) + (4 x100 ) most significant digit 2 least significant digit 4 13
Counting in Binary… Same logic as decimal (denary) system Two symbols When both symbols used start another column…
Counting in Hexadecimal 16 symbols 0-9 plus A-F Same logic as decimal or binary Why bother? represents a nibble as a single symbol!
What does binary 1101 mean? 1 1 0 1 2x2x2 2x2 2 1 23 22 21 20 1 1 0 1 2x2x2 2x2 2 1 23 22 21 20 bracket form – for conversion... (1 x 23) + (1 x 22) + (0 x 21) + (1 x20 ) 8 + 4 + 0 + 1 = 13 in denary (decimal) 16
Binary representation of the 8 bits: 1011 0101 27 26 25 24 23 22 21 20 1 0 1 1 0 1 0 1 128 + 0 + 32 + 16 + 0 + 4+ 0 + 1 = 181 Q. How many different binary numbers can an 8 bit word hold? A. 256 (= 28) ranging from 0000 0000 to 1111 1111 17
“Significance” of a bit All bits aren’t equal! As with decimal, the greater the value… the more significant it becomes e.g. decimal 13821 1 in 10000s column… has much greater value than 1 in the 1s column
What about a 16 bit number 0000 0000 0011 0101 (a) To what decimal number is it equal? (b) What is the value of the most significant bit? (c) How many different 16 bit binary numbers can be represented? 19
The 16 bit number 0000 0000 0011 0101 (a) To what decimal number is it equal? Answer: 32 + 16 + 0 + 4 + 0 + 1 = 53 (b) What is the value of the most significant bit? Answer: 0 (c) How many different 16 bit binary numbers can be represented? Answer: 216 = 65536 (which is 64 k) 20
Shorthand Rows of many 1s and 0s can be very confusing easy to make mistakes Solution: divide into blocks of 4 digits (nibbles) use hexadecimal equivalent for each nibble very useful in hard disk analysis, when searching for data 21
Hexadecimal notation Decimal Binary Hexadecimal 0 0000 0 1 0001 1 0 0000 0 1 0001 1 2 0010 2 3 0011 3 4 0100 4 5 0101 5 6 0110 6 7 0111 7 8 1000 8 9 1001 9 22
Hexadecimal notation Decimal Binary Hexadecimal 10 1010 A 11 1011 B 15 1111 F 23
Notation Useful to know what type of number we are dealing with e.g. “110” use subscript at the end 11010 = 110 (denary) 1102 = 110 (binary) = 6 (denary) 110H or 11016 = 110 (hexadecimal) = 272 (denary) So now you know! 24
Binary Logic & CPU Binary logic + Boolean algebra logic gates mathematically predictable effects of combining them documented as truth tables Problem: valves wired together produce very large, energy hungry logic gates: CPU large, use a lot of energy!
Transistors Same effect as valves Wonderful discovery much smaller use much less energy Wonderful discovery very exciting for Shannon? computers could be much smaller than he expected… http://www.technologyreview.com/featuredstory/401112/claude-shannon-reluctant-father-of-the-digital-age
Effects of Miniaturisation Transistors first used in radios very popular with 1950s “teenagers” Took some time to become part of more sophisticated devices breakthrough: integrated circuits (ICs) many transistors on a single component first IC with enough transistors to be a CPU with programmed instructions… Intel (1972)
Now, let’s make a Computer … or at least the CPU (millions of transistors) Ultra Sparc 1 Pentium 4 Opteron 21364 Itanium 2 McKinley
Computer Program (Code) CPU with INPUT & OUTPUT Computer Program (Code) 1 do this… 2 do that 3 now this 4 goto 1 CPU Memory VDU Plus Data… Keyboard
So THAT’S how they work!? Next week: Structure of a CPU and programming it!