0% found this document useful (0 votes)
73 views35 pages

Fundamentals of Computer Systems: Thinking Digitally

This document provides an overview of the topics that will be covered in a course on fundamentals of computer systems. It discusses how computer systems work through layers of abstraction from application software down to digital circuits and physics. It then describes the course content, which will cover discrete information processing systems, number representations like binary, octal, decimal and hexadecimal, algorithms for addition in different bases, representations of signed numbers, fixed-point and floating-point numbers.

Uploaded by

Srikar Varadaraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views35 pages

Fundamentals of Computer Systems: Thinking Digitally

This document provides an overview of the topics that will be covered in a course on fundamentals of computer systems. It discusses how computer systems work through layers of abstraction from application software down to digital circuits and physics. It then describes the course content, which will cover discrete information processing systems, number representations like binary, octal, decimal and hexadecimal, algorithms for addition in different bases, representations of signed numbers, fixed-point and floating-point numbers.

Uploaded by

Srikar Varadaraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Fundamentals of Computer Systems

Thinking Digitally

Stephen Edwards
Columbia University

Spring 2016

1 / 24

The Subjects of this Class

2 / 24

Computer Systems Work Because of Abstraction


Application Software
Operating Systems
Architecture
Micro-Architecture
Logic
Digital Circuits
Analog Circuits
Devices
Physics
3 / 24

Computer Systems Work Because of Abstraction


Application Software

COMS 3157, 4156, et al.

Operating Systems

COMS W4118

Architecture

Second Half of 3827

Micro-Architecture

Second Half of 3827

Logic

First Half of 3827

Digital Circuits

First Half of 3827

Analog Circuits

ELEN 3331

Devices

ELEN 3106

Physics

ELEN 3106 et al.


3 / 24

Simple information processing system

Discrete
Inputs

Discrete Information
Processing System

Discrete
Outputs

System State

First half of the course

4 / 24

Simple information processing system

Discrete
Inputs

Discrete Information
Processing System

Discrete
Outputs

System State

First quarter of the course

4 / 24

5 / 24

thinkgeek.com

The Decimal Positional Numbering System

Ten figures: 0 1 2 3 4 5 6 7 8 9
7 102 + 3 101 + 0 100 = 73010
9 102 + 9 101 + 0 100 = 99010

Why base ten?

6 / 24

Which Numbering System Should We Use?


Some Older Choices:
Roman: I II III IV V VI VII VIII IX X

Mayan: base 20, Shell = 0

Babylonian: base 60

7 / 24

Hexadecimal, Decimal, Octal, and Binary


Hex

Dec

Oct

0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

0
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17

Bin
0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111

8 / 24

DEC PDP-8/I, c. 1968

Binary and Octal


Oct

Bin

0
1
2
3
4
5
6
7

000
001
010
011
100
101
110
111

PC = 0 211 + 1 210 + 0 29 + 1 28 + 1 27 + 0 26 +
1 25 + 1 24 + 1 23 + 1 22 + 0 21 + 1 20
= 2 83 + 6 82 + 7 81 + 5 80
= 146910
9 / 24

Hexadecimal Numbers
Base 16: 0 1 2 3 4 5 6 7 8 9 A B C D E F
Instead of groups of 3 bits (octal), Hex uses groups of 4.

CAFEF00D16 = 12 167 + 10 166 + 15 165 + 14 164 +


15 163 + 0 162 + 0 161 + 13 160
= 3, 405, 705, 22910
C
A
F
E
F
0
0
D
11001010111111101111000000001101
3 1 2 7 7 5 7 0 0 1
5

Hex
Binary
Octal

10 / 24

Computers Rarely Manipulate True Numbers

Infinite memory still very expensive


Finite-precision numbers typical
32-bit processor: naturally manipulates 32-bit numbers
64-bit processor: naturally manipulates 64-bit numbers
How many different numbers can you
binary
octal
represent with 5
digits?
decimal
hexadecimal

