department of electrical and computer engineering university ...ganesan/old/courses/cse 576 w08...ˆ...
TRANSCRIPT
Copyright © 2005 by W. D. Bishop. All Rights Reserved
Department of Electrical and Computer EngineeringUniversity 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 EngineeringUniversity of Waterloo
�����!&�&��������!&�&���
����������� ����������
Copyright © 2005 by W. D. Bishop. All Rights Reserved
% �������������������������������������������������������� � ������������������������
% ��������������������������������������������������� ������������ �������&���������������
% ������������������ ��������������������������������������� �����/������������������������
'"������"�������'"������"�������
V ery High Speed Integrated CircuitH ardwareD escriptionL 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� �����'222�0��"����5� �����'222�0��"����
% '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 EngineeringUniversity 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…
Configuration1 Configuration n
Configuration
2
����������� ���������� �-
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 ISGENERIC(
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 ISPORT ( a : IN std_logic;
b : IN std_logic;c : OUT std_logic );
END andgate;
����������� ���������� ��
Copyright © 2005 by W. D. Bishop. All Rights Reserved
6��6��
% +���������������$
' ��������� ��������-�������-����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
7����������7����������
% .������������������������ ��������� �����������G����������������������
% ������������������������������������� ���������������������
% *����/���-����������&������������������������������������ ����������������������&��������������������������)���&���������������������������$
' +�� ������
' .���
' +�&������������
' ������ �(��������
����������� ���������� �9
Copyright © 2005 by W. D. Bishop. All Rights Reserved
7������������� ����"�7������������� ����"�
% .��������������������������������� ������� ����&�$
ARCHITECTURE architecture_name OF entity_name ISBEGIN
-- 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 ISBEGIN
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���������������������������������������������������������������������������������������
NZG������������N0G*�������6
NXG*������� �,��&�N1G*�������3
����3 9
����������� ���������� #�
Copyright © 2005 by W. D. Bishop. All Rights Reserved
��������33 ..
% ����9 4������B������������������������������� ������������������������$
NXG*������� �,��&�
NZG������������N0G*�������6
NWG!��,� �,��&�N1G*�������3
NLG!��,�6N-G���G������
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 ISPORT ( din : IN std_logic;
dout : OUT std_logic );END simple_buffer;
ARCHITECTURE behavioural1 OF simple_buffer ISBEGIN
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� 1�0���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 gatesa <= ’0’ WHEN avec = “00” ELSE
b WHEN avec = “11” ELSEc WHEN d = ’1’ ELSE’1’;
-- Selected Signal Assignment Statement-- NOTE: The selection values must be constantsbvec <= d & avec;WITH bvec SELECTa <= ’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 ISPORT( rst, clk, ena, d : IN std_logic;
q : OUT std_logic );END dffe;
ARCHITECTURE synthesis1 OF dffe ISBEGIN
PROCESS (rst, clk)BEGIN
IF (rst = ‘1’) THENq <= ‘0’;
ELSIF (clk’EVENT) AND (clk = ‘1’) THENIF (ena = ‘1’) THEN
q <= d;END IF;
END IF;END PROCESS;
END synthesis1;
����������� ���������� 9+
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/�� �8�0�=��"��� �/������/�� �8�0�=��"��� �/������
% ����/����������������������������������*(�� 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 ISPORT(
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 ISTYPE statetype IS (Idle, Opt1, Opt2, Error);SIGNAL currentstate, nextstate : statetype;
BEGINfsm1: PROCESS( buttons, currentstate )BEGIN
CASE currentstate ISWHEN 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’) THENcurrentstate <= Idle;
ELSIF (clock’EVENT) AND (clock = ‘1’) THENcurrentstate <= nextstate;
END IF;END PROCESS;
END synthesis1;
Copyright © 2005 by W. D. Bishop. All Rights Reserved
Department of Electrical and Computer EngineeringUniversity of Waterloo
�����28��� �������28��� ��
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 ISPORT ( 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 ISBEGIN
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_vectorstd_logicstd_logic_vectorstd_logic_vector
�)��
�
���
�
�
6�
����������� ���������� -
Copyright © 2005 by W. D. Bishop. All Rights Reserved
/���"���"� �28��� ���7�/���"���"� �28��� ���7�33 0 ���"0 ���"
% ��������������������� �����quadmux �������������������������� ����&���$
ENTITY quadmux ISPORT ( 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 ISBEGIN
WITH sel SELECTc <= 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 ISPORT( dataIn : IN std_logic_vector(3 DOWNTO 0);
segments : OUT std_logic_vector(7 DOWNTO 0) );END seven_seg;
ARCHITECTURE synthesis1 OF seven_seg ISBEGIN
WITH dataIn SELECTsegments <= “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�=��"��� �28��� ���0�=��"��� �28��� ���
% �����������������)�������������� ��������� ���79�������������&�����������������������������������������������������
% ��������,��������� �����79�������������������&������&$
����������� ���������� (9
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0�=��"��� �28��� ����0�=��"��� �28��� ����33 0 ���"0 ���"
LIBRARY ieee;USE ieee.std_logic_1164.ALL;
ENTITY dregister ISPORT( 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 ISBEGIN
PROCESS (rst, clk)BEGIN
IF (rst = ‘1’) THENq <= X”00”;
ELSIF (clk’EVENT) AND (clk = ‘1’) THENIF (ena = ‘1’) THEN
q <= d;END IF;
END IF;END PROCESS;
END synthesis1;
����������� ���������� (
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0�=��"��� �28��� ���0�=��"��� �28��� ���
% �����������������)����������������������� ���:;9������������&�����������������������������������������������������
% ��������,��������� �����:;9������������������&������&$
32-Bit Counter
value[31..0]reset
enable
clock
����������� ���������� ((
Copyright © 2005 by W. D. Bishop. All Rights Reserved
0�=��"��� �28��� ����0�=��"��� �28��� ����33 0 ���"0 ���"
LIBRARY ieee;USE ieee.std_logic_1164.ALL;USE ieee.numeric_std.ALL;
ENTITY counter ISPORT(
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�=��"��� �28��� ����0�=��"��� �28��� ����@@ 0 ���"�$�"��%0 ���"�$�"��%
ARCHITECTURE synthesis1 OF counter IS
-- The unsigned type is usedSIGNAL count : unsigned(31 DOWNTO 0); -- so that unsigned arithmetic
-- will be synthesized
BEGINPROCESS (reset, clock)BEGIN
IF (reset = ‘1’) THENcount <= X”00000000”;
ELSIF (clock’EVENT) AND (clock = ‘1’) THENIF (enable = ‘1’) THEN
count <= count + 1;END IF;
END IF;END PROCESS;
-- Here, the count value isvalue <= 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�������