Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Alu

Reply
 
 
crashlcd crashlcd is offline
Junior Member
Join Date: Nov 2009
Posts: 3
 
      11-12-2009
hi guys!! i'm new to VHDL and i'm trying to design an ALU for a project. I want to use components and "case".. here is my code... but i don't have any idea how to enter the components in the case... can anyone please help me??


entity ALU is

port (
opcode:in std_logic_vector (2 downto 0);
A,B :in std_logic_vector (3 downto 0);
Outputut std_logic_vector(3 downto 0);
zerout std_logic

);
end ALU;

architecture Behavioral of ALU is


component nand_gate
port (
a: in std_logic_vector (3 downto 0);
b:in std_logic_vector (3 downto 0);
cut std_logic_vector (3 downto 0)
);
end component;


component and_gate
port (
a: in std_logic_vector (3 downto 0);
b:in std_logic_vector (3 downto 0);
cut std_logic_vector (3 downto 0)
);
end component;


component nor_gate
port (
a: in std_logic_vector (3 downto 0);
b:in std_logic_vector (3 downto 0);
cut std_logic_vector (3 downto 0)
);
end component;


component or_gate
port (
a: in std_logic_vector (3 downto 0);
b:in std_logic_vector (3 downto 0);
cut std_logic_vector (3 downto 0)
);
end component;


component xor_gate
port (
a: in std_logic_vector (3 downto 0);
b:in std_logic_vector (3 downto 0);
cut std_logic_vector (3 downto 0)
);
end component;


component xnor_gate
port (
a: in std_logic_vector (3 downto 0);
b:in std_logic_vector (3 downto 0);
cut std_logic_vector (3 downto 0)
);
end component;



begin

n1:nand_gate
port map (
a=>A,
b=>B,
c=>Output
);

n2:and_gate
port map (
a=>A,
b=>B,
c=>Output
);

n3:nor_gate
port map (
a=>A,
b=>B,
c=>Output
);

n4r_gate
port map (
a=>A,
b=>B,
c=>Output
);

n5or_gate
port map (
a=>A,
b=>B,
c=>Output
);

n6nor_gate
port map (
a=>A,
b=>B,
c=>Output
);


process (opcode,A,B)
begin
case(opcode) is
when "011" =>

when "100" =>

when "101" =>

when "110" =>

when "111" =>

when "010" =>

when "001" => If A=B then zero<= '1';
end if;
when others => output <= "0000";
end case;

end process;


end Behavioral;
 
Reply With Quote
 
 
 
 
joris joris is offline
Senior Member
Join Date: Jan 2009
Posts: 153
 
      11-12-2009
Might try something like this:
Code:
signal  result : std_logic_vector(6 downto 1);

begin

n1:nand_gate
port map (
a=>A,
b=>B,
c=>result(1)
);

n2:and_gate
port map (
a=>A,
b=>B,
c=>result(2)
);

n3:nor_gate
port map (
a=>A,
b=>B,
c=>result(3)
);

n4:xor_gate
port map (
a=>A,
b=>B,
c=>result(4)
);

n5:nor_gate
port map (
a=>A,
b=>B,
c=>result(5)
);

n6:xnor_gate
port map (
a=>A,
b=>B,
c=>result(6)
);


process (opcode,A,B)
begin
case(opcode) is
when "011" => Output <= result(1);

when "100" => Output <= result(2);

when "101" => Output <= result(3);

when "110" => Output <= result(4);

when "111" => Output <= result(5);

when "010" => Output <= result(6);

when "001" => If A=B then zero<= '1';
end if;
when others => output <= "0000";
end case;

end process;
 
Reply With Quote
 
 
 
 
crashlcd crashlcd is offline
Junior Member
Join Date: Nov 2009
Posts: 3
 
      11-14-2009
Thanks a lot dude..
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controling the ALU Cesar Andres Roldan Garcia Python 5 04-02-2005 07:11 PM
Gallery Opening - Jeff T. Alu - Digital Photography Jeff Alu Digital Photography 1 06-30-2004 05:41 PM
millions combinations of test vectors for ALU Lily VHDL 16 05-10-2004 07:22 PM
need help with ALU 8 BIT Lily VHDL 0 04-06-2004 01:08 AM
alu implementation Manuel VHDL 3 02-06-2004 05:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57