title: Decimal number on 7 segment display
body: <p>I've got a big problem with VHDL for a project.  I want to see on 7 segment display a number that user sets with switches. For example if the low-order 5 switches are turned on then they will represent the binary number "11111" that is 31 in decimal. So I want to see 31 on 7 segment display. </p>
  
  <p>To do that I plan these steps:</p>
  
  <ul>
  <li>Insert the 5 value of the switch into an array</li>
  <li>Convert the array into an integer number</li>
  <li>See the integer number into 7 segment display</li>
  </ul>
  
  <p>Point 1) insert into an array</p>
  
  <pre><code>     signal first: std_logic_vector (0 to 4);
       signal temp: integer range 0 to 9999:=0;
       for i in 0 to 4 loop
             first(i)&lt;=SW(i);
       end loop;
       temp&lt;=VEC_TOINT(first);
       HEX0&lt;=INT_TO7SEG(temp);
  </code></pre>
  
  <p>Point 2) Vector to Integer</p>
  
  <pre><code>     Function VEC_TOINT(Vector: in std_logic_vector) return integer is
       variable temp: bit_vector(Vector'range);
       variable result: integer :=0;
       Begin
            for index in Vector'range loop
                 result:=result * 2 + bit'pos(temp(index));
            end loop;
            if Vector(Vector'left) = '1' then 
                 result:=(-result)-1;
            end if;
            return result;
       End VEC_TOINT;
  </code></pre>
  
  <p>For the third point at the moment I don't have any idea.</p>