Guest
Hey guys
I have a presentation for next couple days on VHDL and i need to show
some simple example project, I managed to write a <b>4 Bit Adder</b> as
follow:
Adder4.vhd:
--------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
ENTITY Adder4 IS
PORT
(
Cin : IN STD_LOGIC;
X, Y : IN STD_LOGIC_VECTOR (3 DOWNTO 0);
R : OUT STD_LOGIC_VECTOR (3 DOWNTO 0);
Cout : OUT STD_LOGIC
);
END Adder4;
ARCHITECTURE Adder4_Behav OF Adder4 IS
SIGNAL Carry : STD_LOGIC_VECTOR ( 2 DOWNTO 0);
COMPONENT FullAdder
PORT
(
Cin, A, B : IN STD_LOGIC;
Cout, S : OUT STD_LOGIC
);
END COMPONENT;
BEGIN
FA0: FullAdder PORT MAP ( Cin, X(0), Y(0), Carry(0), R(0));
FA1: FullAdder PORT MAP ( Carry(0), X(1), Y(1), Carry(1), R(1));
FA3: FullAdder PORT MAP ( Carry(1),X(2),Y(2),Carry(2),R(2));
FA4: FullAdder PORT MAP ( Carry(2),X(3),Y(3),Cout,R(3));
END;
--------------------------------------------------------------------------------
FullAdder.vhd
--------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
ENTITY FullAdder IS
PORT
(
Cin, A, B : IN STD_LOGIC;
Cout, S : OUT STD_LOGIC
);
END FullAdder;
ARCHITECTURE FullAdder_Behav OF FullAdder IS
BEGIN
S <= A XOR B XOR Cin;
Cout <= (A AND Cin) OR (B AND Cin) OR (A AND B);
END;
--------------------------------------------------------------------------------
but when i run simulation the output result is not synced at all!
I know i am not considering something here, but what is that?
I need HELP ASAP, please
What is it that i am doing wrong!?
I don't see any attachment option here
but i have uploaded the .vwf and the simulation result as attachments
in
http://embdev.net/attachment/160752/Vector_Wave_File.png
AND
http://embdev.net/attachment/160753/Simu_Result.jpg
Thanks in advace
I have a presentation for next couple days on VHDL and i need to show
some simple example project, I managed to write a <b>4 Bit Adder</b> as
follow:
Adder4.vhd:
--------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
ENTITY Adder4 IS
PORT
(
Cin : IN STD_LOGIC;
X, Y : IN STD_LOGIC_VECTOR (3 DOWNTO 0);
R : OUT STD_LOGIC_VECTOR (3 DOWNTO 0);
Cout : OUT STD_LOGIC
);
END Adder4;
ARCHITECTURE Adder4_Behav OF Adder4 IS
SIGNAL Carry : STD_LOGIC_VECTOR ( 2 DOWNTO 0);
COMPONENT FullAdder
PORT
(
Cin, A, B : IN STD_LOGIC;
Cout, S : OUT STD_LOGIC
);
END COMPONENT;
BEGIN
FA0: FullAdder PORT MAP ( Cin, X(0), Y(0), Carry(0), R(0));
FA1: FullAdder PORT MAP ( Carry(0), X(1), Y(1), Carry(1), R(1));
FA3: FullAdder PORT MAP ( Carry(1),X(2),Y(2),Carry(2),R(2));
FA4: FullAdder PORT MAP ( Carry(2),X(3),Y(3),Cout,R(3));
END;
--------------------------------------------------------------------------------
FullAdder.vhd
--------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
ENTITY FullAdder IS
PORT
(
Cin, A, B : IN STD_LOGIC;
Cout, S : OUT STD_LOGIC
);
END FullAdder;
ARCHITECTURE FullAdder_Behav OF FullAdder IS
BEGIN
S <= A XOR B XOR Cin;
Cout <= (A AND Cin) OR (B AND Cin) OR (A AND B);
END;
--------------------------------------------------------------------------------
but when i run simulation the output result is not synced at all!
I know i am not considering something here, but what is that?
I need HELP ASAP, please
What is it that i am doing wrong!?
I don't see any attachment option here
but i have uploaded the .vwf and the simulation result as attachments
in
http://embdev.net/attachment/160752/Vector_Wave_File.png
AND
http://embdev.net/attachment/160753/Simu_Result.jpg
Thanks in advace