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:
parent
fdedf7b657
commit
a1bebb977e
@ -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');
|
||||
if FIRST then
|
||||
cin <= '1';
|
||||
else
|
||||
cin <= carry_in;
|
||||
end if;
|
||||
result <= sum;
|
||||
carry_out <= cout;
|
||||
when "1010" => -- DEC
|
||||
x <= accu;
|
||||
y <= (others => '1');
|
||||
if FIRST then
|
||||
cin <= '0';
|
||||
else
|
||||
cin <= not carry_in;
|
||||
end if;
|
||||
result <= sum;
|
||||
carry_out <= not cout;
|
||||
when "1011" => -- ZERO
|
||||
|
@ -11,6 +11,9 @@ architecture test of toy_16 is
|
||||
constant period: time := 1us;
|
||||
|
||||
component main
|
||||
generic (
|
||||
FIRST: boolean
|
||||
);
|
||||
port (
|
||||
func: in std_logic_vector(3 downto 0);
|
||||
accu: in std_logic_vector(7 downto 0);
|
||||
@ -43,7 +46,9 @@ architecture test of toy_16 is
|
||||
|
||||
begin
|
||||
|
||||
alu1: main port map (
|
||||
alu1: main generic map (
|
||||
FIRST => true
|
||||
) port map (
|
||||
func => func,
|
||||
accu => accu(7 downto 0),
|
||||
ram => ram(7 downto 0),
|
||||
@ -52,7 +57,9 @@ begin
|
||||
carry_out => carry_propagation
|
||||
);
|
||||
|
||||
alu2: main port map (
|
||||
alu2: main generic map (
|
||||
FIRST => false
|
||||
) port map (
|
||||
func => func,
|
||||
accu => accu(15 downto 8),
|
||||
ram => ram(15 downto 8),
|
||||
|
Loading…
Reference in New Issue
Block a user