Professional Documents
Culture Documents
Mạch trừ đầy đủ: Phương trình
Mạch trừ đầy đủ: Phương trình
Phương trình
Code
--khai bao thu vien
LIBRARY IEEE;
Use IEEE.STD_LOGIC_1164.all;
--khai bao thuc the
ENTITY Botru is
Port( A,B,Cin: in std_logic;
Sub, Cout: out std_logic);
ARCHITECTURE dataflow of Botru is -- dataflow
Begin
Sub <= A xor B xor Cin;
Cout<= (Cin and B) or (not A and B) or (not A and Cin);
End ;
ARCHITECTURE behavioral of Botru is – behavioral
Begin
Process( A,B,Cin)
Begin
If( a=’0’ and
Bài 2:
Library IEEE;
Use IEEE.STD_LOGIC_1164.ALL;
Use IEEE.STD_LOGIC_ARITH.ALL;
Use IEEE.STD_USIGNED.ALL;
Entity mux_4 is
Port( A,B,C,D: in bit;
Sel : in bit_vecter(1 downto 0);
F : out bit);
end entity mux_4to1;
architecture mux_4_arch of mux_4 is
begin
F <=A when Sel=“00” else
B when Sel=“01” else
C when Sel=“10” else
D;
end architecture;