title: Signed Addition overflow in VHDL
body: <p>I tried to implement and addition of two signed numbers. The first one is 32 bit and the second one is also 32 bit, but correspond the addition of the earlier operation. The code VHLD is below :</p>
  
  <pre><code>Entity Sum_Position is 
    port 
    (
       Clk: in std_logic;
       Reset: in std_logic;
       Raz_position: in std_logic;
       Position_In: in std_logic_vector(31 downto 0);
       Position_Out: out std_logic_vector(31 downto 0)
    );
  end Sum_Position;
  
  
  Architecture Arch_position of sum_Position is 
  
      -- create locale signals
      signal position_before: signed (31 downto 0):= (OTHERS =&gt; '0');
      -- both signals have one more bit than the original
      signal Position_s   : SIGNED(Position_In'length downto 0):= (OTHERS =&gt; '0');
      signal Position_Before_s   : SIGNED(Position_In'length downto 0):= (OTHERS =&gt; '0');
      signal Sum_Pos_s : SIGNED(Position_In'length downto 0):= (OTHERS =&gt; '0');
  
      Begin  -- begin of architecture
  
       -- convert type and perform a sign-extension
      Position_s &lt;=SIGNED(Position_In(31) &amp; Position_In);
      Position_Before_s&lt;=resize(signed(position_before), Position_Before_s'length);
  
      Sum_of_position: process(Clk, Reset) 
  
      begin 
  
         IF (Reset='0') THEN          -- when reset is selected
             -- initialize all values 
            Sum_Pos_s&lt;= (OTHERS =&gt; '0');
         ELSIF (Clk'event and Clk = '1') then
             -- addition of two 33 bit values
            Sum_Pos_s &lt;= Position_s + Position_Before_s;
  
         END IF;  
  
      end process Sum_of_position;
  
      -- resize to require size and type conversion
      position_before &lt;= (OTHERS =&gt; '0') WHEN Raz_position='1' else 
                          signed(resize(Sum_Pos_s, position_before'length));
  
      -- Resize and output the result
      Position_Out  &lt;= (OTHERS =&gt; '0') WHEN Raz_position='1' else  
                       std_logic_vector(resize(Sum_Pos_s, Position_Out'length));
  
      end Arch_position;
  </code></pre>
  
  <p>But, i have overflow because the result is very strange. Can you please suggest me a solution? </p>
  
  <p>Best regards; </p>