35
CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall [email protected] 1

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall [email protected] 1

Embed Size (px)

Citation preview

Page 1: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

1

CSE115 / CSE503Introduction to Computer Science I

Dr. Carl Alphonce343 Davis Hall

[email protected]

Page 2: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

2

Announcements

• Recitations begin this week.– “preparatory” lab exercises

• Name sign judging today

Page 3: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

3

cell phones off

laptops away

Page 4: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

4

name signs out

Page 5: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

5

Today

• Representations

• Gates

• Fetch-Decode-Execute cycle

Page 6: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

6

Interpretation

• QUESTION:– What does the bit string 1101

represent?

Page 7: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

7

Interpretation

• QUESTION:– What does the bit string 1101

represent?

• ANSWER:– Whatever we want it to represent!

Page 8: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

8

Roadmap

• A computer is a very simple machine– it manipulates voltages– gates are used to control voltage flow– circuits are combinations of gates– a flip-flop is a circuit that remembers

• Instructions are encoded as bit strings• Machine/assembly/high-level languages• Fetch-Decode-Execute cycle• Requirements for a programming language

Page 9: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

9

physical vs. logical perspectives

• Physical reality:

• Logical view:

WIRE

Carries a HIGH voltage or a LOW voltage

WIRECarries a 1 or a 0

Page 10: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

10

Idea

Page 11: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

11

Idea

Page 12: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

12

http://commons.wikimedia.org/wiki/File:Relay_principle_horizontal.jpgUser:Bisgaard,

Page 13: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

13

http://commons.wikimedia.org/wiki/File:Electronic_component_relays.jpg

User:FDominec

Page 14: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

14

• Electro-mechanical computers – relays: Mark I (1944)

• Electronic computers– vacuum tubes: ENIAC (1946)– transistors: U of Manchester (1953)– integrated circuits (~1963)– microprocessors: Intel 4004 (1971)

Page 15: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

15

Controlling flow

0

Page 16: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

16

Controlling flow

1

Page 17: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

17

Two in a row?

0

Page 18: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

18

Two in a row?

0

Page 19: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

19

Two in a row?

0

Page 20: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

20

Two in a row?

1

Page 21: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

21

AND gate

For which input values is output 1?

For which input values is output 0?

inputs are on leftoutput is on right

0 or 1

Page 22: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

22

Truth table for AND

Input 1 Input 2 Output

0 0 0

0 1 0

1 0 0

1 1 1

Page 23: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

23

OR gate

For which input values is output 1?

For which input values is output 0?

inputs are on leftoutput is on right

Page 24: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

24

Truth table for OR

Input 1 Input 2 Output

0 0 0

0 1 1

1 0 1

1 1 1

Page 25: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

25

NOT gate

For which input value is output 1?

For which input value is output 0?

input is on left output is on right

Page 26: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

26

Truth table for NOT

Input Output

0 1

1 0

Page 27: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

27

Flip-flop (a bit of memory!)

S (set)

R (reset)

remembered value

Page 28: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

28

Setting the flip-flop

The normal value of R and S is zero.

S (set) = 0

R (reset) = 0

remembered value

Page 29: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

29

Setting the flip-flop

To store 1 in the flip-flop, we “raise” S to 1…

S (set) = 1

R (reset) = 0

remembered value

Page 30: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

30

Setting the flip-flop

…which makes the output of the OR gate 1.

S (set) = 1

R (reset) = 0

remembered value

1

Page 31: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

31

Setting the flip-flop

The NOT gate inverts this 1 value to 0, which becomes the second input to the upper OR gate.

S (set) = 1

R (reset) = 0

remembered value

1 0

0

Page 32: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

32

Setting the flip-flop

Since both inputs of the upper OR gate are zero, its output is zero.

S (set) = 1

R (reset) = 0

remembered value

1 0

0

0

Page 33: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

33

Setting the flip-flop

The NOT gate inverts this 0 to a 1; this value becomes the second input to the bottom OR.

S (set) = 1

R (reset) = 0

remembered value

1 0

0

0 1

1

Page 34: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

34

Setting the flip-flopBecause the output of the bottom OR gate will now stay at 1, we can lower S to zero, and the circuit will stay in a stable state, with 1 as the

remembered value!

Resetting the flip-flopResetting the remembered value to zero is similar, except we raise, then

lower, the value on R.

S (set) = 0

R (reset) = 0

remembered value

1 0

0

0 1

1

Page 35: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu 1

35

Recap

• Bit string by itself does not carry meaning.

• Bit string can be interpreted under a given representation scheme, which allows us to recover the encoded meaning.

• Circuits made from simple gates let us store and manipulate bit strings.