advanced digital logic design – eecs...

105
Advanced Digital Logic Design – EECS 303 http://ziyang.eecs.northwestern.edu/eecs303/ Teacher: Robert Dick Office: L477 Tech Email: [email protected] Phone: 847–467–2298

Upload: others

Post on 01-Nov-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

Advanced Digital Logic Design – EECS 303

http://ziyang.eecs.northwestern.edu/eecs303/

Teacher: Robert DickOffice: L477 TechEmail: [email protected]: 847–467–2298

Page 2: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Outline

1. System specification languages

2. Brief introduction to VHDL

3. VHDL sequential system design and specification styles

4. Homework

2 Robert Dick Advanced Digital Logic Design

Page 3: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

System design languages

Software-oriented languages

Graph-based languages

Hardware-oriented languages

3 Robert Dick Advanced Digital Logic Design

Page 4: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Section outline

1. System specification languagesSoftware-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

4 Robert Dick Advanced Digital Logic Design

Page 5: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Software oriented specification languages

ANSI-C

SystemC

Other SW language-based

5 Robert Dick Advanced Digital Logic Design

Page 6: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

ANSI-C

Advantages

Huge code base

Many experienced programmers

Efficient means of SW implementation

Good compilers for many SW processors

Disadvantages

Little implementation flexibility

Strongly SW orientedMakes many assumptions about platform

Poor support for fine-scale HW synchronization

6 Robert Dick Advanced Digital Logic Design

Page 7: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

SystemC

Advantages

Support from big players

Synopsys, Cadence, ARM, Red Hat, Ericsson, Fujitsu, InfineonTechnologies AG, Sony Corp., STMicroelectronics, and TexasInstruments

Familiar for SW engineers

Disadvantages

Extension of SW language

Not designed for HW from the start

Compiler available for limited number of SW processors

New

7 Robert Dick Advanced Digital Logic Design

Page 8: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Other SW language-based

Numerous competitors

Numerous languages

ANSI-C, C++, and Java are most popular starting points

In the end, few can survive

SystemC has broad support

8 Robert Dick Advanced Digital Logic Design

Page 9: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Section outline

1. System specification languagesSoftware-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

9 Robert Dick Advanced Digital Logic Design

Page 10: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Graph-based specification languages

Dataflow graph (DFG)

Synchronous dataflow graph (SDFG)

Control flow graph (CFG)

Control dataflow graph (CDFG)

Finite state machine (FSM)

Petri net

Periodic vs. aperiodic

Real-time vs. best effort

Discrete vs. continuous timing

Example from research

10 Robert Dick Advanced Digital Logic Design

Page 11: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Dataflow graph (DFG)

5 kbNEG

IOP

FIL

FT

DCT

3 kb

4 kb 4 kb

6 kb

3 kb

Soft DL = 150 ms

Soft DL = 230 ms

5 kbNEG

IOP

FIL

FT

DCT

3 kb

4 kb 4 kb

6 kb

3 kb

Nodes are tasks

Edges are data dependencies

Edges have communicationquantities

Used for digital signalprocessing (DSP)

Often acyclic when real-time

Can be cyclic when best-effort

11 Robert Dick Advanced Digital Logic Design

Page 12: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Dataflow graph (DFG)

5 kbNEG

IOP

FIL

FT

DCT

3 kb

4 kb 4 kb

6 kb

3 kb

Soft DL = 150 ms

Soft DL = 230 ms

5 kbNEG

IOP

FIL

FT

DCT

3 kb

4 kb 4 kb

6 kb

3 kb

Nodes are tasks

Edges are data dependencies

Edges have communicationquantities

Used for digital signalprocessing (DSP)

Often acyclic when real-time

Can be cyclic when best-effort

11 Robert Dick Advanced Digital Logic Design

Page 13: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Control flow graph (CFG)

false

false true

true

if k = 3

if i < 2

k = k − 1

j = j + 5

Nodes are tasks

Supports conditionals, loops

No communication quantities

SW background

Often cyclic

12 Robert Dick Advanced Digital Logic Design

Page 14: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Control dataflow graph (CDFG)

≤ 3 msfalse

false true

true

if k = 3

if i < 2

240 Kb

30 Kb

387 Kb

27 Kb

k = k − 1

j = j + 5

Supports conditionals, loops

Supports communicationquantities

Used by some high-levelsynthesis algorithms

