多路选择器VHDL

多路选择器VHDL
多路选择器的顶层电路如图所示。根据真值表,如果输入sel="01"或者sel=“10”,那么输出将等于对应的某一个输人(c=a或c=b)。然而如果输人sel="00"或者sel=“11”,那么输出将分别为0和Z(高阻)。

在这里插入图片描述

library ieee;
use ieee.std_logic_1164.all;
entity mux is
 port (
         a,b: in std_logic_vector(7 downto 0);
		 sel: in std_logic_vector(1 downto 0);
		 c:   out std_logic_vector(7 downto 0)
 
 );
 end entity;
 
 architecture example of mux is 
 begin
     process (a,b,sel)
	 begin
	   if (sel="00")then
	      c <= "00000000";
	    elsif  (sel="01")then
		   c <= a;
		elsif  (sel="10")then
		   c <= b;
	    else 
		   c<= (others => 'Z');
		end if;
    end process;
end example;

注意代码最后赋值的高阻态Z要大写,参考书上说vhdl不区分大小写,但是我用小写会报如下错误,我也不知道为什么?有懂的大佬可以解释一下。
** Error: C:/Users/CLT/Desktop/test/D_NAND.vhd(23): Enumeration literal ‘z’ is type std.STANDARD.CHARACTER; expecting type ieee.std_logic_1164.STD_LOGIC.

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值