copyright © 1997 altera corporation & 提供 beginner vhdl training class danny mok altera hk...

85
Copyright © 1997 Altera Corporation www.FPGA.com.cn & www.PLD.com.cn 提提 Beginner VHDL Training Class Danny Mok Altera HK FAE ([email protected])

Upload: alban-francis

Post on 14-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Beginner VHDLTraining Class

Danny Mok

Altera HK FAE

([email protected])

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

What is VHDL

Very high speed integrated Hardware Description Language (VHDL)– is an industry standard hardware description language– description the hardware in language instead of graphic

• easy to modify• easy to maintain

– very good for• complex combinational logic

– BCD to 7 Segment converter– address decoding

• state machine• more than you want……..

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

What VHDL Standard means??

The VHDL is used to describe– Inputs port– Outputs port– behavior and functions of the circuits

The language is defined by two successive standards– IEEE Std 1076-1987 (called VHDL 1987)– IEEE Std 1076-1993 (called VHDL 1993)Inputs port

Output portfunctions

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Altera VHDL

Altera Max+Plus II support both VHDL 1987 and 1993

Max+Plus II only support SUBSETSUBSET of the two IEEE standard

Detail of the support can be referred to Altera Max+Plus II VHDL handbook on page 89 Section 3

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

How to use the VHDL

use any text editor to create the file– Altera Software Max+Plus II provides text editor

click atthis icon

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

create your VHDL file

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

save your VHDL file as name.VHD

The name must be the same

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Select the Standard Version of VHDL coding– 1987 or 1993

Select whichversion youwant

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Compile your VHDL file

DONE !

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Bonus Topic may help forVHDL Design

withinMax+Plus II

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Turn on some Max+Plus II Option

There are some built-in Option to assist the engineer during the VHDL design stage– Syntax Color Option from the Option menu

Turn onthis option

Reserve word in Blue

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

User can modify the Color Option

use the Color Palette under Option Menu to customize the color of– comments, illegal characters, megafunctions,

macrofuncitons….

Select Element

Select Color

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Error Location during Compilation

Easy to locate the error

Click on the errormessage

Locate the error

Error location

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

VHDL Template

I forgot …….

If-then-elsecase-end caseloop-end loop??…???

Modify the code as user want

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

General VHDL Format

ENTITY test ISPORT ( input_pin_name : IN bit; output_pin_name : OUT bit);END test;ARCHITECTURE test_body OF test ISBEGINoutput_pin_name <= input_pin_name;END test_body;

Key Word

VHDL Format

Logic

This two must be the same

I/O port definesection

Logic Behaviourdefine section

Must be the sameas the save TEST.VHDfile

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Your First VHDL design -- 2 input AND gateEntity simand isPort ( a, b : in bit; c : out bit);end simand;architecture simand_body of simand isbeginc <= a and b;end simand_body;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

More detail

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Why I use VHDL instead of Graphic

Easy to Modify It is more powerful than Graphic VHDL is a portable language because

– is device independent

– the same code can be applied to Device manufactured by Company A or Company B

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Graphic vs VHDL– Graphic is what you draw is what you get

• “ tell me what hardware you want and I will give it to you”

– VHDL is what you write is what functional you get

• “ tell me how your circuit should behave and the VHDL compiler will give you the hardware that does the job”

• but the designer can not control how the circuit implement

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Learning VHDL must learn

What is Combinatorial Logic

What is Sequential Logic

What is Concurrent Statement

What is Process Statement

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Combinatorial Logic

Combinatorial Logic if – Outputs at a specified time are a function only of the inputs at

that time

• e.g. decoders, multiplexers and adders

Output changeinstantly when input change

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Sequential Logic

Sequential Logic if– Outputs at a specified time are a function of the inputs at that time

and at all preceding times– All sequential circuits must include one or more registers

• e.g. State Machine, Counters, Shift Register and Controllers

Outputs dependson inputs and previous output

Register is used to hold the previous value

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Now everyone should know what is– Combinational Logic

– Sequential Logic

Q : Then how about Concurrent or Process Statement ? What is it ?

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Concurrent Statement All the Concurrent Statement is executed in parallel Concurrent Statement does not care the position within the coding Concurrent Statement is : OUTPUT depends on INPUT only