13 Robert Dick Advanced Digital Logic Design

Page 15: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Finite state machine (FSM)

1 1 0

1

0

1 0

0

14 Robert Dick Advanced Digital Logic Design

Page 16: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Finite state machine (FSM)

input0 1

00 10 0001 01 0010 00 0111 10 00

current next

Normally used at lower levels

Difficult to representindependent behavior

State explosion

No built-in representation fordata flow

Extensions have beenproposed

Extensions represent SW, e.g.,co-design finite statemachines (CFSMs)

15 Robert Dick Advanced Digital Logic Design

Page 17: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Section outline

1. System specification languagesSoftware-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

16 Robert Dick Advanced Digital Logic Design

Page 18: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Design representations

VHDL

Verilog

17 Robert Dick Advanced Digital Logic Design

Page 19: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

VHDL

Advantages

Supports abstract data types

System-level modeling supported

Better support for test harness design

Disadvantages

Requires extensions to easily operate at the gate-level

Difficult to learn

Slow to code

18 Robert Dick Advanced Digital Logic Design

Page 20: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Verilog

Advantages

Easy to learn

Easy for small designs

Disadvantages

Not designed to handle large designs

Not designed for system-level

19 Robert Dick Advanced Digital Logic Design

Page 21: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Verilog vs. VHDL

March 1995, Synopsys Users Group meeting

Create a gate netlist for the fastest fully synchronous loadable9-bit increment-by-3 decrement-by-5 up/down counter thatgenerated even parity, carry, and borrow

5 / 9 Verilog users completed

0 / 5 VHDL users completed

Does this mean that Verilog is better?Maybe, but maybe it only means that Verilog is easier to use forsimple designs. VHDL has better system-level support.

20 Robert Dick Advanced Digital Logic Design

Page 22: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Verilog vs. VHDL

March 1995, Synopsys Users Group meeting

Create a gate netlist for the fastest fully synchronous loadable9-bit increment-by-3 decrement-by-5 up/down counter thatgenerated even parity, carry, and borrow

5 / 9 Verilog users completed

0 / 5 VHDL users completed

Does this mean that Verilog is better?Maybe, but maybe it only means that Verilog is easier to use forsimple designs. VHDL has better system-level support.

20 Robert Dick Advanced Digital Logic Design

Page 23: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

Active HDL debate

Synopsys CEO pushes System Verilog

No new VHDL project starts

However, many FPGA designers prefer VHDL

Many places replacing ASICs with FPGAs

A lot of controversy recently

End result unknown

21 Robert Dick Advanced Digital Logic Design

Page 24: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

VHDL

We’ll be introducing VHDL

This will be helpful for later courses

This course will only introduce the language

If you know VHDL and C, learning Verilog will be easy

Still has better support for system-level design

Learn VHDL now but realize that you will probably need to knowmore than one system design language in your career, e.g.,System Verilog, SystemC, or both

22 Robert Dick Advanced Digital Logic Design

Page 25: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Software-oriented specification languagesGraph-based specification languagesHardware-oriented specification languages

System-level representations summary

No single representation has been decided upon

Software-based representations becoming more popular

System-level representations will become more important

Substantial recent changes in the VHDL/Verilog argument

23 Robert Dick Advanced Digital Logic Design

Page 26: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Outline

1. System specification languages

2. Brief introduction to VHDL

3. VHDL sequential system design and specification styles

4. Homework

24 Robert Dick Advanced Digital Logic Design

Page 27: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Section outline

2. Brief introduction to VHDLVHDL background and overviewSignals and timingControl structuresExamplesTest benches

25 Robert Dick Advanced Digital Logic Design

Page 28: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Introduction to VHDL

This is an overview and introduction only!

You may need to use reference material occasionally

VHDL basics

Interface

Architecture body

Process

Signal assignment and delay models

Sequential statements

26 Robert Dick Advanced Digital Logic Design

Page 29: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Modeling

VHDL designed to model any digital circuit that processes orstores information

Model represents relevant information, omits irrelevant detail

Should support

Specification of requirementsSimulationFormal verificationSynthesis

27 Robert Dick Advanced Digital Logic Design

Page 30: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

VHDL roots

Very High Speed Integrated Circuits (VHSIC)

VHSIC Hardware Description Language (VHDL)1 Model digital systems2 Simulate the modeled systems3 Specify designs to CAD tools for synthesis

