Copyright © 2005 by W. D. Bishop. All Rights Reserved
Department of Electrical and Computer Engineering
University of Waterloo
! "
#
$
Copyright © 2005 by W. D. Bishop. All Rights Reserved
! "! "
% &
'
'
'
' ( )
% *
' + ,
' -. -
' (
'
' +
#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
! " $ " %! " $ " %
% /
'
' ( 0
'
Copyright © 2005 by W. D. Bishop. All Rights Reserved
Department of Electrical and Computer Engineering
University of Waterloo
!& &!& &
Copyright © 2005 by W. D. Bishop. All Rights Reserved
%
%
&
%
/
'" "'" "
V ery High Speed Integrated Circuit
H ardware
D escription
L anguage
(
Copyright © 2005 by W. D. Bishop. All Rights Reserved
) *) *
% & ( 1 (
2+ 3456 3476
' ( & "("
' / & 0 / &
% & $
' 3473- & &
' 3478- &
' 3475- 1 93658934752&
' 344:- 1 936589344:2&
' ;66;- 1 936589;66;2&
% & /
)
+
Copyright © 2005 by W. D. Bishop. All Rights Reserved
' " " ,)' " " ,)
%
'
' / &
' / &
%
&
' &
' < )
-
Copyright © 2005 by W. D. Bishop. All Rights Reserved
' " " ,)$ " %' " " ,)$ " %
%
' & *+=.
'
%
'
.(
.
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 0)"/ " " 0)"
% + > & )
/ & & $
' !
" #
! $ !
! % #
% > & & $
'
! &'$(
" $ ) %
#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0 " 1 " *0 " 1 " *
% '222 +(3 .-+
' ( ? @ + A
% '222 +( '4 25652 7 '!403 ..
' ( ? @39BB4:5937393A
% '222 +(3 ..#
' ( ? @39BB4:59:5897A
% '222 +(3
' ( ? @695:739::;89CA
% '222 +(3
' ( ? @695:739:;C596A
Copyright © 2005 by W. D. Bishop. All Rights Reserved
28 " "28 " "
% '222 +( 3 ...
' ( . / 9( / @695:73938C697A
% '222 +( 3 ..(
' ( + , @39BB4:5974C97A
% '222 +( #3 ..+
' ( ( + , @39BB4:594;:9BA
% '222 +( 93 ..
' ( . .( ( @39BB4:5984396A
% '222 +( 38888
' ( + , @< ( ) A
% '222 +( (3 ...
' ( ? 1? 2( @695:73937349;A
Copyright © 2005 by W. D. Bishop. All Rights Reserved
5 '2220 "5 '2220 "
% '222 (93 ..#
' ( ( @39BB4:59;4496A
% '222 #(93 ..
' ( > D &
@39BB4:595;59BA
#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
5 * "5 * "
% &
% * - &
$
' + - -: - = & -< & E ,-<E-
3447"
' + F". - G = -; -
H + - "-( * - .-;66;"
' ( > & I , -*
& -; - = &9 -< & E ,-<E-
;66C"
Copyright © 2005 by W. D. Bishop. All Rights Reserved
Department of Electrical and Computer Engineering
University of Waterloo
: " ": " "
Copyright © 2005 by W. D. Bishop. All Rights Reserved
4 ",/ "& " "4 ",/ "& " "
% * - &
& $
' . , & &
' . & &
' . #
% -
' 1 2 &
'
&
(
Copyright © 2005 by W. D. Bishop. All Rights Reserved
" 6 ; ," 6 ; ,
% , - -
, &
% + ,
% & / ieee
std_logic_1164 , $
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
+
Copyright © 2005 by W. D. Bishop. All Rights Reserved
2" 7 "2" 7 "
/ "*, "/ "*, "
%
- J 9 &
% . /
% . - -
Entity
Architecture 1
Architecture 2
Architecture n…
Configuration
1 Configuration n
Configuration2
-
Copyright © 2005 by W. D. Bishop. All Rights Reserved
2"2"
% . G /
% & $
3"
;". 9
:".
&
% =
.
Copyright © 2005 by W. D. Bishop. All Rights Reserved
2" ) "2" ) "
% & $
ENTITY entity_name IS
GENERIC(
generic_1_name : generic_1_type;
generic_2_name : generic_2_type;
generic_n_name : generic_n_type
);
PORT(
port_1_name : port_1_dir port_1_type;
port_2_name : port_2_dir port_2_type;
port_n_name : port_n_dir port_n_type
);
END entity_name;
Copyright © 2005 by W. D. Bishop. All Rights Reserved
28 2" ) "28 2" ) "
% & /
.< $
4! 2<
+ ? -
9
"
ENTITY andgate IS
PORT ( a : IN std_logic;
b : IN std_logic;
c : OUT std_logic );
END andgate;
Copyright © 2005 by W. D. Bishop. All Rights Reserved
66
% + $
' - - K
' .& &
'
% + $
IN
OUT
INOUT >
BUFFER >
4! 2<
.
L M
"
Copyright © 2005 by W. D. Bishop. All Rights Reserved
6 $ " %6 $ " %
% 338C9344: , &
' / )
std_logic_1164 ,
' &
) $
std_logic
std_logic_vector(<max> DOWNTO <min>)
#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
77
% . G
%
% * / - &
& ) &
$
' +
' .
' + &
' (
9
Copyright © 2005 by W. D. Bishop. All Rights Reserved
7 "7 "
% . & $
ARCHITECTURE architecture_name OF entity_name IS
BEGIN
-- Insert VHDL statements to assign outputs to
-- each of the output signals defined in the
-- entity declaration.
END architecture_name;
Copyright © 2005 by W. D. Bishop. All Rights Reserved
28 7 "28 7 "
% & /
.< $
ARCHITECTURE synthesis1 OF andgate IS
BEGIN
c <= a AND b;
END synthesis1;
4! 2<
, & AND
.< "
(
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ "*, "/ "*, "
% . &
% > - /
%
%
&
+
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0,"0,"
% ( &
% (
% ( &
% (
% 9 $
' /
'
-
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0," 5 " "0," 5 " "
N0G* 6N1G* 3
" )
% > &
% + &
% .
&
.
Copyright © 2005 by W. D. Bishop. All Rights Reserved
33 , 5 " ", 5 " "
% 1 9 2
9
, &
% & 9
ieee.std_logic_1164$
' 9 C
' 9 4
#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
33 99
% 9 C ; 1NXG NZG2
$
% ! &
% 9C
NZGN0G* 6
NXG* , &N1G* 3
3 9
#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
33 ..
% 9 4 B
$
NXG* , &
NZGN0G* 6
NWG! , , &N1G* 3
NLG! ,6N-GG
NHG! ,3NUG)
3 .
% ( &
% ( &
#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
"" 33..
% * ) 94$
std_ulogic
std_ulogic_vector( <max> DOWNTO <min>)
?
std_logic
std_logic_vector( <max> DOWNTO <min> )
% ?
&
##
Copyright © 2005 by W. D. Bishop. All Rights Reserved
33'" )'" )
% 9 &
9
% > 9 & ,& &
% > 9
/
* +REAL
> - -.INTEGER
> - -.BIT_VECTOR
> -BIT
/)
#9
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0)" 0 "0)" 0 "
% . )
% < )
% & $
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY simple_buffer IS
PORT ( din : IN std_logic;
dout : OUT std_logic );
END simple_buffer;
ARCHITECTURE behavioural1 OF simple_buffer IS
BEGIN
dout <= din AFTER 10 ns;
END behavioural1;
#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0)" 0 "$ " %0)" 0 "$ " %
% 36
' 9& O E (
' O + ? .+(
' O <
% )
% (
) , &
% ) 4:
#(
Copyright © 2005 by W. D. Bishop. All Rights Reserved
% & $
% /
&
, !, !
P< ?P ?
< ??
<<.<.<
#+
Copyright © 2005 by W. D. Bishop. All Rights Reserved
! !! !
% & $
Q 10 2
KQ 1< 0 2
R 1 2
S 1= 2
% & $
T 1. 2
9 1( 2
U 1 2
K 1 2
#-
Copyright © 2005 by W. D. Bishop. All Rights Reserved
7 ," " 0 "7 ," " 0 "
SIGNAL a, b, c : std_logic;
SIGNAL avec, bvec, cvec : std_logic_vector(7 DOWNTO 0);
-- Concurrent Signal Assignment Statements
-- NOTE: Both a and avec are produced concurrently
a <= b AND c;
avec <= bvec OR cvec;
-- Alternatively, signals may be assigned constants
a <= ’0’;
b <= ’1’;
c <= ’Z’;
avec <= "00111010"; -- Assigns 0x3A to avec
bvec <= X"3A"; -- Assigns 0x3A to bvec
cvec <= X"3" & X"A"; -- Assigns 0x3A to cvec
#.
Copyright © 2005 by W. D. Bishop. All Rights Reserved
7 ," " 0 " $ " %7 ," " 0 " $ " %
SIGNAL a, b, c, d :std_logic;
SIGNAL avec :std_logic_vector(1 DOWNTO 0);
SIGNAL bvec :std_logic_vector(2 DOWNTO 0);
-- Conditional Assignment Statement
-- NOTE: This implements a tree structure of logic gates
a <= ’0’ WHEN avec = “00” ELSE
b WHEN avec = “11” ELSE
c WHEN d = ’1’ ELSE
’1’;
-- Selected Signal Assignment Statement
-- NOTE: The selection values must be constants
bvec <= d & avec;
WITH bvec SELECT
a <= ’0’ WHEN “000”,
b WHEN “011”,
c WHEN “1--”, -- Some tools won’t synthesize ‘-’ properly
’1’ WHEN OTHERS;
9
Copyright © 2005 by W. D. Bishop. All Rights Reserved
7 ," " 0 " $ " %7 ," " 0 " $ " %
SIGNAL a :std_logic;
SIGNAL avec, bvec :std_logic_vector(7 DOWNTO 0);
-- Selected Signal Assignment Statement
-- NOTE: Selected signal assignments also work
-- with vectors
WITH a SELECT
avec <= “01010101” WHEN ’1’,
bvec WHEN OTHERS;
9
Copyright © 2005 by W. D. Bishop. All Rights Reserved
6 0 "6 0 "
%
% +
% +
' ( &
% * / - 9 9
,
' 9 9
,
' & -
9
Copyright © 2005 by W. D. Bishop. All Rights Reserved
6 0 "6 0 "
% , &
& $
% .
0 &
% + -
0
CASE..WHEN..END CASEWITH..SELECT..WHEN
IF..ELSIF..ELSE..END IFWHEN..ELSE
'" 6! 6
9#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
6 0 " $ " %6 0 " $ " %
SIGNAL reset, clock, d, q :std_logic;
PROCESS (reset, clock)
-- reset and clock are in the sensitivity list to
-- indicate that they are important inputs to the process
BEGIN
-- IF keyword is only valid in a process
IF (reset = ’0’) THEN
q <= 0;
ELSIF (clock’EVENT AND clock = ’1’) THEN
q <= d;
END IF;
END PROCESS;
4! 2<
9
& 9
& "
EVENT
"
99
Copyright © 2005 by W. D. Bishop. All Rights Reserved
6 0 " $ " %6 0 " $ " %
SIGNAL a, b, c, d :std_logic;
PROCESS (a, b, d)
-- a, b, and d are in the sensitivity list to indicate that
-- the outputs of the process are sensitive to changes in them
BEGIN
-- CASE keyword is only valid in a process
CASE d IS
WHEN ‘0’ =>
c <= a AND b;
WHEN OTHERS =>
c <= ‘1’;
END CASE;
END PROCESS;
4! 2<
"
9
Copyright © 2005 by W. D. Bishop. All Rights Reserved
:: 33: 28: 28
% EVENT -
9
% EVENT ,
,
% , * 9* & &$
9(
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0 * " * :0 * " * : 33::
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY dffe IS
PORT( rst, clk, ena, d : IN std_logic;
q : OUT std_logic );
END dffe;
ARCHITECTURE synthesis1 OF dffe IS
BEGIN
PROCESS (rst, clk)
BEGIN
IF (rst = ‘1’) THEN
q <= ‘0’;
ELSIF (clk’EVENT) AND (clk = ‘1’) THEN
IF (ena = ‘1’) THEN
q <= d;
END IF;
END IF;
END PROCESS;
END synthesis1;
9+
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ 80 = " // 80 = " /
% / *( 1* (
2
% *( .(
% * - / *(
/ &
9-
Copyright © 2005 by W. D. Bishop. All Rights Reserved
:" 0 " 28:" 0 " 28
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY vending IS
PORT(
reset : IN std_logic;
clock : IN std_logic;
buttons : IN std_logic_vector(1 DOWNTO 0);
lights : OUT std_logic_vector(1 DOWNTO 0)
);
END vending;
'
" , "
!
, $ % "
!
, $ % "
2
, "
7 ""$ %
"$ %
9.
Copyright © 2005 by W. D. Bishop. All Rights Reserved
:" 0 " 28 $ " %:" 0 " 28 $ " %
ARCHITECTURE synthesis1 OF vending IS
TYPE statetype IS (Idle, Opt1, Opt2, Error);
SIGNAL currentstate, nextstate : statetype;
BEGIN
fsm1: PROCESS( buttons, currentstate )
BEGIN
CASE currentstate IS
WHEN Idle =>
lights <= “00”;
CASE buttons IS
WHEN “00” =>
nextstate <= Idle;
WHEN “01” =>
nextstate <= Opt1;
WHEN “10” =>
nextstate <= Opt2;
WHEN OTHERS =>
nextstate <= Error;
END CASE;
WHEN Opt1 =>
lights <= “01”;
IF buttons /= “01” THEN
nextstate <= Idle;
END IF;
Copyright © 2005 by W. D. Bishop. All Rights Reserved
:" 0 " 28 $ " %:" 0 " 28 $ " %
WHEN Opt2 =>
lights <= “10”;
IF buttons /= “10” THEN
nextstate <= Idle;
END IF;
WHEN Error =>
lights <= “11”;
IF buttons = “00” THEN
nextstate <= Idle;
END IF;
END CASE;
END PROCESS;
fsm2: PROCESS( reset, clock )
BEGIN
IF (reset = ‘0’) THEN
currentstate <= Idle;
ELSIF (clock’EVENT) AND (clock = ‘1’) THEN
currentstate <= nextstate;
END IF;
END PROCESS;
END synthesis1;
Copyright © 2005 by W. D. Bishop. All Rights Reserved
Department of Electrical and Computer Engineering
University of Waterloo
2828
7 " ) " ) & * " *
: * & " " ) ",
"3 " "
7 ) '> ? " )
& = " & " ",
"
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 28/ " " 28
% & / )
% - 0 &
' )
!
#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 28 7/ " " 28 7
% andnand
& $
% std_logic
9
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 28 7/ " " 28 7 33 0 "0 "
% andnand
& $
ENTITY andnand IS
PORT ( a : IN std_logic;
b : IN std_logic;
q : OUT std_logic;
qbar : OUT std_logic );
END andnand;
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " / 28/ " " / 28
%
andnand
% < synthesis1
(
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 28/ " " 28 33 0 "0 "
% andnand
& $
ARCHITECTURE synthesis1 OF andnand IS
BEGIN
q <= a AND b;
qbar<= a NAND b;
END synthesis1;
+
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 28 7/ " " 28 7
% quadmux
# ;9 P & &$
C
3
C
C
<
<
<
"
std_logic_vector
std_logic
std_logic_vector
std_logic_vector
)6
-
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 28 7/ " " 28 7 33 0 "0 "
% quadmux
& $
ENTITY quadmux IS
PORT ( a : IN std_logic_vector(3 DOWNTO 0);
b : IN std_logic_vector(3 DOWNTO 0);
sel : IN std_logic;
c : OUT std_logic_vector(3 DOWNTO 0) );
END quadmux;
.
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 28/ " " 28
%
quadmux
% ? # ;9 P &
$
% < synthesis1
b[3..0]1
a[3..0]0
c[3..0]sel
(
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 28/ " " 28 33 0 "0 "
% quadmux
& $
ARCHITECTURE synthesis1 OF quadmux IS
BEGIN
WITH sel SELECT
c <= a WHEN ‘0’,
b WHEN OTHERS;
END synthesis1;
(
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 28 #/ " " 28 #
% ) (
(
% ( ( &
&$
(
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/ " " 28 #/ " " 28 # 33 0 "0 "
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY seven_seg IS
PORT( dataIn : IN std_logic_vector(3 DOWNTO 0);
segments : OUT std_logic_vector(7 DOWNTO 0) );
END seven_seg;
ARCHITECTURE synthesis1 OF seven_seg IS
BEGIN
WITH dataIn SELECT
segments <= “10000001” WHEN “0000”, -- 0
“11001111” WHEN “0001”, -- 1
“10010010” WHEN “0010”, -- 2
“10000110” WHEN “0011”, -- 3
“11001100” WHEN “0100”, -- 4
“10100100” WHEN “0101”, -- 5
“10100000” WHEN “0110”, -- 6
“10001111” WHEN “0111”, -- 7
“10000000” WHEN “1000”, -- 8
“10000100” WHEN “1001”, -- 9
“11111111” WHEN OTHERS;
END synthesis1;
(#
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0 = " 280 = " 28
% ) 79
&
% , 79 & &$
(9
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0 = " 280 = " 28 33 0 "0 "
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY dregister IS
PORT( rst, clk, ena : IN std_logic;
d : IN std_logic_vector(7 DOWNTO 0);
q : OUT std_logic_vector(7 DOWNTO 0) );
END dregister;
ARCHITECTURE synthesis1 OF dregister IS
BEGIN
PROCESS (rst, clk)
BEGIN
IF (rst = ‘1’) THEN
q <= X”00”;
ELSIF (clk’EVENT) AND (clk = ‘1’) THEN
IF (ena = ‘1’) THEN
q <= d;
END IF;
END IF;
END PROCESS;
END synthesis1;
(
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0 = " 280 = " 28
% ) :;9
&
% , :;9 & &$
32-Bit Counter
value[31..0]reset
enable
clock
((
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0 = " 280 = " 28 33 0 "0 "
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY counter IS
PORT(
reset : IN std_logic;
clock : IN std_logic;
enable : IN std_logic;
value : OUT std_logic_vector(31 DOWNTO 0)
);
END counter;
(+
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0 = " 280 = " 28 @@ 0 "$ " %0 "$ " %
ARCHITECTURE synthesis1 OF counter IS
-- The unsigned type is used
SIGNAL count : unsigned(31 DOWNTO 0); -- so that unsigned arithmetic
-- will be synthesized
BEGIN
PROCESS (reset, clock)
BEGIN
IF (reset = ‘1’) THEN
count <= X”00000000”;
ELSIF (clock’EVENT) AND (clock = ‘1’) THEN
IF (enable = ‘1’) THEN
count <= count + 1;
END IF;
END IF;
END PROCESS;
-- Here, the count value is
value <= std_logic_vector(count); -- converted to std_logic_vector
-- using a conversion function
END synthesis1;
(-
Copyright © 2005 by W. D. Bishop. All Rights Reserved
7 ;" , "7 ;" , "
%
:;C & $
! " , ? >"=
"!" ! ">
? (
% - / /
( 3C3- ;;:- C;5
& $
,. . & H

Vhdl ppt

  • 1.
    Copyright © 2005by W. D. Bishop. All Rights Reserved Department of Electrical and Computer Engineering University of Waterloo ! " # $
  • 2.
    Copyright © 2005by W. D. Bishop. All Rights Reserved ! "! " % & ' ' ' ' ( ) % * ' + , ' -. - ' ( ' ' +
  • 3.
    # Copyright © 2005by W. D. Bishop. All Rights Reserved ! " $ " %! " $ " % % / ' ' ( 0 '
  • 4.
    Copyright © 2005by W. D. Bishop. All Rights Reserved Department of Electrical and Computer Engineering University of Waterloo !& &!& &
  • 5.
    Copyright © 2005by W. D. Bishop. All Rights Reserved % % & % / '" "'" " V ery High Speed Integrated Circuit H ardware D escription L anguage
  • 6.
    ( Copyright © 2005by W. D. Bishop. All Rights Reserved ) *) * % & ( 1 ( 2+ 3456 3476 ' ( & "(" ' / & 0 / & % & $ ' 3473- & & ' 3478- & ' 3475- 1 93658934752& ' 344:- 1 936589344:2& ' ;66;- 1 936589;66;2& % & / )
  • 7.
    + Copyright © 2005by W. D. Bishop. All Rights Reserved ' " " ,)' " " ,) % ' ' / & ' / & % & ' & ' < )
  • 8.
    - Copyright © 2005by W. D. Bishop. All Rights Reserved ' " " ,)$ " %' " " ,)$ " % % ' & *+=. ' % ' .(
  • 9.
    . Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 0)"/ " " 0)" % + > & ) / & & $ ' ! " # ! $ ! ! % # % > & & $ ' ! &'$( " $ ) % #
  • 10.
    Copyright © 2005by W. D. Bishop. All Rights Reserved 0 " 1 " *0 " 1 " * % '222 +(3 .-+ ' ( ? @ + A % '222 +( '4 25652 7 '!403 .. ' ( ? @39BB4:5937393A % '222 +(3 ..# ' ( ? @39BB4:59:5897A % '222 +(3 ' ( ? @695:739::;89CA % '222 +(3 ' ( ? @695:739:;C596A
  • 11.
    Copyright © 2005by W. D. Bishop. All Rights Reserved 28 " "28 " " % '222 +( 3 ... ' ( . / 9( / @695:73938C697A % '222 +( 3 ..( ' ( + , @39BB4:5974C97A % '222 +( #3 ..+ ' ( ( + , @39BB4:594;:9BA % '222 +( 93 .. ' ( . .( ( @39BB4:5984396A % '222 +( 38888 ' ( + , @< ( ) A % '222 +( (3 ... ' ( ? 1? 2( @695:73937349;A
  • 12.
    Copyright © 2005by W. D. Bishop. All Rights Reserved 5 '2220 "5 '2220 " % '222 (93 ..# ' ( ( @39BB4:59;4496A % '222 #(93 .. ' ( > D & @39BB4:595;59BA
  • 13.
    # Copyright © 2005by W. D. Bishop. All Rights Reserved 5 * "5 * " % & % * - & $ ' + - -: - = & -< & E ,-<E- 3447" ' + F". - G = -; - H + - "-( * - .-;66;" ' ( > & I , -* & -; - = &9 -< & E ,-<E- ;66C"
  • 14.
    Copyright © 2005by W. D. Bishop. All Rights Reserved Department of Electrical and Computer Engineering University of Waterloo : " ": " "
  • 15.
    Copyright © 2005by W. D. Bishop. All Rights Reserved 4 ",/ "& " "4 ",/ "& " " % * - & & $ ' . , & & ' . & & ' . # % - ' 1 2 & ' &
  • 16.
    ( Copyright © 2005by W. D. Bishop. All Rights Reserved " 6 ; ," 6 ; , % , - - , & % + , % & / ieee std_logic_1164 , $ LIBRARY ieee; USE ieee.std_logic_1164.ALL;
  • 17.
    + Copyright © 2005by W. D. Bishop. All Rights Reserved 2" 7 "2" 7 " / "*, "/ "*, " % - J 9 & % . / % . - - Entity Architecture 1 Architecture 2 Architecture n… Configuration 1 Configuration n Configuration2
  • 18.
    - Copyright © 2005by W. D. Bishop. All Rights Reserved 2"2" % . G / % & $ 3" ;". 9 :". & % =
  • 19.
    . Copyright © 2005by W. D. Bishop. All Rights Reserved 2" ) "2" ) " % & $ ENTITY entity_name IS GENERIC( generic_1_name : generic_1_type; generic_2_name : generic_2_type; generic_n_name : generic_n_type ); PORT( port_1_name : port_1_dir port_1_type; port_2_name : port_2_dir port_2_type; port_n_name : port_n_dir port_n_type ); END entity_name;
  • 20.
    Copyright © 2005by W. D. Bishop. All Rights Reserved 28 2" ) "28 2" ) " % & / .< $ 4! 2< + ? - 9 " ENTITY andgate IS PORT ( a : IN std_logic; b : IN std_logic; c : OUT std_logic ); END andgate;
  • 21.
    Copyright © 2005by W. D. Bishop. All Rights Reserved 66 % + $ ' - - K ' .& & ' % + $ IN OUT INOUT > BUFFER > 4! 2< . L M "
  • 22.
    Copyright © 2005by W. D. Bishop. All Rights Reserved 6 $ " %6 $ " % % 338C9344: , & ' / ) std_logic_1164 , ' & ) $ std_logic std_logic_vector(<max> DOWNTO <min>)
  • 23.
    # Copyright © 2005by W. D. Bishop. All Rights Reserved 77 % . G % % * / - & & ) & $ ' + ' . ' + & ' (
  • 24.
    9 Copyright © 2005by W. D. Bishop. All Rights Reserved 7 "7 " % . & $ ARCHITECTURE architecture_name OF entity_name IS BEGIN -- Insert VHDL statements to assign outputs to -- each of the output signals defined in the -- entity declaration. END architecture_name;
  • 25.
    Copyright © 2005by W. D. Bishop. All Rights Reserved 28 7 "28 7 " % & / .< $ ARCHITECTURE synthesis1 OF andgate IS BEGIN c <= a AND b; END synthesis1; 4! 2< , & AND .< "
  • 26.
    ( Copyright © 2005by W. D. Bishop. All Rights Reserved / "*, "/ "*, " % . & % > - / % % &
  • 27.
    + Copyright © 2005by W. D. Bishop. All Rights Reserved 0,"0," % ( & % ( % ( & % ( % 9 $ ' / '
  • 28.
    - Copyright © 2005by W. D. Bishop. All Rights Reserved 0," 5 " "0," 5 " " N0G* 6N1G* 3 " ) % > & % + & % . &
  • 29.
    . Copyright © 2005by W. D. Bishop. All Rights Reserved 33 , 5 " ", 5 " " % 1 9 2 9 , & % & 9 ieee.std_logic_1164$ ' 9 C ' 9 4
  • 30.
    # Copyright © 2005by W. D. Bishop. All Rights Reserved 33 99 % 9 C ; 1NXG NZG2 $ % ! & % 9C NZGN0G* 6 NXG* , &N1G* 3 3 9
  • 31.
    # Copyright © 2005by W. D. Bishop. All Rights Reserved 33 .. % 9 4 B $ NXG* , & NZGN0G* 6 NWG! , , &N1G* 3 NLG! ,6N-GG NHG! ,3NUG) 3 . % ( & % ( &
  • 32.
    # Copyright © 2005by W. D. Bishop. All Rights Reserved "" 33.. % * ) 94$ std_ulogic std_ulogic_vector( <max> DOWNTO <min>) ? std_logic std_logic_vector( <max> DOWNTO <min> ) % ? &
  • 33.
    ## Copyright © 2005by W. D. Bishop. All Rights Reserved 33'" )'" ) % 9 & 9 % > 9 & ,& & % > 9 / * +REAL > - -.INTEGER > - -.BIT_VECTOR > -BIT /)
  • 34.
    #9 Copyright © 2005by W. D. Bishop. All Rights Reserved 0)" 0 "0)" 0 " % . ) % < ) % & $ LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY simple_buffer IS PORT ( din : IN std_logic; dout : OUT std_logic ); END simple_buffer; ARCHITECTURE behavioural1 OF simple_buffer IS BEGIN dout <= din AFTER 10 ns; END behavioural1;
  • 35.
    # Copyright © 2005by W. D. Bishop. All Rights Reserved 0)" 0 "$ " %0)" 0 "$ " % % 36 ' 9& O E ( ' O + ? .+( ' O < % ) % ( ) , & % ) 4:
  • 36.
    #( Copyright © 2005by W. D. Bishop. All Rights Reserved % & $ % / & , !, ! P< ?P ? < ?? <<.<.<
  • 37.
    #+ Copyright © 2005by W. D. Bishop. All Rights Reserved ! !! ! % & $ Q 10 2 KQ 1< 0 2 R 1 2 S 1= 2 % & $ T 1. 2 9 1( 2 U 1 2 K 1 2
  • 38.
    #- Copyright © 2005by W. D. Bishop. All Rights Reserved 7 ," " 0 "7 ," " 0 " SIGNAL a, b, c : std_logic; SIGNAL avec, bvec, cvec : std_logic_vector(7 DOWNTO 0); -- Concurrent Signal Assignment Statements -- NOTE: Both a and avec are produced concurrently a <= b AND c; avec <= bvec OR cvec; -- Alternatively, signals may be assigned constants a <= ’0’; b <= ’1’; c <= ’Z’; avec <= "00111010"; -- Assigns 0x3A to avec bvec <= X"3A"; -- Assigns 0x3A to bvec cvec <= X"3" & X"A"; -- Assigns 0x3A to cvec
  • 39.
    #. Copyright © 2005by W. D. Bishop. All Rights Reserved 7 ," " 0 " $ " %7 ," " 0 " $ " % SIGNAL a, b, c, d :std_logic; SIGNAL avec :std_logic_vector(1 DOWNTO 0); SIGNAL bvec :std_logic_vector(2 DOWNTO 0); -- Conditional Assignment Statement -- NOTE: This implements a tree structure of logic gates a <= ’0’ WHEN avec = “00” ELSE b WHEN avec = “11” ELSE c WHEN d = ’1’ ELSE ’1’; -- Selected Signal Assignment Statement -- NOTE: The selection values must be constants bvec <= d & avec; WITH bvec SELECT a <= ’0’ WHEN “000”, b WHEN “011”, c WHEN “1--”, -- Some tools won’t synthesize ‘-’ properly ’1’ WHEN OTHERS;
  • 40.
    9 Copyright © 2005by W. D. Bishop. All Rights Reserved 7 ," " 0 " $ " %7 ," " 0 " $ " % SIGNAL a :std_logic; SIGNAL avec, bvec :std_logic_vector(7 DOWNTO 0); -- Selected Signal Assignment Statement -- NOTE: Selected signal assignments also work -- with vectors WITH a SELECT avec <= “01010101” WHEN ’1’, bvec WHEN OTHERS;
  • 41.
    9 Copyright © 2005by W. D. Bishop. All Rights Reserved 6 0 "6 0 " % % + % + ' ( & % * / - 9 9 , ' 9 9 , ' & -
  • 42.
    9 Copyright © 2005by W. D. Bishop. All Rights Reserved 6 0 "6 0 " % , & & $ % . 0 & % + - 0 CASE..WHEN..END CASEWITH..SELECT..WHEN IF..ELSIF..ELSE..END IFWHEN..ELSE '" 6! 6
  • 43.
    9# Copyright © 2005by W. D. Bishop. All Rights Reserved 6 0 " $ " %6 0 " $ " % SIGNAL reset, clock, d, q :std_logic; PROCESS (reset, clock) -- reset and clock are in the sensitivity list to -- indicate that they are important inputs to the process BEGIN -- IF keyword is only valid in a process IF (reset = ’0’) THEN q <= 0; ELSIF (clock’EVENT AND clock = ’1’) THEN q <= d; END IF; END PROCESS; 4! 2< 9 & 9 & " EVENT "
  • 44.
    99 Copyright © 2005by W. D. Bishop. All Rights Reserved 6 0 " $ " %6 0 " $ " % SIGNAL a, b, c, d :std_logic; PROCESS (a, b, d) -- a, b, and d are in the sensitivity list to indicate that -- the outputs of the process are sensitive to changes in them BEGIN -- CASE keyword is only valid in a process CASE d IS WHEN ‘0’ => c <= a AND b; WHEN OTHERS => c <= ‘1’; END CASE; END PROCESS; 4! 2< "
  • 45.
    9 Copyright © 2005by W. D. Bishop. All Rights Reserved :: 33: 28: 28 % EVENT - 9 % EVENT , , % , * 9* & &$
  • 46.
    9( Copyright © 2005by W. D. Bishop. All Rights Reserved 0 * " * :0 * " * : 33:: LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY dffe IS PORT( rst, clk, ena, d : IN std_logic; q : OUT std_logic ); END dffe; ARCHITECTURE synthesis1 OF dffe IS BEGIN PROCESS (rst, clk) BEGIN IF (rst = ‘1’) THEN q <= ‘0’; ELSIF (clk’EVENT) AND (clk = ‘1’) THEN IF (ena = ‘1’) THEN q <= d; END IF; END IF; END PROCESS; END synthesis1;
  • 47.
    9+ Copyright © 2005by W. D. Bishop. All Rights Reserved / 80 = " // 80 = " / % / *( 1* ( 2 % *( .( % * - / *( / &
  • 48.
    9- Copyright © 2005by W. D. Bishop. All Rights Reserved :" 0 " 28:" 0 " 28 LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY vending IS PORT( reset : IN std_logic; clock : IN std_logic; buttons : IN std_logic_vector(1 DOWNTO 0); lights : OUT std_logic_vector(1 DOWNTO 0) ); END vending; ' " , " ! , $ % " ! , $ % " 2 , " 7 ""$ % "$ %
  • 49.
    9. Copyright © 2005by W. D. Bishop. All Rights Reserved :" 0 " 28 $ " %:" 0 " 28 $ " % ARCHITECTURE synthesis1 OF vending IS TYPE statetype IS (Idle, Opt1, Opt2, Error); SIGNAL currentstate, nextstate : statetype; BEGIN fsm1: PROCESS( buttons, currentstate ) BEGIN CASE currentstate IS WHEN Idle => lights <= “00”; CASE buttons IS WHEN “00” => nextstate <= Idle; WHEN “01” => nextstate <= Opt1; WHEN “10” => nextstate <= Opt2; WHEN OTHERS => nextstate <= Error; END CASE; WHEN Opt1 => lights <= “01”; IF buttons /= “01” THEN nextstate <= Idle; END IF;
  • 50.
    Copyright © 2005by W. D. Bishop. All Rights Reserved :" 0 " 28 $ " %:" 0 " 28 $ " % WHEN Opt2 => lights <= “10”; IF buttons /= “10” THEN nextstate <= Idle; END IF; WHEN Error => lights <= “11”; IF buttons = “00” THEN nextstate <= Idle; END IF; END CASE; END PROCESS; fsm2: PROCESS( reset, clock ) BEGIN IF (reset = ‘0’) THEN currentstate <= Idle; ELSIF (clock’EVENT) AND (clock = ‘1’) THEN currentstate <= nextstate; END IF; END PROCESS; END synthesis1;
  • 51.
    Copyright © 2005by W. D. Bishop. All Rights Reserved Department of Electrical and Computer Engineering University of Waterloo 2828 7 " ) " ) & * " * : * & " " ) ", "3 " " 7 ) '> ? " ) & = " & " ", "
  • 52.
    Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 28/ " " 28 % & / ) % - 0 & ' ) !
  • 53.
    # Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 28 7/ " " 28 7 % andnand & $ % std_logic
  • 54.
    9 Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 28 7/ " " 28 7 33 0 "0 " % andnand & $ ENTITY andnand IS PORT ( a : IN std_logic; b : IN std_logic; q : OUT std_logic; qbar : OUT std_logic ); END andnand;
  • 55.
    Copyright © 2005by W. D. Bishop. All Rights Reserved / " " / 28/ " " / 28 % andnand % < synthesis1
  • 56.
    ( Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 28/ " " 28 33 0 "0 " % andnand & $ ARCHITECTURE synthesis1 OF andnand IS BEGIN q <= a AND b; qbar<= a NAND b; END synthesis1;
  • 57.
    + Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 28 7/ " " 28 7 % quadmux # ;9 P & &$ C 3 C C < < < " std_logic_vector std_logic std_logic_vector std_logic_vector )6
  • 58.
    - Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 28 7/ " " 28 7 33 0 "0 " % quadmux & $ ENTITY quadmux IS PORT ( a : IN std_logic_vector(3 DOWNTO 0); b : IN std_logic_vector(3 DOWNTO 0); sel : IN std_logic; c : OUT std_logic_vector(3 DOWNTO 0) ); END quadmux;
  • 59.
    . Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 28/ " " 28 % quadmux % ? # ;9 P & $ % < synthesis1 b[3..0]1 a[3..0]0 c[3..0]sel
  • 60.
    ( Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 28/ " " 28 33 0 "0 " % quadmux & $ ARCHITECTURE synthesis1 OF quadmux IS BEGIN WITH sel SELECT c <= a WHEN ‘0’, b WHEN OTHERS; END synthesis1;
  • 61.
    ( Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 28 #/ " " 28 # % ) ( ( % ( ( & &$
  • 62.
    ( Copyright © 2005by W. D. Bishop. All Rights Reserved / " " 28 #/ " " 28 # 33 0 "0 " LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY seven_seg IS PORT( dataIn : IN std_logic_vector(3 DOWNTO 0); segments : OUT std_logic_vector(7 DOWNTO 0) ); END seven_seg; ARCHITECTURE synthesis1 OF seven_seg IS BEGIN WITH dataIn SELECT segments <= “10000001” WHEN “0000”, -- 0 “11001111” WHEN “0001”, -- 1 “10010010” WHEN “0010”, -- 2 “10000110” WHEN “0011”, -- 3 “11001100” WHEN “0100”, -- 4 “10100100” WHEN “0101”, -- 5 “10100000” WHEN “0110”, -- 6 “10001111” WHEN “0111”, -- 7 “10000000” WHEN “1000”, -- 8 “10000100” WHEN “1001”, -- 9 “11111111” WHEN OTHERS; END synthesis1;
  • 63.
    (# Copyright © 2005by W. D. Bishop. All Rights Reserved 0 = " 280 = " 28 % ) 79 & % , 79 & &$
  • 64.
    (9 Copyright © 2005by W. D. Bishop. All Rights Reserved 0 = " 280 = " 28 33 0 "0 " LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY dregister IS PORT( rst, clk, ena : IN std_logic; d : IN std_logic_vector(7 DOWNTO 0); q : OUT std_logic_vector(7 DOWNTO 0) ); END dregister; ARCHITECTURE synthesis1 OF dregister IS BEGIN PROCESS (rst, clk) BEGIN IF (rst = ‘1’) THEN q <= X”00”; ELSIF (clk’EVENT) AND (clk = ‘1’) THEN IF (ena = ‘1’) THEN q <= d; END IF; END IF; END PROCESS; END synthesis1;
  • 65.
    ( Copyright © 2005by W. D. Bishop. All Rights Reserved 0 = " 280 = " 28 % ) :;9 & % , :;9 & &$ 32-Bit Counter value[31..0]reset enable clock
  • 66.
    (( Copyright © 2005by W. D. Bishop. All Rights Reserved 0 = " 280 = " 28 33 0 "0 " LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.numeric_std.ALL; ENTITY counter IS PORT( reset : IN std_logic; clock : IN std_logic; enable : IN std_logic; value : OUT std_logic_vector(31 DOWNTO 0) ); END counter;
  • 67.
    (+ Copyright © 2005by W. D. Bishop. All Rights Reserved 0 = " 280 = " 28 @@ 0 "$ " %0 "$ " % ARCHITECTURE synthesis1 OF counter IS -- The unsigned type is used SIGNAL count : unsigned(31 DOWNTO 0); -- so that unsigned arithmetic -- will be synthesized BEGIN PROCESS (reset, clock) BEGIN IF (reset = ‘1’) THEN count <= X”00000000”; ELSIF (clock’EVENT) AND (clock = ‘1’) THEN IF (enable = ‘1’) THEN count <= count + 1; END IF; END IF; END PROCESS; -- Here, the count value is value <= std_logic_vector(count); -- converted to std_logic_vector -- using a conversion function END synthesis1;
  • 68.
    (- Copyright © 2005by W. D. Bishop. All Rights Reserved 7 ;" , "7 ;" , " % :;C & $ ! " , ? >"= "!" ! "> ? ( % - / / ( 3C3- ;;:- C;5 & $ ,. . & H