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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

本文(VHDL语法格式.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

VHDL语法格式.docx

1、VHDL语法格式VHDL语法格式上篇 基础元素目录: 数据类型 数据对象 运算符 语句 基本程序结构 电路描述方式数据类型 预定义类型 bit bit_victor integer std_logic std_logic_victor 自定义类型 枚举类型 type 新数据类型 is (元素1, 元素2, .) 例 定义 type state_type is (s1, s2, s3. s4); - 定义一个新类型state_type 引用 signal state : state_type; - 定义一个信号state,类型为state_type 数组类型 type 数组 is array (

2、范围) of 数据类型; 例 定义 type byte is array (7 downto 0) of bit; - 定义一个8bit的数组 type word is array (31 downto 0) of bit; - 定义一个32bit的数组数据对象 端口 声明 端口 : in | out 数据类型; - 端口在特性上等同于信号,但赋值在entity的port中 赋值 端口 = 表达式; 信号 声明 signal 信号 : 数据类型; 赋值 信号 = 表达式; 变量 声明 varable 变量 : 数据类型; 赋值 变量 := 表达式; 常数 声明 常数 : 数据类型 := 数值;

3、运算符 算术运算 +, -, * 并置运算 & 关系运算 =, /=, , , = 逻辑运算 and, or, not, nand, nor, xor, xnor语句 并行语句 信号赋值语句 简单信号赋值语句 信号 = 表达式; 选择信号赋值语句 with 选择表达式 select 信号 = 表达式1 when 选择值1, 表达式2 when 选择值2, . 表达式n when others; 条件信号赋值语句 信号 = 表达式1 when 条件关系式1 else 表达式2 when 条件关系式2 else . 表达式n when 条件n else 表达式; 过程调用语句 过程 (实参); 函

4、数调用语句 信号 = 连接端口1, 元件端口2 = 连接端口2, .); 生成语句 格式 1 标号: for 循环变量 in 取值范围 generate 声明语句, begin 并行语句, end generate 标号; 取值范围: 表达式 to 表达式; - 递增方式,如1 to 5 表达式 downto 表达式 ; - 递减方式,如5 downto 1 格式 2 标号: if 条件关系式 generate 声明语句; begin 并行语句, end generate 标号 , 块语句 块标号: block (保护条件) 接口声明; 类属声明; begin 并行语句; - 被保护的变量前需

5、加上保留字guarded end block 块标号; 带保护的块语句举例: entity latch is port( d, clk : in bit; q, qb : out bit ); end latch; achetectire latch_guard of latch is begin b1 : block(clk = 1 ) begin q = guarded d after 5 ns; qb = guarded not(d) after 7 ns; end block b1; end latch_guard 进程语句 标号: process (敏感信号) 声明语句; -常量,变

6、量,信号 begin 顺序语句; end process 标号:;顺序语句 赋值语句 - 在进程中 信号 顺序语句; . when others = 顺序语句; end case; for_loop 语句 标号: for 循环变量 in 值 to 值 loop; 顺序语句; end loop 标号;时钟边沿描述 上升沿 时钟 event and时钟 = 1 | rising_edge (时钟) 下降沿 时钟 event and时钟 = 0 | falling_edge (时钟)程序基本结构- 主程序与元件程序在同一文件中,library ieee;use 主程序entity 实体名 is -实

7、体名必须与文件名相同 port (端口声明; );end entity work1;architecture struc of work1 is 声明语句; -常量,变量,信号,元件,函数等begin 并行语句;end architecture struc;电路描述方式 行为描述方式 以用状态机描述电路为典型 数据流 ( 寄存器 ) 描述方式 即用逻辑表达式描述电路 结构描述方式 以用元件复用的方式描述电路为典型VHDL语法格式下篇 复合元素和状态机元件 - 1 单文件元件 2 多文件元件函数 - 3 单文件函数 4 多文件函数过程 - 5 单文件过程 6 多文件过程moorl 状态机 - 7

8、 二进程moorl状态机 8 三进程moorl状态机meaky 状态机 - 9 二进程mealy状态机 10 三进程mealy状态机状态机实例 - 11 交通灯之一 12 交通灯之二附录 - 13 状态转移图 14 用户库的格式和用法单文件元件- 主程序与元件程序在同一文件中,library ieee;use 主程序entity work1 is port ( r,s,t,u : in std_logic; v : out std_logic );end entity work1;architecture struc of work1 is component ym - 将实体ym声明为元件

9、port ( a,b : in std_logic; c : out std_logic ); end component ym; component hm - 将实体hm声明为元件 port ( a,b : in std_logic; c : out std_logic ); end component hm; signal temp1,temp2 : std_logic;begin u1 : ym port map ( r, s, temp1 ); - 元件例化 u2 : ym port map ( t, u, temp2 ); u3 : hm port map ( temp1, temp

10、2, v );end architecture struc;- ym元件实体定义程序library ieee;use ym is port ( a,b : in std_logic; c : out std_logic );end entity ym;architecture ym1 of ym isbegin c = a and b;end architecture ym1;- hm元件实体定义程序library ieee;use hm is port ( a,b : in std_logic; c : out std_logic );end entity hm;architecture h

11、m1 of hm isbegin c = a or b;end architecture hm1;多文件元件- 主程序文件和定义元件的程序文件都要添加到工程中- 主程序文件,不需要声明用户库文件library ieee;use zhu_map is port ( r,s,t,u : in std_logic; v : out std_logic );end entity zhu_map;architecture niu of zhu_map is component ym port ( a,b : in std_logic; c : out std_logic ); end component

