分类:
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;