VHDL provides a blackboard for designing digital systems

An initial design is progressively expanded and refined

28 Robert Dick Advanced Digital Logic Design

Page 31: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Functional and structural specification

VHDL capable of functional and structural specification

Functional: What happens

Structural: How components are connected together

Supports different levels, from algorithmic to gate

29 Robert Dick Advanced Digital Logic Design

Page 32: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Example functional specification

entity XOR2_OP is-- IO portsport (

A, B : in bit;Z : out bit

);end XOR2_OP;

-- Bodyarchitecture EX_DISJUNCTION of XOR_OP2 isbegin

Z <= A xor B;end EX_DISJUNCTION;

30 Robert Dick Advanced Digital Logic Design

Page 33: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

VHDL interface and body

A VHDL entity consists of two parts1 Interface denoted by keyword entity

Describes external view

2 Body denoted by keyword architecture

Describes implementation

31 Robert Dick Advanced Digital Logic Design

Page 34: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Interface

entity [identifier] isport ([name]: in/out/inout bit/[type]);end [identifier];-- lines beginning with two dashes are comments

32 Robert Dick Advanced Digital Logic Design

Page 35: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Body

Architecture body describes functionality

Allows for different implementations

Can have behavioral, structural, or mixed representations

33 Robert Dick Advanced Digital Logic Design

Page 36: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Body

architecture [identifier] of[interface identifier] is

begin[code]

end [identifier];

34 Robert Dick Advanced Digital Logic Design

Page 37: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Data types

The type of a data object defines the set of values that objectcan assume and set of operations on those values

VHDL is strongly typed

Operands not implicitly converted

Four classes of objects1 Constants2 Variables3 Signals4 Files

35 Robert Dick Advanced Digital Logic Design

Page 38: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Constants

The value of a constant cannot be changed

constant [identifier] : [type] (:= expression)

Examples

constant number of bytes : integer := 4;constant prop delay : time := 3ns;constant e : real := 2.2172;

36 Robert Dick Advanced Digital Logic Design

Page 39: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Variable declaration

The value of a variable can be changed

variable [identifier] [type] (:= [expression])

Examples

variable index: integer := 0;variable sum, average, largest : real;variable start, finish : time := 0 ns;

37 Robert Dick Advanced Digital Logic Design

Page 40: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Variable assignment

Once a variable is declared, its value can be modified by anassignment statement

([label] :) [name] := [expression];

Examples

program counter := 0;index := index + 1;

Variable assignment different from signal assignment

A variable assignment immediately overrides variable with newvalue

A signal assignment schedules new value at later time

38 Robert Dick Advanced Digital Logic Design

Page 41: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Scalar types

Variable can only assign values of nominated type

Default types: integer, real, character, boolean, bit

User defined types: type small int is range 0 to 255;

Enumerated types: type logiclevel is (unknown, low, driven,high);

39 Robert Dick Advanced Digital Logic Design

Page 42: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Sub-types

A type defines a set of values

Sub-type is a restricted set of values from a base type

subtype [identifier] is [name] range [simple expression] to/downto[simple expression]

Examples

subtype small int is integer range -128 to 127;subtype bit index is integer range 31 downto 0;

40 Robert Dick Advanced Digital Logic Design

Page 43: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Operators

Operator Operation Operand types** exponentiation integer, realabs absolute value numeric

*, /, mod, rem mult, div, modulus, remainder integer, realand, nand, or, nor, xor, xnor, not logical ops bit, boolean, or 1-D array

sll, srl, sla,sra Shift left/right 1-D array of bit/boolean+, - add, subtract integer, real

=, / =, <, <=, >, >= equal, greater scalar

41 Robert Dick Advanced Digital Logic Design

Page 44: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

VHDL modeling concepts

Meaning is heavily based on simulation

A design is described as a set of interconnected modules

A module could be another design (component) or could bedescribed as a sequential program (process)

42 Robert Dick Advanced Digital Logic Design

Page 45: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

VHDL simulator

start

Stop

I ni t

t = 0

m ore

ev ent

get ear l i est

event

del ta delay

update

si gnal s

adv ance

tim e

ex ecute

tr i ggered

processes

43 Robert Dick Advanced Digital Logic Design

Page 46: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Process statements

[process label]: process-- declarative part declares functions, procedures,-- types, constants, variables, etc.begin-- Statement partsequential statement;sequential statement;-- E.g., Wait for 1 ms; or wait on ALARM_A;wait statement;sequential statement;...wait statement;end process;

44 Robert Dick Advanced Digital Logic Design

Page 47: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Sequential statements

Sequential statements of various types are executed in sequencewithin each VHDL process

Variable statement

[variable] := [expression];

Signal Assignment

If statement

Case statement

Loop statement

Wait statement

45 Robert Dick Advanced Digital Logic Design

Page 48: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Section outline

2. Brief introduction to VHDLVHDL background and overviewSignals and timingControl structuresExamplesTest benches

46 Robert Dick Advanced Digital Logic Design

Page 49: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Variable and sequential signal assignment

Variable assignment

New values take effect immediately after execution

variable LOGIC A, LOGIC B : BIT;LOGIC A := ’1’;LOGIC B := LOGIC A;

Signal assignment

New values take effect after some delay (delta if not specified)

signal LOGIC A : BIT;LOGIC A <= ’0’;LOGIC A <= ’0’ after 1 sec;LOGIC A <= ’0’ after 1 sec, ’1’ after 3.5 sec;

47 Robert Dick Advanced Digital Logic Design

Page 50: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Signal declaration and assignment

Signal declaration: Describes internal signal

signal [identifier] : [type] [ := expression]

Example: signal and a, and b : bit;

Signal Assignment: name <= value expression [ aftertime expression];

Example: y <= not or a b after 5 ns;

This specifies that signal y is to take on a new value at a time5 ns later statement execution.

Difference from variable assignment, which only assigns somevalues to a variable

48 Robert Dick Advanced Digital Logic Design

Page 51: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Inertial delay model

Reflects inertia of physical systems

Glitches of very small duration not reflected in outputs

Logic gates exhibit low-pass filtering

SIG OUT <= not SIG IN after 7 ns –implicit

SIG OUT <= inertial ( not SIG IN after 7 ns )

49 Robert Dick Advanced Digital Logic Design

Page 52: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Transport delay model

Under this model, ALL input signal changes are reflected at theoutput

SIG OUT <= transport not SIG IN after 7 ns;

50 Robert Dick Advanced Digital Logic Design

Page 53: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Section outline

2. Brief introduction to VHDLVHDL background and overviewSignals and timingControl structuresExamplesTest benches

51 Robert Dick Advanced Digital Logic Design

Page 54: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

If statement

if [boolean expression] then

[sequential statement]

elsif [boolean expression] then

[sequential statement]

else

[sequential statement]

endif;

if sel=0 then

result <= input_0; -- executed if sel = 0

else

result <= input_1; -- executed if sel = 1

endif;

52 Robert Dick Advanced Digital Logic Design

Page 55: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Case statement

Example of an ALU operation

case func iswhen pass1 =>

result := operand1;when pass2 =>

result := operand2;when add =>

result := operand1 + operand2;when subtract =>

result := operand1 - operand2;end case;

53 Robert Dick Advanced Digital Logic Design

Page 56: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

While

while condition loop[sequential statements]

end loop;

while index > 0 loopindex := index -1;

end loop;

54 Robert Dick Advanced Digital Logic Design

Page 57: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

For

for identifier in range loop[sequential statements]

end loop;

for count in 0 to 127 loopcount_out <= count;wait for 5~ns;

end loop;

for i in 1 to 10 loopcount := count + 1;

end loop;

55 Robert Dick Advanced Digital Logic Design

Page 58: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Wait statement

A wait statement specifies how a process responds to changes insignal values.

wait on [signal name]wait until [boolean expression]wait for [time expression]

56 Robert Dick Advanced Digital Logic Design

Page 59: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Wait statement example

half_add: process isbegin

sum <= a xor b after T_pd;carry <= a and b after T_pd;wait on a, b;

end process;

57 Robert Dick Advanced Digital Logic Design

Page 60: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Equivalent process sensitivity list

half_add: process (a,b) isbegin

sum <= a xor b after T_pd;carry <= a and b after T_pd;

end process;

58 Robert Dick Advanced Digital Logic Design

Page 61: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Section outline

2. Brief introduction to VHDLVHDL background and overviewSignals and timingControl structuresExamplesTest benches

59 Robert Dick Advanced Digital Logic Design

Page 62: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Clock generator

clock_gen: process (clk) isbegin

