数字逻辑电路课程设计_4B5B编码_VHDL实现(含完整代码!!)_第1页
数字逻辑电路课程设计_4B5B编码_VHDL实现(含完整代码!!)_第2页
数字逻辑电路课程设计_4B5B编码_VHDL实现(含完整代码!!)_第3页
数字逻辑电路课程设计_4B5B编码_VHDL实现(含完整代码!!)_第4页
数字逻辑电路课程设计_4B5B编码_VHDL实现(含完整代码!!)_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、电 子 科 技 大 学UNIVERSITY OF ELECTRONIC SCIENCE AND TECHNOLOGY OF CHINA数字逻辑设计实验报告实验题目: 4B5B编码器 学生姓名: 指导老师: 一、实验内容4B/5B编码是百兆以太网中线路层编码类型之一,该试验需要实现用5bit的二进制数来表示4bit二进制数。二、实验要求1、功能性要求: 能够实现4B5B编码,即输入4bit数据时能输出正确的5bit编码结果。2、算法要求: 利用卡诺图对编码真值表进行化简,得出其逻辑表达式,并基于此进行硬件设计。3、设计性要求:使用代码及原理图两种设计方式来进行设计。采用基本门结构化描述。能够编写

2、Test Bench文件,并利用Modelsim进行仿真。三、实验原理及设计思路1、实验原理:在IEEE 802.9a等时以太网标准中的4B:5B编码方案,因其效率高和容易实现而被采用。这种编码的特点是将欲发送的数据流每4bit作为一个组,然后按照4B/5B编码规则将其转换成相应5bit码。5bit码共有32种组合,但只采用其中的16种对应4bit码的16种,其他的16种或者未用或者用作控制码,以表示帧的开始和结束、光纤线路的状态(静止、空闲、暂停)等。4B5B编码表如下:2、 设计思路:(1) 整体思路: 对已知的编码真值表,首先利用卡诺图对其进行化简,得出其逻辑表达式,再用基本门结构将其实

3、现。(2) 卡诺图与表达式: 设输入的4位编码为:ABCD,输出的5位编码为:VWXYZ,则分别画出其卡诺图并得出表达式如下:1.V:V=A+BD+BC2.W:W=B+AC3.X:X=C+ABD4.Y:Y=AB+AB+CD+AC5.Z:Z=D(3) 基本门结构设计: 由上述表达式可见,用到的基本门有:非门、2输入与门、3输入与门、2输入或门、3输入或门、4输入或门,用not、and、or将其一一表示出即可。四、程序设计1、顶层模块:library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity main is Port ( a : in STD_LOGIC; b

4、 : in STD_LOGIC; c : in STD_LOGIC; d : in STD_LOGIC; v : out STD_LOGIC; w : out STD_LOGIC; x : out STD_LOGIC; y : out STD_LOGIC; z : out STD_LOGIC);end main;architecture Behavioral of main isCOMPONENT notiPORT(i : IN std_logic; o : OUT std_logic);END COMPONENT;COMPONENT and2iPORT(i1 : IN std_logic;i

5、2 : IN std_logic; o : OUT std_logic);END COMPONENT; COMPONENT and3iPORT(i1 : IN std_logic;i2 : IN std_logic;i3 : IN std_logic; o : OUT std_logic);END COMPONENT;COMPONENT or2iPORT(i1 : IN std_logic;i2 : IN std_logic; o : OUT std_logic);END COMPONENT;COMPONENT or3iPORT(i1 : IN std_logic;i2 : IN std_lo

6、gic;i3 : IN std_logic; o : OUT std_logic);END COMPONENT;COMPONENT or4iPORT(i1 : IN std_logic;i2 : IN std_logic;i3 : IN std_logic;i4 : IN std_logic; o : OUT std_logic);END COMPONENT;signal nota,notb,notc,notd,v1,v2,v3,w1,w2,x1,x2,y1,y2,y3,y4,vv,ww,xx,yy,zz : std_logic;begin-not-Inst_noti_nota: noti P

7、ORT MAP(i = a,o = nota);Inst_noti_notb: noti PORT MAP(i = b,o = notb);Inst_noti_notc: noti PORT MAP(i = c,o = notc);Inst_noti_notd: noti PORT MAP(i = d,o = notd);-v-v1 notb,i2 = notd,o = v2 );Inst_and2i_v3: and2i PORT MAP(i1 = notb,i2 = c,o = v3 );Inst_or3i_vv: or3i PORT MAP(i1 = v1,i2 = v2,i3 = v3,

8、o = vv);-w-w1 nota,i2 = notc,o = w2 );Inst_or2i_ww: or2i PORT MAP(i1 = w1,i2 = w2,o = ww);-x-x1 nota,i2 = notb,i3 = notd,o = x2);Inst_or2i_xx: or2i PORT MAP(i1 = x1,i2 = x2,o = xx);-y-Inst_and2i_y1: and2i PORT MAP(i1 = nota,i2 = b,o = y1);Inst_and2i_y2: and2i PORT MAP(i1 = a,i2 = notb,o = y2);Inst_a

