|
我用的是ISE8.1 里面自带的仿真工具来仿真这个四选一数据选择器,里面仿真出来的波形文件总是不正确。不知道是为什么?
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity sxone is
port ( clk : in std_logic;
s4,s3,s2,s1: in std_logic;
z4,z3,z2,z1: out std_logic);
end sxone;
architecture Behavioral of sxone is
signal sel: integer range 0 to 15 ;
begin
process(clk)
begin
if clk='1' and clk'event then
sel<=0;
if(s1='1') then
sel<=sel+1;
elsif (s2='1') then
sel<=sel+2;
elsif (s3='1') then
sel<=sel+4;
elsif (s4='1') then
sel<=sel+8;
else null ;
end if;
z1<='0';z2<='0';z3<='0';z4<='0';
case sel is
when 0 => z1<='1';
when 1|3 => z2<='1';
when 4 to 7|2 => z3<='1';
when others => z4<='1';
end case;
end if;
end process ;
end Behavioral; |
|