CPSC 359

Assignment 2 Prep

PhD Student

Fall 2018

Today

Preparatory material for assignment 2:

  • Stateful problem example
  • 5 variable k-map explanation and example

Pedestrian crosswalk

Problem

Design a crosswalk system in which a user presses a button at the crosswalk, singling a traffic light to turn yellow for a brief moment, then eventually red for at least two seconds. 

It's not a great crosswalk, but it's easy to illustrate the design process

Pedestrian crosswalk

Buttons?

A button isn't great for these designs.

We want behaviour similar to an elevator button.

This is just an SR latch...

Problem

Inputs: 

  • Button press -- we'll name the input variable b

 

Outputs:

  • Red light: r
  • Yellow light: y
  • Green light: g
  • Button reset: reset

How many flip flops do we need?

\(G\)

Assume state transitions happen every 2 seconds

No button press

Button press

\(Y\)

\(R_0\)

\(R_1\)

reset button state

State Diagram

State Diagram

We have \(2^2=4\) states so we need two flip flops to represent this state. We'll name them A and B

00

Assume state transitions happen every two seconds

01

11

10

0/1000

1/0100

X/0010

X/0010

X/1001

b/g,y,r,reset

inputs/outputs

A B b A B Ja Ka Jb Kb
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

State

Next State

J K flip-flop inputs for next state

Excitation Table

\(G\)

\(Y\)

\(R_1\)

\(R_0\)

A B b A B Ja Ka Jb Kb
0 0 0 0 0
0 0 1 0 1
0 1 0 1 1
0 1 1 1 1
1 0 0 0 0
1 0 1 0 0
1 1 0 1 0
1 1 1 1 0

State

Next State

J K flip-flop inputs for next state

Excitation Table

\(G\)

\(Y\)

\(R_1\)

\(R_0\)

A B b A B Ja Ka Jb Kb
0 0 0 0 0 0 X 0 X
0 0 1 0 1
0 1 0 1 1
0 1 1 1 1
1 0 0 0 0
1 0 1 0 0
1 1 0 1 0
1 1 1 1 0

State

Next State

J K flip-flop inputs for next state

Excitation Table

\(G\)

\(Y\)

\(R_1\)

\(R_0\)

A B b A B Ja Ka Jb Kb
0 0 0 0 0 0 X 0 X
0 0 1 0 1 0 X 1 X
0 1 0 1 1
0 1 1 1 1
1 0 0 0 0
1 0 1 0 0
1 1 0 1 0
1 1 1 1 0

State

Next State

J K flip-flop inputs for next state

Excitation Table

\(G\)

\(Y\)

\(R_1\)

\(R_0\)

A B b A B Ja Ka Jb Kb
0 0 0 0 0 0 X 0 X
0 0 1 0 1 0 X 1 X
0 1 0 1 1 1 X X 0
0 1 1 1 1 1 X X 0
1 0 0 0 0 X 1 0 X
1 0 1 0 0 X 1 0 X
1 1 0 1 0 X 0 X 1
1 1 1 1 0 X 0 X 1

State

Next State

J K flip-flop inputs for next state

Excitation Table

\(G\)

\(Y\)

\(R_1\)

\(R_0\)

A B b A B g y r reset
0 0 0 0 0 1 0 0 0
0 0 1 0 1 0 1 0 0
0 1 0 1 1 0 0 1 0
0 1 1 1 1 0 0 1 0
1 0 0 0 0 1 0 0 1
1 0 1 0 0 1 0 0 1
1 1 0 1 0 0 0 1 0
1 1 1 1 0 0 0 1 0

State

Next State

Combinational Outputs

\(G\)

\(Y\)

\(R_1\)

\(R_0\)

Excitation Table

00

01

11

10

0/1000

1/0100

X/0010

X/0010

X/1001

b/g,y,r,reset

inputs/outputs

A B b A B g y r reset
0 0 0 0 0 1 0 0 0
0 0 1 0 1 0 1 0 0
0 1 0 1 1 0 0 1 0
0 1 1 1 1 0 0 1 0
1 0 0 0 0 1 0 0 1
1 0 1 0 0 1 0 0 1
1 1 0 1 0 0 0 1 0
1 1 1 1 0 0 0 1 0

State

Next State

Combinational Outputs

\(G\)

\(Y\)

\(R_1\)

\(R_0\)

Excitation Table

k-Maps

0 0 1 1
X X X X

00

01

11

10

0

1

Ja

A

B,b

1 1 0 0
X X X X

00

01

11

10

0

1

A

B,b

Ka

Ja=B

Ka=B'

k-Maps

0 1 X X
0 0 X X

00

01

11

10

0

1

Jb

A

B,b

X X 0 0
X X 1 1

00

01

11

10

0

1

A

B,b

Kb

Jb=A'b

Kb=A

k-Maps

1 0 0 0
1 1 0 0

00

01

11

10

0

1

g

A

B,b

0 1 0 0
0 0 0 0

00

01

11

10

0

1

A

B,b

y

g=B'b' + AB'

y=A'B'b

k-Maps

