Top Banner
VHDL 03/30/22 www.noteshit.com 1
84

VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Jan 11, 2016

Download

Documents

Gerard Parsons
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

VHDL

04/21/23 www.noteshit.com 1

Page 2: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

What is VHDL?

A Standard Language

VHDL is the VHSIC (Very High Speed IntegratedCircuit) Hardware Description Language

A Simulation Modeling Language

A Design Entry Language

A Netlist Language

04/21/23 www.noteshit.com 2

Page 3: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

History of VHDL

* 1981: Initiated in 1981 by US DoD to address the hardware life-cycle crisis

* 1983-85: Development of baseline language by Intermetrics, IBM and TI

* 1986: All rights transferred to IEEE

* 1987: Publication of IEEE Standard

* 1987: Mil Std 454 requires comprehensive VHDL descriptions to be delivered with ASICs

* 1994: Revised standard (named VHDL 1076-1993)

04/21/23 www.noteshit.com 3

Page 4: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Basic Terminology

VHDL can be used to model a digital system.An entity is used to describe a hardware moduleVHDL provides five different types of primary

constructs called design units. They arei. Entity Declarationii. Architecture bodyiii. Configuration declarationiv. Package declarationv. Package body

04/21/23 www.noteshit.com 4

Page 5: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Entity declaration

It defines the names, input output signals and modes of ahardware module.Syntax:

entity entity_name is Port declaration; end entity_name;

starts with ‘entity’ and ends with ‘end’ keywords. Ports are interfaces through which an entity can Communicate with

its environment Each port must have a name,direction and a type. The direction

will be input, output or inout.

In Port can be read

Out Port can be written

Inout Port can be read and written

Buffer Port can be read and written, it can have only one source.

04/21/23 www.noteshit.com 5

Page 6: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Architecture Describes the internal description of design or it tells what is there

inside design. Each entity has at least one architecture and an entity can have

many architecture. Architecture can be described using structural, dataflow, behavioral

or mixed style.

Syntax: architecture architecture_name of entity_name

architecture_declarative_part; begin Statements; end architecture_name;

04/21/23 www.noteshit.com 6

Page 7: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Modeling Styles

The internal working of an entity can be definedusing different modeling styles inside architcturebody. They are

Dataflow modeling. Behavioral modeling. Structural modeling.

04/21/23 www.noteshit.com 7

Page 8: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Structure of an Entity

04/21/23 www.noteshit.com 8

Page 9: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Basic Language Elements

Identifiers• Set of upper case letters(A-Z), lower case

letters(a-z), digit(0-9) and an underscore (_) can be used.

• First character must be a letter and last character may not be an underscore.

• VHDL is not case sensitive. • Comment line must be preceded by two

consecutive hyphens(--)

04/21/23 www.noteshit.com 9

Page 10: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

VHDL Operators

• Logical Operators: and, or, not, nand, nor, xor, xnor

• Relational Operators: = , /=, <, <=, >, >=• Shift Operators: sll, srl, sla, sra, rol,ror• Adding Operators: +, - , &• Multiplying Operators: *, /, mod, rem

04/21/23 www.noteshit.com 10

Page 11: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Shifting Operation

• Pbm 1001010 srl3 – 0001001 sll3 – 1010000 sra3 – 1111001 sla3 – 1010000 rol3 – 1010100 ror3 - 0101001

04/21/23 www.noteshit.com 11

Page 12: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Multiplying Operation

7 mod 4 = 3 -7 rem 4 = -3 7 mod -4= -3 -7 rem -4=-3

04/21/23 www.noteshit.com 12

Page 13: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Data ObjectsA data object holds a value of a specified type.Four classes of data objects are• Constant - hold a single value of a given type. This value cannot be

changed during simulation. eg. constant rise_time:time:=10ns;• Variable - hold a single value of a given type. Different values can be

assigned at different times. - local storage in process, procedures & functions eg. variable sum:integer range 0 to 100:=10; variable found:boolean;04/21/23 www.noteshit.com 13

Page 14: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Data Objects• Signal - holds a list of values which include the

current value of the signal and a set of possible future values.

- declared outside the process and can be used anywhere within the architecture.

