5
7/30/2019 LECT04 DIGITAL DESIGN http://slidepdf.com/reader/full/lect04-digital-design 1/5 Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-1 Electrical & Computer Engineering Digital Systems Design Guidelines for VHDL-based Design Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-2 Electrical & Computer Engineering VHDL coding basics Here, we describe a set of basic guidelines for coding in VHDL • The objective is to produce readable VHDL source that is targeted for synthesis Many factors affect the ultimate performance of a VHDL-based design including VHDL coding style EDA tool(s) used: synthesis and place/route Characteristics of the target device User/designer awareness of how the above 3 items interact and depend on each other

LECT04 DIGITAL DESIGN

Embed Size (px)

Citation preview

Page 1: LECT04 DIGITAL DESIGN

7/30/2019 LECT04 DIGITAL DESIGN

http://slidepdf.com/reader/full/lect04-digital-design 1/5

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-1Electrical & Computer Engineering

Digital Systems Design

Guidelines for VHDL-based Design

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-2Electrical & Computer Engineering

VHDL coding basics

• Here, we describe a set of basic guidelines forcoding in VHDL

• The objective is to produce readable VHDL sourcethat is targeted for synthesis

• Many factors affect the ultimate performance of aVHDL-based design including

– VHDL coding style

– EDA tool(s) used: synthesis and place/route– Characteristics of the target device

– User/designer awareness of how the above 3 itemsinteract and depend on each other

Page 2: LECT04 DIGITAL DESIGN

7/30/2019 LECT04 DIGITAL DESIGN

http://slidepdf.com/reader/full/lect04-digital-design 2/5

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-3Electrical & Computer Engineering

Sources of information

• Various sources of information exist that shouldhelp you learn and use good coding practice

– Altera online help in Quartus II gives a set of guidelinesfor VHDL coding

– Altera website provides numerous design examples

– Internet newsgroups comp.arch.fpga andcomp.lang.vhdl are a good source for learning

• Here you can see questions people typically have about VHDLand programmable devices. Look at the answers/hints that otherpeople post to help you learn.

• Do not post questions directly related to your homework/labassignments to these groups.

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-4Electrical & Computer Engineering

Sources of information (continued)

• Various internet resources– Altera provided design examples

• www.altera.com/support/examples/exm-index.html

– Literature for various Altera device families• CYCLONE IV -- www.altera.com/literature/lit-cyclone-iv.jsp

– Various related sources• www.eeproductcenter.com – Numerous IC resources including

FPGAs

• www.fpga-faq.com– FPGA FAQ

• www.fpga4fun.com – Various FPGA projects• www.google.com– search for FPGA

Page 3: LECT04 DIGITAL DESIGN

7/30/2019 LECT04 DIGITAL DESIGN

http://slidepdf.com/reader/full/lect04-digital-design 3/5

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-5Electrical & Computer Engineering

Simulation accuracy and speed

• Accuracy– Ensure the sensitivity list of process statements is

complete

• Speed– Use a process statement in preference to concurrent

signal assignments• Reduces the number of signals a simulator must continually

monitor for changes and so improves simulation speed

– Design models to minimize the number of signals in aprocess statement

• Less signals to monitor will improve simulation speed– Do not model many small process statements

• If there are many registers being clocked from the same clocksource, it is better to put them in one process.

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-6Electrical & Computer Engineering

Synthesis modeling recommendations

• When modeling purely combinational logic, ensuresignals are assigned in every branch of conditionalassignment statements

• Use case statements in preference to if statementscontaining else-if clauses

• The others default case branch ensures all branchvalues are covered.

• There is no real need to use a wait statement toinfer flip-flops.– The if statement can do all that wait does and has the

added advantage that combinational logic can be inferred.Source: D. J. Smith, HDL Chip Design, Doone Publi cations, 2001.

Page 4: LECT04 DIGITAL DESIGN

7/30/2019 LECT04 DIGITAL DESIGN

http://slidepdf.com/reader/full/lect04-digital-design 4/5

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-7Electrical & Computer Engineering

General HDL modeling recommendations

• Before attempting to code a model, know and understandwhat it is you are modeling

• Divide your design into sub-designs when possible• Promotes short, easy to read, reusable code

• Make models as generic as possible• Parameterize bus widths

• Use meaningful signal names.• For active low signals use <signal_name>_n for clearer understanding

and easier debugging

• Use comments liberally.

• A header should describe each module and each signal declarationshould have a comment

• Dated, inconsistent comments are worse than none at all.

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-8Electrical & Computer Engineering

 Assigning Values in Different Number 

Formats

• Assignment statements (with VHDL 1993 syntax) can usedifferent number formats as appropriate– X (hex), O (Octal)

• Assume reg is STD_LOGIC_VECTOR(7 DOWNTO 0)

reg <= “10101111” ; is the same as reg <=x”AF”;

• Underscores can be used to separate fields in long

strings to enhance readability

instruction <=“0000000001000010000100000100000”;

instruction <=“000000_00001_00001_00001_00000_100000”;

Page 5: LECT04 DIGITAL DESIGN

7/30/2019 LECT04 DIGITAL DESIGN

http://slidepdf.com/reader/full/lect04-digital-design 5/5

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-9Electrical & Computer Engineering

VHDL Aggregates

• An aggregate is a collection of items that are gatheredtogether to form a total quantity.

SI GNAL V : STD_LOGI C_VECTOR(7 DOWNTO 0) ;

V <= ( others => ' 0' ) ; - - "00000000"

V <= ( ' 1' , ' 0' , ot hers => ' 0' ) ; - - "10000000"

V <= ( 4 => ' 1' , ot her s => ' 0' ) ; - - "00010000"

V <= ( 3 DOWNTO 0 => ' 0' , other s => ' 1' ) ; - - "11110000"

- - V <= ( "0000", others => ' 1' ) ; - - i l l egal !

Electrical & Computer Engineering Dr. D. J. Jackson Lecture 4-10Electrical & Computer Engineering

VHDL Generics

• VHDL generics may be used to parameterize codemaking components as modular (and hence)reusable as possible

• For example:ENTI TY count ers I S

GENERI C ( WI DTH : I NTEGER : = 8 ) ;

PORT(

d : I N STD_LOGI C_VECTOR(WI DTH- 1 DOWNTO 0) ;

cl k : I N STD_LOGI C;

cl ear : I N STD_LOGI C;l oad : I N STD_LOGI C;

up_down : I N STD_LOGI C;

qd : OUT STD_LOGI C_VECTOR( WI DTH- 1 DOWNTO 0) ) ;

END counter s;