Upload
traci
View
182
Download
13
Embed Size (px)
DESCRIPTION
§ 3.9 基本逻辑电路设计. 基本逻辑电路: 组合逻辑电路、 时序逻辑电路 一 组合逻辑电路设计 简单门电路、编码器、译码器、 加法器、多路选择器、三态门等。. 1 、基本门电路. 2 、编码器 设计一个 8 输入优先级编码器, y0 级别最低, y7 级别最高;输出为 3 位编码。. 方法 1 : 利用 if 多选择语句自顶向下的优先特性. 方法 2 : 进程内为顺序语句,最先描述优先级最低, 最后描述优先级最高,可实现优先级编码。. 方法 3 :利用条件赋值语句 - PowerPoint PPT Presentation
Citation preview
1
基本逻辑电路: 组合逻辑电路、 时序逻辑电路
一 组合逻辑电路设计 简单门电路、编码器、译码器、 加法器、多路选择器、三态门等。
§3.9 基本逻辑电路设计
2
1 、基本门电路
3
2 、编码器 设计一个 8 输入优先级编码器, y0 级别最低,y7 级别最高;输出为 3 位编码。
Y7=1 Vec=111
Y6=1 Vec=110
Y5=1 Vec=101
Y4=1 Vec=100
Y3=1 Vec=011
Y2=1 Vec=010
Y1=1 Vec=001
Y0=1 Vec=000
4
方法 1:利用 if 多选择语句自顶向下的优先特性
5
方法 2:进程内为顺序语句,最先描述优先级最低, 最后描述优先级最高,可实现优先级编码。
6
方法 3:利用条件赋值语句 architecture behavior of priority is begin vec <= “111” when y7 = ‘1’ else “110” when y6 = ‘1’ else “101” when y5 = ‘1’ else “100” when y4 = ‘1’ else “011” when y3 = ‘1’ else “010” when y2 = ‘1’ else “001” when y1 = ‘1’ else “000” when y0 = ‘1’ else “XXX”; end behavior;
7
3 、译码器 译码器是编码器的逆过程。如 3-8 译码器:
sel=000 Y=00000001
sel =001 Y=00000010
sel =010 Y=00000100
sel =011 Y=00001000
sel =100 Y=00010000
sel =101 Y=00100000
sel =110 Y=01000000
sel =111 Y=10000000
8
方法 1:使用逻辑左移运算符 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity decoder is port(inp : in std_logic_vector(2 downto 0); outp : out std_logic_vector(7 downto 0)); end decoder;
architecture rtl of decoder is begin outp<=“00000001” sll(conv_integer(inp)); end rtl;
9
方法 2:使用 process 语句 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity decoder is port(inp : in std_logic_vector(2 downto 0); outp : out std_logic_vector(7 downto 0)); end decoder; architecture rtl of decoder is begin process(inp) begin outp<=(others=>’0’); outp(conv_integer(inp))<=‘1’; end process; end rtl;
10
方法 3:使用 case 语句实现。
11
译码输出低有效
12
方法 4:使用条件赋值语句
13
3-8 译码器仿真结果:
译码输出低有效
14
4 、加法器 带进位的 4位加法器符号如下:
Sum(i) = a(i) b(i) cin
C(i+1) = a(i) b(i) +((a(i) + b(i) ) c(i)
15
方法 1:用 for – loop 语句实现
16
方法 2:直接使用加法“ +”函数:
17
加法器仿真结果:
18
5 、多路选择器
前面用 if 语句、 case 语句、条件赋值语句、选择赋值语句分别描述过 4选 1选择器。
6 、三态门及总线缓冲器 VHDL 语言通过指定大写的 Z值表示高阻状态 a : std_logic; a_bus:std_logic_vector(7 downto 0); 指定高阻状态如下: a <= ‘Z’ ; a_bus <= “ZZZZZZZZ” ;
19
1 )三态门电路描述
20
三态门仿真结果:
21
2 )单向总线缓冲器
22
3 )双向总线缓冲器
23
二 时序逻辑电路设计 触发器、寄存器、计数器、分频器、信号发生器等。
一)时序电路特殊信号的描述 时钟信号和复位信号
1 、时钟信号描述 常用的描述方式: 1 )进程的敏感信号是时钟信号,在进程内 部用 if 语句描述时钟的边沿条件。
24
如: process (clock_signal) begin if (clock_edge_condition) then signal_out <= signal_in ; ┇ 其它时序语句 ┇ end if ; end process ;
25
2 )在进程中用 wait until 语句描述时钟信号,此
时进程将没有敏感信号。 如: process begin wait until (clock_edge_condition); signal_out <= signal_in ; ┇ 其它时序语句 ┇ end process ;
26
注意: a.在对时钟边沿说明时,一定要注明是上升沿 还是下降沿。 b.一个进程中只能描述一个时钟信号。 c.wait until 语句只能放在进程的最前面或 最后面。
3)时钟边沿的描述 时钟上升沿: (clock’event and clock = ‘1’) 时钟下降沿: (clock’event and clock = ‘0’)
27
2 、触发器的复位信号描述 1 )同步复位:在只有以时钟为敏感信号的进程 中定义。 如: process (clock_signal) begin if (clock_edge_condition) then if (reset_condition) then signal_out <= reset_value; else signal_out <= signal_in ; ┇ end if ; end if ; end process ;
28
2 )异步复位:进程的敏感信号表中除时钟信 号外,还有复位信号。 如: process (reset_signal, clock_signal) begin if (reset_condition) then signal_out <= reset_value; elsif (clock_edge_condition) then signal_out <= signal_in ; ┇ end if ; end process ;
29
二 ) 常用时序电路设计 1 、触发器( Flip_Flop ) 1 ) D触发器
30
异步置位 /复位 D触发器
31
同步复位 D触发器
32
比较:异步置位的锁存器( Latch )
33
library ieee; use ieee.std_logic_1164.all;
entity t_ff is port(t, clk : in std_logic; q : buffer std_logic); end t_ff;
architecture rtl of t_ff is begin process(clk) begin if clk’event and clk=‘1’ then if t=‘1’ then q<=not q; else q<=q; end if; end process; end rtl;
T
Clk
Q
Q
2 ) T触发器
34
library ieee; use ieee.std_logic_1164.all; entity rs_ff is port(r, s, clk : in std_logic; q, qn : buffer std_logic); end rs_ff; architecture rtl of rs_ff is begin
process(r, s, clk) begin if clk’event and clk=‘1’ then if s = ‘1’ and r = ‘0’ then q<=‘0’; qn<=‘1’; elsif s=‘0’ and r=‘1’ then q<=‘1’; qn<=‘0’; elsif s=‘0’ and r=‘0’ then q<=q; qn<=q n; else null; end if; end if; end process; end rtl;
S
Clk
Q
QR
S R Q Qn
0 0 Q Qn
0 1 1 0
1 0 0 1
1 1 Ø Ø
3 ) RS 触发器
35
2 、寄存器 8 位串行输入、串行输出移位寄存器:
z0 z1 z2 z3 z4 z5 z6 z7 z8
36
8 位移位寄存器描述(结构描述)
37
8 位移位寄存器直接用信号连接描述
38
移位寄存器仿真结果:
39
3 、计数器
计数器分为:同步计数器 异步计数器
( 1)同步计数器
同步计数器指在时钟脉冲(计数脉冲)的控
制下,构成计数器的各触发器状态同时发生变化
的计数器。
40
带允许端的十二进制计数器
41
可逆计数器(加减计数器)
42
可逆计数器仿真结果:
43
例:六十进制(分、秒)计数器
44
45
60 进制计数器仿真结果:
46
( 2)异步计数器
异步计数器又称为行波计数器,它的低位计数器的输出作为高位计数器的时钟信号。
异步计数器采用行波计数,使计数延迟增加,计数器工作频率较低。
描述异步计数器与同步计数器的不同主要体现在对各级时钟脉冲的描述上。
47
例:由 8个触发器构成的行波计数器:
48
基本元件 dffr 的描述:
49
采用元件例化描述 8位行波计数器 :
50
8 位行波计数器仿真结果:
51
4 、序列信号发生器、检测器 1 )“ 01111110”序列发生器
52
53
仿真结果:
54
2 )序列信号检测器,检测“ 01111110”
55
56
57
58
简洁的序列信号检测器:
59
60
三 存储器设计1 、 ROM
61
62
2 、 SRAM
63
64
仿真结果:
65
第 3章 习题四 1 、给触发器复位的方法有哪两种?如果时钟进程 中用了敏感信号表,哪种复位方法要求把复位 信号放在敏感信号表中? 2 、设计一个任意 n 分频的分频器。 3 、设计一个用于时钟(分、秒)计数的 60 进制 的计数器(分个、十位)。 4 、设计一个用于时钟(小时)计数的 24 进制的 计数器(分个、十位)。 5 、给定一个参考晶振频率 f = 1MHz,设计一个 数字电子表。