mahi.
Newbie level 1
- Joined
- Feb 27, 2010
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- cairo, egypt
- Activity points
- 1,298
i made this code its an alu doing add, addition with carry, subtraction, AND, OR & NOT. its in multiplexer that when certain code enters, it select corresponding operation. but when i compile, it give alot of errors so if u can help me fix these errors tht would be great.
library ieee;
use ieee.std_logic_1164.all;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity mux is
port (a:in std_logic;
b:in std_logic;
cin:in std_logic;
sel:in std_logic;
resut std_logic);
end mux;
architecture structure of mux is
component adding
port(A,B : in std_logic;
Sum,Cout : out std_logic);
end component;
component sub
port ( A, B: in std_logic;
sum,cout: out std_logic);
end component;
component full
Port ( x,y,cin : in bit;
sum, carry ut bit);
end component;
component andgate
port (a,b : in std_logic ;
c : out std_logic);
end component;
component notgate
port (A: in std_logic;
O : out std_logic);
end component;
component or_gate
port (a,b : in std_logic ;
c : out std_logic);
end component;
begin
process(a,b,sel)
begin
case sel is
when "000" =>
Sum<= a xor b;
res<= a and b;
when "001" =>
signal compl:std_logic;
compl <= NOT b;
sum<= a XOR compl;
res<= a AND compl;
when "010" =>
signal s1,s2, s3 : std_logic;
U1:half port map (x,y,s1,s2);
U2:half port map (s1,cin,sum,s3);
Carry <= s2 or s3;
when "011" =>
res <= a and b;
when "100" =>
res <= not A;
when "101" =>
res <= a or b;
when others =>
res := "XXXXXXXX";
end case;
end process;
end mux;
library ieee;
use ieee.std_logic_1164.all;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity mux is
port (a:in std_logic;
b:in std_logic;
cin:in std_logic;
sel:in std_logic;
resut std_logic);
end mux;
architecture structure of mux is
component adding
port(A,B : in std_logic;
Sum,Cout : out std_logic);
end component;
component sub
port ( A, B: in std_logic;
sum,cout: out std_logic);
end component;
component full
Port ( x,y,cin : in bit;
sum, carry ut bit);
end component;
component andgate
port (a,b : in std_logic ;
c : out std_logic);
end component;
component notgate
port (A: in std_logic;
O : out std_logic);
end component;
component or_gate
port (a,b : in std_logic ;
c : out std_logic);
end component;
begin
process(a,b,sel)
begin
case sel is
when "000" =>
Sum<= a xor b;
res<= a and b;
when "001" =>
signal compl:std_logic;
compl <= NOT b;
sum<= a XOR compl;
res<= a AND compl;
when "010" =>
signal s1,s2, s3 : std_logic;
U1:half port map (x,y,s1,s2);
U2:half port map (s1,cin,sum,s3);
Carry <= s2 or s3;
when "011" =>
res <= a and b;
when "100" =>
res <= not A;
when "101" =>
res <= a or b;
when others =>
res := "XXXXXXXX";
end case;
end process;
end mux;