?? addsub.vhd
字號:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;
entity addsub is
Port(
X : in std_logic_vector(3 downto 0); -- first operator
Y : in std_logic_vector(3 downto 0); -- second operator
S : in std_logic; -- select signal: 0 for add, 1 for sub
Cin : in std_logic; -- carry in
F : out std_logic_vector(3 downto 0); -- out
Cout : out std_logic
); -- carry out
end addsub;
architecture Behavioral of addsub is
component adder4 Port (
X : in std_logic_vector(3 downto 0);
Y : in std_logic_vector(3 downto 0);
S : out std_logic_vector(3 downto 0);
Cin : in std_logic;
Cout : out std_logic
); end component;
SIGNAL YY : std_logic_vector(3 downto 0);
begin
YY(0) <= S xor Y(0);
YY(1) <= S xor Y(1);
YY(2) <= S xor Y(2);
YY(3) <= S xor Y(3);
U2: adder4 port map (X,YY,F,S,Cout);
end Behavioral;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -