2第3章VHDL基础
合集下载
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
y:out std_logic);
End nand3_gate1;
Architecture ab of nand3_gate1 is
Begin
y<=not(a and b and c);
End ab;
(程序中的英文不区分大小写)
程序结构(三输入与非门)
要求:先学会看程序结构
Begin
是该结构体名称
y<=not(a and b and c);
End ab; (程序中的英文不区分大小写)
--结构体结束
再在书中找任意程序看 程序结构
三输入与非门程序 (程序结构)
Library ieee;
Use ieee.std_logic_1164.all;
Entity nand3_gate1 is
同时学习 when else 语句
(1) 画出电路的端口信息 (2)写出电路的真值表 (3)写程序
例2:用when-else语句设计半加器
解: (1) 画出电路的端口信息 (2)写出电路的真值表 (3)写程序
(3)写程序
Library ieee;
Use ieee.std_logic_1164.all;
Begin
y<=not(a and b and c);
End ab;
(程序中的英文不区分大小写)
库与程序包 实体
结构体
书中找任意程序看 程序结构
三输入与非门程序 (程序结构)
Library ieee;
--ieee库
Use ieee.std_logic_1164.all; --ieee库中的程序包
三输入与非门程序 (程序结构)
Library ieee;
Use ieee.std_logic_1164.all;
Entity nand3_gate1 is
port(a,b,c:in std_logic;
y:out std_logic);
End nand3_gate1;
Architecture ab of nand3_gate1 is
Begin
y<=not(a and b and c);
End ab;
Architecture语句 下必须有begin 程序格式
Begin后面的语 句表示电路的逻
辑功能
结构体(三输入与非门程序)
Architecture ab of nand3_gate1 is
Begin
y<=not(a and b and c);
Entity nand3_gate1 is port(a,b,c:in std_logic;
--实体开始,nand3_gate1
是该实体名称
y:out std_logic);
End nand3_gate1;
--实体结束
Architecture ab of nand3_gate1 is --结构体开始, ab
b、真值表(truth table)
Y ABC
A BC Y 0 0 01 0 0 11 0 1 01 0 1 11 1 0 01 1 0 11 1 1 01 1 1 10
c、逻辑符号
1、三输入端与非门
b、真值表(truth table)
A BC Y 0 0 01 0 0 11 0 1 01 0 1 11 1 0 01 1 0 11 1 1 01 1 1 10
结束。
Begin后面的语 句表示电路的逻
辑功能
练习(学会编写程序)
用VHDL语言编写异或门程序 (1) (2) (3)
练习(学会编写程序)
用VHDL语言编写半加器 (1) (2) (3)
设计2选1数据选择器
(1) 画出电路的端口信息 (2)写出电路的真值表 (3)写程序
库与程序包 实体
结构体
给定程序,学会看程序结构(要求1)
程序结构有几个组成部分? 库与程序包 实体 结构体
典型的组合逻辑电路(复习)
编码器 译码器 数据选择器 加法器 数值比较器 奇偶校验电路
2选1数据选择器
给出2选1数据选择器的VHDL程序 加深对程序结构的理解
Begin
y<=a when s= End ab;
端口数据类型 bit , std_logic 端口数据类型为 Bit 时,程序结构: 实体+结构体
端口数据类型为 std_logic 时,程序结构: 库与程序包+实体+结构体
端口数据类型:bit Bit的取值 ‘0’ 或‘1’ Bit数据类型能否模拟所有的电路状况? 电路出现故障时? 端口数据类型: std_logic(P69) 9种取值,与实际电路相接近
实体:描述电路端口信息 结构体 描述电路功能
实体(三输入与非门程序)
Entity nand3_gate1 is
port(a,b,c:in std_logic;
y:out std_logic);
End nand3_gate1;
实体(三输入与非门程序)
Entity nand3_gate1 is
端口数据类型不同,程序结构不同
一、程序结构
端口数据类型:bit
std_logic
端口数据类型不同,程序结构不同
小结
掌握了写VHDL程序的步骤(思维过程)
掌握了 语句(when else 语句)
掌握了 至少两个电路
例3:用VHDL语言编写4选1数据选择器程序
4选1数据选择器(when else)
Entity nand3_gate1 is
port(a:in std_logic;
b:in std_logic;
端口信号名称
c:in std_logic;
y:out std_logic);
端口模式
End nand3_gate1;
端口数据类型
结构体
结构体 描述电路功能
结构体(三输入与非门程序)
‘0’;
End ab;
(程序中的英文不区分大小写)
要求掌握的知识点
端口数据类型 VHDL程序由几个部分组成? 端口模式 端口信号名起名的规则 文件存盘名是什么?有没有规定?
when else 语句 关系表达式
Std_logic 库与程序包+实体+结构体
Entity hadd1 is
port(a,b:in std_logic;
s,c:out std_logic);
End hadd1;
Architecture ab of hadd1 is
Begin
s<=‘0’ when a=b else
‘1’;
c<=‘1’ when (a=‘1’ and b=‘1’) else
Architecture ab of nand3_gate1 is
Begin
y<=not(a and b and c);
指明是哪个实 体的结构体
End ab;
结构体开始 的关键字
结构体的名 称
结构体(三输入与非门程序)
Architecture ab of nand3_gate1 is
Begin
y<=a when s=‘0’ else
b;
End ab;
学会编写程序(要求2)
用VHDL语言编写三输入端与非门 在编写此程序(第一个)时,学习编写程序
的方法,学习程序中的细节 (1) 画出电路的端口信息 (2)写出电路的真值表 (3)写程序
这里要求教师板书
In out (C的规则) 文件存盘名必须是实体名。实体名尽量与电
路的功能符合,便于以后使用 第9章、第10章目录 P331
P63
Entity mux21a is
port(a,b,s:in bit;
y:out bit);
End mux21a;
Architecture ab of mux21a is
Library ieee;
Use ieee.std_logic_1164.all;
Entity mux41a is
port(s0,s1:in std_logic;
d0,d1,d2,d3:in std_logic;
y:out std_logic);
End mux41a ;
Architecture ab of mux41a is
同时请同学们跟着教师,在笔记上练习写程 序
画出电路的端口信息
写出电路的真值表
A BC
Y
000
1
001
1
010
1
011
1
100
1
101
1
110
1
111
0
写程序
写程序时要记得 程序结构
程序结构中的 实体:对应 电路端口信息
实体由 端口信号名称 端口模式 端口数据类型 构成
程序结构中的 结构体 对应 真值表
End ab;
此处的逻辑功能 是用逻辑函数表 达式表示的
Begin后面的语 句表示电路的逻
辑功能
结构体(三输入与非门程序)
Architecture ab of nand3_gate1 is
Begin
y<=not(a and b and c);
End ab;
逻辑功能结束 Architecture语句
Begin
y<=d0 when (s0=‘0’ and s1=‘0’) else
port(a,b,c:in std_logic;
y:out std_logic);
End nand3_gate1;
Architecture ab of nand3_gate1 is
Begin
y<=not(a and b and c);
End ab;
(程序中的英文不区分大小写)
端口数据类型
End nand3_gate1;
端口模式
端口
3根输入端名称
实体(三输入与非门程序)
Entity nand3_gate1 is
port(a,b,c: in std_logic;
y: out std_logic);
End nand3_gate1;
端口数据类型
端口
1根输出端名称
第三章 VHDL设计初步
一、程序结构 二、语句 三、端口信号数据类型
组合逻辑电路
四、时序逻辑电路
3.1 组合逻辑电路的设计(复习)
组合逻辑电路的最小单元是门电路
与门,或门,非门 与非门,或非门,异或门,与或非门 三态门,OC门
1、三输入端与非门
a、逻辑函数表达式
Library ieee;
Use ieee.std_logic_1164.all;
Entity mux21b is
port(a,b,s:in std_logic;
y:out std_logic);
End mux21b;
Architecture ab of mux21b is
端口模式
实体(三输入与非门程序)
Entity nand3_gate1 is
port(a,b,c:in std_logic;
y:out std_logic);
End nand3_gate1;
端口结束
实体结束
实体名称
一条语句的结束标志是 ;
实体(三输入与非门程序)
三输入与非门程序的实体还可以写成:
逻辑功能的描述有:
逻辑函数表达式 真值表 逻辑符号
学习新语句(要求3)
现在想学习 根据真值表 写程序 不写表达式 必须学习VHDL语言中的新的语句
新语句用在哪里?
新语句 用在结构体中的电路逻辑功能的描述上
整个程序框架,用VHDL编写电路的方法 不变
例1:设计2选1数据选择器
port(a,b,c:in std_logic;
y:out std_logic);
End nand3_gate1;
实体开始 的关键字
实体名称,也是程 序的存盘名
实体(三输入与非门程序)
Entity nand3_gate1 is
port(a,b,c: in std_logic;
y:out std_logic);
3.1 组合逻辑电路的VHDL描述
1、三输入端与非门 下面给出“三输入端与非门”的VHDL程序
三输入与非门VHDL程序
Library ieee;
Use ieee.std_logic_1164.all;
Entity nand3_gate1 is
port(a,b,c:in std_logic;