eg. signal clock:bit; signal data_bus: bit_vector(0 to 7); signal g_delay:time:=10ns;

04/21/23 www.noteshit.com 14

Page 15: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Data Objects• File - contains a sequence of values. - values can be read or written to the file using

read and write procedures. syntax: file filename:file-type-name [[open mode] is

string-expression]; eg: file stimulus:text open read_mode is

“/user/home/add.sti”;04/21/23 www.noteshit.com 15

Page 16: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Dataflow Modeling--program for half adderLibrary ieee;Use ieee.std_logic_1164.all;Entity ha isPort(a,b:in std_logic; sum,carry:out std_logic);End ha;Architecture halfadder of ha isBegin

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

End halfadder;

04/21/23 www.noteshit.com 16

Page 17: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Behavioral Modeling--program for half adderLibrary ieee;Use ieee.std_logic_1164.all;Entity ha isPort(a,b:in std_logic; sum,carry:out std_logic);End ha;Architecture halfadder of ha isBegin

Process(a,b)begin

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

end process;End halfadder;04/21/23 www.noteshit.com 17

Page 18: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Behavioral Modeling--same entityArchitecture half of ha isBeginProcess(a,b) begin if a=‘0’ and b=‘0’ then sum=‘0’; carry=‘0’; elsif a=‘0’ and b=‘1’ then sum=‘1’; carry=‘0’; elsif a=‘1’ and b=‘0’ then sum=‘1’; carry=‘0’; elsif a=‘1’ and b=‘1’ then sum=‘0’; carry=‘1’; else sum=X; carry=X; end if;End process;End half;

04/21/23 www.noteshit.com 18

Page 19: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Structural Modeling--program for half adder--same entityArchitecture half of ha isComponent xor2 port(p,q:in std_logic; r:out std_logic);End componentComponent and2 port(x,y:in std_logic; z:out std_logic);End component;BeginX1:xor2 port map(a,b,sum);X2:and2 port map(a,b,carry);End half;

04/21/23 www.noteshit.com 19

Page 20: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Full Adder using Half Adder

04/21/23 www.noteshit.com 20

Page 21: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Full Adder using Half AdderLibrary ieee;Use ieee.std_logic_1164.all;Entity fa is port(x,y,z:in std_logic; s,c:out std_logic);End fa;

Architecture fa_str of fa is

Component ha port(a,b:in std_logic; sum,carry:out std_logic);End component;

Componet or2 port(p,q:in std_logic; r:out std_logic);End component;04/21/23 www.noteshit.com 21

Page 22: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Full Adder using Half Adder

Signal s1,c1,c2:std_logic;

BeginFa1:ha port map(x,y,s1,c1);Fa2:ha port map(s1,z,s,c2);Fa3:or2 port map(c1,c2,c);

End fa_str;

04/21/23 www.noteshit.com 22

Page 23: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4-bit Ripple Carry Adder using Full Adder

04/21/23 www.noteshit.com 23

Page 24: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4-bit Ripple Carry Adder using Full AdderLibrary ieee;Use ieee.std_logic_1164.all;Entity ripple_str is port(A:in std_logic_vector(3 downto 0); B:in std_logic_vector(3 downto 0); Cin:in std_logic; sum:out std_logic_vector(3 downto 0); Cout:out std_logic);End ripple_str;

Architecture ripple_str_fa of ripple_str isSignal Cint:std_logic_vector(1 to 3);

Component fa port(x,y,z:in std_logic; s,c:out std_logic);End component;04/21/23 www.noteshit.com 24

Page 25: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4-bit Ripple Carry Adder using Full Adder

Beginrip1:fa port map(A(0),B(0),Cin,sum(0),Cint(1));

rip2:fa port map(A(1),B(1),Cint(1),sum(1),Cint(2)); rip1:fa port map(A(2),B(2),Cint(2),sum(2),Cint(2)); rip1:fa port map(A(3),B(3),Cint(3),sum(3),Cout);End ripple_str_fa;

