VHDL——74LS138译码器

1.功能描述

功能描述:该3-8译码器有六个输入端:S1,S2,S3为控制信号,a0,a1,a2为三个输入信号。一个输出端口y为八位总线,表示译码结果。

2.真值表

3.VHDL语言
3.1case语句

library ieee;
use ieee.std_logic_1164.all;

entity decode38 is
    port(a,b,c,g1,g2a,g2b : in std_logic;
	     y : out std_logic_vector(7 downto 0));
end decode38;

architecture rtl of decode38 is
signal indata : std_logic_vector(2 downto 0);
begin
    indata <= c&b&a;
process(indata,g1,g2a,g2b)
begin
    if(g1 = '1' and g2a = '0' and g2b = '0')then
	 case indata is
	 when "000" => y <= "11111110";
	 when "001" => y <= "11111101";
	 when "010" => y <= "11111011";
	 when "011" => y <= "11110111";
	 when "100" => y <= "11101111";
	 when "101" => y <= "11011111";
	 when "110" => y <= "10111111";
	 when "111" => y <= "01111111";
	 when others => y <= null;      --输入其他数据,y指向空
	 end case;
    else
	 y <= "11111111";
	 end if;
end process;
end rtl;
	 

3.2if语句

library ieee;
use ieee.std_logic_1164.all;

entity decode38 is
    port(a,b,c,g1,g2a,g2b : in std_logic;
	     y : out std_logic_vector(7 downto 0));
end decode38;

architecture rtl of decode38 is
signal indata : std_logic_vector(2 downto 0);
begin
    indata <= c&b&a;
process(indata,g1,g2a,g2b)
begin
    if(g1 = '1' and g2a = '0' and g2b = '0')then
	   if(indata = "000") then y <= "11111110";
	   elsif(indata = "001") then y <= "11111101";
	   elsif(indata = "010") then y <= "11111011";
	   elsif(indata = "011") then y <= "11110111";
	   elsif(indata = "100") then y <= "11101111";
	   elsif(indata = "101") then y <= "11011111";
	   elsif(indata = "110") then y <= "10111111";
	   elsif(indata = "111") then y <= "01111111";
	   else
	   y <= null;
	   end if;
    else
	 y <= "11111111";
	 end if;
end process;
end rtl;
	 
  • 4
    点赞
  • 55
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

364.99°

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值