Entity test1 IsPort ( a, b : in bit; c, d : out bit);end test1;architecture test1_body of test1 isbeginc <= a and b;d <= a or b;end test1_body;

Entity test1 IsPort ( a, b : in bit; c, d : out bit);end test1;architecture test1_body of test1 isbegind <= a or b;c <= a and b;end test1_body;

This two excutein parallel

Does not care the position within the coding

Output depends on Input onlywithout any conditionalconstraint

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

THE SAME

C = A and B

D = A OR B

c <= a and b;d <= a or b;

d <= a or b;c <= a and b;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Process Statement All the Process Statement is executed in parallel Within the Process Statement, the coding is execute in sequential Process Statement is : OUTPUT depends on INPUT with Sensitivity List

to control the event happen

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Entity test1 isPort ( clk, d1, d2 : in bit; q1, q2 : out bit);end test1;architecture test1_body of test1 isbeginProcess (clk, d1)beginif (clk’event and clk = ‘1’) thenq1 <= d1;end if;end process;Process (clk, d2)beginif (clk’event and clk= ‘1’) thenq2 <= d2;end if;end process;end test1_body;

Entity test1 isPort ( clk, d1, d2 : in bit; q1, q2 : out bit);end test1;architecture test1_body of test1 isbeginProcess (clk, d2)beginif (clk’event and clk = ‘1’) thenq2 <= d2;end if;end process;Process (clk, d1)beginif (clk’event and clk= ‘1’) thenq1 <= d1;end if;end process;end test1_body;

This two processes execute in parallel

The coding is execute in sequential within the process

The output dependson input with conditional constraint

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

The two process statement execute in parallel

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Now, I know what is– combinational logic

– sequential logic

– concurrent statement

– process statement

Q : What is the usage of this in VHDL ?

A : Engineer can use the mixture of combinational logic, sequential logic, concurrent statement

and process statement

to do the design

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

How to ... ?

Now I know what is Combinational Logic but

Q : How to implement of Combinational Logic in VHDL? Combinational Logic can be implemented by

– Concurrent Signal Assigment Statements– Process Statement that describe purely combinational behaviour i.e.

behaviour that does not depends on any CLOCK EDGE

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Concurrent Statementsfor

Combinational Logic

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Concurrent Statements

There are several different kinds of Concurrent Statements– (1) Simple Signal Assigments

– (2) Conditional Signal Assigments

– (3) Selected Signal Assigments

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

(1) Simple Signal Assigment

These kind of statements are executed in Parallel

Entity test1 isport ( a, b, e : in bit; c, d : out bit);end test1;architecture test1_body of test1 isbeginc <= a and b;d <= e;end test1_body;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

What kind of logic support

AND NAND OR NOR XOR NOT more .......

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

I want 5 Input AND Gate

Q :AND is only a two input, if I want more input, what can I do ?

A : It is easy, we are due with Language not Graphic

Entity test1 isport ( a, b, c, d, e : in bit; f : out bit);end test1;architecture test1_body of test1 isbeginf <= a and b and c and d and e;end test1_body;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

LAB 1

Design a 7 Input OR gate

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Sampling Coding

Entity test1 isport ( a, b, c, d, e, f, g : in bit; h : out bit);end test1;architecture test1_body of test1 isbeginh <= a or b or c or d or e or f or g;end test1_body;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

(2) Conditional Signal Assigments

The output get the value when the condition is true– e.g. 2 to 1 multiplexer

Entity test1 isport (in1, in2, sel : in bit; d : out bit);end test1;architecture test1_body of test1 isbegind <= in1 when sel = ‘0’ else in2;end test1_body;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

If I want more -- 4 to 1 Mux

Once again, you are due with Language not Graphic, so it is easy

Entity test1 isport (in1, in2, in3, in4 : in bit; sel1, sel2 : in bit; d : out bit);end test1;architecture test1_body of test1 isbegind <= in1 when sel1 = ‘0’ and sel2 = ‘0’ else in2 when sel1 = ‘0’ and sel2 = ‘1’ else in3 when sel1 = ‘1’ and sel2 = ‘0’ else in4;end test1_body;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

(3) Select Signal Assignments

The output get value when matching with the selected itemEntity test1 isport (a, b: in bit; sel : in bit; c : out bit);end test1;architecture test1_body of test1 isbeginwith sel select c <= a when ‘1’, b when ‘0’;end test1_body;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

