ece 353 computer systems lab ii vhdl and laboratory tools tutorial professors maciej ciesielski...

19
ECE 353 ECE 353 Computer Systems Lab II Computer Systems Lab II VHDL AND LABORATORY VHDL AND LABORATORY TOOLS TUTORIAL TOOLS TUTORIAL Professors Maciej Professors Maciej Ciesielski & Ciesielski & T. Baird Soules T. Baird Soules

Upload: nigel-johnson

Post on 18-Dec-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

ECE 353 ECE 353 Computer Systems Lab IIComputer Systems Lab II

VHDL AND LABORATORY VHDL AND LABORATORY TOOLS TUTORIALTOOLS TUTORIAL

Professors Maciej Ciesielski &Professors Maciej Ciesielski &

T. Baird SoulesT. Baird Soules

Page 2: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Today’s ObjectivesToday’s Objectives

Basic Principles and Basic Principles and Applications of VHDL Applications of VHDL ProgrammingProgramming

Introduction to Altera Tools Introduction to Altera Tools MAX-PLUS+MAX-PLUS+

Basic Tutorial on Logic Basic Tutorial on Logic Analyzer ToolsAnalyzer Tools

Page 3: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

What is VHDL?What is VHDL?VVery High Speed Integrated Circuit ery High Speed Integrated Circuit

HHardware ardware DDescription escription LLanguageanguage Used to describe a desired logic circuitUsed to describe a desired logic circuit Compiled, Synthesized and Burned Compiled, Synthesized and Burned

onto a working chiponto a working chip Simplifies hardware for large projectsSimplifies hardware for large projects ExamplesExamples: Combinatorial Logic, Finite : Combinatorial Logic, Finite

State MachinesState Machines

Page 4: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Let’s Start SimpleLet’s Start Simple

Combinatorial/Arithmetic LogicCombinatorial/Arithmetic Logic 1-bit full-adder1-bit full-adder

Three Approaches to VHDL Programming: Structural, Arithmetic, and Behavioral

Page 5: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Structural (I)Structural (I)

Included Libraries: Used in compiling and synthesis. The same for each project.

Entity Declaration: Indicates what comes in and what goes out.

Architecture Declaration: Defines the entity on a functional level.

Page 6: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Structural (II)Structural (II)

Structurally Structurally defined code defined code assigns a assigns a logical logical function of function of the inputs to the inputs to each outputeach output

This is most This is most useful for useful for simple simple combinatorial combinatorial logiclogic

Page 7: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

ArithmeticArithmetic

Arithmetic Operation allows for simpler code, but Arithmetic Operation allows for simpler code, but possibly at the expense of chip real estate.possibly at the expense of chip real estate.

What is wrong with this code? Think about how What is wrong with this code? Think about how the integers are implemented by the synthesizer.the integers are implemented by the synthesizer.

Page 8: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Arithmetic (II)Arithmetic (II)

If you choose to code on a higher level, be sure If you choose to code on a higher level, be sure to specify ranges for your variables, otherwise to specify ranges for your variables, otherwise Altera will assume 32-bit unsigned values.Altera will assume 32-bit unsigned values.

There is not enough room on the whole chip to There is not enough room on the whole chip to store one 32-bit value.store one 32-bit value.

Page 9: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

BehavioralBehavioral

Describe how the circuit works is Describe how the circuit works is meant to work and let the meant to work and let the synthesizer work out the details.synthesizer work out the details.

This is most useful for Finite State This is most useful for Finite State Machines and programs involving Machines and programs involving sequential statements and sequential statements and processes. We’ll see some examples processes. We’ll see some examples shortly.shortly.

Page 10: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Bringing Components Bringing Components TogetherTogether

You can design several different You can design several different “circuits” in Altera and then bring “circuits” in Altera and then bring them together to form a larger them together to form a larger design on a single chip.design on a single chip.

Two methods:Two methods:

-Code Directly via the Netlist-Code Directly via the Netlist

-Altera Tools Graphical -Altera Tools Graphical EditorEditor

Page 11: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Structural NetlistStructural NetlistUsing our Full Adder code from earlier. . .

-Each stage is made up of a full adder component.-The fulladd code from earlier is also part of this vhdl file, it is not shown here. -The carry out from each stage is assigned as carry in to the next stage.-Notice that c1, c2, c3 are internal signals written in to allow transfer of data between the stages. -This is important because you cannot specify an output pin of a component as an input pin in the same entity. c1, c2, and c3 are like buffers.

Page 12: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Syntax Notes and Helpful Syntax Notes and Helpful HintsHints Don’t forget semi-colons where Don’t forget semi-colons where

necessarynecessary Top level entity and filename must be Top level entity and filename must be

the samethe same If you design a smaller “circuit” to be If you design a smaller “circuit” to be

part of a larger project, it is worthwhile part of a larger project, it is worthwhile for you to test that small piece to ensure for you to test that small piece to ensure that it functions as you intend it to.that it functions as you intend it to.

More is often less. Be specific about More is often less. Be specific about your code and the synthesizer will your code and the synthesizer will reward you with ample chip space.reward you with ample chip space.

Page 13: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Finite State Machines Finite State Machines (FSMs)(FSMs)

What is an FSM?What is an FSM?

Two types:Two types:– Moore Moore – MealyMealy

Figure B.27

Computer Organization & Design. 2nd Ed. (Patterson, Hennessy)

Page 14: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Moore FSMMoore FSM

Output depends Output depends ONLY on current ONLY on current statestate

Outputs associated Outputs associated with each state are with each state are set at clock set at clock transitiontransition

Page 15: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Mealy FSMMealy FSM

Output depends on Output depends on inputs AND current inputs AND current statestate

Outputs are set Outputs are set during transitionsduring transitions

Page 16: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Coding FSMs in AlteraCoding FSMs in Altera

Page 17: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Process StatementProcess Statement

Process computes outputs of sequential Process computes outputs of sequential statements on each clock tick with statements on each clock tick with respect to the sensitive signals.respect to the sensitive signals.

Sensitivity list

Page 18: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

’’EVENTEVENT

’’EVENT is an Altera construct that EVENT is an Altera construct that represents when the signal is transitioningrepresents when the signal is transitioning

IF statement reads:If Clock is making a positive transition THEN…

Page 19: ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules

Mealy FSM – see Mealy FSM – see mealy1.vhdmealy1.vhd on the on the webweb

Moore FSM - see moore.vhd on the Moore FSM - see moore.vhd on the webweb

Now let’s take a look how to edit, Now let’s take a look how to edit, compile, simulate and synthesize your compile, simulate and synthesize your design using Altera software …. design using Altera software ….

… …. (proceed with hands on tutorial). (proceed with hands on tutorial)

VHDL codes for FSM VHDL codes for FSM