VHDL程序设计3案例

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
3
方法1:利用 if 多选择语句自顶向下的优先特性
Y7=1 Y6=1 Y5=1 Y4=1 Y3=1 Y2=1 Y1=1 Y0=1
Vec=111 Vec=110 Vec=101 Vec=100 Vec=011 Vec=010 Vec=001 Vec=0400
方法2:进程内为顺序语句,最先描述优先级最低, 最后描述优先级最高,可实现优先级编码。
§3.9 基本逻辑电路设计
基本逻辑电路: 组合逻辑电路、 时序逻辑电路
一 组合逻辑电路设计 简单门电路、编码器、译码器、 加法器、多路选择器、三态门等。
1
1、基本门电路
2
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
13
方法1:用for – loop语句实现
14
方法2:直接使用加法“+”函数:
位宽扩展
15
加法器仿真结果:
16
5、多路选择器
前面用 if 语句、case 语句、条件赋值语 句、选择赋值语句分别描述过4选1选择器。
6、三态门
VHDL语言通过指定大写的Z值表示高阻状态 a : std_logic; a_bus:std_logic_vector(7 downto 0);
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));
begin
outp<=shl(“00000001”, inp);
end rtl;
Y=00000001 Y=00000010 Y=00000100 Y=00001000 Y=00010000 Y=00100000 Y=01000000 Y=10000000
8
方法2:使用process语句
library ieee;
Y7=1 Y6=1 Y5=1 Y4=1 Y3=1 Y2=1 Y1=1 Y0=1
Vec=111 Vec=110 Vec=101 Vec=100 Vec=011 Vec=010 Vec=001 Vec=000
5
方法3:利用条件赋值语句
6
3、译码器
译码器是编码器的逆过程。如 3-8 译码器:
sel=000 sel =001 sel =010 sel =011 sel =100 sel =101 sel =110 sel =111
22
注意: a.在对时钟边沿说明时,一定要注明是上升沿 还是下降沿。 b.一个进程中只能描述一个时钟信号。 c.wait until 语句只能Leabharlann Baidu在进程的最前面或 最后面。
3)时钟边沿的描述 时钟上升沿: (clock’event and clock = ‘1’) 时钟下降沿: (clock’event and clock = ‘0’)
end decoder; architecture rtl of decoder is begin
process(inp) begin
outp<=(others=>’0’); outp(conv_integer(inp))<=‘1’; end process; end rtl;
sel=000 sel =001 sel =010 sel =011 sel =100 sel =101 sel =110 sel =111
20
如: process (clock_signal) begin if (clock_edge_condition) then signal_out <= signal_in ; ┇ 其它时序语句 ┇ end if ; end process ;
21
2)在进程中用wait until语句描述时钟信号,此 时进程将没有敏感信号。 如: process begin wait until (clock_edge_condition); signal_out <= signal_in ; ┇ 其它时序语句 ┇ end process ;
sel =100 sel =101 sel =110 sel =111
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
Y=00000001 Y=00000010 Y=00000100 Y=00001000 Y=00010000 Y=00100000 Y=01000000 Y=10000000
9
方法3:使用 case 语句实现。
10
11
方法4:使用条件赋值语句
12
4、加法器
带进位的 4位加法器符号如下:
Sum(i) = a(i) b(i) cin C(i+1) = a(i) b(i) +((a(i) + b(i) ) c(i)
Y=00000001 Y=00000010 Y=00000100 Y=00001000 Y=00010000 Y=00100000 Y=01000000 Y=10000000
7
方法1:使用逻辑左移运算符
sel=000 sel =001
sel =010
sel =011
library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;
指定高阻状态如下: a <= ‘Z’ ; a_bus <= “ZZZZZZZZ” ;
17
三态门电路描述
18
三态门仿真结果:
19
二 时序逻辑电路设计
触发器、寄存器、计数器、分频器、信号发 生器等。
一)时序电路特殊信号的描述 时钟信号和复位信号
1、时钟信号描述 常用的描述方式: 1)进程的敏感信号是时钟信号,在进程内 部用if 语句描述时钟的边沿条件。
相关文档
最新文档