Completato modulo TwoComplement

This commit is contained in:
2019-08-29 15:12:25 +02:00
parent 8b08af2782
commit 12f2e36d7c
166 changed files with 1038 additions and 6113 deletions

View File

@@ -2,30 +2,53 @@ library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity TwoComplement is
generic(BITCOUNT : integer := 8);
generic(
BITCOUNT : integer := 8
);
port(
DIFF_EXP_C2 : in std_logic_vector((BITCOUNT-1) downto 0);
DIFF_EXP_ABS : out std_logic_vector((BITCOUNT-2) downto 0);
DIFF_EXP : out std_logic_vector((BITCOUNT-1) downto 0)
);
end TwoComplement;
architecture TwoComplementArch of TwoComplement is
signal S : std_logic;
signal M : std_logic_vector((BITCOUNT-2) downto 0);
begin
S <= DIFF_EXP_C2(BITCOUNT-1);
M <= DIFF_EXP_C2((BITCOUNT-2) downto 0);
signal SIGN : std_logic;
signal DIFF_EXP_ABS : std_logic_vector((BITCOUNT-2) downto 0);
begin
SIGN <= DIFF_EXP_C2(BITCOUNT-1);
C2_PROCESS : process(DIFF_EXP_C2, SIGN)
C2 : process(DIFF_EXP_C2)
begin
for i in (BITCOUNT-2) downto 0 loop
M(i) <= S xor M(i);
DIFF_EXP_ABS(i) <= SIGN xor DIFF_EXP_C2(i);
end loop;
end process;
--sommare 1 a M se S = '1'
SUM : process(DIFF_EXP_ABS, SIGN)
DIFF_EXP_ABS <= M;
variable CARRY : std_logic;
begin
CARRY := SIGN;
for i in 0 to (BITCOUNT-2) loop
DIFF_EXP(i) <= DIFF_EXP_ABS(i) xor CARRY;
CARRY := DIFF_EXP_ABS(i) and CARRY;
end loop;
DIFF_EXP(BITCOUNT-1) <= CARRY;
end process;
end TwoComplementArch;