可编逻辑电璐没计 Digital Design Using PlD 可编程逻辑电路设计教学组 二OO七年
可编程逻辑电路设计教学组 二○○七年
PLD设计的VHDL语言实现 (概述及组合逻辑部分)
Hardware Description Language(HDL) 口数字系统的描述方式 设计层次 行为描述 结构描述 系统级 算法流程图 由C四或控制器、存储器等组成的逻 辑框图 寄存器传输级(RIL) 数据流图、真值表、状态机、状态图寄存器、AL、MX、ROM等组成 的逻辑图 逻辑门级 布尔方程、真值表、卡诺图 逻辑门、触发器、锁存器等构成的逻 辑图(网表) 口HDL语言既包含一些高级程序设计语言的结构形式,也兼顾描述硬件线路 连接的构件,可以支持从系统级到门级的各个层次的行为描述和结构描述 口HDL语言基本特征是并发的(硬件的基本特征),但也提供顺序功能的描 述手段。 口HDL语言特点 ◇文本输入 令适于设计大系统表达功能,隐藏细节 令高表达效率 ◇易修改、开发周期短 ◇通用语言,模块可重用性好 口常用HDL语言:VHDL、Ⅴ erilog-HDL、AHDL
Hardware Description Language (HDL) ❑ 数字系统的描述方式 ❑ HDL语言既包含一些高级程序设计语言的结构形式,也兼顾描述硬件线路 连接的构件,可以支持从系统级到门级的各个层次的行为描述和结构描述。 ❑ HDL语言基本特征是并发的(硬件的基本特征),但也提供顺序功能的描 述手段。 ❑ HDL语言特点: ❖ 文本输入 ❖ 适于设计大系统——表达功能,隐藏细节 ❖ 高表达效率 ❖ 易修改、开发周期短 ❖ 通用语言,模块可重用性好 ❑ 常用HDL语言:VHDL、Verilog-HDL、AHDL 设计层次 行为描述 结构描述 系统级 算法流程图 由Cpu或控制器、存储器等组成的逻 辑框图 寄存器传输级(RTL) 数据流图、真值表、状态机、状态图 (表) 寄存器、ALU、MUX、ROM等组成 的逻辑图 逻辑门级 布尔方程、真值表、卡诺图 逻辑门、触发器、锁存器等构成的逻 辑图(网表)
ⅤHDL语言 a Very high speed integrated circuit HDL 口IEEE工业标准HDL语言 口可支持仿真与综合 口两个版本: 令1076-1987 ☆1076-1993
VHDL语言 ❑ Very high speed integrated circuit HDL ❑ IEEE工业标准HDL语言 ❑ 可支持仿真与综合 ❑ 两个版本: ❖ 1076-1987 ❖ 1076-1993
ⅤHDL程序结构 口1、USE定义区 ☆ Library-—定义所使用的元件库 Pack 定义所使用的元件库中的包 口2、Enty定义区:定义电路实体的ⅣO接口规格 口3、 Architecturel定义区:描述电路内部具体功能 令 Component定义区 信号定义 令行为描述/数据流描述/结构描述 ( guration定义区:决定使用哪一个 architecture 口4、 Confi
VHDL程序结构 ❑ 1、USE定义区 ❖ Library——定义所使用的元件库 ❖ Package——定义所使用的元件库中的包 ❑ 2、Entity定义区:定义电路实体的I/O接口规格 ❑ 3、Architecture定义区:描述电路内部具体功能 ❖ Component定义区 ❖ 信号定义 ❖ 行为描述/数据流描述/结构描述 ❑ 4、Configuration定义区:决定使用哪一个architecture (非必须)
Use定义区 Library ieee; 库定义 Use IEEE std logic 1164. all 包引用 Use IEEE std logic arith. all 包引用 引用语句的用法: Library , library name>; Use lib name. pack name object;
Use定义区 Library IEEE; --库定义 Use IEEE.std_logic_1164.all; --包引用 Use IEEE.std_logic_arith.all; --包引用 引用语句的用法: Library , ; Use lib_name.pack_name.object;
Packages Package is Constant Declarations Type Declarations Signal Declarations Subprogram Declarations Component Declarations Other Declarations End ; (1076-1987) End Package ; (1076-1993) Package body is Constant Declarations Type Declarations Subprogram Body End Package (1076-1987) End Package Body (1076-1993)
Packages Package is Constant Decclarations Type Declarations Signal Declarations Subprogram Declarations Component Declarations Other Declarations End ; (1076-1987) End Package ; (1076-1993) Package Body is Constant Declarations Type Declarations Subprogram Body End Package ; (1076-1987) End Package Body (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 Is generic declarations port declarations End 日 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 is generic declarations port declarations End ; ❑ 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;