11 / 24

Jargon
Bit

Binary digit: 0 or 1

Byte

Eight bits

Word

Natural number of bits for the processor, e.g., 16, 32, 64

LSB

Least Significant Bit (rightmost)

MSB

Most Significant Bit (leftmost)


12 / 24

Decimal Addition Algorithm

434
+628

4 + 8 = 12

0
1
2
3
4
5
6
7
8
9
10

0 1 2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
8 9 10
9 10 11
10 11 12

3
4
5
6
7
8
9
10
11
12
13

4
5
6
7
8
9
10
11
12
13
14

5
6
7
8
9
10
11
12
13
14
15

6
7
8
9
10
11
12
13
14
15
16

7
8
9
10
11
12
13
14
15
16
17

8
9
10
11
12
13
14
15
16
17
18

9
10
11
12
13
14
15
16
17
18
19

13 / 24

Decimal Addition Algorithm

1
434
+628
2

4 + 8 = 12
1+3+2 =

0
1
2
3
4
5
6
7
8
9
10

0 1 2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
8 9 10
9 10 11
10 11 12

3
4
5
6
7
8
9
10
11
12
13

4
5
6
7
8
9
10
11
12
13
14

5
6
7
8
9
10
11
12
13
14
15

6
7
8
9
10
11
12
13
14
15
16

7
8
9
10
11
12
13
14
15
16
17

8
9
10
11
12
13
14
15
16
17
18

9
10
11
12
13
14
15
16
17
18
19

13 / 24

Decimal Addition Algorithm

1
434
+628
62

4 + 8 = 12
1+3+2 =

4 + 6 = 10

0
1
2
3
4
5
6
7
8
9
10

0 1 2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
8 9 10
9 10 11
10 11 12

3
4
5
6
7
8
9
10
11
12
13

4
5
6
7
8
9
10
11
12
13
14

5
6
7
8
9
10
11
12
13
14
15

6
7
8
9
10
11
12
13
14
15
16

7
8
9
10
11
12
13
14
15
16
17

8
9
10
11
12
13
14
15
16
17
18

9
10
11
12
13
14
15
16
17
18
19

13 / 24

Decimal Addition Algorithm

1 1
434
+628
062

4 + 8 = 12
1+3+2 =

4 + 6 = 10

0
1
2
3
4
5
6
7
8
9
10

0 1 2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
8 9 10
9 10 11
10 11 12

3
4
5
6
7
8
9
10
11
12
13

4
5
6
7
8
9
10
11
12
13
14

5
6
7
8
9
10
11
12
13
14
15

6
7
8
9
10
11
12
13
14
15
16

7
8
9
10
11
12
13
14
15
16
17

8
9
10
11
12
13
14
15
16
17
18

9
10
11
12
13
14
15
16
17
18
19

13 / 24

Decimal Addition Algorithm

1 1
434
+628
1062

4 + 8 = 12
1+3+2 =

4 + 6 = 10

0
1
2
3
4
5
6
7
8
9
10

0 1 2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
8 9 10
9 10 11
10 11 12

3
4
5
6
7
8
9
10
11
12
13

4
5
6
7
8
9
10
11
12
13
14

5
6
7
8
9
10
11
12
13
14
15

6
7
8
9
10
11
12
13
14
15
16

7
8
9
10
11
12
13
14
15
16
17

8
9
10
11
12
13
14
15
16
17
18

9
10
11
12
13
14
15
16
17
18
19

13 / 24

Binary Addition Algorithm

10011
+11001
+

1 + 1 = 10

0
1
10

00 01
01 10
10 11

14 / 24

Binary Addition Algorithm


1
10011
+11001
0
+

1 + 1 = 10
1 + 1 + 0 = 10

0
1
10

00 01
01 10
10 11

14 / 24

Binary Addition Algorithm


11
10011
+11001
00
+

