VHDL
VHDL
VHDL
Circuits.
Package
Entity
Architecture
Entity
Archr
Pair
Entity
Archr
Pair
Entity
Archr
Pair
Configuration
Entity <entity_name> is
port( <signal_name1>: <mode> <type>;
<signal_name2>: <mode> <type>;
--);
End <entity_name>;
Where
Entity name : identifier selected by the user
Signal name: name of the external interface signal
Modes:
IN: Input port
OUT: Output port
INOUT: Bidirectional port
Buffer: Output port
Entity ful_adder is
port( A, B, Cin : IN BIT;
Sum, Cout : OUT BIT);
End ful_adder;
Entity declaration for: 4-to-1 mux
Entity mux_4_1 is
port( D : IN BIT_VECTOR(0 to 3);
S1, S0 : OUT BIT;
Y : OUT BIT);
End mux_4_1;
Logical
Relational
Arithmetic
Shift and Rotate
It includes:
Numeric data types: integer, floating point
(real)
Enumerated types: BIT, Boolean, & character
User defined types: user can define a type by
using keyword: TYPE
Ex: TYPE arth_op is ( add, sub, mul, div);
It includes:
Array : 1) string 2) Bit_vector
Records: it is analogous to struct in C
Ex:
Type DATE is
record
day: Integer range 1 to 31
month: mth_name;
year: integer range 0 to 4000;
End record;
1)
2) Variable:
Unlike signal a variable does not necessarily
represents a wire in a ckt.
Syntax:
Variable var_name: var_type:= initial_value.
Ex: variable index: Integer range 0 to 20:= 0;
3) Constants:
Syntax:
constant const_name: type:= value;
Ex:
constant Bus_size: Integer:= 32
Declarative parts:
All different components used in the system
description are declared.
For ex. Description of AND gate components:
Component AND2
port ( I1, I2: IN STD_LOGIC;
O2: OUT STD_LOGIC);
End component
Syntax:
Comp_label: comp_name port map
( signal1, signal2 signaln );
Ex:
A2: and2 port map (A,B, Cout);
VHDL Code:
Library IEEE;
USE IEEE.std_logic_1164.all;
-- Entity declaration
Entity half_adder is
port( A, B, : IN std_logic;
Sum, Cout : OUT std_logic);
End half_adder;
Continue..
Begin
-- Component instantiation
X1: XOR2 port map (A, B, Sum)
A1: AND2 port map (A,B, Cout)
End Adder
Library IEEE;
USE IEEE.std_logic_1164.all
Entity XOR2 is
port (I1, I2: IN std_logic;
O1: OUT std_logic);
End XOR2;
Architecture XOR_gate of XOR2 is
Begin
O1 I1 XOR I2;
End XOR_gate;
Library IEEE;
USE IEEE.std_logic_1164.all
Entity AND2 is
port (I1, I2: IN std_logic;
O1: OUT std_logic);
End AND2;
Architecture AND_gate of AND2 is
Begin
O1 I1 AND I2;
End AND_gate;
Sum= ABC;
Cout= AB + AC + BC;
Which can be represented using dataflow
modeling having concurrent stmts as:
Sum A XOR B XOR C
after 10ns;
Cout (A AND B) OR ( A AND C) OR (B AND C) after
20ns;
Entity f_adder is
port( A, B, Cin : IN bit;
Sum, Cout : OUT bit);
End f_adder;
Architecture adder of f_adder is
Begin
sum A XOR B XOR Cin;
Cout (A and B) OR ( Cin and A) Or
( Cin
And B);
End adder;