if clk = ’0’ thenclk <= ’1’ after T_pw, ’0’ after 2*T_pw;

endif;end process clock_gen;

60 Robert Dick Advanced Digital Logic Design

Page 63: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

MUX example

mux: process (a, b, sel) isbegin

case sel iswhen ’0’ =>

z <= a after prop_delay;when ’1’ =>

z <= b after prop_delay;end process mux;

61 Robert Dick Advanced Digital Logic Design

Page 64: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

XOR2 functional example

-- Interfaceentity XOR2_OP is-- IO

port (a, b: in bit;z: out bit

);end XOR2_OP;

62 Robert Dick Advanced Digital Logic Design

Page 65: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

XOR2 functional example (cont.)

-- Bodyarchitecture EX_DISJUNCTION of XOR2_OP isbegin

z <= a xor b;end EX_DISJUNCTION;

63 Robert Dick Advanced Digital Logic Design

Page 66: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

XOR3 structural example

entity XOR3_OP isport (

a, b, c: in bit;z: out bit

);end XOR3_OP;

64 Robert Dick Advanced Digital Logic Design

Page 67: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

XOR3 structural example (cont.)

architecture DISJ_STRUCT of XOR3_OP iscomponent XOR2_OP

port (a, b: in bit; z: out bit);end component;signal a_int: bit;beginx1: XOR2_OP port map (a, b, a_int);x2: XOR2_OP port map (c, a_int, z);end DISJ_STRUCT;

65 Robert Dick Advanced Digital Logic Design

Page 68: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Section outline

2. Brief introduction to VHDLVHDL background and overviewSignals and timingControl structuresExamplesTest benches

66 Robert Dick Advanced Digital Logic Design

Page 69: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Test bench for XOR2

entity test_bench isend;

architecture test1 of test_bench issignal a, b, z : BIT := ’0’;component XOR2_OPport (a, b: in BIT; z : out BIT);end component;for U1: XOR2_OP use

entity work.XOR2_OP(EX_DISJUNCTION);beginU1: XOR2_OP port map (a, b, z);

67 Robert Dick Advanced Digital Logic Design

Page 70: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Test bench for XOR2 (cont.)

input_changes: processbegina <= ’0’ after 0 ns,’1’ after 10 ns;b <= ’0’ after 0 ns,’1’ after 5 ns,’0’ after 10 ns,’1’ after 15 ns;wait;end process;end test1;

68 Robert Dick Advanced Digital Logic Design

Page 71: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Test bench for XOR3

architecture test2 of test_bench issignal a, b, c, z : BIT := ’0’;component XOR3_OPport (a, b, c: in BIT; z : out BIT);end component;for U1: XOR3_OP use

entity work.XOR3_OP(DISJ_STRUCT);beginU1: XOR3_OP port map (a, b, c, z);

69 Robert Dick Advanced Digital Logic Design

Page 72: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Test bench for XOR3 (cont.)

a_change: processbegin loop

a <= ’0’;wait for 5 ns;a <= ’1’;wait for 5 ns;

end loop;end process;

70 Robert Dick Advanced Digital Logic Design

Page 73: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Test bench for XOR3 (cont.)

b_change: processbegin loop

b <= ’0’;wait for 10 ns;b <= ’1’;wait for 10 ns;

end loop;end process;

71 Robert Dick Advanced Digital Logic Design

Page 74: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

VHDL background and overviewSignals and timingControl structuresExamplesTest benches

Test bench for XOR3 (cont.)

c_change: processbegin loop

c <= ’0’;wait for 20 ns;c <= ’1’;wait for 20 ns;

end loop;end process;

end test2;

72 Robert Dick Advanced Digital Logic Design

Page 75: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Outline

1. System specification languages

2. Brief introduction to VHDL

3. VHDL sequential system design and specification styles

4. Homework

73 Robert Dick Advanced Digital Logic Design

Page 76: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Section outline

3. VHDL sequential system design and specification stylesSequential system designBehavior and structural specification

74 Robert Dick Advanced Digital Logic Design

Page 77: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Introduction to VHDL sequential system design

Fundamental meaning of state variables

AFSM solution to latch problem

Use of asynchronous reset

Multiple output sequence detector

Multi-output pattern recognizers

Laboratory four walk-through

VHDL examples

75 Robert Dick Advanced Digital Logic Design

Page 78: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Fundamental meaning of state variables

