58
EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

  • View
    214

  • Download
    1

Embed Size (px)

Citation preview

Page 1: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

EECS 20

Lecture 4 (January 24, 2001)

Tom Henzinger

Block Diagrams

Page 2: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

1 Systems are functions

2 Signals are functions

Page 3: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Systems as Functions

Input Output

Domain: set of possible inputs

Range: set of possible outputs

Graph: set of pairs ( input, output )

Page 4: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Factorial System

!Nats Nats

Page 5: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Factorial System

!Nats Nats

3 6

Page 6: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Factorial System

!Nats Nats

4 24

Page 7: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Factorial System

!Nats Nats

4 24

Domain: Nats

Range: Nats

Graph: { ( 1, 1 ), ( 2, 2 ), ( 3, 6), ( 4, 24 ), … }

Page 8: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Inverter System

Bools

Bools

Page 9: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Inverter System

Bools

Bools true false

Page 10: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Inverter System

Bools

Bools false true

Page 11: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Inverter System

Bools

Bools false true

Domain: Bools

Range: Bools

Graph: { ( true, false ), ( false, true ) }

Page 12: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Composition of Systems

Bools

Bools Bool

s true truefalse

Page 13: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Composition of Systems

Bools

Bools Bool

s false falsetrue

Page 14: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

This is again a system !

Bools Bool

s

Page 15: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

The Identity System

Bools

Bools id

Domain: Bools

Range: Bools

Graph: { ( x, y ) Bools2 | x = y }

Page 16: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

System Composition is Function Composition

= id

because domain ( ) = domain (id)

range ( ) = range (id)

x Bools, ( x ) = id (x)

Page 17: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

And System

Bools

Page 18: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

And System

Bools2 Bools

Page 19: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

And System

Bools (true, false) false

Bools2

Page 20: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

And System

Bools

Bools

Bools

Page 21: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

And System

Bools

Bools

Bools true

falsefalse

Page 22: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Exponentiation System

Nats exp

Nats

Nats 2

3?

-

graph (exp) = { ( (x,y), z ) Nats2 Nats | z = x

y }

Page 23: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Exponentiation System

Nats exp

Nats

Nats 2

38

2

1

graph (exp) = { ( (x,y), z ) Nats2 Nats | z = x

y }

Page 24: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Nats exp

Nats

Nats 2

39

1

2

Exponentiation System

graph (exp) = { ( (x,y), z ) Nats2 Nats | z = x

y }

Page 25: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Bools

Bools

Bools

Bools

Bools

Bools

Block Diagram

This cannot be written easily using .

Page 26: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Bools

Bools

Bools

Block Diagram

true

false

Page 27: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Bools

Bools

Bools

Block Diagram

true

false true

false

Page 28: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Bools

Bools

Bools

Block Diagram

true

false true

false

false

Page 29: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Bools

Bools

Bools

Block Diagram

true

false

true

true

false

false

Page 30: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Bools

Bools

Bools

Or System

domain () = Bools2

range () = Bools

graph () = { ( (x,y), z ) Bools2 Bools | z = x y }

Page 31: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Bools

Bools

Bools

Or System

domain () = Bools2

range () = Bools

graph () = { ( (x,y), z ) Bools2 Bools | z = x y }

-

Page 32: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Block Diagrams with Forks

Page 33: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Block Diagrams with Forks

true

false

Page 34: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Block Diagrams with Forks

true

false

f

Page 35: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Block Diagrams with Forks

true

false

f

f

t

Page 36: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Block Diagrams with Forks

true

false

f

f

t

true

Page 37: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Joins are illegal

Page 38: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Joins are illegal

true

false

Page 39: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Joins are illegal

true

false

f

t

?

Page 40: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Multiple Outputs

Nats

Nats Nats0

Nats0

f

f: Nats2 Nats02 such that

x,yNats, f (x,y) = { (q,r)Nats02 | x = q· y + r r <

y }

Page 41: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Division System

Nats

Nats

divide

divide: Nats2 Nats02 such that

x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r

< y }

1

2

1

2

quotient

remainderNats0

Nats0

Page 42: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Division System

Nats

Nats

divide

7

3

1

2

1

2

divide: Nats2 Nats02 such that

x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r

< y }

Nats0

Nats0

Page 43: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Division System

Nats

Nats

divide

7

3

1

2

1

2

2

1

divide: Nats2 Nats02 such that

x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r

< y }

Nats0

Nats0

Page 44: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Division System

Nats

Nats

divide

3

7

1

2

1

2

divide: Nats2 Nats02 such that

x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r

< y }

Nats0

Nats0

Page 45: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Division System

Nats

Nats

divide

3

7

1

2

1

2

0

3

divide: Nats2 Nats02 such that

x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r

< y }

Nats0

Nats0

Page 46: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Division System

Nats

Nats

divide

9

3

1

2

1

2

3

0

divide: Nats2 Nats02 such that

x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r

< y }

Nats0

Nats0

Page 47: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Many possible implementations

Nats

Nats

1

2

1

2

C program for Euclid’s algorithm

divide

divide: Nats2 Nats02 such that

x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r

< y }

Nats0

Nats0

Page 48: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Many possible implementations

Nats

Nats Nats0

Nats01

2

1

2

circuit

divide

divide: Nats2 Nats02 such that

x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r

< y }

Page 49: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Block diagrams can hide outputs

divide22

1 1

zerocheck

zerocheck: Nats0 Bools such that

xNats, zerocheck (x) x = 0 .

Nats

Nats

Bools

Page 50: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Block Diagrams can hide outputs

divide22

1 1

zerocheck

zerocheck: Nats0 Bools such that

xNats, zerocheck (x) x = 0 .

Nats

Nats

Bools

Page 51: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Block Diagrams can hide outputs

2

1Nats

Nats

Boolsdivisible

divisible: Nats2 Bools such that

x,yNats, divisible (x,y) ( qNats, x = q· y ) .

Page 52: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Hidden inputs are illegal, for now

Page 53: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Hidden inputs are illegal, for now

true

?

Page 54: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Constant functions have no inputs

true

Page 55: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Constant function

true

true truetrue

Page 56: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Cycles are illegal, for now

divide

Page 57: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Block Diagrams

-are nested, directed, acyclic graphs

-allow compositional, hierarchical system description

Page 58: EECS 20 Lecture 4 (January 24, 2001) Tom Henzinger Block Diagrams

Quiz

1. set x, x P(x)

2. function f, { x domain (f) | x = f(x) }

3. n Nats, n = 2 ( n, n+1 ) { 1, 2, 3 }

2

4. f [Nats Nats], f(x) = x 2