您好,欢迎来到99网。
搜索
您的当前位置:首页选1多路选择器

选1多路选择器

来源:99网
EDA实验二4选1多路选择器设计实验

一、实验目的

进一步熟悉 QuartusII 的 VHDL 文本设计流程、 组合电路的设计仿真和测试。

二、实验内容

实验内容一:根据4.1流程,利用 QuartusII 完成四选一多路选择器的文本 编辑输入和仿

真测试等步骤,给出仿真波形。

实验内容二:对 VHDL 不同描述方式的四选一多路选择器进行硬件实验, 比较他们的特

性。

三、实验记录

1. when-else语句设计的4选1多路选择器

a).利用when-else语句的vhdl程序 library ieee;

use ieee.std_logic_11.all; entity mux41a is port(

a,b,c,d,s0,s1:in std_logic; y:out std_logic); end entity mux41a;

architecture one of mux41a is begin

y<= a when s0='0' and s1='0' else b when s0='1' and s1='0' else c when s0='0' and s1='1' else d;

end architecture one; 备注

以上是when-else语句设计的4选1多路选择器的vhdl描述。程序中应该注意的有以下几点

A. 一:实体的命名要和工程名相同,并且不能是中文的或者以数字开头; B. 二:when-else语句具有最高赋值优先级;

b).when-else语句设计的4选1多路选择器的RTL图

图(1)when-else语句设计的4选1多路选择器的RTL图 c).when-else语句设计的4选1多路选择器的时序仿真波形图

图(2)when-else语句设计的4选1多路选择器的时序仿真波形图

d).when-else语句设计的4选1多路选择器功能仿真波形图

图(3)when-else语句设计的4选1多路选择器功能仿真波形图

2. if-then语句设计的4选1多路选择器

a).利用when-else语句的vhdl程序 library ieee;

use ieee.std_logic_11.all; entity mux41b is port(

a,b,c,d,s0,s1:in std_logic;

y:out std_logic); end entity mux41b;

architecture one of mux41b is begin

process (a,b,c,d,s0,s1) begin

if s0='0' and s1='0' then y<= a;end if; if s0='1' and s1='0' then y<= b;end if; if s0='0' and s1='1' then y<= c;end if; if s0='1' and s1='1' then y<= d;end if; end process;

end architecture one;

备注:

以上是if—then语句设计的4选1多路选择器的vhdl描述。值得注意以下几点: A. 程序开头应该包含std_logic_11.all这个程序库包添加进去(由于在定义端口是端口号

的类型为std_logic);

B. 进程语句应该将能够导致本进程启动的信号加到进程后的敏感信号表中,这能才能使得

进程更加具有一般意义;

C. 每一条的if-then语句后都应该以endif结束;

b).if-then语句设计的4选1多路选择器的RTL图

图(4)if-then语句设计的4选1多路选择器的RTL图

`

c).if-then语句设计的4选1多路选择器的时序仿真波形图

图(5)if-then语句设计的4选1多路选择器的时序仿真波形图

d).if-then语句设计的4选1多路选择器的功能仿真波形图

图(6)if-then语句设计的4选1多路选择器的功能仿真波形图

3. case语句设计的4选1多路选择器

a).利用case语句的vhdl程序 library ieee;

use ieee.std_logic_11.all; entity mux41d is port(

a,b,c,d,s0,s1:in std_logic; y:out std_logic); end entity mux41d;

architecture one of mux41d is

signal s:std_logic_vector(1 downto 0); begin

s <= s0 & s1; process(s) begin case s is

when \"00\" => y<= a; when \"10\" => y<= b; when \"01\" => y<= c; when \"11\" => y<= d; when others =>null; end case; end process;

end architecture one;

b).case语句设计的4选1多路选择器的RTL图

图(7)case语句设计的4选1多路选择器的RTL图

c).case语句设计的4选1多路选择器的时序仿真图

图(8)case语句设计的4选1多路选择器的时序仿真图

d).case语句设计的4选1多路选择器的功能仿真图

图(9)case语句设计的4选1多路选择器的功能仿真图

实验总结

一、通过上面的三种不同vhdl语言的描述的4选1多路选择器的仿真结果可以看出,在相

同的输入信号的条件下,实验的结果是相同的。 二、对比与功能仿真与时序仿真,我们可以看出功能仿真是一种理想的实验结果,而时序仿

真却存在这毛刺现象。这就是逻辑电路存在的竞争冒险等原因引起的毛刺现象。

三、对比三种不同vhdl语言的描述,其RTl图也存在这不同。由于if—then采用了进程语

句,所以RTl图与when—else语句描述时的RTl图有逻辑上的一点不同,但是大致框架相似。而case语句描述的4选1多路选择器的RTL图就存在这很大的不同。

四、单从RTL视图来看,二者综合后的结果是有明显区别的。If…else趋向于有优先级的结

构,而case则是并行的结构。

但是我们可以从以下两个方面来对比if-then描述和case描述;  它们所占用的资源

If-then结构的资源占用 Total logic elements 2 / 10,570 ( < 1 % ) -- Combinational with no register 2 -- Register only 0 -- Combinational with a register 0 Logic element usage by number of LUT inputs -- 4 input functions 2 -- 3 input functions 0 -- 2 input functions 0 -- 1 input functions 0 -- 0 input functions 0 Logic elements by mode -- normal mode 2 -- arithmetic mode 0 -- qfbk mode 0 -- register cascade mode 0 -- synchronous clear/load mode 0 -- asynchronous clear/load mode 0 Total registers 0 / 12,506 ( 0 % ) I/O pins 7 / 336 ( 2 % ) Maximum fan-out node s0 Maximum fan-out 2 Total fan-out 9 Average fan-out 0.90

备注:

从上面可以看出,二者资源占用的情况基本是完全一样。

Case结构的资源占用 Total logic elements 2 / 10,570 ( < 1 % ) -- Combinational with no register 2 -- Register only 0 -- Combinational with a register 0 Logic element usage by number of LUT inputs -- 4 input functions 2 -- 3 input functions 0 -- 2 input functions 0 -- 1 input functions 0 -- 0 input functions 0 Logic elements by mode -- normal mode 2 -- arithmetic mode 0 -- qfbk mode 0 -- register cascade mode 0 -- synchronous clear/load mode 0 -- asynchronous clear/load mode 0 Total registers 0 / 12,506 ( 0 % ) I/O pins 7 / 336 ( 2 % ) Maximum fan-out node s0 Maximum fan-out 2 Total fan-out 9 Average fan-out 0.90  再看他们的Technology Map Viewer

If-then结构的Technology Map Viewer

图(10)If-then结构的Technology Map Viewer

Case结构的Technology Map Viewer

图(11)Case结构的Technology Map Viewer

备注:

上面两者完全一致,所以我们可以看出,虽然RTL图两者是不同的,但是他们的实现都是并行的,而且完全一致。

通过查阅相关资料知道,这样的结果是由于软件升级的同时,if-then和case语句机构的优化也随着软件升级,已经不再简单的交给用户的代码来决定,而是默认优化了。

(本实验的结果是本人在quartus II 9.1上运行得出的结果。)

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 99spj.com 版权所有 湘ICP备2022005869号-5

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务