这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 高校专区 » 周师电子设计创新社区 » EDA 第七次作业

共1条 1/1 1 跳转至

EDA 第七次作业

菜鸟
2015-01-10 21:33:55     打赏

EDA第七次作业

5-1,VHDL设计中,给时序电路清0(复位)有两种不同方法,它们是什么?如何实现?

 

:同步清零和异步清零。

同步清零是指与时钟同步,即时钟触发条件满足时检测清零信号是否有效,有效则在下一个时间周期的触发条件下,执行清零。

异步清零是清零信号有效时,无视触发脉冲,立即清零。

 

5-7VHDL设计一个功能类似74LS160的计数器。

答:library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity counter is

port(

allow,reset,clk :in bit;

o:out integer range 0 to 10;

c:out bit);

end counter;

architecture behaver of counter is

begin

 p1: process (clk,reset,allow)

 variable ot:integer range 0 to 10:=0;

 variable t:bit ;

 begin

if(reset='1')then o<=0;

 elsif (allow='1') then

  if(clk'event and clk='1')then

  ot:=ot+1;t:='0';

  if(ot>9) then ot:=0;t:='1';

  end if;

  end if;

  o<=ot;

  c<=t;

end if;

end process p1;

end architecture behaver;

5-8给出含有异步清0和计数使能的16位二进制加减可控计数器的VHDL描述。

 

答:代码如下。clr1异步清零。k1时执行加法计数器,为0时执行减法计数器。仿真图如下:

library IEEE;use IEEE.std_logic_1164.all;

use IEEE.std_logic_unsigned.all;

entity cnt_16 is

    port (

        clk: in STD_LOGIC;

        k: in STD_LOGIC;

        clr: in STD_LOGIC;

        q: out STD_LOGIC_VECTOR (15 downto 0)

    );

end cnt_16;

architecture cnt_16_arch of cnt_16 is

signal qq:std_logic_vector(15 downto 0);

begin

process(clk,clr,k)

begin

 if clr='1' then

  qq<="0000000000000000";

 elsif clk'event and clk='1' then

  if k='1' then

     qq<=qq+'1';

  else

     qq<=qq-'1';

   end if;

 end if;

end process;

process(qq)

begin

 q<=qq;

end process;

end cnt_16_arch




关键词: 时序 清零    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]