2022年实验四:序列发生器与检测器的设计

上传人:大米 文档编号:567342095 上传时间:2024-07-20 格式:PDF 页数:9 大小:381.51KB
返回 下载 相关 举报
2022年实验四:序列发生器与检测器的设计_第1页
第1页 / 共9页
2022年实验四:序列发生器与检测器的设计_第2页
第2页 / 共9页
2022年实验四:序列发生器与检测器的设计_第3页
第3页 / 共9页
2022年实验四:序列发生器与检测器的设计_第4页
第4页 / 共9页
2022年实验四:序列发生器与检测器的设计_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《2022年实验四:序列发生器与检测器的设计》由会员分享,可在线阅读,更多相关《2022年实验四:序列发生器与检测器的设计(9页珍藏版)》请在金锄头文库上搜索。

1、南昌大学实验报告学生姓名:学号:专业班级:实验类型 :验证综合设计创新实验日期:11.16_ 实验成绩 : 实验四序列信号发生器与检测器设计一、实验目的1、了解序列检测器的工作原理。2、掌握时序电路设计中状态机的应用。3、进一步掌握用 VHDL 语言实现复杂时序电路的设计过程。二、实验内容要求用 状态机 设计实现串行序列检测器的设计,先设计(可用原理图输入法)序列信号发生器,产生序列:0111010011011010 ;再设计检测器,若检测到串行序列11010则输出为 “1”,否则输出为 “0”,并对其进行仿真和硬件测试。1、序列检测器用于检测一组或多组有二进制码组成的脉冲序列信号。这种检测要

2、求检测器必须记住前一次的正确码及正确序列,直到在连续的检测中所收到的每一位都与预置数的对应码相同。在检测过程中, 任何一位不相等都将回到相应状态,重新开始检测。序列发生器和检测器分别用上升沿和下降沿比较好,否则会在开始多一位或少一位。2、信号发生器和检测器工程文件要保存在同一文件夹中才能调用;仿真时尽量避开发生信号和检测信号同时跳变,避免毛刺出现。2、在实验箱上验证时, 设计的输入可用脉冲键 +琴键组合输入任意序列, 并用 LED 灯串行移位显示出来,随后将检测到的11010数目用静态数码管显示出来。三、实验原理序列检测器的作用就是从一系列的码流中找出用户希望出现的序列,该电路的核心部分就是状

3、态机转换检模块,通过VHDL 语言的 CASE-WHEN 顺序语句判断输入条件来选择某一状态的执行,达到以此判断执行的效果。 其中,本实验所设计状态机的状态转换图如下4-3 所示。精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 1 页,共 9 页图 4-3 序列信号检测器状态转换图由图可以看出,初始状态为S0,当检测到输入的序列为1 时,状态跳转至S1;检测到 0 时,原地等待;在S1 状态下,当检测到 0 时跳转至 S0,检测到 1时跳转至 S2;在 S2 状态下,当检测到0 时跳转至 S3,检测到 1 时跳转至 S2;在 S3 状态下,当检测到

4、 1 时跳转至 S4,检测到 0 时仍跳转至 S0;在 S4 状态下,当检测到 0 时跳转至 S5,检测到 1 时跳转至 S2;在 S5状态下,当检测到0 时跳转至 S0,检测到 1时跳转至 S1;即实现了对序列 “ 11010” 的检测。四、实验步骤1、打开 QUARTUSII 软件,新建一个工程。取名为wanexp20;2、在该工程目录下, 建立六个 VHD 文件,编辑六个功能模块程序,分别实现六种不同功能,其实验程序如下所示- - 实验名称 :序列信号发生器与检测器设计- 参考自课本- 共分为 6 个进程- 实验日期 : 2012-11-16 - 精选学习资料 - - - - - - -

5、 - - 名师归纳总结 - - - - - - -第 2 页,共 9 页- 进程p1;- 实验共能是分频;- clk为输入 10khz时钟信号, clk1hz为分频输出 1hz信号;library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity p1 is port(clk:in std_logic; clk1hz:out std_logic ); end p1; - architecture behave of p1 is signal Clk_Count1 : std_logic_vect

6、or(13 downto 0); begin process(clk) begin if(Clkevent and Clk=1) then if(Clk_Count110000) then Clk_Count1=Clk_Count1+1; else Clk_Count1=00000000000001; end if; end if; end process; Clk1Hz=Clk_Count1(13); end behave; - - 进程 p2 - 实现功能为序列信号发生器- clk1hz 为输入 1hz 分频信号, xlout 为输出信号位library ieee; use ieee.st

7、d_logic_1164.all; entity p2 is port (clk1hz : in std_logic; xlout:out std_logic ); end entity; - architecture bhv of p2 is signal bs: std_logic_vector(15 downto 0):=0111010011011010; 精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 3 页,共 9 页begin xlout=bs(15); - 将 bs 的最高位复值给xlout process (clk1hz) begi

