EDA技术及应用课件:3-2 (1).ppt

上传人(卖家):罗嗣辉 文档编号:2040961 上传时间:2022-01-19 格式:PPT 页数:131 大小:2.10MB
下载 相关 举报
EDA技术及应用课件:3-2 (1).ppt_第1页
第1页 / 共131页
EDA技术及应用课件:3-2 (1).ppt_第2页
第2页 / 共131页
EDA技术及应用课件:3-2 (1).ppt_第3页
第3页 / 共131页
EDA技术及应用课件:3-2 (1).ppt_第4页
第4页 / 共131页
EDA技术及应用课件:3-2 (1).ppt_第5页
第5页 / 共131页
点击查看更多>>
资源描述

1、 ARCHITECTURE Process ProcessENTITYSequentialProcessCombinationalProcessportsportscomponent3.4 VHDL3.4 VHDL顺序语句(顺序语句(SequentialSequential)SIGNAL Declarationslabel1: PROCESSVARIABLE Declarationslabel2: PROCESSVARIABLE Declarations architecture rtl of ex is signal a : std_logic;begin process() begin a

2、 = b; a = c; end process;end rtl;architecture rtl of ex is signal a : std_logic;begin process() begin a = b; end process; process() begin a = c; . end process;end ex;if 条件 then 顺序处理语句;end if ;括号可以去掉If ena = 1 thenLibrary ieee ;Use ieee.std_logic_1164.all;Entity dff isPort(clk, d: in std_logic ; q: o

3、ut std_logic);End dff;Architecture rtl of dff isBeginProcess(clk)BeginIf clkevent and clk = 1 then q = d ;End if ;End process ;End rtl ;if 条件 then 顺序处理语句;else 顺序处理语句;end if ;if 条件 then 顺序处理语句;elsif 条件 then 顺序处理语句; elsif 条件 then 顺序处理语句;else 顺序处理语句;end if; Library ieee ;Use ieee.std_logic_1164.all;ent

4、ity mux4 is port(input: in std_logic_vector(3 downto 0); sel: in std_logic_vector(1 downto 0); y: out std_logic); end mux4 ;Architecture rtl of mux4 isBegin process(input, sel) begin if sel = “00” then y = input(0) ; elsif sel = “01” then y = input(1) ; elsif sel = “10” then y = input(2) ; else y =

5、input(3) ; end if ; end process ;End rtl ; if_then_elsif 语句中隐含了优先级别的判断,最先出现的条件优先级最高,可用于设计具有优先级的电路。如8-3优先级编码器。 library ieeelibrary ieee; ; use ieee.std_logic_1164.all; use ieee.std_logic_1164.all; entity coder is entity coder is port(input: in std_logic_vector(7 downtoport(input: in std_logic_vector(

6、7 downto 0); 0); output: out std_logic_vector(2 downtooutput: out std_logic_vector(2 downto 0); 0); end coder; end coder; architecture art of coder is begin process(input) begin if input(7)=0 then output=“000”; elsif input(6)=0 then output=“001”; elsif input(5)=0 then output=“010”; elsif input(4)=0

7、then output=“011”; elsif input(3)=0 then output=“100”; elsif input(2)=0 then output=“101”; elsif input(1)=0 then output=“110”; else output 顺序处理语句; when 分支条件 = 顺序处理语句; when 分支条件 = 顺序处理语句; end case;例:用case 语句描述四选一电路例:case 语句的误用 signal value:integer range 0 to 15; signal out_1 : bit ;case value is - 缺少

8、 when条件语句end case ;case value is - 分支条件不包含2到15 when 0 = out_1 out_1 out_1 out_1 = 0 ;end case ;例:根据输入确定输出值 library ieee; use ieee.std_logic_1164.all; entity mux41 is port(s4,s3,s2,s1: in std_logic; z4,z3,z2,z1: out std_logic); end mux41; architecture art of mux41 is begin process(s4, s3, s2, s1) var

9、iable sel: integer range 0to15; begin sel:=0; if s1=1 then sel:=sel+1; end if; if s2=1 then sel:=sel+2; end if; if s3=1 then sel:=sel+4; end if; if s4=1 then sel:=sel+8; end if; z1=0; z2=0; z3=0; z4z1z2z3z410; end loop L2; 标号:for 循环变量 in 离散范围 loop 顺序处理语句; end loop 标号;-奇校验library ieee ; use ieee.std_

10、logic_1164.all ;entity parity_check isport(a: in std_logic_vector(7 downto to ) ; y: out std_logic);end parity_check ;architecture rtl of parity_check isbeginprocess(a) variable tmp: std_logic ;begin tmp := 1 ; for i in 0 to 7 loop tmp := tmp xor a(i) ; end loop ;y = tmp ;end process ;end rtl ;标号:wh

11、ile 循环条件 loop 顺序处理语句; end loop 标号;next 标号 when 条件表达式;1) Next ; next 标号 ; 3) next 标号 when 条件表达式;exit 标号 when 条件表达式;wait on 信号,信号;process(a, b) begin y= a and b;end process; processbegin y= a and b; wait on a, b; end process;wait until 表达式;时钟信号 clk 的上升沿的描述: wait until clk = 1; wait until rising_edge(c

12、lk); wait until clkevent and clk = 1; wait until not(clkstable) and clk=1;由以上描述可实现相同的硬件电路结构。 时钟信号下降沿的描述? end process;五、五、return return 语句语句 return 语句只能用于子程序中,并用来终止一个子程序的执行。格式:分为:1)return ; 用于过程,只是结束过程,不返回任何值。 2)return 表达式; 用于函数,并且必须返回一个值。 return 表达式;例:用于过程的return语句 procedure rs (s,r: in std_logic; q

13、, nq : inout std_logic) is begin if s=1 and r=1 then report “forbidden state: s and r are equal to 1 ”; return; else q=s and nq after 5 ns; nq= a and q after 5 ns; end if; end procedure rs;例:用于函数的return语句 function opt (a,b,sel: std_logic ) return std_logic is begin if sel = 1 then return ( a and b )