They are not remembering something specific about the inputs

Every state transition is a function of the current state and inputonly

However, multiple cycles of memory are possible because thecurrent state is a function of the state before it

When designing an FSM, consider the meaning of each state

Example: Design a recognizer for any sequence that ends with 01and observed 1101 at any time.

76 Robert Dick Advanced Digital Logic Design

Page 79: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Lab assignment four

Use VHDL to specify and synthesize a FSM

Design a pattern recognizer FSM

Specify it in VHDL

Simulate it with Mentor Graphics ModelSim

Synthesize it with Synopsys Design Compiler

77 Robert Dick Advanced Digital Logic Design

Page 80: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Multiple-output sequence detector

If the last two inputs were 00, G is high

If the last three inputs were 100, H is high

78 Robert Dick Advanced Digital Logic Design

Page 81: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Lab example interface

entity RECOG isport (

clk, a, reset: in bit;h: out bit

);end RECOG;

79 Robert Dick Advanced Digital Logic Design

Page 82: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Lab example body

architecture STATE_MACHINE of RECOG is

type state_type is (s0, s1, s2, s3);

signal ps, ns : state_type;

begin

STATE: process (reset, clk)

begin

if (reset = ’1’) then

ps <= s0;

elsif (clk’event and clk = ’1’) then

ps <= ns;

end if;

end process STATE;

80 Robert Dick Advanced Digital Logic Design

Page 83: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Lab example body

NEW_STATE: process (ps, a)

begin

case ps is

when s0 =>

case a is

when ’0’ => ns <= s1;

when ’1’ => ns <= s0;

end case;

when s1 =>

case a is

when ’0’ => ns <= s2;

when ’1’ => ns <= s0;

end case;

81 Robert Dick Advanced Digital Logic Design

Page 84: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Lab example body

when s2 =>

case a is

when ’0’ => ns <= s2;

when ’1’ => ns <= s3;

end case;

when s3 =>

case a is

when ’0’ => ns <= s1;

when ’1’ => ns <= s0;

end case;

end case;

end process NEW_STATE;

82 Robert Dick Advanced Digital Logic Design

Page 85: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Lab example body

OUTPUT: process (ps)begin

case ps iswhen s0 => h <= ’0’;when s1 => h <= ’0’;when s2 => h <= ’0’;when s3 => h <= ’1’;

end case;end process OUTPUT;

end STATE_MACHINE;

83 Robert Dick Advanced Digital Logic Design

Page 86: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Test bench

entity test_bench is

end;

architecture test_recog of test_bench is

signal clk, input, reset, output : bit := ’0’;

component RECOG

port (clk, a, reset: in bit; h : out bit);

end component;

for U1: RECOG use entity work.RECOG(STATE_MACHINE);

begin

U1: RECOG port map (clk, input, reset, output);

84 Robert Dick Advanced Digital Logic Design

Page 87: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Test bench

CLK_CHANGE: processbegin

loopclk <= ’1’;wait for 5 ns;clk <= ’0’;wait for 5 ns;

end loop;end process CLK_CHANGE;

85 Robert Dick Advanced Digital Logic Design

Page 88: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Test bench

RESET_CHANGE: processbegin

reset <= ’1’ after 0 ns,’0’ after 5 ns;

wait;end process RESET_CHANGE;

86 Robert Dick Advanced Digital Logic Design

Page 89: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Test bench

INPUT_CHANGE: process

begin

input <=

’0’ after 5 ns,

’1’ after 15 ns,

’0’ after 25 ns,

’0’ after 35 ns,

’1’ after 45 ns,

’0’ after 55 ns,

’1’ after 65 ns,

’1’ after 75 ns,

’0’ after 85 ns,

’0’ after 95 ns,

’0’ after 105 ns,

’1’ after 115 ns;

wait;

end process INPUT_CHANGE;

end test_recog;

87 Robert Dick Advanced Digital Logic Design

Page 90: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Timing diagram

0 40 80 120

/test_bench/clk

/test_bench/input

/test_bench/reset

/test_bench/output

Entity:test_bench Architecture:test_recog Date: Thu May 29 01:09:07 CDT 2003 Row: 1 Page: 1

88 Robert Dick Advanced Digital Logic Design

Page 91: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Optimized implementation

89 Robert Dick Advanced Digital Logic Design

Page 92: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Section outline

