📄 fuyongqi.vhd
字号:
----------方案1:using a signal(not ok)---------------
library ieee;
use ieee.std_logic_1164.all;
--------------------------------------------------------
entity fuyongqi is
port( a,b,c,d,s0,s1: in std_logic;
y: out std_logic);
end fuyongqi;
-------------------------------------------------------
architecture not_ok of fuyongqi is
signal sel: integer range 0 to3;
begin
process(a,b,c,d,s0,s1)
begin
sel <= 0;
if (s0 = '1' )then sel <= sel+1;
end if;
if (s1 = '1')then sel <= sel+2;
end if;
case sel is
when 0 => y <= a;
when 1 => y <= b;
when 2 => y <= c;
when 3 => y <= d;
end case;
end process;
end not_ok;
--------------------------------------------------------
---------------方案2:using a variable(ok)-------------
library ieee;
use ieee.std_logic_1164.all;
----------------------------------------------------------
entity fuyongqi is
port( a,b,c,d,s0,s1: in std_logic;
y: out std_logic);
end fuyongqi;
-------------------------------------------------------
architecture ok of fuyongqi is
begin
process(a,b,c,d,s0,s1)
variable sel: integer range 0 to3;
begin
sel =: 0;
if (s0 = '1' )then sel := sel+1;
end if;
if (s1 = '1')then sel := sel+2;
end if;
case sel is
when 0 => y <= a;
when 1 => y <= b;
when 2 => y <= c;
when 3 => y <= d;
end case;
end process;
end not_ok;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -