Digital Logic
Digital Logic
ANS: VHDL stands for very high-speed integrated circuit hardware description language. Which is one
of the programming languages used to model a digital system by dataflow, behavioral and structural style of
modeling.
Use library_name.package_name.item_name;
1. Entity declaration.
2. Architecture.
3. Configuration
4. Package declaration.
5. Package body.
Port declaration;
end entity_name;
port(A : in std_logic;
B : in std_logic;
Y : out std_logic);
end andGate;
5. what is port in VHDL?
⚫ Ports are interface through which an entity can communicates with its
environments.
⚫ Port declaration defines the name, type, direction and possible defaults value forthe signal. Each
port has a type i.e. bit_type, std_logic type.
⚫ Each port has a direction i.e. IN, OUT, INOUT,BUFFER
IN — Input: It indicates the input port whose values can read but cannot assignany values i.e. c <= a
OUT — Output : It indicates the output port to which value can only be assignbut not read.
INOUT – It indicate bidirectional port whose value can be read and also assign
BUFFER – It is an output port with read capability. It is not a bidirectional port i.e. port can be read and
write. It has only one source.
Library ieee;
Use ieee.std_logic_1164.all;
Entity and_2 is
Z : out std_logic);
End and_2;
6. What is architecture in VHDL?how to write an architecture in vhdl?
Architecture body contains the internal description of the entity. It describes the functioning and the
structure of the circuit. Architecture always present with an entity i.e. without entity architecture is
not possible. Single entity can have
multiple architecture. Architecture can be used to described a design at different level of abstraction
like gate level or behavioral level
Architecture contains only concurrent statement. Process is only
concurrent statement that contains sequential statement inside it.
Architecture can be describe using structural, data flow, behavioral or mixedstyle
⚫ Syntax:
⚫ Architecture architecture_name of entity_name is
⚫ [ declaration ]
⚫ Begin
◦ [ statements ] End
architecture_name;
There are 4 different modeling style use in architecture body
1. As a set of interconnection ports ( to represent the structure)
2. As a set of concurrent assignment statements ( to represents data flow)
3. As a set of sequential statements ( to represents behavioral )
4. as the combination of above three ( mixed style)For ex.
Library ieee;
Use ieee.std_logic_1164.all;Entity
and_2 is
Port ( a,b : in std_logic;z :
out std_logic);
End and_2;
Architecture Df of and_2 isBegin
Z <= a and b;
End DF;
7. what is Configuration in VHDL? how to write it in VHDL?
⚫ If an entity contains many architectures and any one of the possible architecture
binding with its entity is done using configuration. It is used to bind the architecture body to its
entity and a component with an entity.
⚫ Syntax:
🞄 Configuration configuration_name of entity_name is
🞄 For architecture_name
🞄 End for;
🞄 End configuration_name;
For example
Configuration DEC_CONFIG of DECODER 2x4 isFor
DEC_DATA FLOW
End for;
End DEC_CONFIG;
8. What is package in VHDL?
The internal working of an entity can be defined using different modeling styles inside architecture
body. They are
Behavioral modeling
Data flow modeling
Structural modeling
Mixed Style
Behavioral Style:
No structure
Sometime called high level description
Set of assignment statement to represent a behavior.
It consists of sequential statement of VHDL under the process statement.
For Ex.: NAND Gate
library ieee;
Use ieee.std_logic_1164.all;Entity
nand_2 is
Port ( a,b : in std_logic; y : out std_logic);end
nand_2;
Architecture beh of nand_2 isBegin
Process (a,b)
Begin
If (a = ‘1’ and b =‘1’) then
Y <= ‘0’;
Else
Y <= ‘1’;
End if;
End process;
End beh;
End DF;
An object of variable class can hold a single value of given type. The different values can be assigned
to variable at different time using variable assignment statement. Variable assignment is done using
symbol “:=”.
Syntax:
Variable variable_name: variable_type (range):= [initial value]For Ex:
Variable count: std_logic_vector (3 downto 0):= “0000”;
Physical Type:
It represents physical quantities such as distance, time, length, voltage, current etc. a physical data
type provides for a base unit & successive units are definedin terms of unit.
Composite Type:
A composite type represent collection of values. There are two types-Array Type:- It
contain many elements of same type
Record Type:- It contain many elements of different type Array are
further two types-
Undimensional or one dimensional array:
type array_name is array (index range) of element type;For Ex: type
byte is array ( 7 downto 0) of std_logic; Multidimensional array:-
type array_name is array (index range1, index range2) of element type;For Ex:
type memory is array ( 3 downto 0, 7 downto 0) of std_logic;
Access Type:
Value belonging to access type are pointers to a dynamic allocated object ofsome other type.
They are similar to pointers in pascal & C-language.
Example:
Type ptr is access module;
In this example declares ptr of access type whose values are addresses of module
File Type:
Object of file type represents files in the host environment. They provide amechanism by
which a VHDL design communicates with the host environment. Examples
Type vector is file of BIT_VECTOR;Type
tom is file of BIT_VECTOR;
Syntax:
if condition then
sequential statement;elsif
condition then sequential
statement;else
sequential statement;end
if;
If statement select sequential statement for execution based on the value ofcondition.
It is similar to when-else statement in the concurrent statement. If statement is executed by checking
each condition sequentially untill the first true condition is found, then set of sequential statement
associated with this condition is executed.Case Statement:
Syntax:
Case expression is
When choice => sequential statement;….branch1 When choice
=> sequential statement;….branch2
.
.
When others => sequential statement;….last branch
The expression value may be discrete type or one dimensional array type. The choices may be express
as a single value, as a range of value or by using other clause (when others)
The others clause can be used as a choice to catch all values. And if present it must be last branch in
the case statement.