1 / 15

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

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’

lily
Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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’ • then Q1<=D; • end if; • Q<=Q1; • End process; • End bhv;

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

  3. 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; • 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;

  4. 4.2.3 实现时序电路的VHDL不同表达方式 • 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’的。

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

  6. Rising_edge()是VHDL在IEEE库中标准程序包std_logic_1164内的预定义函数,此语句只能用于std _logic的信号。 例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;

  7. 例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;

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

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

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

  11. …… Architecture bhv of multi_dff is signal q1,q2: std_logic; Begin pro1: 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;

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

More Related