º»¹®/³»¿ë
1. °³ ¿ä
¡Û °¡»ê±â ¼³°è¸¦ ÅëÇÑ Àü¹ÝÀûÀÎ Modelsim, Xilinx ISE »ç¿ë¹ý ½Ç½À
¡Û TEST bench, simulation ¹æ¹ý ÀÌÇØ
2. ¹® Á¦
(1) 3*8 Decoder
-Behavioral modeling
library ieee;
use ieee.std_logic_1164.all;
entity decoder is
port (x : in std_logic_vector(2 downto 0);
d : out std_logic_vector(7 downto 0));
end decoder;
architecture behavioral of decoder is
begin
process (x)
begin
case x is
when "000" => d <= "10000000" ;
when "001" => d <= "xxx00000" ;
when "xxx" => d <= "0xxx0000" ;
when "xxx" => d <= "00xxx000" ;
when "100" => d <= "000xxx00" ;
when "101" => d <= "0000xxx0" ;
when "110" => d <= "00000xxx" ;
when others => d <= "00000001" ;
end case;
end process;
end behavioral;
-Data flow modeling
library ieee;
use ieee.std_logic_1164.all;
entity decoder_dataflow is
p¡¦(»ý·«)
d(2) <= not x(0) and x(1) and not x(2);
d(3) <= x(0) and x(1) and not x(2);
d(4) <= not x(0) and not x(1) and x(2);
d(5) <= x(0) and not x(1) and x(2);
d(6) <= not x(0) and x(1) and x(2);
d(7) <= x(0) and x(1) and x(2);
x <= "xxx"; wait for 50 ns;
x <= "100"; wait for 50 ns;
x <= "101"; wait for 50 ns;
x <= "110"; wait for 50 ns;
x <= "111"; wait for 50 ns;
end process tb_x;
end;
(2) 3*8 Encoder
-Behavioral modeling
library ieee;
use ieee.std_logic_1164.all;
entity encoder_behavior is
port(d: in std_logic_vector(7 downto 0);
x: out std_logic_vector(2 downto 0));
end encoder_behavior;
architecture behavioral of encoder_behavior is
begin
process (d)
begin
case d is
when "00000001" => x <= "000" ;
when "00000xxx" => x <= "001" ;
when "0000xxx0" => x <= "xxx" ;
when "000xxx00" => x <= "xxx" ;
when "00xxx000" => x <= "100" ;
when "0xxx0000" => x <= "101" ;
when "xxx00000" => x <= "110" ;
when others => x <= "111" ;
end case;
end process;
end behavioral;
-Encoder test bench
library ieee;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_11