数字逻辑电路课程设计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

提交评论