12、 ym; component hm port ( a,b : in std_logic; c : out std_logic ); end component hm; signal temp1,temp2 : std_logic;begin u1 : ym port map ( r, s, temp1 ); - 元件例化 u2 : ym port map ( t, u, temp2 ); u3 : hm port map ( temp1, temp2, v );end architecture niu;- 定义元件实体的程序文件- ym元件实体定义程序library ieee;use ym i

13、s port ( a,b : in std_logic; c : out std_logic );end entity ym;architecture ym1 of ym isbegin c = a and b;end architecture ym1;- hm元件实体定义程序library ieee;use hm is port ( a,b : in std_logic; c : out std_logic );end entity hm;architecture hm1 of hm isbegin c = a or b;end architecture hm1;单文件函数library i

14、eee;use func is port ( din1,din2 : in std_logic_vector( 0 to 3 ); dout : out std_logic_vector( 0 to 3 ) );end entity;architecture a of func is- 定义函数 function ls_xj ( d1, d2 : in std_logic_vector( 0 to 3 ) ) return std_logic_vector is variable temp : std_logic_vector( 0 to 3 ); begin temp := d1 + d2;

15、 return temp; end function;- 定义函数结束begin dout = ls_xj ( din1, din2 ); -调用函数end architecture;多文件函数- 主程序文件和定义函数的程序文件都要添加到工程中- 主程序文件,必须声明用户库文件library ieee;use - 作为用户库entity zhu_func is port ( din1,din2 : in std_logic_vector( 0 to 3 ); dout : out std_logic_vector( 0 to 3 ) );end;architecture niu of zhu_

16、func isbegin dout = ls_xj ( din1, din2 ); - 调用函数end;- 定义函数的文件library ieee;use use_func is - 声明 function ls_xj ( d1, d2: in std_logic_vector( 0 to 3 ) ) return std_logic_vector;end use_func;package body use_func is - 程序体 function ls_xj ( d1, d2 : in std_logic_vector( 0 to 3 ) ) return std_logic_vecto

17、r is variable temp : std_logic_vector( 0 to 3 ); begin temp := d1 and d2; return temp; end function;end use_func;单文件过程library ieee;use call_proce is port ( d1 : in integer range 0 to 31; d2 : in integer range 0 to 31; fout : out integer range 0 to 31 ); end;architecture a of call_proce is- 过程定义 proc

18、edure jfq ( din1, din2 : in integer range 0 to 31; dout : out integer range 0 to 31 ) is begin dout := din1 + din2; end;- 过程定义结束begin process ( d1, d2 ) variable fo : integer range 0 to 31; begin jfq ( d1, d2, fo ); - 调用过程 fout = fo; end process;end;多文件过程- 主程序文件和定义过程的程序文件都要添加到工程中- 主程序文件,必须声明用户库文件lib

19、rary ieee;use - 作为用户库entity zhu_proc is port ( d1, d2 : in integer range 0 to 31; fout : out integer range 0 to 31 ); end;architecture niu of zhu_proc isbegin process ( d1, d2 ) variable fo : integer range 0 to 31; begin jfq ( d1, d2, fo ); - 调用过程 fout = fo; end process;end;- 定义过程的文件library ieee;use

20、 use_proc is - 声明 procedure jfq ( din1 : in integer range 0 to 31; din2 : in integer range 0 to 31; dout : out integer range 0 to 31 );end use_proc;package body use_proc is - 程序体 procedure jfq ( din1, din2 : in integer range 0 to 31; dout : out integer range 0 to 31 ) is begin dout := din1 + din2; e

21、nd jfq;end use_proc;二进程moorl状态机library ieee;use moorl_1 isport ( reset : in std_logic; clock : in std_logic; din : in std_logic; dout : out std_logic_vector ( 2 downto 0 ) );end entity;architecture statemachine of moorl_1 is type state_type is ( s0, s1, s2, s3 ); signal state : state_type;begin proc

22、ess( reset, clock ) - 变换状态 begin if reset = 1 then state if din = 1 then state if din = 1 then state if din = 1 then state if din = 1 then state = s0; else state dout dout dout dout = 111; end case; end process;end;三进程moorl状态机library ieee;use moorl_2 isport ( reset : in std_logic; clock : in std_log

23、ic; din : in std_logic; dout : out std_logic_vector( 2 downto 0 ) );end entity;architecture statemachine of moorl_2 is type state_type is ( s0, s1, s2, s3 ); signal presentstate : state_type; signal nextstate : state_type;begin process ( reset, clock ) - 更新当前状态 begin if reset = 1 then presentstate =

24、 s0; elsif rising_edge ( clock ) then presentstate if din = 1 then nextstate = s1; else nextstate = s0; end if; -dout if din = 1 then nextstate = s2; else nextstate = s1; end if; -dout if din = 1 then nextstate = s3; else nextstate = s2; end if; -dout if din = 1 then nextstate = s0; else nextstate =

25、 s1; -dout dout dout dout dout = 111; end case; end process;end;二进程mealy状态机library ieee;use mealy_1 isport ( reset : in std_logic; clock : in std_logic; din : in std_logic; dout : out std_logic_vector ( 2 downto 0 ) );end entity;architecture statemachine of mealy_1 is type state_type is ( s0, s1, s2, s3 ); signal state : state_type;begin process ( reset, clock ) - 变换状态 begin if rese

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1