(or)rip1:fa port map(x=>A(0), y=>B(0), z=>Cin, s=>sum(0), c=>Cint(1);

04/21/23 www.noteshit.com 25

Page 26: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Generate Statement• Concurrent statements can be conditionally selected or

replicated during the elaboration phase using the generate statement

• for-generation and if-generation scheme• for-generate : syntax generate-label:for generate-identifier in discrete-range

generate concurrent –statements end generate [generate-label];• If-generate : syntax generate-label:if expression generate concurrent –statements end generate [generate-label];04/21/23 www.noteshit.com 26

Page 27: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4-bit Ripple Carry Adder using generate statement

--same entityArchitecture ripple_str_fa of fa is--same componentSignal Cint:std_logic_vector(0 to 4);begin

Cint(0)<=Cin; rip_gen:for i in 0 to 3 generate rip1:fa port map(A(i),B(i),Cint(i),sum(i),Cint(i+1)); End generate; Cout<=Cint(4);End ripple_str_fa; 04/21/23 www.noteshit.com 27

Page 28: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Concurrent Statements

• Concurrent Signal Assignment Statement• Conditional Signal Assignment Statement• Selected Signal Assignment Statement• Block Statement• Concurrent Assertion Statement

04/21/23 www.noteshit.com 28

Page 29: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4:1 MUX

04/21/23 www.noteshit.com 29

Page 30: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Conditional Signal Assignment Statement

Syntax:Target-signal<= waveform-elements when condition else waveform-elements when condition else ……….. waveform-elements [when condition];

04/21/23 www.noteshit.com 30

Page 31: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4:1 MUX using conditional signal assignment statement

04/21/23 www.noteshit.com 31

Page 32: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4:1 MUX using conditional signal assignment statement

04/21/23 www.noteshit.com 32

Page 33: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Selected Signal Assignment Statement

Syntax:with expression selecttarget-signal<=waveform-elements when choices,

waveform-elements when choices,

……. waveform-elements when choices;

04/21/23 www.noteshit.com 33

Page 34: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4:1 MUX using selected signal assignment statement

04/21/23 www.noteshit.com 34

Page 35: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4:1 MUX using selected signal assignment statement

04/21/23 www.noteshit.com 35

Page 36: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Concurrent StatmentsBlock statement:• To disable signal drivers by using guards• To limit scope of declarations• To represent a portion of a design• Any declaration appearing between block ….end

block are visible only within the block.Block-label: block [(guard expression)] [is][block-header][block-declarations]BeginConcurrent – statementsEnd block[block-label];04/21/23 www.noteshit.com 36

Page 37: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Concurrent Assertion Statement• Used to check if a signal value lies within a

specified range.• If check fails, a message is reported.• Syntax: assert boolean-expression

[report string-expression] [severity expression]• Predefined severity are NOTE, WARNING,

ERROR and FAILURE.04/21/23 www.noteshit.com 37

Page 38: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Concurrent Assertion StatementExample:Architecture srflp of srff isBeginassert (S=‘1’ and R=‘1’)report “Not valid inputs”severity ERROR;End srflp

04/21/23 www.noteshit.com 38

Page 39: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Sequential Statements• Variable-assignment statements• Signal assignment• Wait• If• Case• Loop• Null• Exit, next, assertion, report, return,

procedure-call04/21/23 www.noteshit.com 39

Page 40: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Case statement

• Syntax:case expression is

when choices=>sequential-statementswhen choices=>sequential-statements…………..[when others=>sequential-statements]

end case;

04/21/23 www.noteshit.com 40

Page 41: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4:1 MUX using case

04/21/23 www.noteshit.com 41

Page 42: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

8:1 MUX using 4:1 MUX

04/21/23 www.noteshit.com 42

Page 43: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

8:1 MUX using 4:1 MUX

04/21/23 www.noteshit.com 43

Page 44: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Sequential Statements - Wait an alternative to a sensitivity list a process cannot have both wait st. and a sensitivity list Generic form of a process with wait statement(s)

Processbegin

sequential-statementswait statementsequential-statementswait-statement...

end process; How wait statements work?

Execute seq. statement until wait statement is encountered.Wait until the specified condition is satisfied.When the end of the process is reached start over again at the beginning.

04/21/23 www.noteshit.com 44

Page 45: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Sequential Statements - Waitwait on sensitivity-list;

– until one of the signals in the sensitivity list changes– Eg. Wait on A,B; Wait on clk for 20 ns;

wait for time-expression;– waits until the time specified by the time expression has elapsed– What is this:wait for 0 ns;

wait until boolean-expression;– the boolean expression is evaluated whenever one of the signals in

the expression changes, and the process continues execution when the expression evaluates to TRUE.

– Wait until sum>100 for 50 ns; – Wait until A=B;

04/21/23 www.noteshit.com 45

Page 46: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Sequential Statements - Loop– The loop label is optional. By defining the range the direction as well

as the possible values of the loop variable are fixed. – The loop variable is only accessible within the loop.– For synthesis the loop range has to be locally static and must not

depend on signal or variable values.– While loops are not generally synthesizable.– Three kinds of iteration statements. [ label: ] loop sequence-of-statements -- use exit statement to get outend loop [ label ] ; [ label: ] for variable in range loop sequence-of-statements end loop [ label ] ; [ label: ] while condition loop sequence-of-statements end loop [ label ] ; 04/21/23 www.noteshit.com 46

Page 47: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Sequential Statements - Loop• Egs.1.fact:=1; for no in 2 to N loop fact:=fact*no; end loop;2. j:=0;sum:=10; wh_lp:while j<20 loop sum:=sum*2; j:=j+3; end loop;04/21/23 www.noteshit.com 47

Page 48: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Sequential Statements - NextA statement that may be used in a loop to causethe next iteration.

[ label: ] next [ label2 ] [ when condition ] ; next; next outer_loop; next when A>B; next this_loop when C=D or done;

-- done is a Boolean variable

04/21/23 www.noteshit.com 48

Page 49: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Sequential Statements – Exit & Null• A statement that may be used in a loop to immediately exit the loop. [ label: ] exit [ label2 ] [ when condition ] ; exit; exit outer_loop; exit when A>B; exit this_loop when C=D or done; -- done is a Boolean variable • Null --does not cause any action to take place; execution

continues with the next statement.04/21/23 www.noteshit.com 49

Page 50: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Mixed Style of Modeling

04/21/23 www.noteshit.com 50

Page 51: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Program for Sequential Circuits – D Flip-Flop

04/21/23 www.noteshit.com 51

Page 52: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

D Flip-Flop

04/21/23 www.noteshit.com 52

Page 53: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

D Flip-Flop

04/21/23 www.noteshit.com 53

Page 54: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

JK Flip-Flop

04/21/23 www.noteshit.com 54

Page 55: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

JK Flip-Flop

04/21/23 www.noteshit.com 55

Page 56: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

4-bit Up Counter

04/21/23 www.noteshit.com 56

Page 57: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

04/21/23 www.noteshit.com 57

Page 58: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Generics• Generics of an entity are declared along with

its ports in the entity declaration• It declares a constant object of mode in(only

as input data object)• The value of this constant can be specified as

a globally static expression.• Example of a generic n-input and gate is given

next.

04/21/23 www.noteshit.com 58

Page 59: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Generic n-input AND Gate

04/21/23 www.noteshit.com 59

Page 60: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

5-input AND Gate

04/21/23 www.noteshit.com 60

Page 61: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

N-bit Adder using Generic

04/21/23 www.noteshit.com 61

Page 62: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Functions and ProceduresFunctions:• Used to describe frequently used sequential

algorithms that return a single value.• This value is returned to the calling program using

return statement.• Function function-name [(parameter-list)] return

return-type is {declarative items} begin {sequential statements} end [function][function-name];• Function call: function-name [(parameter)]04/21/23 www.noteshit.com 62

Page 63: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Functions and ProceduresProcedures:• Procedure can have a no. of i/p, o/p, inout

parameters.• Syntax: procedure pro-name [parameter list] is {declarative part} begin {sequential statements} end [procedure] [pro-name];• Procedure call: pro-name [parameter list];

04/21/23 www.noteshit.com 63

Page 64: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Packages• Package declaration: package package-name is package-item-declarations --function declarations --procedure declarations --type, subtype, file, signal, variable,

component…. Declarations end [package] [package-name];• Package Body

package body package-name is --subpgm bodies -- type,subtype,file, subpgm declarations end [package body][package-name];04/21/23 www.noteshit.com 64

Page 65: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Packages

04/21/23 www.noteshit.com 65

Page 66: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Functions - Example

04/21/23 www.noteshit.com 66

Page 67: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Full Adder using Funtions

04/21/23 www.noteshit.com 67

Page 68: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Procedures - Example

04/21/23 www.noteshit.com 68

Page 69: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Subprogram Overloading

• Sometimes it is convenient to have two or more subprograms with the same name.

• It might be overloaded and the subprograms also become overloaded

• Eg:Function COUNT(n:INTEGER)Return(INTEGER);Function COUNT(n1:INTEGER)Return(INTEGER);Both functions are overloaded.

04/21/23 www.noteshit.com 69

Page 70: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Operator Overloading• Most useful features in the language• When a standard operator symbol is made to behave

differently based on the type of its operands then the operator is said to be overloaded

• Two different types of notations:– Standard Operator notation– Standard function call notationEg:Signal a,b,c:mvl;Signal x,y,z:bit;a<= ‘z’ or ‘1’ -- standard operator notationb<=“or”(‘0’,’z’); --Function call notation

04/21/23 www.noteshit.com 70

Page 71: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

VHDL Data Types

04/21/23 www.noteshit.com 71

Page 72: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Predefined Data Types

• bit (‘0’ or ‘1’)• bit_vector (array of bits)• integer• real• time (physical data type)

04/21/23 www.noteshit.com 72

Page 73: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Integer

• Integer• Minimum range for any implementation as defined by standard:

-2,147,483,647 to 2,147,483,647• Integer assignment example

04/21/23 www.noteshit.com 73

Page 74: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Real

• Real• Minimum range for any implementation as defined by standard:

-1.0E38 to 1.0E38• Real assignment example

04/21/23 www.noteshit.com 74

Page 75: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Enumerated

• Enumerated• User defined range• Enumerated example

04/21/23 www.noteshit.com 75

Page 76: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Physical

• Time units are the only predefined physical type in VHDL.

• Physical• Can be user defined range• Physical type example

04/21/23 www.noteshit.com 76

Page 77: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Array• Array

• Used to collect one or more elements of a similar type in a single construct.

• Elements can be any VHDL data type.

04/21/23 www.noteshit.com 77

Page 78: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Record

• Record• Used to collect one or more elements of different types in a single

construct.• Elements can be any VHDL data type.• Elements are accessed through field name.

04/21/23 www.noteshit.com 78

Page 79: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Subtype

• Subtype• Allows for user defined constraints on a data type.• May include entire range of base type.• Assignments that are out of the subtype range result in error.• Subtype example

04/21/23 www.noteshit.com 79

Page 80: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Natural and Positive Integers

• Integer subtypes:• Subtype Natural is integer range 0 to

integer’high;

• Subtype Positive is integer range 1 to integer’high;

04/21/23 www.noteshit.com 80

Page 81: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Boolean, Bit and Bit_vector

• type Boolean is (false, true);• type Bit is (‘0’, ‘1’);• type Bit_vector is array (integer range <>)

of bit;

04/21/23 www.noteshit.com 81

Page 82: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Char and String

• type Char is (NUL, SOH, …, DEL);• 128 chars in VHDL’87• 256 chars in VHDL’93

• type String is array (positive range <>) of Char;

04/21/23 www.noteshit.com 82

Page 83: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Configuration• Used to bind -- An architecture body to its entity declaration -- A component with an entity• This can be done by -- By using a configuration specification• syntax: for list-of-comp-labels: component-name binding-indication• Binding Indication:Use entity entity-name[(architecture-name)][generic map (generic-association-list)][port map (port-association-list)]Eg. For X1,X2:Xor2 use entity work.xor2(xor2beh); 04/21/23 www.noteshit.com 83

Page 84: VHDL 9/12/2015. What is VHDL? A Standard Language VHDL is the VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.

Configuration -- By using a configuration declaration• Syntax:Configuration configuration-name of entity-name isBlock-configurationEnd[configuration][configuration-name];• Block-configuration

for block-namecomponent-configurationsblock-configurations

end for;

04/21/23 www.noteshit.com 84