If I want more choice ---

It is easyEntity test1 isport (in1, in2, in3, in4 : in bit; sel : in integer; out1 : out bit);end test1;architecture test1_body of test1 isbeginwith sel select out1 <= in1 when 0, in2 when 1, in3 when 2, in4 when 3;end test1_body;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

LAB 2

Convert the design from Graphic to VHDL

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Design Constraint

Use the WHEN-ELSE statement to finish your design

100

010

001

other

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Sampling Coding

Entity test1 isport (high, medium, low : in bit; highest_level3, highest_level2 : out bit; highest_level1, highest_level0 : out bit);end test1;architecture test1_body of test1 isbeginhighest_level3 <= ‘1’ when high=‘1’ and medium=‘0’ and low=‘0’ else ‘0’;highest_level2 <= ‘1’ when high=‘0’ and medium=‘1’ and low=‘0’ else ‘0’;highest_level1 <= ‘1’ when high=‘0’ and medium=‘0’ and low=‘1’ else ‘0’; highest_level0 <= ‘0’ when high=‘1’ and medium=‘0’ and low=‘0’ else ‘0’ when high=‘0’ and medium=‘1’ and low=‘0’ else ‘0’ when high=‘0’ and medium=‘0’ and low=‘1’ else ‘1’;end test1_body;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Simulation

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Process Statementfor

Combinational Logic

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Process Statement

There are some rules for the Process Statement usage– any kind of Process Statement must have SENITIVITY LIST

• sensitivity list contains the signals that cause the process statement to execute if their values change

– the statement within the Process Statement will be execute STEP-BY-STEP

Q : What does it all means ?

A : Follow me.......

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Template for Process Statement

Using the “SENSITIVITY LISTSENSITIVITY LIST”

name : PROCESS (sensitivity_list)begin sequential statement #1 sequential statement #2 ....... sequential statement # NEND PROCESS name;

General format for a Process StatemtentProcess ( )begin..end process

Sensitivity List

Sequential StatementThe sequential statement execute one by one andfollow the order, ie. finish the #1 then #2 then #3

name is optional

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Example will be more clear

Entity test1 isport (a, b, sel1, sel2 : in bit; result : out bit);end test1;architecture test1_body of test1 isbeginprocess (sel1, sel2,a, b)beginif (sel1 = ‘1’) thenresult <= a;elsif (sel2 = ‘1’) thenresult <= b;elseresult <= ‘0’;end if;end process;end test1_body;

Result change if sel1, sel2, a or b change the value

Wait : I can do the same join with Concurrent Statement

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Entity test1 isport (a, b, sel1, sel2 : in bit; result : out bit);end test1;architecture test1_body of test1 isbeginresult <= a when sel1 = ‘1’ else b when sel2 = ‘1’ else ‘0’;end test1_body;

Entity test1 isport (a, b, sel1, sel2 : in bit; result : out bit);end test1;architecture test1_body of test1 isbeginprocess (sel1, sel2,a, b)beginif (sel1 = ‘1’) thenresult <= a;elsif (sel2 = ‘1’) thenresult <= b;elseresult <= ‘0’;end if;end process;end test1_body;

Same function but differentway to do the coding

Concurrent Statement Process Statement

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Q : What is the different between Concurrent and Process Statement

A : For this simple example, both Concurrent and Process can do the same job. But some function must use Process Statement to do

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

How to ... ?

Now I know what is Sequential Logic but

Q : How to implement of Sequential Logic in VHDL? Sequential Logic can be implemented by

– Process Statement describe the logic with some CLOCK signal

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Process Statementfor

Sequential Logic

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

How to do the Latch

Entity test1 isport (clk, d , reset : in bit; q : out bit);end test1;architecture test1_body of test1 isbeginprocess (clk, d, reset)begin if (reset = ‘1’) then q <= ‘0’; elsif (clk = ‘1’) then q <= d; end if;end process;end test1_body;

Reset takeover the control first

Clk take the controlsecond

Within the process excute instep-by-step

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

This is a LATCH

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

If I modify the code to...

Entity test1 isport (clk, d , reset : in bit; q : out bit);end test1;architecture test1_body of test1 isbeginprocess (clk)begin if (reset = ‘1’) then q <= ‘0’; elsif (clk = ‘1’) then q <= d; end if;end process;end test1_body;