0 0 1 1
0 0 1 1

00

01

11

10

0

1

r

A

B,b

0 0 0 0
1 1 0 0

00

01

11

10

0

1

A

B,b

reset

r=B

reset=AB

k-Map Recap

Ja=B

Ka=B'

Jb=A'b

Kb=A

g=B'b' + AB'

y=A'B'b

r=B

reset=AB

The minimized functions are:

Logisim Demo

00

01

11

10

0/1000

1/0100

X/0010

X/0010

X/1001

State Diagram Notes

00

01

10

11

0/1000

1/0100

X/0010

X/0010

X/1001

State Diagram Notes

A B b A B Ja Ka Jb Kb
0 0 0 0 0 0 X 0 X
0 0 1 0 1 0 X 1 X
0 1 0 1 0 1 X 1 X
0 1 1 1 0 1 X 1 X
1 0 0 1 1 X 0 1 X
1 0 1 1 1 X 0 1 X
1 1 0 0 0 X 1 X 1
1 1 1 0 0 X 1 X 1

State

Next State

J K flip-flop inputs for next state

Excitation Table

\(G\)

\(Y\)

\(R_1\)

\(R_0\)

00

01

10

11

/01

/11

/10

/00

Two Bit Gray Code

Without direction or enable

00

01

11

10

/01

/11

/10

/00

Two Bit Gray Code

Without direction or enable

5-variable k-Maps

a b c d e f(a,b,c,d,e)
0 0 0 0 0 0
0 0 0 0 1 1
0 0 0 1 0 0
0 0 0 1 1 1
0 0 1 0 0 0
0 0 1 0 1 1
0 0 1 1 0 0
0 0 1 1 1 0
0 1 0 0 0 0
0 1 0 0 1 1
0 1 0 1 0 0
0 1 0 1 1 1
0 1 1 0 0 1
0 1 1 0 1 0
0 1 1 1 0 0
0 1 1 1 1 0

5-variable k-Maps

a b c d e f(a,b,c,d,e)
1 0 0 0 0 1
1 0 0 0 1 1
1 0 0 1 0 0
1 0 0 1 1 1
1 0 1 0 0 0
1 0 1 0 1 0
1 0 1 1 0 0
1 0 1 1 1 0
1 1 0 0 0 0
1 1 0 0 1 1
1 1 0 1 0 0
1 1 0 1 1 1
1 1 1 0 0 1
1 1 1 0 1 0
1 1 1 1 0 0
1 1 1 1 1 1

5-variable k-Maps

a=0

a=1

bc

bc

de

de

00

01

11

10

00

01

11

10

00

01

11

10

General Strategy: Use two 4 variable maps

00

01

11

10

5-variable k-Maps

a b c d e f(a,b,c,d,e)
0 0 0 0 0 0
0 0 0 0 1 1
0 0 0 1 0 0
0 0 0 1 1 1
0 0 1 0 0 0
0 0 1 0 1 1
0 0 1 1 0 0
0 0 1 1 1 0
0 1 0 0 0 0
0 1 0 0 1 1
0 1 0 1 0 0
0 1 0 1 1 1
0 1 1 0 0 1
0 1 1 0 1 0
0 1 1 1 0 0
0 1 1 1 1 0

5-variable k-Maps

0 1 1 0
0 1 0 0
1 0 0 0
0 1 1 0

a=0

a=1

bc

bc

de

de

00

01

11

10

00

01

11

10

00

01

11

10

General Strategy: Use two 4 variable maps

00

01

11

10

5-variable k-Maps

a b c d e f(a,b,c,d,e)
1 0 0 0 0 1
1 0 0 0 1 1
1 0 0 1 0 0
1 0 0 1 1 1
1 0 1 0 0 0
1 0 1 0 1 0
1 0 1 1 0 0
1 0 1 1 1 0
1 1 0 0 0 0
1 1 0 0 1 1
1 1 0 1 0 0
1 1 0 1 1 1
1 1 1 0 0 1
1 1 1 0 1 0
1 1 1 1 0 0
1 1 1 1 1 1

5-variable k-Maps

0 1 1 0
0 1 0 0
1 0 0 0
0 1 1 0
1 1 1 0
0 0 0 0
1 0 1 0
0 1 1 0

a=0

a=1

bc

bc

de

de

00

01

11

10

00

01

11

10

00

01

11

10

General Strategy: Use two 4 variable maps

00

01

11

10

5-variable k-Maps

a=0

a=1

5-variable k-Maps

0 1 1 0
0 1 0 0
1 0 0 0
0 1 1 0
1 1 1 0
0 0 0 0
1 0 1 0
0 1 1 0

a=0

a=1

bc

bc

de

de

00

01

11

10

00

01

11

10

00

01

11

10

Colour indicates the same group

00

01

11

10

bcd'e'

+ c'e

+ a'b'd'e

+ abde

+ ab'c'd'

f(a,b,c,d,e) =

CPSC 359: Assignment 2 Prep

By Joshua Horacsek

CPSC 359: Assignment 2 Prep

  • 1,628