3. VHDL sequential system design and specification stylesSequential system designBehavior and structural specification

90 Robert Dick Advanced Digital Logic Design

Page 93: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Behavioral and structural specification

Can either specify behavior or structure of circuit

May use both styles in a single design

Also have control over detail of specification

For example, can keep states abstract and allow synthesis tool todo assignment

91 Robert Dick Advanced Digital Logic Design

Page 94: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Detail of specification

Could manually specify states

Could describe entire circuit’s connectivity

Abstract specifications allow synthesis software more freedom

Have more potential for automatic optimization

Detailed specification doesn’t rely on as much intelligence insynthesis

92 Robert Dick Advanced Digital Logic Design

Page 95: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

VHDL behavioral modeling example

architecture primitive of and_or_inv issignal and_a, and_b, or_a_b : bit;beginand_gate_a : process (a1,a2) isbegin

and_a <= a1 and a2;end process and_gate_a;and_gate_b : process (b1,b2) isbegin

and_b <= b1 and b2;end process and_gate_b;

93 Robert Dick Advanced Digital Logic Design

Page 96: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Behavioral modeling example (cont.)

or_gate: process (and_a, and_b) isbegin

or_a_b <= and_a or and_b;end process or_gate;inv : process (or_a_b) isbegin

y <= not or_a_b;end process inv;end architecture primitive;

94 Robert Dick Advanced Digital Logic Design

Page 97: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

High-level algorithmic specification

cpu: process is

variable instr_reg, PC : word;

begin

loop

address <= PC;

mem_read <= 1;

wait until mem_ready = 1;

PC := PC + 4; -- variable assignment, not a signal;

--- execute instruction

end loop;

end process cpu;

95 Robert Dick Advanced Digital Logic Design

Page 98: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Memory specification

memory: process is

type memory_array is array (0 to 2**14 - 1) of word;

variable store: memory_array := ();

begin

wait until mem_read = 1 or mem_write = 1;

if mem_read = 1 then

read_data <= store(address/4);

mem_ready <= 1;

wait until mem_ready = 0;

else

. --- perform write access;

end process memory;

96 Robert Dick Advanced Digital Logic Design

Page 99: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Example of component instantiation

Structural specification requires connecting components

entity DRAM_controller isport (rd, wr, mem: in bit;

ras, cas, we, ready: out bit);end entity DRAM_controller;

97 Robert Dick Advanced Digital Logic Design

Page 100: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

Example of component instantiation

We can then perform a component instantiation as follows assumingthat there is a corresponding architecture called “fpld” for the entity.

main_mem_cont : entity work.DRAM_controller(fpld)port map(rd=>cpu_rd, wr=>cpu_wr,

mem=>cpu_mem, ready=>cpu_rdy,ras=>mem_ras, cas=>mem_cas, we=>mem_we);

98 Robert Dick Advanced Digital Logic Design

Page 101: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

VHDL synthesis quirks

Given a statement

y <= a + b + c + d;

Synthesis tool will create a tree of adders by adding a + b, thenadding to c, and then to c;

Instead if specified as

y <= (a +b) + (c +d);

The synthesis tool will be forced to synthesize a tree of depth 2by adding (a+b), and (c+d) in parallel, then adding resultstogether.

99 Robert Dick Advanced Digital Logic Design

Page 102: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Sequential system designBehavior and structural specification

VHDL synthesis quirks

Another possible mistake

y <= a or b or c and d;

Instead write as

y <= (a or b) or (c and d);

100 Robert Dick Advanced Digital Logic Design

Page 103: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Outline

1. System specification languages

2. Brief introduction to VHDL

3. VHDL sequential system design and specification styles

4. Homework

101 Robert Dick Advanced Digital Logic Design

Page 104: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Reading assignment

Zvi Kohavi. Switching and Finite Automata Theory. McGraw-HillBook Company, NY, 1978

Chapter 11

102 Robert Dick Advanced Digital Logic Design

Page 105: Advanced Digital Logic Design – EECS 303ziyang.eecs.umich.edu/~dickrp/eecs303/lectures/adld-l12.pdf · 2008. 12. 3. · VHDL designed to model any digital circuit that processes

System specification languagesBrief introduction to VHDL

VHDL sequential system design and specification stylesHomework

Next lecture

More on VHDL

Introduction to asynchronous FSM design

103 Robert Dick Advanced Digital Logic Design