Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung...

10
" $ !$ ! $ ! #& # % & $ ! ' ! "# # & $ # ! "& ! !#& # ( ! # ! ! & !$ # ! # # $ # # #& # #" && # # ! ! & # $ ! "& ! ! " &

Transcript of Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung...

Page 1: Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung Department of Electrical & Electronic Engineering ... 2-to-l multiplexer and 7 segment

���� ���������"����������� ��� ���������������$�!����$����������!���� �������� ��� ������$� ����������������� ��� ��! ���� ��� �������������������#&

�������������#� �����%���������������� ���������� �������������&����������$���!������������������������������� ����� ������ �������������' ���!������ ��������"������#�����������������#��� ��������������&������� �$�#���!������ ��� ���������������������" �����&���!������������������� ������� ��� ����� ������ ���������! #&���� ������� �������� ��������� �����������������������������������#���� ����( ������!����������������� ������#���!��������!� �����������&����!� ��$�#���!������ �������������������#� ������������ ��� ��#���������� ��������� ����������$� ���#����������� �������������������������� �������������#�#�������&

����� ���� �#������������������������� �� ���������� ���������������#�� "����&&������������� ��#����������� ���#���!������ �����!���������������� ������������������������������������������� ����������&

������������������ ��������#� �������������� �����������$�!������� ���� ����������"�������&������!���������������������������������������������������!��������� ���"������������������������ ��������������&

� � �������������� ���� ��� ���� � ��� ��� ������� �������������� �� ��������������� ������� ������ ������� ������������������������������ ���� ������������� � ������������ ���� �������� �������� ��� ������� ����� �������� ��� ���� ���� ����� ������������������ ������������ ���������� ��������������������� �������������������� �������������������������� ��� ���������� �� ����������� �������� � ��������� ��������������� ������ �������

Page 2: Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung Department of Electrical & Electronic Engineering ... 2-to-l multiplexer and 7 segment

�������� ��#����������!���������������������'�����!� ��������������������������������������������������������������'����������������������!�����������#�������������������������������������������� ��������������������������������������������������������#������������������� ������!���'������������������(����!�������������������������)�*����+'

�������������������� �����������������������������������#����#����������������������&�-+��������������������������������������������*����������� ������ ���������������+%�.+�������������������������������������������#��������������!��������"������������!�������������%�/+������� ��#���������������"����������������������������������$� ��������� ��#����#�!�����������������������%�0+��#����������� ����������������������������������2$�,����'%�1+�#������������#�����$������������������������"������$��������������!����!�����������������������'

�������������������$�������������������������'���!�#���������'�����������������$���!�������������������#���!�#�!��������"�����'

