ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

30
ECE 448: Spring 13 Lab 3 equential Logic for Synthesi Simulation using ModelSim

description

ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim. Agenda for today. Part 1: Introduction to Lab 3 Top-level circuit LFSR MISR Debouncer Edge Detector Part 2: Hands-on Session: Simulation Using ModelSim Part 3: Demos of Lab 2. Part 1. - PowerPoint PPT Presentation

Transcript of ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Page 1: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

ECE 448: Spring 13Lab 3

Sequential Logic for Synthesis

Simulation using ModelSim

Page 2: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Part 1: Introduction to Lab 3

• Top-level circuit

• LFSR

• MISR

• Debouncer

• Edge Detector

Part 2: Hands-on Session:

Simulation Using ModelSim

Part 3: Demos of Lab 2

Agenda for today

Page 3: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

ECE 448 – FPGA and ASIC Design with VHDL

Part 1

Introduction to Lab 3

Page 4: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Top-Level Circuit

Page 5: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

rstclk

enCNTRUP

rstclk

enMISR

ld

rst clk

enLFSR

X”00” 8

8

8

IVBloadB

rst

OR

loadB

nexti

10cnz

ld

rst clk

enLFSR

X”00” 8

8

8

IVAloadA

rst

OR

loadA

10cnz

clkclk

LAB2

A B

X Y

sel

En ‘0’

8

clkrst

8

YSGN

nexti

nextrst

clk

enMISR

8

clkrst

8

XSGN

next

10k

k9..8

2

k7..0

8

≠ 0

cnz

= X”3FF”10

done

rstclk

next

OR

AND not donenext

step run

AND

cnz

Page 6: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Used to enterIVA, IVB

Used to generateloadA, loadB,

step, run

Used to displayXSGN, YSGN

Source of Inputs & Display of Outputs (to be experimentally tested in Lab 4)

Page 7: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Connection of Buttons to the Pins of FPGA

Page 8: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

RED = Rising Edge Detector

RESET

BTNL

BTNR

BTNU

BTNS

Debouncer RED loadA

Debouncer RED loadB

Debouncer RED step

rst

Debouncer RED

runD Q‘1’

en

rst

clk

rst

clkrst

clk

rst

clkrst

clk

rst

clk

rst

clk

rst

clk

rst

clk

Generation of Inputs Using Buttons

Page 9: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Pseudo-Random Number Generators

Implemented Using LFSRs

Page 10: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

PRNG• Generates a sequence of numbers that

approximates the properties of random numbers.

• The sequence is fully deterministic, i.e., it can be repeated based on an initial state of PRNG.• The period of the sequence may be made very

large (typically, 2n-1, where n is an internal state size)

Page 11: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

PRNG

• Random Numbers are often important– Testing of VLSI circuits– Cryptography– Monte Carlo simulations– Noise addition– Bit error detection, and many other applications

Page 12: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Linear Feedback Shift Register (LFSR)

L, C(D)

Connection polynomial, C(D)

C(D) = 1 + c1D + c2D2 + . . . + cLDL

Length

Each stage = D flip-flop

Page 13: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Initial state[sL-1, sL-2, . . . , s1, s0]

LSFR recursion:

sj = c1sj-1 c2sj-2 . . . cL-1sj-(L-1) cLsj-L

for j L

Sj-1 Sj-2 Sj-(L-1) Sj-L

Page 14: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

4, 1+D+D4

Connection polynomial, C(D)Length

Example of LFSR

c1=1 c2=0 c3=0 c4=1

C(D) = 1 + 1D + 0D2 + 0D3 + 1D4

Page 15: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

LFSR State Sequence

s4 = c1s3 c2s2 c3s1 c4s0 = s3 s0

s4 s3 s2 s1 s0

Page 16: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

8, 1+D4+D5+D6+D8

Connection polynomial, C(D)Length

LFSR to be used in Lab 3

Selected to make a period = 28-1 = 255

Page 17: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Initializing Serial Shift Register with Parallel Load

D(3)

D Q

Clock

Enable

SinD(2)

D Q

D(1)

D Q

D(0)

D Q

Q(0)Q(1)Q(2)Q(3)

Load

Hint: Use similar technique for initializing LFSR

Page 18: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Multiple Input Signature Register

MISR

Page 19: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

AND

D Q

C7

en

rst

rst

en

D7

AND

D Q

C6

en

rst

rst

en

D6

AND

D Q

C5

en

rst

rst

en

D5

AND

D Q

C4

en

rst

rst

en

D4

AND

D Q

C3

en

rst

rst

en

D3

AND

D Q

C2

en

rst

rst

en

D2

AND

D Q

C1

en

rst

rst

en

D1

AND

D Q

C0

en

rst

rst

en

D0

MISR - Multiple Input Signature Register

Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0

C=C7..C0 should be declared as a generic in VHDL code

For the purpose of testing set C=X”B8”

MISR is used to compress multiple inputs D to a single signature Q

Page 20: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Debouncer

Page 21: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Debouncer

Capacitance in the button and contacts “bouncing” causes spurs that cause false positives.

A debouncing circuit removes these spurs.This graphs shows releasing a button.

Page 22: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Debouncer

When the first change is detected, we ignore all subsequent changes for some period of time, preferably until all of the bouncing would have occurred. This is usually in the order of ms.

Page 23: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Debouncer

Debouncer

reset

input

clk

output

Page 24: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Debouncer

Page 25: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Rising Edge Detector

RED

Page 26: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Rising Edge Detector - RED

• Turn a step function into an impulse• Allows a step to run a circuit for only one clock

cycle

Rising Edge Detector

Page 27: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Rising Edge Detector

clk

input

output

input

clk

output

rising edge detector

reset

Page 28: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

ECE 448 – FPGA and ASIC Design with VHDL

Part 2

Hands-on Session

Simulation Using ModelSim

Page 29: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

Hands-on Session

on ModelSim using

four_bit_counter

based on JK flip-flops

Page 30: ECE 448: Spring 13 Lab 3 Sequential Logic for Synthesis Simulation using ModelSim

ECE 448 – FPGA and ASIC Design with VHDL

Part 3

Lab 2 Demos