Sie sind auf Seite 1von 38

HDL

A designer can enter his /her design using a hardware description language (HDL) HDL is computer programming language to define hardware of the design. The HDLs prominent in the industry are VHDL and Verilog There is another language that is recently making ground called as System C Being similar to C language gives it an advantage to be more user friendly and comfortable to designers familiar with C Using the code entry method is the most preferred one since it offers: Design flexibility Code re-use Easy modification Easy control over resources

STRUCTURE OF VHDL

Data Types
bit values: '0', '1' boolean values: TRUE, FALSE integer values: -(231) to +(231 - 1)
std_logic values: 'U','X','1','0','Z','W','H','L','-'

U' = uninitialized 'X' = unknown 'W' = weak 'X 'Z' = floating 'H'/'L' = weak '1'/'0 '-' = don't care
Std_logic_vector (n downto 0); Std_logic_vector (0 upto n);

VHDL features
Case insensitive inputa, INPUTA and InputA are refer to same variable Comments -- until end of line If you want to comment multiple lines, -- need to be put at the beginning of every single line Statements are terminated by ; Signal assignment: <= User defined names: letters, numbers, underscores (_) start with a letter

VHDL structure
Library Definitions, constants Entity Interface Architecture Implementation, function

Libraries
Library ieee; Use ieee.std_logic_1164.all; Use ieee.std_logic_arith.all;

Use ieee.std_logic_signed.all;
Use ieee.std_logic_unsigned.all;

VHDL - Library
Include library

library IEEE;
Define the library package used

use IEEE.STD_LOGIC_1164.all;
Define the library file used For example, STD_LOGIC_1164 defines 1 as logic

high and 0 as logic low

output <= 1; --Assign logic high to output

VHDL - Entity
It is the interface for

communication among different modules / components and define the signal port modes (INPUT and OUTPUT)

Entity name

Input 1 Input 2 ... Input n

Output 1 Output 2 ... Output n

This is a black box that implemented by the statements in Architecture

Entity
Define inputs and outputs Example:

Inputs and Outputs

Entity test is Port( A,B,C,D: in std_logic; E: out std_logic); End test;

A B E

Chip
C D

Entity declaration
Defines the input and output ports of the design Name of the entity can be anything other than the

reserved VHDL word Each port in the port list must be allotted: a name ( should be self-explanatory that provides information about its function) data flow direction or mode a type Ports should be well documented with comments at the end of line providing additional information about the signal

VHDL - Entity
Define INPUT, OUTPUT Port

entity test7 is port ( inputa : in std_logic; inputb : in std_logic; output : out std_logic ); end test7;

DO NOT have ; here

Entity name should be same as the file name

Modes in entity:
Ports in the port list have modes which indicate the driver direction Mode also indicates whether or not the port can be read from within the entity Four modes are available: Mode IN Mode OUT Mode INOUT Mode BUFFER

Design using VHDL


Define the logic function

output <= inputa and inputb; output is assigned to be inputa AND inputb LHS contains only 1 variable only RHS can be logics operations for many variables

Architecture
Define functionality of the chip X <= A AND B; Y <= C AND D;

A B C D

Chip
X Y E

E <= X OR Y;

Signal
All internal variables

Signal X,Y : std_logic;

A B C D

Chip
X Y E Signal

Final code

LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY TEST IS PORT (A,B,C,D : IN STD_LOGIC; E : OUT STD_LOGIC); END TEST; ARCHITECTURE BEHAVIOR OF TEST IS SIGNAL X,Y : STD_LOGIC; BEGIN X <= (not A) AND B; Y <= C AND D; E <= X OR Y; END BEHAVIOR;

Port Map
Chip1 : Chip_A Port map (A,B,C,X,Y); Chip2 : Chip_B Port map (X,Y,D,E);

A X B C D
Chip_A

Chip_B

Final code
LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; COMPONENT Chip_B PORT (Q,R,S : IN STD_LOGIC; T : OUT STD_LOGIC); END COMPONENT; ENTITY TEST IS PORT (A,B,C,D : IN STD_LOGIC; E : OUT STD_LOGIC); END TEST; BEGIN Chip1 : Chip_A PORT MAP (A,B,C,X,Y); ARCHITECTURE BEHAVIOR OF TEST IS SIGNAL X,Y : STD_LOGIC; Chip2 : Chip_B PORT MAP (X,Y,D,E);

COMPONENT Chip_A PORT (L,M,N : IN STD_LOGIC; O,P : OUT STD_LOGIC); END COMPONENT;

END BEHAVIOR;

Statements in VHDL
There are 3 types of statements are there in VHDL 1.Declaration statements 2.Concurrent statements 3.Sequenttial statements

Declaration statement
Declaration statements can be used to define Constants Objects(signals, variables, components) Types Sub-programs Declarations can be made in many different locations of VHDL.

Concurrent statement:

Sequential statement:

Operators:
VHDL includes the following kinds of operators:
Logical Relational Arithematic

Logical Operators:
VHDL includes the following logical operators:
AND OR NAND NOR XOR NOT These operators can be defined for the types BIT & BOOLEAN

Relational Operators:
Relational operators are used to create equality & magnitude comparison functions:

Arithmetic Operators:

Generic:
As the name suggests, GENERIC is a way of specifying a generic parameter a static parameter that can be easily modified and adapted to different applications The purpose is to make the code more flexible and reusable must be declared in the ENTITY More than one GENERIC parameter can be specified in an ENTITY

Syntax of Generic:
GENERIC (parameter_name : parameter_type := parameter_value); The GENERIC statement below specifies a parameter called n, of type INTEGER, whose default value is 8. Therefore, whenever n is found in the ENTITY itself or in the ARCHITECTURE (one or more) that follows, its value will be assumed to be 8 ENTITY my_entity IS GENERIC (n : INTEGER := 8; vector: BIT_VECTOR := "00001111"); PORT (...); END my_entity; ARCHITECTURE my_architecture OF my_entity IS ... END my_architecture;

Das könnte Ihnen auch gefallen