VHDL-A Hardware Discription Language: Manish Kumar Jaiswal Manish - Iitm@yahoo - Co.in
VHDL-A Hardware Discription Language: Manish Kumar Jaiswal Manish - Iitm@yahoo - Co.in
Faculty Member
Department of Electronics Engineering
ICFAI-Tech, Dehradun
Lowest Level
Transistor Level Design
Highest Level
Behaviour Level Design (wrtie a HDL program)
Lowest Level
Transistor Level Design
Highest Level
Behaviour Level Design (wrtie a HDL program)
Lowest Level
Transistor Level Design
Highest Level
Behaviour Level Design (wrtie a HDL program)
Lowest Level
Transistor Level Design
Highest Level
Behaviour Level Design (wrtie a HDL program)
Gate Level
y = sdo + s d1
Transistor Level
Library IEEE;
Use IEEE.std_logc_1164.all;
entity entity_name is
port{
in1, in2 : in std_logic;
out1 : out std_logic;
};
end entity_name;
architecture arch_name of entity_name is
- -signal-declaration
begin
- -concurrent-statement
end arch_name;
Comments
- - - - - - This is a comment.
Identifiers
A sequence of one or more uppercase letters, lower case letters,
digits and the underscore.
Case insensitive
First character must be a letter.
The last character cannot be a underscore.
Two underscore can not be together.
Example
SIGNAL x : BIT;
VARIABLE y: INTEGER;
CONSTANT one: std_logic_vector(3 downto 0) := "0001"’
M. K. Jaiswal [email protected] (Faculty
VHDL-Member
A Hardware
Department
Discription
of Electronics
Language Engineering ICFAI-Tech, Dehradun) 13 / 34
Basic Language Elements
Data Objects: Signal , Variable, and constant
SIGNAL represents logic signals on a wire in the ckt. A signal
does not have memory, thus if source of the signal is removed, the
signal will not have a value.
A VARIABLE objects remember its content and is used for
computation in a behaviour model. The scope of a VARIABLE is
local to the corresponding PROCESS.
A CONSTANT object must be initialized with a value when
declared and this value cann’t be changed.
Example
SIGNAL x : BIT;
VARIABLE y: INTEGER;
CONSTANT one: std_logic_vector(3 downto 0) := "0001"’
M. K. Jaiswal [email protected] (Faculty
VHDL-Member
A Hardware
Department
Discription
of Electronics
Language Engineering ICFAI-Tech, Dehradun) 13 / 34
Basic Language Elements
Data Types
BIT & BIT_VECTOR (Predefined in VHDL. Can have Value ’0’ or
’1’).
STD_LOGIC & STD_LOGIC_VECTOR (Not Predefined n VHDL)
Can have 9-value 0,1,Z,-,L,H,U,X,W.
Need to add these lines.
Library IEEE;
Use IEEE.std_logic_1164.all;
INTEGER (Predefined, Uses 32-bits to represents the binary
numbers.)
BOOLEAN (Predefined, having two value TRUE & FALSE)
Data Types
Enumeration TYPE (Allow user to specify the values that the data
can have)
Syntax: TYPE identifier IS (value1, value2, ...);
Example:
TYPE state_type IS (S1, S2, S3);
SIGNAL state: state_type;
state <= S1;
ARRAY (Groups single data objects of same type together into
one-diamentional or multidiamentional array)
Syntax: TYPE identifier IS ARRAY (range) of TYPE;
Example: TYPE byte IS ARRAY (7 downto 0) of BIT;
Data Types
SUBTYPE (A subset of TYPE)
Syntax: SUBTYPE identifier IS TYPE RANGE range;
Example: SUBTYPE integer4 IS INTEGER RANGE -8 TO 7;
SUBTYPE cell IS STD_LOGIC_VECTOR(3 downto 0);
Data Operators
LOGICAL (AND, OR, NOT, NAND, NOR, XOR, XNOR)
Arithmetic (a+b, a-b, a*b, a/b,a MOD b, a REM b, a**b,
’a’&’b’(concatenation))
Relational (=, /=, <, <=, >, >=)
Shift (SLL(Shift left Logic), SRL, SLA(Shift Left Arithmetic), SRA,
ROL(Rotate Left), ROR)
ARCHITECTURE
Syntax(Data Flow Model)
architecture arch_name of entity_name is
signal declaration;
begin
concurrent statements;
end arch_name;
Example
architecture data_arch of module is
signal t1: std_logic;
begin
t1 <= M or O;
S <= t1 and N;
end arch_name;
ARCHITECTURE
Syntax(Behavioural Model)
architecture arch_name of entity_name is
signal declaration;
function declaration;
procedure declaration;
begin
PROCESS-blocks;
concurrents statements;
end arch_name;
ARCHITECTURE
Example(Behavioural Model)
architecture behav_arch of module is
signal t1: std_logic;
begin
PROCESS(M,N,O)
BEGIN t1 <= M or O;
S <= t1 and N;
end PROCESS
end arch_name;
ARCHITECTURE
Syntax(Structural Model)
architecture arch_name of entity_name is
signal declaration;
component declaration;
begin
instance-name: PORT MAP-statement;
concurrents statements;
end arch_name;
ARCHITECTURE
Example(Structural Model)
architecture struct_arch of module is
COMPONENT OR2 {
in1, in2: in std_logic; out1: out std_logic };
end COMPONENT
signal t1: std_logic;
begin
U0: OR2 PORT MAP (M, O, t1);
S <= t1 and N;
end arch_name;
GENERIC
Component Declaration Syntax
COMPONENT entity_name
GENERIC (identifier: type:=constant); - - with an optional value
given by the constant
port { - -list of port names and types;
};
end COMPONENT;
PACKAGE
A PACKAGE provides a mechanism to group together and share
declarations that are used by several entity units.
A package itself includes a declaration and, optionally, a body.
The PACKAGE declaration and body usually are stored together
in a separate file from the rest of the design units.
The file name given for this file must be the same as the package
name.
PACKAGE Example
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
PACKAGE my_package IS
SUBTYPE bit4 IS STD_LOGIC_VECTOR(3 DOWNTO 0);
FUNCTION Shiftright (input: IN bit4) RETURN bit4; – declare a function
SIGNAL mysignal: bit4; – a global signal
END my_package;
PACKAGE BODY my_package IS
– implementation of the Shiftright function
FUNCTION Shiftright (input: IN bit4) RETURN bit4 IS
BEGIN
RETURN ’0’ & input(3 DOWNTO 1);
END shiftright;
END my_package;
Using a PACKAGE
LIBRARY WORK;
USE WORK.my_package.ALL;
entity test_package is
PORT }
x:in bit4; y:out bit4 };
end test_package;
architecture behav_arch of test_package is
begin
mysignal <= x;
y <= shiftright(mysignal);
behav_arch
References