14、; else return (a or b ); end if; end function opt;六六 null null 语句语句 null为空语句,不作任何操作。格式: null;七、其它语句和说明七、其它语句和说明 属性(attribute)描述: 属性是某一对象的特征表示,是一个内 部预定义函数。格式为: 综合器支持的属性有: left、 right、 high、 low、 range、 reverse_range、 length、 event、 stable对象名属性标识符属性属性 eventevent 对在当前的一个极小的时间段内发生的事件的情况进行检测。如发生事件,则返回 tr

15、ue,否则返回 false。 发生事件:信号电平发生变化。 clockeventclock=1clockeventclock=0clockevent时钟信号的上升沿描述: clockevent and clock = 1时钟信号的下降沿描述: clockevent and clock = 0上升沿触发器描述: process(clock) begin if clockevent and clock = 1 then q = data ; end if ; end process;属性属性 stablestable 属性 stable 的测试功能与 event刚好相反,信号在时间段内无事件发生,

16、则返回 true,否则返回 false。 以下两语句的功能相同: clockevent and clock = 1 not ( clockstable ) and clock = 1第3章 习题二 1、信号与变量的区别有哪些?信号可以用来描 述哪些硬件特性? 2、if 语句可分为哪几种类型?如何用嵌套式 if语句描述具有优先级的电路? 3、case 语句有什么特点?其分支条件使用时有 哪些注意事项? 4、loop 语句的类型有哪些?其循环变量有什么 特点? 5、next 语句与 exit 语句的区别是什么? 6、wait 语句有哪些类型?wait 语句在进程中 的作用是什么?与敏感信号表有什么

