ImageVerifierCode 换一换
格式:PPT , 页数:44 ,大小:158KB ,
资源ID:6989015      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-6989015.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(VHDL硬件描述语言基础优质PPT.ppt)为本站会员(wj)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

VHDL硬件描述语言基础优质PPT.ppt

1、end eqcomp4;architecture dataflow of eqcomp4 isbegin equal=1 when a=b else 0;End dataflow;,VHDL 大小写不敏感,eqcomp4.vhd,包,实体,构造体,文件名和实体名一致,每行;结尾,关键字begin,关键字end后跟实体名,关键字end后跟构造体名,库,实体(Entity),描述此设计功能输入输出端口(Port)在层次化设计时,Port为模块之间的接口在芯片级,则代表具体芯片的管脚,A3.0,B3.0,equal,Entity eqcomp4 isport(a,b:,实体端口的模式,输入(Inpu

2、t)输出(Output)双向(Inout):可代替所有其他模式,但降低了程序的可读性,一般用于与CPU的数据总线接口缓冲(Buffer):与Output类似,但允许该管脚名作为一些逻辑的输入信号,Out与Buffer的区别,Entity test1 is port(a:in std_logic;b,c:end test1;architecture a of test1 is begin b=not(a);c=b;-Error end a;,Entity test2 is port(a:b:buffer std_logic;c:end test2;architecture a of test2

3、is begin b=not(a);end a;,结构体(Architecture),描述实体的行为结构体有三种描述方式行为描述(behavioral)数据流描述(dataflow)结构化描述(structural),结构体行为描述,Architecture behavioral of eqcomp4 is begincomp:process(a,b)beginif a=b then equal=1;else equal=0;end if;end process comp;end behavioral;,高层次的功能描述,不必考虑在电路中到底是怎样实现的。,结构体数据流描述描述输入信号经过怎样

4、的变换得到输出信号,Architecture dataflow1 of eqcomp4 is begin equal=1 when a=b else 0;end dataflow1;,Architecture dataflow2 of eqcomp4 is beginequal=not(a(0)xor b(0)and not(a(1)xor b(1)and not(a(2)xor b(2)and not(a(3)xor b(3);end dataflow2;,当a和b的宽度发生变化时,需要修改设计,当宽度过大时,设计非常繁琐,结构体结构化描述,architecture struct of eq

5、comp4 isbegin U0:xnor2 port map(a(0),b(0),x(0);U1:xnor2 port map(a(1),b(1),x(1);U2:xnor2 port map(a(2),b(2),x(2);U3:xnor2 port map(a(3),b(3),x(3);U4:and4 port map(x(0),x(1),x(2),x(3),equal);end struct;,类似于电路的网络表,将各个器件通过语言的形式进行连接,与电路有一一对应的关系。一般用于大规模电路的层次化设计时。,三种描述方式的比较,VHDL标识符(Identifiers),基本标识符由字母、数

6、字和下划线组成第一个字符必须是字母最后一个字符不能是下划线不允许连续2个下划线保留字(关键字)不能用于标识符大小写是等效的,VHDL数据对象(Data Objects),常数(Constant)固定值,不能在程序中被改变增强程序的可读性,便于修改程序在综合后,连接到电源和地可在Library、Entity、Architecture、Process中进行定义,其有效范围也相应限定Constant data_bus_width:integer:=8;,VHDL数据对象(Data Objects),信号(Signals)代表连线,Port也是一种信号没有方向性,可给它赋值,也可当作输入在Entity

7、中和Architecture中定义设定的初始值在综合时没有用,只是在仿真时在开始设定一个起始值。在MaxPlusII中被忽略。用=进行赋值signal count:bit_vector(3 downto 0):=“0011”;,VHDL数据对象(Data Objects),变量(Variable)临时数据,没有物理意义只能在Process和Function中定义,并只在其内部有效要使其全局有效,先转换为Signal。用:=进行赋值 variable result:std_logic:=0;,信号与变量的区别,architecture rtl of start is signal count:i

8、nteger range 0 to 7;begin process(clk)begin if(clkevent and clk=1)then count=count+1;if(count=0)then carryout=1;else carryout=0;end process;end rtl;,architecture rtl of start is begin process(clk)variable count:begin if(clkevent and clk=1)then count:=count+1;,信号与变量的区别,architecture a of start is sign

9、al tmp:std_logic;begin process(a_bus)begin tmp=1;for i in 3 downto 0 loop tmp=a_bus(i)and tmp;end loop;carryout=tmp;,architecture a of start is begin process(a_bus)variable tmp:begin tmp:=1;for i in 3 downto 0 loop tmp:=a_bus(i)and tmp;,VHDL数据类型,标量类型(Scalar)枚举(Enumeration)整数(Integer)浮点数(Float)物理(Phy

10、sical)复合类型(Composite),VHDL数据类型枚举,列举数据对象可能存在的值,一般用于定义状态机的状态Type states is(idle,start,running,pause,stop)Signal current_state:states;IEEE1076标准中预定义了两个枚举类型Type boolean is(False,True)Type bit is(0,1)Signal a:bit;,VHDL数据类型枚举,IEEE1164标准中预定义了一个枚举类型Type std_logic is(U,X,0,1,Z,W,L,H,-);该类型能比较全面地包括数字电路中信号会出现的

11、几种状态,因此一般情况把这种类型代替bitSignal a:注意:这里的大小写是敏感的,VHDL数据类型,整数、浮点数方便用于数值方面的运算:加减乘除整数范围:-231 231 1,经常用于计数器实数范围:-1.0E38+1.0E38,不被MaxPLusII支持Variable a:integer range 255 to+255;物理类型主要用于调试,VHDL数据类型复合类型,Array Types多个相同类型成员组成的队列,一般用于定义数据总线、地址总线等。Signal a:std_logic_vector(7 downto 0);a=B“00111010”;a=X“3A”;可自定义复合类

12、型Type word is array(15 downto 0)of bit;Signal b:word;Type table8x4 is array(0 to 7,0 to 3)of bit;,VHDL数据类型复合类型,Record Types相同或不同类型的元素组成,类似C中的结构具有模型抽象能力,用于描述一个功能模块Type iocell is record Enable:DataBus:bit_vector(7 downto 0);end record;singal bus:iocell;bus.Enable=1;bus.DataBus=“00110110”;,VHDL数据类型及子类型

13、Types And Subtypes,VHDL是强类型语言,必须用类型转换函数才能进行不同类型之间的转换type byte_size is integer range 0 to 255;signal a:byte_size;signal b:integer range 0 to 255;if a=b then 采用以下方式 subtype byte_size is integer range 0 to 255;,属性(Attributes),提供Entity、Architecture、Type和Signals的信息。有许多预定义的值、信号和范围的属性一个最常用的属性是eventif clkev

14、ent and clk=1 thenleft,right,high,low,lengthtype count is integer range 0 to 127countleft=0;countright=127;counthigh=127;countlow=0;countlength=128;,VHDL运算符,逻辑运算符AND、OR、NAND、NOR、XOR、NOT关系运算符=、/=、=算术运算符+、-、*、/并置(连接)运算符&,组合电路并行语句(Concurrent),并行语句位于Process外面,同时执行,不分位置的先后顺序并行语句包括:布尔等式:=With-select-whenW

15、hen-else布尔等式 A=s(0)and s(1);B=not(y);,组合电路并行语句,With-select-when语句 With Sel_signal select Signal_name=a when Sel_signal_1,b when Sel_signal_2,c when Sel_signal_3,x when Sel_signal_x;,Signal s:std_logic_vector(1 downto 0);Signal a,b,c,d,x:With s select x=a when“00”,b when“01”,c when“10”,d when others;

16、,组合电路并行语句,When-else语句 Signal_name=a when condition1 else b when condition2 else c when condition3 else x;,x=a when s=“00”else b when s=“01”else c when s=“10”else d;,Signal a,b,c,d:Signal w,x,y,z:x=w when a=1 else x when b=1 else y when c=1 else z when d=1 else 0;,组合电路并行语句,实现优先级编码器 encode=“111”when D

17、(7)=1 else“110”when D(6)=1 else“101”when D(5)=1 else“100”when D(4)=1 else“011”when D(3)=1 else“010”when D(2)=1 else“001”when D(1)=1 else“000”when D(0)=1 else“000”;,组合电路并行语句,When-else语句条件语句可以是一个简单的表达式With-select-when则不能采用表达式作为条件 a=“0000”when state=idle and state=1 else“0001”when state=idle and state=

18、0 else b when state=running and state=1 else a;,组合电路顺序语句(Sequential),Process,Function,Procedure中的语句都是顺序执行,以Process为例Process与Process之间,与其他并行语句之间都是并行的关系If-then-elseCase-when,组合电路顺序语句,If-then-elseIf(condition1)then do something;elsif(condition2)then else do something different;,组合电路顺序语句,Process(addr)Be

19、gin step=0;if(addr=X“F”)then step=1;End process;,Process(addr)Begin if(addr=X“F”)then step=1;else step=0;,Step=addr(3)*addr(2)*Addr(1)*addr(0)+step,组合电路顺序语句,用于作地址译码InRam=X“0000”and addr=X“4000”and addr=X“4008”and addr=X“8000”and addr=X“C000”then EEPRom=1;,组合电路顺序语句,Case-when case sel_signal is when v

20、alue_1=(do sth)when value_2=(do sth)when value_last=(do sth)end case;,组合电路顺序语句,实现数码管译码器Process(address)begin case address is when“0000”=decode decode decode decode decode=X“00”;end case;,几种语句的比较,同步时序逻辑电路,Process(clk)begin if(clkevent and clk=1)then q=d;,Process(clk)begin if(clk=1)then q=d;,D触发器,缓冲器,实现T触发器,Process(clk)begin if(clkevent and clk=1)then if(t=1)then q=not(q);else q=q;,

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2