���+����$(�#�)$�*(����'�!$������(�)�����'�,�'����(�'�%)�$#�!�#�*�����$'�)��(�"$�*!�1����'�!$���(�+�'.�(�"�!�'�)$�)�����!�#�*���/�,�����.$*�(�$*!���!'���.� #$,��'$"�!�()�.��'1���$,�+�'/�.$*�"*()��!,�.(�'�"�"��'�)��)�� �������������� ����������������������� �������� ��������� ������1

�$*���#�*(����'�!$��)$���(�'����.$*'�����)�!���'�,�'���#�)�'��������'�#)�!�+�!�$����()'��)�$#0�� ���������� ����� 2 .$*�$#!.���(�'�����$,�)�����'�,�'��(�$*!������+��,�)�$*)�����'���'�#���)$�����)�!���'�,�'�1���� �������������������� �3��4�2 ��'��)�����(�'�%)�$#��((*"�(�)����-�()�#���$��'���()�'(��#��)��(���'���!$� ����.����!$� �(��#�!1�����'��$'������)�!���)���(�)'�#(��''����'$"�$#��'���()�'�)$�)���#�-)�$#�(*���((�+���!$� ��.�!�(1����"�#��3�#�)�'"(�$���!$� ��.�!�(4��(�)��'��$'���-%!���)!.�����#����#�)�����'�!$���$��1�����(��(�)���!�+�!�$����(��#�,��*(��"$()��'�&*�#)!.��#�)��(��$*'(�1�� ��������� �2 )��(��(�)���!$,�()�!�+�!���(�'�%)�$#�,��'���������)���#���)(��#)�'�$##��)�$#��'���-%!���)!.�(%�������1����'�!$���(�#$)�$#!.���(%�������)�$#�!�#�*����,�����)�!!(�)�������(.()�"�,��)���'�,�'���(�(*%%$(��)$��$/��)��!($��#�!*��(����$"%!�)��(�"*!�)�$#��#+�'$#"�#)1������'�!$���$"%�!�'��$�(�"$'��)��#�"�%%�#��.$*'��$���)$���'�,�'�/��)��!($���#����� ��� 3$'��-��*)�4�.$*'���(��#�)$�%'����)�)�������+�$*'�$��.$*'���'�*�)1��)��(�)���%'��$"�#�#)�!�#�*����*(����$'����%���(��#1�$*�,�!!�!��'#���'�!$��)�'$*����-�"%!�(��#���-�'��(�(/�#$)�)�'$*���!��)*'�1���$,�+�'/��,�!!�(%�#���*()�),$�!��)*'�(�)$��$+�'�)�����(��(�$����'�!$�1��

Page 3: Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung Department of Electrical & Electronic Engineering ... 2-to-l multiplexer and 7 segment

�������������������� ��������������������/*��*.�� ������#��'������������������������������� �������,�#����������������� ��$"���-'������������������������������������������� �� ������������������� ��'��������������� �������&�������'�����������������������������������&�0���� ����%�� ������%�����/�� �� ������ ��������� '����"�$�� ����������� �������������������� ������������!�������������'

� �� ���������$�"���������������� ������"�������������� �� �%����������������������$�������������������������������'������$%�����/*��*.�� ������#����� ��������������������������������� ����������"������������ ������������� �������'������������������� ���������������������� ������#���+ ���������������!��!��'������������������������������������������������"����out ����outbar'��������������������������������������������������������������������� ����������'������"�������� �����������������$�����"���������(�#�� ��)�����������������"������"����� �������������������'������������������ �� �������������� '

���"��#�#!��!!������"�!�������!��������"�������� �#�"!�+ �#"�#"��!����"��#�#!�&� �����"����"������ �"���!���������"��"������#"(��#!"�������� �$� �)������� �"��"�#��������� �� �����������#���(�"���"$�����"��#�#!��!!������"�!"�"����"!��� ������!�����&������ �$� ���������(���"����!� ��!)�� ��$����!��!���"��������"������!"�"����"�"��"��!���#�������)�����!����!��� ���"�&�"��"����#��"���������0*"�*/��#�"����%� ������ �$� �������!�$����&�#!������ � ����)�# "�� �� �(�"�� ��� �����&��"�� �������������� �"���"������ �"� !������������ � �����,�!�����-)��� ���!����#����!#��� &��������"��� � �������� �"� !�,#!����������%� �!!���-)��,���"��!��� ��#�"��������.�'����$��"�&�#�"�������"��!�&�# !����������)-

Page 4: Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung Department of Electrical & Electronic Engineering ... 2-to-l multiplexer and 7 segment

����������������������������������������/*��*.���!����"�����������(����� ��)$��������������� ������������ �� ������������ ������������� ����������&��������"�������� ���� �������%����$� � ���� � � ���&������� ��������� �������,���� ���� ������-� ���������� ����������� ���� ��� �������������������� ������������&

��" ���������� �����$� � ���� � �������� ��+ ���"�������"� ��� ��������� ���&����"� ��� ��������� ������� ������������������������������ ��*� ���� �����/$�0$�1$�'&&���"�������#

������� �������������������������� ���$� ������"�� �������������� ���%� .� ��� /&������� ������������� ��������� ������������ ��&��������� ��$�(� �����)� ������������������!����������� ����������������� ��������&������������� ���� ����������������� �����') ���(�������� �����) ��������� ����� � ������������� �� ��&������ "��� ��� �����������(������������) ������� ��&

��������������� �������������������������������� ��� ����$� �������������������������������������(����)&�������! ����$� ��� ������������������������������ �����$� ����������������������������������������� � ������"������ ������������ ������������� ������������&

������� �������������������������!����� ������� ��� � �!$��&������'������������������� ��� ������������� �������������$���������������������������$

��������������������������������������* ���������� ������&�� ����������������'$���!�� ���!� ���������������� ������&�����' ��� �������� ��!���&�� ������'"��$�$��� ���� ������������������������������ �� ���������� � ������� ����������������� ������ �$

��������� ��� ����������������������* ������������������ �� �"������������������������ ������"���������� ��� �� ��������������$�������!�������������� ����#

&�� �!�������!� ����������������"�� �����"���������������� ������������ ���'$� �����!"����!������������������ ������������� �� ����������"���������������� �!����������������� �!����� �����������#

%$$���� �!����,�+��$$$$����((��� �!�������!� ������ ������!�������������

����������������������� �"�!����������� �����������)���������������$��������� ���"� �������������������������$���������������������������������������� �������������� ���������$

Page 5: Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung Department of Electrical & Electronic Engineering ... 2-to-l multiplexer and 7 segment

���������������� ����������� ���������������������������������� ������������������������������������������������������� ������������������������������������������������������ ������������������������������������������������������������������������������������������ ����� ������������������������ ������������������������������������������������ ������������������� �������������

��

������������������������������������������������������������������������������������������������ �������������������������������������� ����

Page 6: Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung Department of Electrical & Electronic Engineering ... 2-to-l multiplexer and 7 segment

��

��������!�������������!������� ��!������� �� ���#������������������� ������������������������������� ��� �#���������"��������� ������������������������������$���%���������#������ ������������������#����� ���� �����*&�����������'������("���� ������!���������)����*#

���������������������� ����������� ������� ���������������������������������������������������������#������� �����"� ��������� ���#������+�������������������������������������#������������������� ��������������!�������#�������������������������������� ��������!#

��

� ������������������ �������������������������� ��������������� ������� ����� ���������������������������������� ������������������� ��������!-������#,�($"����� ����� ��������������� �����������-��������* �� )�������������

���� �������������������������������������� ������������������������%����&����� ���������

� ���������������������������������������������������������������������������������������� �!��������������������������"�������� ����������������������������- ������������������#,�($������)+ ������������������#)*�($������������������� ���

assign b[12:0] = {5’b0, a[7:0]};

Page 7: Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung Department of Electrical & Electronic Engineering ... 2-to-l multiplexer and 7 segment

��

������������������ �����%����������� �����.'������ � �������/����������� ����&������� ���� ������������� �������������/'���������� �������������������%�+*������������������)�������������������������������� ����*$�,*����/�����������'�����)������������������������ �����������!*$�-*���������������������&��������������!���������������!��������'����&�������� �� �����������������#�!������������!�������!�������������&�������� �� ���#����� ��������� ��������������������!����������� ���!�( !����������������������'��������������������������� �������������!"

��

������������������� ��� ������������������ ������� ���������� ����������� �����������������������������������������������������������������������������

Page 8: Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung Department of Electrical & Electronic Engineering ... 2-to-l multiplexer and 7 segment

��

����������������������������������� ���������� ���� ���������� � � ������������������ ������� ��������� ��������� ����� �������� �������������� �������

��

������������ � ������������������������ ���� ������� ��������� ������������������� ���������������������� ��� ��������� ������ ���������������� �� �������

Page 9: Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung Department of Electrical & Electronic Engineering ... 2-to-l multiplexer and 7 segment

��

���������������� �������������������������������������� ���������������������� ���������������������������������� ������������ ������������������������������ �������������������������������������������

��

��������� �#� �� ������ ������������� ����� ��������������������� �� ����������� �������������������������� ����� ���������������������� � �������������

���������������������������"���� ��������������������������"!

Page 10: Lecture 3 - Verilog HDL-Part 1 · 2019-10-14 · Lecture 3 Verilog HDL — Part 1 Peter Cheung Department of Electrical & Electronic Engineering ... 2-to-l multiplexer and 7 segment

��

�������������������� ���������������������������������������������� ������������!������������������������������������������������������������������������������ ����"�

��