Unit III
Unit III
1
HDL – Hardware Description Language
HDL stands for Hardware Description
Language. It is a programming
language that is used to describe,
simulate, and create hardware like digital
circuits (ICS). HDL is mainly used to discover
the faults in the design before implementing
it in the hardware.
The main advantage of HDLs is that it
provides flexible modeling capabilities and
can express the large complex designs
(>107 gates).
VHDL
VHDL stands for Very High-Speed Integration Circuit HDL (Hardware
Description Language). It is an IEEE (Institute of Electrical and
Electronics Engineers) standard hardware description language that is
used to describe and simulate the behavior of complex digital circuits.
The most popular examples of VHDL are Odd Parity Generator, Pulse
Generator, Priority Encoder, Behavioral Model for 16 words, 8bit
RAM, etc.
Design exchange
Standardization
Documentation
Readability
Large-scale design
/ Division
& Concatenation
mod Modulus
rem Remainder
abs Absolute Value
** Exponentiation
4. Shift Operators
In VHDL, shift operator is used to perform
the bit manipulation on the data by shifting
and rotating the bits of its first operand right
or left.
VHDL supports the following Miscellaneous
Operators:
Sll shift logical left
Srl shift logical right
Sla shift arithmetic left
Sra shift arithmetic right
Rol rotate left
Ror rotate right
Basic Structure of VHDL
module <module name> <optional list of I/O
parameters>;
<input/output declarations>;
<local variable declarations>;
<program statement>;
<program statement>; // Comments
endmodule
Module bg-circuit(a,b,c,d,e)
Input a,b,c;
Output d,e;
Wire w;
And G1(w,a,b);
Not G3(e,c);
Or G2(d,w,e);
End module;
Array
In VHDL (VHSIC Hardware Description
Language), arrays are used to define
collections of elements of the same type, such
as a group of signals or a memory block.
Arrays can be one-dimensional or multi-
dimensional. Below is a basic explanation of
how to define and use arrays in VHDL.
Defining an Array Type
type int_array is array (0 to 7) of integer;
Declaring an Array Signal or Variable
signal my_array : int_array;
signal my_array : int_array := (0, 1, 2, 3, 4, 5, 6, 7);
Accessing Array Elements
my_array(0) <= 10; -- Set the first element to 10
variable temp : integer;
temp := my_array(3); -- Read the fourth element into a variable
Multi-Dimensional Arrays
type matrix is array (0 to 3, 0 to 3) of integer;
signal my_matrix : matrix := ((1, 2, 3, 4),
(5, 6, 7, 8),
(9, 10, 11, 12),
(13, 14, 15, 16));
entity array_example is
end array_example;
process
variable sum : integer;
begin
my_procedure(5, 10, sum);
wait;
end process;
Functions:
process
variable L: line;
begin
write(L, string'("Hello, VHDL!"));
writeline(output, L); -- Output to
console
wait;
end process;
Modules and Ports
In VHDL, the concept of "modules" and
"ports" aligns closely with entities and
architectures. Entities define the interface
(similar to a module in Verilog or a function in
programming languages), and ports within
entities define the inputs and outputs.
1. Entity (Module)
The entity in VHDL is equivalent to a module
in Verilog. It defines the interface of the
hardware block, specifying the input and
output ports.
Example:
entity my_module is
port (
clk : in std_logic; -- Input clock signal
reset : in std_logic; -- Input reset signal
data_in : in std_logic_vector(7 downto 0); -- 8-bit input
data
data_out : out std_logic_vector(7 downto 0) -- 8-bit
output data
);
end my_module;
Ports
Ports are the input and output signals that allow the
entity to communicate with other entities or with
external signals in the design.
in: Input port, receives data from the external
environment.
out: Output port, sends data to the external
environment.
inout: Bidirectional port, can act as both input and
output.
buffer: Similar to out but can also read back the
current value within the architecture.
Port Types:
std_logic: Represents a single-bit signal that can
have multiple values (0, 1, Z, X, etc.).
std_logic_vector: Represents a bus or a group of
std_logic signals.
Architecture
The architecture in VHDL describes the
internal implementation of the entity. It
defines how the inputs are processed to
generate the outputs.
architecture Behavioral of my_module is
begin
process(clk, reset)
begin
if reset = '1' then
data_out <= (others => '0'); -- Reset output
to 0
elsif rising_edge(clk) then
data_out <= data_in; -- Pass input data to
output on clock edge
end if;
end process;
end Behavioral;
Hierarchical Design
Types of Modeling styles in VHDL
1. Data flow modeling (Design Equations)
Data flow modeling can be described based on the Boolean expression.
It shows how the data flows from input to output. It works on
Concurrent execution.
2. Behavioral modeling (Explains Behaviour)
Behavioral modeling is used to execute statements sequentially. It
shows that how the system performs according to the current statement.
Behavioral modeling may contain Process statements, Sequential
statements, Signal assignment statements, and wait statements.
3. Structural modeling (Connection of sub modules)
Structural modeling is used to specify the functionality and structure of
the circuit.
Structural modeling contain signal declarations, component instances,
and port maps in component instance.
1. Data flow modeling (Design Equations)
Data flow modeling can be described based on the Boolean
expression. It shows how the data flows from input to
output. It works on Concurrent execution.
2. Behavioral modeling (Explains Behaviour)
Behavioral modeling is used to execute statements sequentially. It shows that
how the system performs according to the current statement.
Behavioral modeling may contain Process statements, Sequential statements,
Signal assignment statements, and wait statements.
module mux4x1_bh
(i0,i1,i2,i3,select,y);
input i0,i1,i2,i3;
input [1:0] select;
output y;
reg y;
always @(i0 or i1 or i2 or i3 or
select)
case (select)
2'b00: y = i0;
2'b01: y = i1;
2'b10: y = i2;
2'b11: y = i3;
endcase
endmodule
3. Structural modeling or gate level modeling
(Connection of sub modules)
Structural modeling is used to specify the functionality and structure of the
circuit.
Structural modeling contain signal declarations, component instances, and port
maps in component instance.