时序电路设计

1.时钟信号和复位信号

(1)时钟信号的描述

若进程的敏感信号是时钟信号,这时时钟信号出现在process后的括号中。

例:

process(clock_signal)

begin

if(clock_edge_condition) then

signal_out<=signal_in

其他语句

end if;

end process;

在进程中用wait on 语句等待时钟

这样的电路没有敏感信号,进程通常停留在wait on 语句上,只有时钟信号到来且满足一定条件时,其余语句才能执行。

例:

process

begin

wait on(clock_signal) until (clock_edge_condition)

signal_out<=signal_in;

其他语句

end process;

敏感表中只能有一个时钟信号

wait on 语句只能放在进程的最前面或者最后面

时钟的边沿描述

描述时钟一定要指明是上升沿还是下降沿

上升沿到来的条件:

if clk='1' and clk'last_value='0' and clk'event

下降沿到来的条件:

if clk='0' and clk'last_value='1' and clk'event

关于时钟信号的总结:

if clock_signal=current_value and

clock_signal' last and

clock_signal'event

也可以写为:

if clock_signal=clock_siganl'event and current_value

例:

上升沿d触发器:

library ieee;

use ieee.std_logic_1164.all;

entity dff1 is

port(clk,d:in std_logic;

q:out std_logic

);

end;

architecture bhv of dff1 is

signal q1:std_logic;

begin

process(clk,d)

begin

if clk'event and clk='1' then

q1<=d;

end if;

end process;

q<=q1;

end bhv;

例2:

process

begin

wait until clk'event and clk='1';

q<=d;

end process;

2.复位信号

*同步复位

当复位信号有效且在给定的时钟边沿到来时,触发器才被复位。

例:

process(clock)

begin

if(clock_edge_condition) then

if(reset_condition)then

signal_out<=reset_value;

else

signal_out=signal_in;

其他语句

end if;

end if;

end process;

例2:

process(clock)

if clock'event and clock='1' then

if reset='1' then

count<='0';

else

count<=count+1;

end if;

end if;

end process;

其中敏感表中只有时钟信号,因为只有时钟到来时才能复位。

*异步复位

只要复位信号有效,触发器就被复位,所以敏感表中除时钟信号外,还要复位信号。

格式:

process(rest_signal,clock_signal)

begin

if(reset_signal) then

signal_out<=reset_value;

elsif (clock_event and clock_edge_condition) then

signal_out<=signal_in;

其他语句

end if;

end process;

例2:

process(clock,reset)

begin

if reset='1' then

count<='0';

elsif clock'event and clock='1' then

count<=count+1;

end if;

end process;

 

posted on 2019-11-09 16:53  李好123  阅读(732)  评论(0编辑  收藏  举报