EDA实验报告 计数器及序列检测器
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
EDA实验报告
通信工程二班李桐20100820212
实验目的:
1.计数器的原理及应用。
2.混合模式的工程设计法的应用。
3.数码管扫描电路的应用。
4.序列检测器原理。
5.Mealy型与Moore型状态机原理。
6.状态图输入法。
实验原理:
1.计数器是一种常用的可统计时钟脉冲个数的时序逻辑器件。计数器中的“数”是触发器的状态组合,即编码。计数器循环一次所包含的状态总数就称作模。本次试验采用VHDL语言直接构建一个202进制计数器。
2.状态机是由一组状态、一个初始状态、输入输出和状态转换函数组成的时序电路。状态机主要用来控制电路的状态转移,针对不同类型的状态机,输出可以由现态确定,也可以由现态及次态共同确定。按状态机的信号输出方式分类,可分为Mealy型状态机和Moore型状态机。Mealy型状态机,次态和输出均取决于现态和当前输入;Moore型状态机,下一状取决于当前状态和当前输入,但其输出仅取决于当前状态。序列检测器是用于从二进制码流中检测出一组特定序列信号的时序电路。接受的序列信号与检测器预设值变焦,相同则输出为1,否则输出为 0。
实验具体步骤:
1.202进制加法计数器
(1).VHDL结构式描述顶层(调用了202进制加法计数器与七段译码器)
library ieee;
use ieee.std_logic_1164.all;
entity cnt212_7seg is
port( clk,clrn,en,scan_clk:in std_logic;
cout:out std_logic;
seg7:out std_logic_vector(6 downto 0);
wei:out std_logic_vector(2 downto 0));
end cnt212_7seg;
architecture arch of cnt212_7seg is
component cnt212 is
port( clk,clrn,En:in std_logic;
cout:out std_logic;
b,s,g:out std_logic_vector(3 downto 0));
end component;
component scan_led3_vhd is
port(
scan_clk,cnt_aclr:in std_logic;
datab,datas,datag:in std_logic_vector(3 downto 0);
seg7:out std_logic_vector(6 downto 0);
wei:out std_logic_vector(2 downto 0));
end component;
signal wdatab,wdatas,wdatag:std_logic_vector(3 downto 0);
begin
cnt_212:cnt212 port map(clk,clrn,En,cout,wdatab,wdatas,wdatag);
scan_led3:scan_led3_vhd port map(scan_clk,(not clrn),wdatab,wdatas,wdatag,seg7,wei); end arch;
(2).VHDL语言描述学号计数器(调用了10进制加法计数器)
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity cnt212 is
port( clk,clrn,En:in std_logic;
cout:out std_logic;
b,s,g:out std_logic_vector(3 downto 0));
end cnt212;
architecture arch of cnt212 is
component exp_cnt10 is
port(clk,clrn,En:in std_logic;
cq:out std_logic_vector(3 downto 0);
cout:out std_logic);
end component;
component dff
port(d,clk,clrn:in std_logic;
q:out std_logic);
end component;
signal couts,coutg,coutb,q1,q2,lkaclr:std_logic;
signal regb,regs,regg:std_logic_vector(3 downto 0);
begin
cntg:exp_cnt10 port map(clk,(clrn and lkaclr),En,regg,coutg);
dff1:dff port map(coutg,clk,clrn,q1); --利用D触发器实现进位cnts:exp_cnt10 port map(q1,(clrn and lkaclr),En,regs,couts);
dff2:dff port map((couts and coutg),clk,clrn,q2); --利用D触发器实现进位cntb:exp_cnt10 port map(q2,(clrn and lkaclr),En,regb,coutb);
lkaclr<= '0' when ( regb=x"2" and regs=x"1" and regg=x"2") else --在此实现清零
'1' ;
cout<= '1' when ( regb=x"2" and regs=x"1" and regg=x"1") else --在此使进位为'1'
'0';
b<=regb;
s<=regs;
g<=regg;
end arch;
(3).VHDL语言描述10进制加法计数器
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity exp_cnt10 is
port(clk,clrn,En:in std_logic;
cq:out std_logic_vector(3 downto 0);
cout:out std_logic);
end exp_cnt10;
architecture arch of exp_cnt10 is
signal cqi:std_logic_vector(3 downto 0);
begin
process(En,clk,clrn,cqi)
begin
if clrn='0' then
cqi<="0000";
elsif clk'event and clk='1' then
if En='1' then
if cqi<9 then
cqi<=cqi+1;
else
cqi<="0000";
end if;
end if;
end if;
if cqi=9 then
cout<='1';
else
cout<='0';