收藏 分销(赏)

数字逻辑实验 8_序列检测器.doc

上传人:s4****5z 文档编号:8734268 上传时间:2025-02-28 格式:DOC 页数:7 大小:139.50KB 下载积分:10 金币
下载 相关 举报
数字逻辑实验 8_序列检测器.doc_第1页
第1页 / 共7页
数字逻辑实验 8_序列检测器.doc_第2页
第2页 / 共7页


点击查看更多>>
资源描述
实验八 序列检测器的设计与仿真 一、 实验要求 1. 用VHDL语言设计一个Mealy机以检测“1101001”序列; 2. 用VHDL语言设计一个Moore机以检测“1101001”序列; 3. 在文本编辑区使用VHDL硬件描述语言设计逻辑电路,再利用波形编辑区进行逻辑功能仿真,以此验证电路的逻辑功能是否正确。 二、 实验内容 用VHDL语言设计各一个mealy和moore状态机测试“1101001”位串的序列检测器,并通过仿真波形验证设计的功能是否正确。 三、 实验过程 由于在报告1中已经详尽描述了如何使用Quartus 2建立逻辑原理图和使用VHDL语言实现元件功能,所以本次的实验报告中便不再赘述上述内容,报告将主要就VHDL语言描述实现元件的功能的过程进行阐述。 1. Mealy机 选择File→New,弹出新建文本对话框,在该对话框中 选择VHDL File并单击OK按钮,进入文本编辑窗口,输入VHDL代码。 library ieee; use ieee.std_logic_1164.all; entity melay is port(clk,rst,d: in std_logic; z: out std_logic); end melay; architecture arc of melay is type state_type is(s0,s1,s2,s3,s4,s5,s6); signal state: state_type; begin process(clk,rst) begin if rst= '1' then state<=s0; elsif (clk'event and clk ='1') then case state is --1101001 when s0 => if d='1' then state<=s1; else state<=s0; end if; when s1=> if d='1' then state<=s2; else state<=s0; end if; when s2=> if d='0' then state<=s3; else state<=s2; end if; when s3=> if d='1' then state<=s4; else state<=s0; end if; when s4=> if d='0' then state<=s5; else state<=s1; end if; when s5=> --1101001 if d='0' then state<=s6; else state<=s1; end if; when s6=> if d='1' then state<=s0; else state<=s0; end if; end case; end if; end process; process(state,d) begin case state is when s6=> if d='1' then z<='1'; else z<='0'; end if; when others=> z<='0'; end case; end process; end arc; 保存文件并编译,选择菜单File→New,选择Vector Waveform File新建波形图,添加节点,参数设置为:End Time=2us, Grip size=50ns。所完成的波形图如下图: 波形解释:rst为复位端,高电平有效,返回最初状态;clk为时钟信号输入端口;,state。s0~s6表示mealy机中各步状态;z表示检测序列为“1101001”时,表示输出高电平。 保存波形文件,并在settings中选择functional功能仿真,绘制网格,仿真可得出如图波形: 根据mealy状态表和序列检测器相应功能验证,当rst=‘1’时,不管当前状态为何,都将被初始为最初态s0;当输入d端依次输入“1101001”时,当检测到最后一位输入正确的同时,z端马上跳为高电平,表示所检测序列正确。其他可看出,当处于时钟上升沿时,state中各状态依照输入数据依次跳变。最后mealy机成功检测出相应序列,设计成功。 已知序列检测器的Mealy机状态表为: 现 态 (present_state) 次态 / 输出(next_state / cout) cin=0 cin=1 S0 S0 / 0 S1 / 0 S1 S0 / 0 S2 / 0 S2 S0 / 0 S3 / 0 S3 S4 / 0 S3 / 0 S4 S5 / 0 S1 / 0 S5 S0 / 0 S6 / 0 S6 S0 / 1 S2 / 0 同样可依次对照上述仿真图形,显然上述序列检测器mealy机功能设计正确。 2. 序列检测器moore机 选择File→New,弹出新建文本对话框,在该对话框中 选择VHDL File并单击OK按钮,进入文本编辑窗口,输入VHDL代码。 library ieee; use ieee.std_logic_1164.all; entity moore is port(clk,rst,d: in std_logic; z: out std_logic); end moore; architecture arc of moore is --moore: 输出只和当前状态有关; type state_type is(s0,s1,s2,s3,s4,s5,s6,s7); signal state:state_type; begin process(clk,rst) begin if rst= '1' then --1101001 state<=s0; elsif(clk'event and clk='1') then case state is --1101001 when s0 => if d='1' then state<=s1; else state<=s0; end if; when s1=> if d='1' then state<=s2; else state<=s0; end if; when s2=> if d='0' then state<=s3; else state<=s2; end if; when s3=> if d='1' then state<=s4; else state<=s0; end if; when s4=> if d='0' then state<=s5; else state<=s1; end if; when s5=> --1101001 if d='0' then state<=s6; else state<=s1; end if; when s6=> if d='1' then state<=s7; else state<=s0; end if; when s7=> if d='1' then state<=s1; else state<=s0; end if; end case; end if; end process; process(state,d) begin case state is when s6=> if d='1' then z<='1'; else z<='0'; end if; when others=> z<='0'; end case; end process; end arc; 可看出,moore机的设计和mealy机上大体相同,只有在状态的传递上有细微区别。 保存文件并编译,选择菜单File→New,选择Vector Waveform File新建波形图,添加节点,参数设置为:End Time=3us, Grip size=50ns。所完成的波形图如下图: 图中各端口设置功能同mealy机。 保存波形文件,并在settings中选择functional功能仿真,绘制网格,仿真可得出如图波形: 仿真波形分析: 由于设计的moore状态机检测序列功能相同,与mealy不同在于当状态跳变判断s7时,z端才跳变为高电平。根据刚刚对mealy机的仿真分析和下表的状态值变化显然可知,moore机实现了检测序列“1101001”的功能,设计成功。 已知序列检测器的Mealy机状态表为: 现 态 (present_state) 次态 输出 z d=0 d=1 S0 S0 S1 0 S1 S0 S2 0 S2 S0 S3 0 S3 S4 S3 0 S4 S5 S1 0 S5 S0 S6 0 S6 S0 S7 0 S7 s0 s1 1 四、 总结 本节实验中,通过对用VHDL语言对mealy状态机和moore状态机进行设计,更加熟练了使用VHDL语言对元件的设计。也通过用不同的状态机设计序列检测器,而对两种状态机的区别有了更深刻的了解。Moore状态机输出只和当前状态有关,而mealy机输出和当前状态和输入信号有关,由于moore机没有组合逻辑,所以moore机的状态会多一些。也对序列检测器的实现使得我对序列检测器的作用和功能了之于心。一开始没有弄清moore机和mealy机的区别,导致后来写moore机的时候出现了停滞,不过在弄清他们的区别时候,写出moore机就没什么问题了。 不已然,已经到了数字逻辑的最后一个实验了,回想做实验时,有苦有乐,从开始的对VHDL语言的一窍不通,到现在可以用它设计简单的元件并实现功能,实验中我收获了许多,实验对我成长的帮助必不可少。虽然马上就要结束实验,不过还有许多VHDL语言的奥妙在可以发挥它的地方等待着我们去探索,我也会继续探索VHDL语言,用它来实现更多好玩好用的东西。 2013/12/23
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 百科休闲 > 社会民生

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服