1 + 1 = 10
1 + 1 + 0 = 10

0
1
10

00 01
01 10
10 11

1 + 0 + 0 = 01

14 / 24

Binary Addition Algorithm


011
10011
+11001
100
+

1 + 1 = 10
1 + 1 + 0 = 10

0
1
10

00 01
01 10
10 11

1 + 0 + 0 = 01
0 + 0 + 1 = 01

14 / 24

Binary Addition Algorithm


0011
10011
+11001
1100
+

1 + 1 = 10
1 + 1 + 0 = 10

0
1
10

00 01
01 10
10 11

1 + 0 + 0 = 01
0 + 0 + 1 = 01
0 + 1 + 1 = 10

14 / 24

Binary Addition Algorithm


10011
10011
+11001
101100
+

1 + 1 = 10
1 + 1 + 0 = 10

0
1
10

00 01
01 10
10 11

1 + 0 + 0 = 01
0 + 0 + 1 = 01
0 + 1 + 1 = 10

14 / 24

Signed Numbers: Dealing with Negativity

How should both positive and negative numbers be


represented?

15 / 24

Signed Magnitude Numbers


You are most familiar with this:
negative numbers have a leading
In binary, a
leading 1 means
negative:

Can be made to work, but addition is


annoying:

00002 = 0

If the signs match, add the magnitudes


and use the same sign.

00102 = 2
10102 = 2
11112 = 7

If the signs differ, subtract the smaller


number from the larger; return the
sign of the larger.

10002 = 0?

16 / 24

Ones Complement Numbers

Like Signed Magnitude, a leading 1 indicates a negative


Ones Complement number.
To negate a number, complement (flip) each bit.
00002 = 0
00102 = 2
11012 = 2
10002 = 7
11112 = 0?

Addition is nicer: just add the ones


complement numbers as if they were
normal binary.
Really annoying having a 0: two
numbers are equal if their bits are the
same or if one is 0 and the other is 0.

17 / 24

18 / 24

Twos Complement Numbers


Really neat trick: make the most
significant bit represent a negative
number instead of positive:
11012 = 8 + 4 + 1 = 3
11112 = 8 + 4 + 2 + 1 = 1
01112 = 4 + 2 + 1 = 7
10002 = 8
Easy addition: just add in binary and discard any carry.
Negation: complement each bit (as in ones
complement) then add 1.
Very good property: no 0
Twos complement numbers are equal if all their bits
are the same.
19 / 24

Number Representations Compared


Bits

Binary

Signed
Mag.

Ones
Comp.

Twos
Comp.

0000
0001
..
.

0
1

0
1

0
1

0
1

0111
1000
1001
..
.

7
8
9

7
0
1

7
7
6

7
8
7

6
7

1
0

2
1

1110
14
1111
15
Smallest number
Largest number

20 / 24

Twos Complement, In Summary

https://xkcd.com/571/

21 / 24

Fixed-point Numbers

How to represent fractional


numbers? In decimal, we continue
with negative powers of 10:
31.4159 = 3 101 + 1 100 +
4 101 + 1 102 + 5 103 + 9 104
The same trick works in binary:
1011.01102 = 1 23 + 0 22 + 1 21 + 1 20 +
0 21 + 1 22 + 1 23 + 0 24
= 8 + 2 + 1 + 0.25 + 0.125
= 11.375

22 / 24

Need a bigger range? Try Floating Point


Representation.
Floating point can represent very large numbers in a
compact way.
A lot like scientific notation, 7.776 103 , where you
have the mantissa (7.776) and exponent (3).
But for this course, think in binary: 1.10x20111
The bits of a 32-bit word are separated into fields. The
IEEE 754 standard specifies

which bits represent which fields (bit 31 is sign, bits


30-23 are 8-bit exponent, bits 22-00 are 23-bit
fraction)

how to interpret each field


23 / 24

Characters and Strings? ASCII.

24 / 24

You might also like