15
4.2 4.2 寄寄寄寄寄寄寄 寄寄寄寄寄寄寄 VHDL VHDL 寄寄寄寄 寄寄寄寄 Library ieee; Use ieee.std_logic_1164.all; Entity dff1 is port ( clk: in std_logic; D : in std_logic; Q : out std_logic); End; Architecture bhv of dff1 is Signal Q1: std_logic; Begin process(clk) begin if clk’event and clk=‘1’ then Q1<=D; end if; Q<=Q1; End process; End bhv;

4.2 寄存器描述及其 VHDL 语言现象

  • Upload
    lily

  • View
    123

  • Download
    7

Embed Size (px)

DESCRIPTION

4.2 寄存器描述及其 VHDL 语言现象. Library ieee; Use ieee.std_logic_1164.all; Entity dff1 is port ( clk: in std_logic; D : in std_logic; Q : out std_logic); End; Architecture bhv of dff1 is Signal Q1: std_logic; Begin process(clk) begin if clk’event and clk=‘1’ - PowerPoint PPT Presentation

Citation preview

Page 1: 4.2  寄存器描述及其 VHDL 语言现象

4.2 4.2 寄存器描述及其寄存器描述及其 VHDLVHDL 语言现象语言现象 Library ieee; Use ieee.std_logic_1164.all; Entity dff1 is port ( clk: in std_logic; D : in std_logic; Q : out std_logic); End; Architecture bhv of dff1 is Signal Q1: std_logic; Begin process(clk) begin if clk’event and clk=‘1’ then Q1<=D; end if; Q<=Q1; End process; End bhv;

Page 2: 4.2  寄存器描述及其 VHDL 语言现象

不完整条件语句与时序电路不完整条件语句与时序电路 IF 语句没有利用 else 明确指出当 if 语句不满足条件时做何操作,这就是一种不完整的条件语句。 利用不完整的条件语句的描述引进寄存器元件,从而构成时序电路的方式是 VHDL 描述时序电路最重要的途径。 通常,完整的条件语句只能构成组合逻辑电路。 如果没有充分考虑电路中所有可能出现的问题,即没有列全所有的条件及其对应的处理方法,将导致不完整的条件语句描述,将会产生不希望的组合和时序电路的混合体。 P81-82 例 4-9 和例 4-10 的比较

Page 3: 4.2  寄存器描述及其 VHDL 语言现象

Entity com is port(a1,b1: in bit; q1: out bit); End; Architecture one of com is Begin Process(a1,b1) Begin if a1>b1 then q1<=‘1’; elsif a1<b1 then q1<=‘0’; end if; End process; End one;

Entity com is port(a1,b1: in bit; q1: out bit); End; Architecture one of com is Begin Process(a1,b1) Begin if a1>b1 then q1<=‘1’; else q1<=‘0’; end if; End process; End one;

Page 4: 4.2  寄存器描述及其 VHDL 语言现象

4.2.3 4.2.3 实现时序电路的实现时序电路的 VHDLVHDL 不同表达方不同表达方式式 clk’event and clk=‘1’ clk’event and (clk=‘1’) and (clk’last_value=‘0’) 与 event 一样,’ last_value 属于预定义信号属性,表示最近一次事件发生前的值。 clk’last_value=‘0’ 为 ture 时,表示 clk 在时刻前为‘ 0’ ; clk’event and (clk=‘1’) and (clk’last_value=‘0’)

为 true 时,就保证了 clk 在时刻内的跳变是从‘ 0’ 变到‘ 1’ 的。

Page 5: 4.2  寄存器描述及其 VHDL 语言现象

例 1 :……Process(clk) beginIf clk’event and (clk=‘1’) and (clk’last_value=‘0’) then Q<=D; -- 确保 clk 的变化是一次上升沿的跳变End if;End process;

例 2 : ……Process(clk) beginIf clk=‘1’ and (clk’last_value=‘0’) then Q<=D; -- 确保 clk 的变化是一次上升沿的跳变End if;End process;

Page 6: 4.2  寄存器描述及其 VHDL 语言现象

例 3 : library ieee;Use ieee.std_logic_1164.all;Entity dff3 is port(clk,D:in std_logic; Q: out std_logic);End dff3;Architecture bhv of dff3 is signal Q1:std_logic;begin Process(clk) begin If rising_edge(clk) -- 必须打开 std_logic_1164 程序包 then Q<=D; End if; Q<=Q1; End process;End bhv;

Rising_edge() 是VHDL 在 IEEE 库中标准程序包std_logic_1164 内的预定义函数,此语句只能用于 std _logic 的信号。

Page 7: 4.2  寄存器描述及其 VHDL 语言现象

例 4 :……Process begin wait until clk=‘1’; -- 利用 wait 语句 Q<=D; End process; 例 5 :……Process(clk) begin If clk=‘1’ then Q<=D; -- 利用进程的启动特性产生对 clk 的边沿检测 End if;End process; 例 6 :……Process(clk,D) begin If clk=‘1’ -- 电平触发型寄存器 then Q<=D; End if;End process;

Page 8: 4.2  寄存器描述及其 VHDL 语言现象
Page 9: 4.2  寄存器描述及其 VHDL 语言现象

例 6 :……Process(clk,D) begin If clk=‘1’ -- 电平触发型寄存器 then Q<=D; End if;End process; 对于此类功能只有 MAX + plusII 等少数 EDA 工具含有,大多数专业 VHDL 综合器不承认这类语法表述,它们都要求将进程中的所有输入信号都列入敏感信号表中,否则给与警告信息。 对于那些综合器,无法设计出电平型触发的时序元件,综合出的电路将于其它几个例子相同。 注:一般情况下,不推荐使用例 5 和例 6 的表达方式产生时序电路。

Page 10: 4.2  寄存器描述及其 VHDL 语言现象

时序电路只能利用进程中的顺序语句来建立。 多数综合器并不理会边沿检测语句中的信号的 std_logic 数据类型,因此最常用和通用的边沿检测表达式仍然为 clk’event

and clk=‘1’ 。

Page 11: 4.2  寄存器描述及其 VHDL 语言现象

4.2.4 4.2.4 异步时序电路设计异步时序电路设计 注:在时序电路设计中,一个时钟进程只能构成对应单一时钟信号的时序电路。 如果在进程中需要构成多触发器时序电路,也只能产生对应某个时钟的同步时序逻辑。 异步逻辑最好用多个时钟进程语句来构成。

Page 12: 4.2  寄存器描述及其 VHDL 语言现象

…… Architecture bhv of multi_dff is signal q1,q2: std_logic; Beginpro1: process(clk) begin if clk’event and clk=‘1’ then q1<=not (q2 or a); end if; end process;por2: process(q1) begin if q1’event and q1=‘1’ then q2<=d; end if; qq<=q2; end process;

Page 13: 4.2  寄存器描述及其 VHDL 语言现象
Page 14: 4.2  寄存器描述及其 VHDL 语言现象
Page 15: 4.2  寄存器描述及其 VHDL 语言现象

4.4 VHDL 4.4 VHDL 文本输入设计方法初步文本输入设计方法初步 以 D触发器为例说明!!