Chinaunix首页 | 论坛 | 博客
  • 博客访问: 404425
  • 博文数量: 105
  • 博客积分: 4100
  • 博客等级: 上校
  • 技术积分: 1040
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-27 19:57
文章存档

2012年(1)

2011年(9)

2010年(4)

2009年(25)

2008年(66)

我的朋友

分类:

2008-07-28 10:17:59

 

38译码器的几种描述方法

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity decoder38 is
port (Q0: out std_logic_vector(7 downto 0);
   Q1: in std_logic_vector(2 downto 0);
   en: in std_logic);
end entity decoder38;
-----the num.1 method to descript
architecture code1 of decoder38 is
 begin
 process(Q1,en)
 variable temp : std_logic_vector(7 downto 0);
 begin
  if en = '1' then temp := "ZZZZZZZZ";---"en" is effective on low voltage;
   else
    case Q1 is
     when "000" => temp := "00000001";
     when "001" => temp := "00000010";
     when "010" => temp := "00000100";
     when "011" => temp := "00001000";
     when "100" => temp := "00010000";
     when "101" => temp := "00100000";
     when "110" => temp := "01000000";
     when "111" => temp := "10000000";
    end case;
  end if;
  Q0 <= temp;
 end process;
end architecture code1;

----the num.2 method to descript
architecture code2 of decoder38 is
 begin
 process(Q1,en)
  variable temp : std_logic_vector(7 downto 0);
  begin
  if en = '1' then temp := "ZZZZZZZZ";
   else
    temp(0) := (not Q1(2)) and (not Q1(1)) and (not Q1(0));
    temp(1) := (not Q1(2)) and (not Q1(1)) and Q1(0);
    temp(2) := (not Q1(2)) and  Q1(1) and (not Q1(0));
    temp(3) := (not Q1(2)) and  Q1(1) and Q1(0);
    temp(4) := Q1(2) and (not Q1(1)) and (not Q1(0));
    temp(5) := Q1(2) and (not Q1(1)) and Q1(0);
    temp(6) := Q1(2) and Q1(1) and (not Q1(0));
    temp(7) := Q1(2) and Q1(1) and Q1(0);
  end if;
 Q0 <= temp;
 end process;
end architecture code2;

----the num.3 mothed to descript
architecture code3 of decoder38 is
 begin
  process(Q1,en)
   variable temp : std_logic_vector(7 downto 0);
   begin
   if (en = '1') then temp := "ZZZZZZZZ";
    elsif (Q1 = "000") then temp := "00000001";
    elsif (Q1 = "001") then temp := "00000010";
    elsif (Q1 = "010") then temp := "00000100";
    elsif (Q1 = "011") then temp := "00001000";
    elsif (Q1 = "100") then temp := "00010000";
    elsif (Q1 = "101") then temp := "00100000";
    elsif (Q1 = "110") then temp := "01000000";
         else temp := "10000000";
   end if;
   Q0 <= temp;
  end process;
end architecture code3;

----use the configuration statement to select architecture
configuration conf1 of decoder38 is
 for code3
 end for;
end configuration conf1;


阅读(4682) | 评论(3) | 转发(0) |
给主人留下些什么吧!~~

zhangyu19865172008-11-24 21:33:19

如果定义的输入端variable input,输出端variable output。 output = 2 ** input

fxz_abc2008-09-25 12:41:53

对我帮助挺大,谢谢了!

fxz_abc2008-09-25 12:41:47

对我帮助挺大,谢谢了!