Altera_Forum
Honored Contributor
12 years agoProblem with 7 segment display
Hello to everyone,
I've got a problem with 7 segment display on my Altera DE1 board. I want to do the same thing: With 5 switch i wanto to set a binary number for example: SW1-SW2-SW3-SW4-SW5 are in ON Position the number is "11111" that in decimal is 31 and want to see 31 on the 7 segment display. At the beginning i've create a std_logic_vector with this declaration and initialization: signal First std_logic_vector (0 to 4); ----- declaration First <= (x4,x3,x2,x1,x0); ----- initialization Then i think that it's necessary convert the number that is inside on the vector to a decimal number but according me there is a problem, if i convert it the number (for example 31) will be avaiable on the first position of the another vector, but my idea is not this, i want that every number have a different position, i explain better Vector 1 Position0: contain number 1 Position1: contain number 3 so i will match every number with the following algorithm for visualize the number on 7 segment display function int_to7seg (a: std_logic_vector) return std_logic_vectorvariable result: std_logic_vector (6 downto 0);
begin
casa a is:
when 0 => result:="1000000";
.................
end case;
return result;
end int_to7seg;
There is anyone that can help me? Thanks a lot for your cooperation Best Regards Michele