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:
@ -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
|
||||
|
Reference in New Issue
Block a user