Fix INC and DEC by specifying if alu is the first one

If it is not the first, only increment or decrement when carry or
borrow is set.
This commit is contained in:
Max Braungardt
2018-04-26 20:09:04 +02:00
parent fdedf7b657
commit a1bebb977e
2 changed files with 21 additions and 5 deletions

View File

@ -5,7 +5,8 @@ use ieee.numeric_std.ALL;
entity main is
generic (
WIDTH: integer := 8
WIDTH: integer := 8;
FIRST: boolean := true
);
port (
func: in std_logic_vector(3 downto 0);
@ -77,13 +78,21 @@ begin
when "1001" => -- INC
x <= accu;
y <= (others => '0');
cin <= '1';
if FIRST then
cin <= '1';
else
cin <= carry_in;
end if;
result <= sum;
carry_out <= cout;
when "1010" => -- DEC
x <= accu;
y <= (others => '1');
cin <= '0';
if FIRST then
cin <= '0';
else
cin <= not carry_in;
end if;
result <= sum;
carry_out <= not cout;
when "1011" => -- ZERO