Note : the result is totally different

What is it ?

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

I get a Flip-Flop not a LATCH

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Why I have a Flip-Flop not a Latch

Latch with a Sensitivity listprocess (clk, d, reset)

Flip-Flop with a Sensitivity listprocess(clk)

Q : What is the Sensitivity list use for ?

A : The OUTPUT change when the Sensitivity list change

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

More Detail

process (clk, d, reset)– this say that the OUTPUT change when either clk, d or reset

change, if clk, d or reset not change, then maintain the output

– what kind of device will provide this function ?

LATCH

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

process (clk)– this say that OUTPUT change when CLK change, if clk does not change,

maintain the output– what kind of device will provide this function ?

Flip-Flop

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Now you can see VHDL is very powerful, but if you don’t know what you are doing, you may not get what you want– e.g. you want a latch but actually you get a Flip-Flop

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

The other way of coding

LIBRARY IEEE;USE IEEE.std_logic_1164.all;ENTITY tdff ISPORT(clk, d: in std_logic; q : out std_logic);END tdff;ARCHITECTURE behaviour OF tdff ISBEGINPROCESSBEGINwait until clk = '1';q <= d;END PROCESS;END behaviour;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Compare IF-THEN-ELSE vs WATI UNTILLIBRARY IEEE;USE IEEE.std_logic_1164.all;ENTITY tdff ISPORT(clk, d: in std_logic; q : out std_logic);END tdff;architecture behaviour OF tdff ISBEGINPROCESSBEGINwait until clk = '1';q <= d;END PROCESS;END behaviour;

Entity test1 isport (clk, d : in bit; q : out bit);end test1;architecture test1_body of test1 isbeginprocess (clk)begin if (clk = ‘1’) then q <= d; end if;end process;end test1_body;

Entity test1 isport (clk, d : in bit; q : out bit);end test1;architecture test1_body of test1 isbeginprocess (clk,d)begin if (clk = ‘1’ and clk’event) then q <= d; end if;end process;end test1_body;

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Review

Concurrent Statement for– combinational logic (without Flip-flop circuit)

• eg. decoder, multiplixer, multiplier, adder

Process Statement for– combinational logic (without Flip-Flop circuit)

– Sequential logic (with Flip-Flop circuit)

• e.g. State machine, counters, controller

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

ENTITY test1 ISPORT( clk, a,b,c : in bit;

d : out bit);END test1;architecture test1_body of test1 isbegind <= ((a and b) xor c);end test1_body;

Is this OK ????

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

ENTITY test1 ISPORT( clk, a,b,c : in bit;

d, e : out bit);END test1;architecture test1_body of test1 isbeginprocess(a,b,c)begind <= ((a and b) xor c);e <= ((a or b) nand c);end process;end test1_body;

Is this OK ????

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

ENTITY test1 ISPORT( clk, a,b,c : in bit; d : out bit);END test1;architecture test1_body of test1 isbeginprocess(a,b,c)begind <= ((a and b) xor c);end process;end test1_body;

Is this OK ????

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

ENTITY test1 ISPORT( clk, a,b,c : in bit; d,e : out bit);END test1;architecture test1_body of test1 isbeginprocess(a,b,c)begind <= ((a and b) xor c);e <= ((a or b) nand c);end process;end test1_body;

Is this OK ????

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