17、关系?3.5 VHDL3.5 VHDL并发语句(并发语句(ConcurrentConcurrent) Architecture并发语句并发语句并发语句信号信号信号 进程语句 process信号信号信号 进程语句 process 进程语句 process敏感信号表:进程内要读取的所有敏感信号 (包括端口)的列表。每一个敏感 信号的变化,都将启动进程。 格式:标记: process ( 敏感信号表) 进程说明项 begin 顺序描述语句 end process 标记;信号名称 ,信号名称 敏感信号表的特点: 1、同步进程的敏感信号表中只有时钟信号。 如: process(clk) begin if

18、(clkevent and clk = 1) then if reset = 1 then data = “00”; else data = in_data; end if; end if; end process;2、异步进程敏感信号表中除时钟信号外,还有其 它信号。 例: process(clk,reset) begin if reset = 1 then data = “00”; elsif(clkevent and clk = 1) then data = in_data; end if; end process; PROCESS (a,b) BEGIN -sequential sta

19、tements END PROCESS; PROCESS BEGIN - sequential statements WAIT ON (a,b) ; END PROCESS;4、若是组合电路,则所有进程内的读信号均需出现在敏感列表中process(input, sel)begin if sel = “00” then y = input(0) ; elsif sel = “01” then y = input(1) ; elsif sel = “10” then y = input(2) ; else y = input(3) ; end if ; end process ;定义:给一个信号赋

20、值,即为该信号创建一个驱动 器(驱动信号)。多个进程或并发语句给同 一个信号赋值,则该信号为多信号源驱动。例: a_out = a when enable_a else Z ; b_out = b when enable_b else Z ; process ( a_out) begin sig = a_out ; end process ; process ( b_out ) begin sig = b_out ; end process ;三态缓冲器总线结构与多驱动信号三态缓冲器总线结构与多驱动信号二、块语句二、块语句 块语句将一系列并行描述语句进行组合,目的是改善并行语句及其结构的可读性

21、。可使结构体层次鲜明,结构明确。语法如下: 标记:block ( 块保护表达式 ) 块说明项 begin 并行语句 end block 标记 ;1 1、块语句的使用不影响逻辑功能、块语句的使用不影响逻辑功能 以下两种描述结果相同: 描述一: a1: out1=1 after 2 ns; a2: out2=1 after 2 ns; a3: out3=1 after 2 ns; 描述二: a1: out1=1 after 2 ns; blk1: block begin a2: out2=1 after 2 ns; a3: out3=1 after 2 ns; end block blk1; ar

22、chitecture behav of a_var is begin output=a(i);end behav;architecture behav of a_var is begin process(a, i) begin output=a(i); end process; end behav;一个简单并行信号赋值语句是一个进程的缩写。LIBRARY ieee;USE ieee.std_logic_1164.all;ENTITY ex1 IS PORT(a, b : IN STD_LOGIC; y : OUT STD_LOGIC);END ex1;ARCHITECTURE rtl OF e

23、x1 IS SIGNAL c : STD_LOGIC;BEGIN c = a and b; y = c;END rtl;LIBRARY ieee;USE ieee.std_logic_1164.all;ENTITY ex2 IS PORT(a,b : IN STD_LOGIC; y : OUT STD_LOGIC);END ex2;ARCHITECTURE rtl OF ex2 IS SIGNAL c : STD_LOGIC;BEGIN process1: PROCESS(a, b) BEGIN c = a and b; END PROCESS process1; process2: PROC

24、ESS(c) BEGIN y = c; END PROCESS process2;END rtl;LIBRARY ieee;USE ieee.std_logic_1164.all;ENTITY ex1 IS PORT(a, b : IN STD_LOGIC; y : OUT STD_LOGIC);END ex1;ARCHITECTURE rtl OF ex1 IS SIGNAL c : STD_LOGIC;BEGIN c = a and b; y = c;END rtl;LIBRARY ieee;USE ieee.std_logic_1164.all;ENTITY ex2 IS PORT(a,

25、b : IN STD_LOGIC; y : OUT STD_LOGIC);END ex2;ARCHITECTURE rtl OF ex2 IS SIGNAL c : STD_LOGIC;BEGIN PROCESS(a, b, c) BEGIN c = a and b; y = c; END PROCESS;END rtl;目的信号量 = 表达式1 when 条件1 else 表达式2 when 条件2 else 表达式3 when 条件3 else 表达式n;q = a WHEN sela = 1 ELSE b WHEN selb = 1 ELSE c;PROCESS(sela, selb,

26、a, b, c)BEGIN IF sela=1 THEN q = a; ELSIF selb=1 THEN q = b; ELSE q = c; END IF;END PROCESS;with 表达式 select 目的信号量 q q q q = d; END CASE;END PROCESS;WITH sel SELECT q 表达式 ,类属名称 = 表达式 ) port map ( 端口名称 = 表达式 , 端口名称 = 表达式 );例: u1:ADD generic map (N = 4) port map (x,y,z,carry); 此电路由 9个元件组成:3个D触发器、1个非门、1

27、个 2 输入或门、3个2输入与非门、1个2输入异或非门。对应的元件例化(结构化)描述如下:标号:for 循环变量 in 范围 generate 并行语句 end generate 标号;4位移位寄存器的等效描述:标号:if 条件表达式 generate 并行语句 end generate 标号;7 6 5 4 3 2 1 03.6 3.6 子程序(子程序(SUBPROGRAMSUBPROGRAM)Procedure 过程名(参数声明);参数名:方式 参数类型 ;参数名:方式 参数类型Function 函数名 (参数声明)return 类型;参数名:方式 参数类型 ;参数名:方式 参数类型Pro

28、cedure 过程名 (参数声明) is 子程序声明项begin 顺序语句end 过程名;Function 函数名称 (参数声明)return 类型 is 函数声明项begin 顺序语句end 函数名称;例:过程重载 procedure cal (v1, v2 : in real; signal out1: inout integer); procedure cal (v1, v2 : in integer; signal out1: inout real); cal (20.15, 1.42, sign1); cal (23, 320, sign2); 二二 数据流描述:数据流描述: 数据流

29、描述又称为寄存器传输级描述(RTL _Register Transfer Level)。RTL级描述是以寄存器为特征,在寄存器之间插入组合逻辑电路。即以描述数据流的流向为特征。三三 结构化描述:结构化描述: 在多层次的设计中,高层次的设计模块调用低层次的设计模块,构成模块化的设计。结构描述是元件互连的描述,使用元件例化语句。一位全加器的原理图一位全加器的VHDL结构化描述第3章 习题三 1、进程语句的特点是什么?应从哪几个方面来理 解进程语句? 2、块语句的作用是什么?有什么特点? 3、简单并行赋值语句与什么语句等效?为什么? 条件信号赋值语句、选择信号赋值语句又分别 与什么语句等效?有什么异同点? 4、元件例化语句的作用是什么?如何进行元件例 化?元件例化时端口映射有哪两种方式?有什 么注意事项? 5、生成语句与循环语句的异同点是什么?

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 大学
版权提示 | 免责声明

1,本文(EDA技术及应用课件:3-2 (1).ppt)为本站会员(罗嗣辉)主动上传,163文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。
2,用户下载本文档,所消耗的文币(积分)将全额增加到上传者的账号。
3, 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(发送邮件至3464097650@qq.com或直接QQ联系客服),我们立即给予删除!


侵权处理QQ:3464097650--上传资料QQ:3464097650

【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。


163文库-Www.163Wenku.Com |网站地图|