8、n if (clk1hzevent and clk1hz=1) then bs= bs(14 downto 0)&bs(15); - 通过 & ,实现序列的循环位移。end if; end process; end bhv; - - 进程 p3 - 实现功能为采用状态机实现序列检测- clr 为输入初始设置信号,功能是初始时将状态设置为s0,并使 dclk=0;library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity p3 is port ( clr : in std_logic; cl

9、k1hz : in std_logic; - 输入 1hz 信号频率xlout : in std_logic; - 输入序列result : out std_logic - 输出结果,若检测到目标序列,则输出高电平。); end entity; - architecture bhv of p3 is type state_value is(s0,s1,s2,s3,s4,s5); - 定义 state_value 数据类型,其为五个状态组成signal state: state_value; signal dclk: std_logic; begin result=dclk; process (

10、clr,clk1hz) begin if (clr=0) then state=s0; dclk if xlout=1 then state=s1; else state if xlout=1 then state=s2; else state if xlout=0 then state=s3; else state if xlout=1 then state=s4; else state if xlout=0 then state=s5; dclk=1; else state if xlout=0 then state=s0; else state=s1; end if; dclk stat

11、e=s0; end case; end if; end process; end bhv; - 进程 p4 - 实现功能为xlout 的串行移位输出, 由 led 灯的亮灭来显示,便于观察最近xlout 的五个值- 其中 xlout 作为输入信号,其为信号发生器的输出library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity p4 is port(clk1hz:in std_logic; xlout:in std_logic; ledag :buffer std_logic_vector(

12、4 downto 0) ); end p4; - architecture behave of p4 is begin process(clk1hz) begin if(clk1hzevent and clk1hz=1) then ledag(4)=ledag(3); - 实现串行移位;ledag(3)=ledag(2); 精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 5 页,共 9 页ledag(2)=ledag(1); ledag(1)=ledag(0); ledag(0)=xlout; end if; end process; end be

13、have; - - 进程 p5 - 实现功能为序列计数器,即计算检测到的目标序列个数library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity p5 is port ( Result : in std_logic; d6,d7 : out std_logic_vector(3 downto 0) ); end entity; - architecture behave of p5 is signal cnt0,cnt1:std_logic_vector(3 downto 0):=0000;

14、 begin process (result) begin if (resultevent and result=0) then if (cnt0=1001 and cnt1=1001) then cnt0=0000; cnt1=0000; elsif (cnt0=1001) then cnt0=0000; cnt1=cnt1+1; else cnt0=cnt0+1; end if; end if; end process; d6=cnt1;d7=cnt0; end behave; - - 进程 p6 - 实现功能为数码管的动态扫描显示- clk 为 10khz 输入时钟信号精选学习资料 -

15、- - - - - - - - 名师归纳总结 - - - - - - -第 6 页,共 9 页library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity p6 is port(clk:in std_logic; sel0,sel1:buffer std_logic; sg:out std_logic_vector(6 downto 0); sel:out std_logic_vector(7 downto 0); - 数码管位选通信号d6,d7:in std_logic_vector(3

16、downto 0) - d6 为计数个位, d7 为计数十位); end p6; - architecture behave of p6 is signal cnt:std_logic_vector(1 downto 0); signal A:std_logic_vector(3 downto 0); begin process(clk) begin if clkevent and clk=1 then if cnt01 then cnt=cnt+1; else cnt0); end if; end if; sel(0)=sel0; sel(1)sel1=0;sel0=1;Asel1=0;se

17、l0=0;Anull; end case; end process; process(A) - 数码管七段显示begin case A is when 0000 =sgsgsgsgsgsgsgsgsgsgnull; end case; end process; end behave; - 3、 对上述程序分别进行编译保存,通过后在通过File-create/update-create symbol files for current file, 将上述六个功能模块分别生成原理图形式,结果如下所示: 4、新建立一个bdf 文件,保存在该工程目录下,命名为exp20 后按下图所示进行连线。精选学习

18、资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 8 页,共 9 页五、功能仿真1、验证序列产生器p2 输出 xlout 波形,从图中可观察得到, xlout 为反复循环输出0111010011011010; 与实验程序所设定的值相同。2、当 ledag4.0=” 11010” 时,result 输出也为 1,而 ledag 的值为当前最近输入的五个值,说明状态机的设计是正确的3、 如下图所示,当 result每输出一个脉冲, d7 便加 1, 当 d7 增加到 9 时, 若 result在给 1 脉冲, d7 便向 d6进位。说明序列计数器p3的设计是正确的。六、实验心得在实验设计中要特别注意 led 模块一定要用上升沿驱动, 否则led 灯串行显示与当前数码管加 1(即目标序列)不一致。即存在时延的问题。精选学习资料 - - - - - - - - - 名师归纳总结 - - - - - - -第 9 页,共 9 页

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号