选多路选择器 部门: xxx 时间: xxx
整理范文,仅供参考,可下载自行编辑EDA实验二4选1多路选择器设计实验 一、实验目的 进一步熟悉 QuartusII 的 VHDL 文本设计流程、 组合电路的设计仿真和测试。 二、实验内容 实验内容一:根据4.1流程,利用 QuartusII 完成四选一多路选择器的文本 编辑输入和仿真测试等步骤,给出仿真波形。 b5E2RGbCAP 实验内容二:对 VHDL 不同描述方式的四选一多路选择器进行硬件实验, 比较他们的特性。 三、实验记录 1. when-else语句设计的4选1多路选择器 a>.利用when-else语句的vhdl程序 library ieee。 use ieee.std_logic_1164.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_1164.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描述。值得注意以下几点: 程序开头应该包含std_logic_1164.all这个程序库包添加进去<由于在定义端口是端口号的类型为std_logic);p1EanqFDPw 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_1164.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多路选择器的仿真结果可以看出,在相同的输入信号的条件下,实验的结果是相同的。DXDiTa9E3d 二、 对比与功能仿真与时序仿真,我们可以看出功能仿真是一种理想的实验结果,而时序仿真却存在这毛刺现象。这就是逻辑电路存在的竞争冒险等原因引起的毛刺现象。RTCrpUDGiT 三、 对比三种不同vhdl语言的描述,其RTl图也存在这不同。由于if—then采用了进程语句,所以RTl图与when—else语句描述时的RTl图有逻辑上的一点不同,但是大致框架相似。而case语句描述的4选1多路选择器的RTL图就存在这很大的不同。5PCzVD7HxA 单从RTL视图来看,二者综合后的结果是有明显区别的。If…else趋向于有优先级的结构,而case则是并行的结构。jLBHrnAILg 但是我们可以从以下两个方面来对比if-then描述和case描述; 它们所占用的资源
xHAQX74J0X 备注: 从上面可以看出,二者资源占用的情况基本是完全一样。
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
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 再看他们的Technology Map Viewer If-then结构的Technology Map Viewer
图<10)If-then结构的Technology Map Viewer Case结构的Technology Map Viewer
图<11)Case结构的Technology Map Viewer 备注: 上面两者完全一致,所以我们可以看出,虽然RTL图两者是不同的,但是他们的实现都是并行的,而且完全一致。LDAYtRyKfE 通过查阅相关资料知道,这样的结果是由于软件升级的同时,if-then和case语句机构的优化也随着软件升级,已经不再简单的交给用户的代码来决定,而是默认优化了。Zzz6ZB2Ltk