Use定义区 Library ieee; 库定义 Use IEEE std logic 1164. all 包引用 Use IEEE std logic arith. all 包引用 引用语句的用法: Library <library name>, library name>; Use lib name. pack name object;
Use定义区 Library IEEE; --库定义 Use IEEE.std_logic_1164.all; --包引用 Use IEEE.std_logic_arith.all; --包引用 引用语句的用法: Library <library_name>,<library_name> ; Use lib_name.pack_name.object;
Packages Package <Package name> is Constant Declarations Type Declarations Signal Declarations Subprogram Declarations Component Declarations Other Declarations End <package name>; (1076-1987) End Package <package name>; (1076-1993) Package body <Package name>is Constant Declarations Type Declarations Subprogram Body End Package <package name> (1076-1987) End Package Body <Package name> (1076-1993)
Packages Package <Package_name> is Constant Decclarations Type Declarations Signal Declarations Subprogram Declarations Component Declarations Other Declarations End <package_name> ; (1076-1987) End Package <package_name>; (1076-1993) Package Body <Package_name> is Constant Declarations Type Declarations Subprogram Body End Package <package_name>; (1076-1987) End Package Body <Package_name> (1076-1993)
Package Example package package example is type life is(sleeping, working, eating, entertaiment, otheractions); subtype uint 4 is integer range 0 to 15 subtype uint is integer range 0 to 31 function compare(a, b: integer) return boolean; end package exampl package body package_ example is function compare(a, b: integer) return boolean is variable temp: boolean; gI In if a<b then temp - true else temp: =false end if return tem end compare end package example
Package Example package package_example is type life is (sleeping, working, eating, entertaiment, otheractions); subtype uint4 is integer range 0 to 15; subtype uint5 is integer range 0 to 31; function compare(a, b: integer) return boolean; end package_example; package body package_example is function compare(a,b: integer) return boolean is variable temp:boolean; begin if a<b then temp:=true; else temp:=false; end if; return temp; end compare; end package_example;
Libraries 口包括一系列的 packages 口隐含 Libraries:不用声明,自动引用 ☆STD: Standard定义bit, Boolean, Integer,rel和time以及支持它们的运算符。 Textio:定义文件操作。 ☆Work: ☆IEEE Std logic 1164 Std logic arith Std logic signed Std logic unsigned 其它库 Altera的元件库 用户自定义库
Libraries ❑ 包括一系列的packages ❑ 隐含Libraries: 不用声明,自动引用 ❖ STD: – Standard:定义bit, Boolean, integer, real和time以及支持它们的运算符。 – Textio:定义文件操作。 ❖ Work: ❖ IEEE: – Std_logic_1164 – Std_logic_arith – Std_logic_signed – Std_logic_unsigned ❖ 其它库: – Altera的元件库 – 用户自定义库
Entity(实体) 口Enty定义语法 Entity <entity name> Is generic declarations port declarations End <Entity name> 日 Entity example Entity adder is generic( data width: integer: =4); add a, add b: in std logic vector(data width-1 downto 0) sum: out std logic vector(data width downto 0)) End adder
Entity(实体) ❑ Entity定义语法 Entity <Entity_name> is generic declarations port declarations End <Entity_name>; ❑ Entity Example Entity adder is generic(data_width:integer:=4 ); port( add_a, add_b: in std_logic_vector(data_width-1 downto 0); sum: out std_logic_vector(data_width downto 0) ); End adder;