根据输入确定输出值<br /> library ieee;<br /> use ieee.std_logic_1164.all;<br /> entity mux41 is<br /> port(s4,s3,s2,s1: in std_logic;<br /> z4,z3,z2,z1: out std_logic);<br /> end mux41;<br /> architecture art of mux41 is<br /> begin<br /> process(s4, s3, s2, s1)<br /> variable sel: integer range 0to15;<br /> begin<br /> sel:=0;<br /> if s1=‘1’ then sel:=sel+1; end if;<br /> if s2=‘1’ then sel:=sel+2; end if;<br /> if s3=‘1’ then sel:=sel+4; end if;<br /> if s4=‘1’ then sel:=sel+8; end if;<br /> z1<=‘0’; z2<=‘0’; z3<=‘0’; z4<=‘0’;<br /> case sel is<br /> when 0 =>z1<=‘1’;<br /> when 1|3 =>z2<=‘1’;<br /> when 4 to 7|2 =>z3<=‘1’;<br /> when others =>z4<=‘1’;<br /> end case;<br /> end process;<br />end art; <br />按要求应该是根据四位输入码来确定四位输入中哪一位输出为1,但这程序貌似不是这样的,还有那case语句中1,3,4,7,2.。。。。是怎么确定的哦??<br />谢谢了~~~ |
|