9、nd2i_y3: and2i PORT MAP(i1 = notc,i2 = notd,o = y3);Inst_and2i_y4: and2i PORT MAP(i1 = a,i2 = notc,o = y4);Inst_or4i_yy: or4i PORT MAP(i1 = y1,i2 = y2,i3 = y3,i4 = y4,o = yy);-z-zz vv,o = v);Inst_noti_w: noti PORT MAP(i = ww,o = w);Inst_noti_x: noti PORT MAP(i = xx,o = x);Inst_noti_y: noti PORT MAP(

10、i = yy,o = y);Inst_noti_z: noti PORT MAP(i = zz,o = z);end Behavioral;2、非门:entity noti is Port ( i : in STD_LOGIC; o : out STD_LOGIC);end noti;architecture Behavioral of noti isbegino = not i;end Behavioral;3、2输入与门:entity and2i is Port ( i1 : in STD_LOGIC; i2 : in STD_LOGIC; o : out STD_LOGIC);end a

11、nd2i;architecture Behavioral of and2i isbegino = i1 and i2;end Behavioral;4、3输入与门:entity and3i is Port ( i1 : in STD_LOGIC; i2 : in STD_LOGIC; i3 : in STD_LOGIC; o : out STD_LOGIC);end and3i;architecture Behavioral of and3i isbegino=i1 and i2 and i3;end Behavioral;5、2输入或门:entity or2i is Port ( i1 :

12、in STD_LOGIC; i2 : in STD_LOGIC; o : out STD_LOGIC);end or2i;architecture Behavioral of or2i isbegino=i1 or i2;end Behavioral;6、3输入或门:entity or3i is Port ( i1 : in STD_LOGIC; i2 : in STD_LOGIC; i3 : in STD_LOGIC; o : out STD_LOGIC);end or3i;architecture Behavioral of or3i isbegino = i1 or i2 or i3;e

13、nd Behavioral;7、4输入或门:entity or4i is Port ( i1 : in STD_LOGIC; i2 : in STD_LOGIC; i3 : in STD_LOGIC; i4 : in STD_LOGIC; o : out STD_LOGIC);end or4i;architecture Behavioral of or4i isbegino=i1 or i2 or i3 or i4;end Behavioral;5、 仿真与硬件调试1、仿真:(1)顶层仿真:1.仿真文件:LIBRARY ieee;USE ieee.std_logic_1164.ALL;ENTI

14、TY test1 ISEND test1; ARCHITECTURE behavior OF test1 IS - Component Declaration for the Unit Under Test (UUT) COMPONENT main PORT( a : IN std_logic; b : IN std_logic; c : IN std_logic; d : IN std_logic; v : OUT std_logic; w : OUT std_logic; x : OUT std_logic; y : OUT std_logic; z : OUT std_logic );

15、END COMPONENT; -Inputs signal a : std_logic := 0; signal b : std_logic := 0; signal c : std_logic := 0; signal d : std_logic := 0; -Outputs signal v : std_logic; signal w : std_logic; signal x : std_logic; signal y : std_logic; signal z : std_logic; - No clocks detected in port list. Replace below w

16、ith - appropriate port name BEGIN - Instantiate the Unit Under Test (UUT) uut: main PORT MAP ( a = a, b = b, c = c, d = d, v = v, w = w, x = x, y = y, z = z ); - Stimulus process stim_proc: process begina=0;b=0;c=0;d=0; wait for 100 ns; a=0;b=0;c=0;d=1; wait for 100 ns; a=0;b=0;c=1;d=0; wait for 100

17、 ns; a=0;b=0;c=1;d=1; wait for 100 ns; a=0;b=1;c=0;d=0; wait for 100 ns; a=0;b=1;c=0;d=1; wait for 100 ns; a=0;b=1;c=1;d=0; wait for 100 ns; a=0;b=1;c=1;d=1; wait for 100 ns; a=1;b=0;c=0;d=0; wait for 100 ns; a=1;b=0;c=0;d=1; wait for 100 ns; a=1;b=0;c=1;d=0; wait for 100 ns; a=1;b=0;c=1;d=1; wait f

18、or 100 ns; a=1;b=1;c=0;d=0; wait for 100 ns; a=1;b=1;c=0;d=1; wait for 100 ns; a=1;b=1;c=1;d=0; wait for 100 ns; a=1;b=1;c=1;d=1; - insert stimulus here wait; end process;END;2.仿真结果:(2)非门仿真:(3)2输入与门仿真:(4)2输入或门仿真:(5)3输入或门仿真:(6)4输入或门仿真:2、 硬件调试:(1) 管脚配置:NET a LOC = P6; #sb1NET b LOC = P141;NET c LOC = P136;NET d LOC = P129;NET v LOC = P122;NET

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论