ARCHITECTURE studentVersion OF triangleToPolygon IS

  signal mySignal : unsigned(bitNb downto 0);
  constant aFullTriangle : unsigned(bitNb downto 0) := (others => '1');
  signal bigTriangle: unsigned(bitNb downto 0);
  signal oneOfHeight: unsigned(bitNb downto 0);
  signal fiveOfHeight: unsigned(bitNb downto 0);

BEGIN

  resizeTriangle: process(triangle)
  begin
    bigTriangle <= ('0' & triangle) + ('0' & shift_right(triangle, 1));
    oneOfHeight <= shift_right(aFullTriangle, 3);
    fiveOfHeight <= shift_right(aFullTriangle, 1) + shift_right(aFullTriangle, 3);
  end process resizeTriangle;

  convert: process(bigTriangle)
  begin
    
    if bigTriangle < oneOfHeight then

      mySignal <= oneOfHeight;
      
    elsif bigTriangle > fiveOfHeight then

      mySignal <= fiveOfHeight;

    else
      mySignal <= bigTriangle;

    end if ;

  end process convert;
  
  polygon <= resize(mySignal-oneOfHeight, bitNb);
END ARCHITECTURE studentVersion;
