Tutorial 1: Signal Processing, CE00039-2 Signal Processing, CE00039-2
Tutorial 1: Signal Processing, CE00039-2 Signal Processing, CE00039-2
Tutorial 1
Signal Processing, CE00039-2
Introduction
Two major HDLs:
VHDL
standardized by IEEE in 1987,1993, 2002, 2006
object-oriented, very widely used
Has Verbose syntax like Ada
Verilog
standardized by IEEE in 1995, 2001, 2005
has concise syntax like C
ModelSim XE II 5.7g
ModelSim XE II 5.7g
ModelSim XE II 5.7g
ModelSim XE II 5.7g
ModelSim XE II 5.7g
ModelSim XE II 5.7g
ModelSim XE II 5.7g
ModelSim XE II 5.7g
ModelSim XE II 5.7g
VHDL
Tutorial 2
Signal Processing, CE00039-2
Hardware abstraction
Library library_name;
Use library_name.package name.package
parts;
library
packages
ieee library
Std_logic_1164
Std_logic_arith
Std_logic_signed
Std_logic_unsigned
Architecture body:syntax
AND gate
library ieee;
use ieee.std_logic_1164.all;
entity and2 is
port(x,y:in std_logic;z:out std_logic);
end and2;
architecture data flow of and2 is
begin
z<= x and y;
end data flow ;
Signal Processing, CE00039-2
VHDL
Tutorial 3
Signal Processing, CE00039-2
Architecture Body
There are 4 different ways of
modeling styles
1.
2.
3.
4.
Behavioral Modeling
Usage of sequential signal assignment statements
Order dependent
Eg: OR GATE
begin
process(a,b)
begin
if a=0 and b=0 then
c<=0;
else
c<=1;
end if;
end process;
end architecture_name;
VHDL
Tutorial 4
Signal Processing, CE00039-2
comparator
library ieee;
use ieee.std_logic_1164.all;
entity Comparator is
port( A: in std_logic;
B: in std_logic;
c: out std_logic_vector(0 to 1));
end Comparator;
architecture behv of Comparator is
begin
process(A,B)
begin
if (A<B) then
c <= "00";
elsif (A=B) then
c <= "01";
else
c <= "11";
end if;
end process;
end behv;
VHDL
Tutorial 5
Signal Processing, CE00039-2
variable
It is assigned a value
instantaneously
Assignment operator is :=
Usage of signals
library ieee;
use ieee.std_logic_1164.all;
entity aoi is
port(
a,b,c,d: in std_logic;z:out std_logic);
end aoi;
architecture data of aoi is
signal l,m,n:std_logic;
begin
l<=a and b;
m<=c and d;
n<=l or m;
z<=not n;
end data;
Usage of variables
library ieee;
use ieee.std_logic_1164.all;
entity aoi is
port(
a,b,c,d: in std_logic;z:out std_logic);
end aoi;
architecture behv of aoi is
begin
process(a,b,c,d)
variable l,m,n:std_logic;
begin
l:=a and b;
m:=c and d;
n:=l or m;
z<=not n;
end process;
end behv;
ALU
library ieee;
use ieee.std_logic_1164.all;
entity ALU is
port(
A:
in std_logic_vector(1 downto 0);
B:
in std_logic_vector(1 downto 0);
Sel: in std_logic_vector(1 downto 0);
Res: out std_logic_vector(1 downto 0) );
end ALU;
architecture behv of ALU is
begin
process(Sel)
begin
case Sel is
when "00" =>
Res <= A or B;
when "01" =>
Res <= A and B;
when "10" =>
Res <= A nand B;
when "11" =>
Res <= A nor B;
when others =>
Res <= "XX";
end case;
end process;
end behv;
Signal Processing, CE00039-2
VHDL
Tutorial 6
Signal Processing, CE00039-2
Structural modeling
architecture HA_STRUCTURE of HALF_ADDER is
component XOR2
port (X, Y: in BIT; Z: out BIT);
end component;
component AND2
port (L, M: in BIT; N: out BIT);
end component;
begin
X1: XOR2 port map (A, B, SUM);
A1: AND2 port map (A, B, CARRY);
end HA_STRUCTURE;
Signal Processing, CE00039-2
VHDL
Tutorial 7
Signal Processing, CE00039-2
VHDL
Tutorial 8
Signal Processing, CE00039-2
VHDL
Tutorial 9
Signal Processing, CE00039-2
VHDL
Tutorial 10
Signal Processing, CE00039-2