ENTITY test1 ISPORT( clk, a,b,c : in bit;

d, e : out bit);END test1;architecture test1_body of test1 isbeginif (clk'event and clk='1') thend <= ((a or b) and c);end test1_body;

Is this OK ????

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

ENTITY test1 ISPORT( clk, a,b,c : in bit;

d : out bit);END test1;architecture test1_body of test1 isbeginprocess(clk)beginif (clk'event and clk='1') thend <= ((a or b) and c);end if;end process;end test1_body;

Is this OK ????

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

ENTITY test1 ISPORT( clk, a,b,c : in bit; d,e : out bit);END test1;architecture test1_body of test1 isbeginprocess(clk,a,b,c)beginif (clk'event and clk='1') thend <= ((a xor b) and c);end if;e <= ((a or b) nand c);end process;end test1_body;

Is this OK ????

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

ENTITY test1 ISPORT( clk, a,b,c : in bit; d,e,f : out bit);END test1;architecture test1_body of test1 isbeginprocess(clk,a,b,c)beginif (clk'event and clk='1') thend <= ((a xor b) and c);end if;if (clk'event and clk='1') thene <= ((a or b) nand c);end if;if (a = '1') thenf <= (a or b);end if;end process;end test1_body;

Is this OK ????

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Seat down an think of your design

D es ig n F low

C on cu rren ts ta tem en t

o rP rocess s ta tem en t

P rocesss ta tem en t

C on cu rren t+

P rocesss ta tem en t

D oes th ed es ig n is a

p u reseq u en tia l c ircu it

D oes th ed es ig n is a

p u recom b in a tion a l c ircu it

Y N

Y N

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Compare of AHDL vs VHDL

Variable

temp : dff

temp.clk = clk;temp.d = dataout = temp.out

if (clk’event and clk=‘1’)thenout <= d;end if;

AHDLAHDL VHDLVHDL

Both give me the DFF, and timing, functionalare all the same, there is no difference between!!!

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Closer look of the ADHL

Variable

temp : dff

temp.clk = clk;temp.d = dataout = temp.out

I want a DFF and named it as “temp”

The DFF’s clock input pin is connected to “clk”The DFF’s data input pin is connected to “data”

The DFF’s out output pin is connected to “out”

You want a DFF and tell the Max+Plus II how to connect all the input and output pin,so Max+Plus II will follow your instruction and give you a DFFgive you a DFF and connect all the pinconnect all the pin in order to give you what you want. You will get a DFF today, tomorrow or 1000 years later,because you tell me you want a DFF

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Closer look at the VHDL

if (clk’event and clk=‘1’)thenout <= d;end if;

When there is a “clk” transaction and stable at “1” then perform the following function, how to connect the pin, I don’t know!!!

I want the “out” equal to the “d”, but how to connect the pin,I don’t know!!!!!!

So now, base on what the function you want, the VHDL compiler find out that a DFF will meet your requirement, so it give you a DFF. Since the DFF is given to you by VHDL compiler, so youmay get a DFF today, but get a latch tomorrow, or get a JKFF 1000 years later -- because you justtell me what is the function you want and how to implement it is really up to the VHDL compiler, as far as VHDL give you the function you want is OK!!

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Conclusion of learning

Learned what is Combinational Logic/Circuits Learned what is Sequential Logic/Circuits Understand the different between Concurrent

Statement and Process Statement

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Understand the usage of the– Concurrent Statement

• for Combinational Logic – simple signal assignment statement– conditional signal assignment statement– selected signal assignement statement

– Process Statement• for Combinational Logic• for Sequential Logic

– if-then-else structure for Latch– if-then-else structure for Flip-Flop– wait until structure for Flip-Flop

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

All you learn is the basic concept of the VHDL language

This is the Beginner VHDL Training Class The detail of the Circuit design will be covered at the

Intermediate VHDL Training Class Advance VHDL language will be covered at the

Expert VHDL Training Class

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

The most important thing of VHDL Language

“ Tell me how your circuit should behave and the VHDL compiler will give you the hardware circuit that does the job”

e.g. Latch and Flip-Flop is a good example

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

VHDLwith

Graphic Interface

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

I have some bug free Graphic designs .

Q : I have some bug free Graphic designs, how can I re-use it with my new VHDL design file ?

A : You can convert your Graphic design to VHDL coding design manually, but

• it takes time• human conversion error

OR

A : You can convert your new VHDL coding design to Graphic and integrate with your old Graphic design

• it is fast and easy• Max+Plus II handle the conversion, so no error guarantee

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

Good but How ???

It is easy, just follow meIt is easy, just follow me

LIBRARY ieee;USE ieee.std_logic_1164.all;USE ieee.std_logic_arith.all;

ENTITY adder ISPORT (op1, op2 : IN UNSIGNED(7 downto 0); result : OUT INTEGER);END adder;

ARCHITECTURE maxpld OF adder ISBEGIN result <= CONV_INTEGER(op1 + op2);END maxpld;

Use it as normal Graphic Symbol

Copyright © 1997 Altera Corporation

www.FPGA.com.cn & www.PLD.com.cn 提供

See you at the Intermediate VHDL training class