Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17267 Discussions

Using 7 segment on De1 Board

Altera_Forum
Honored Contributor II
9,200 Views

Hello to every one, 

 

I've just bought the DE1 board and i try to do some sample program with VHDL like put led on when switch is on and something similar. 

 

I kindly ask you if you can tell me how i can set-up 7 segment display. Is necessary a multiplexer?? 

 

Best Regards 

 

Michele
0 Kudos
13 Replies
Altera_Forum
Honored Contributor II
4,915 Views

The 4 displays of the DE1 board are not multiplexed. They use 28 pins to drive each segment. In the reference manual you can see pin assigments for the 7 segments displays.

0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

But for use it what i must do? 

 

Of course i an output so i can declare it into entity like: 

 

HEX0, HEX1 ........ OUT STD_LOGIC_VECTOR (0 TO 6) 

 

But in architecture? I want for example that the display count how many SW are on if i do the assignment 

 

LEDR <= SW led are on when switch is on but i don't find any assignment for the display can you help me pls?
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

To count how many '1's ( or '0's ) you may design a majority circuit. This code: 

 

jurado1: process (t1) 

variable m1 : unsigned (2 downto 0); 

begin 

m1:=TO_UNSIGNED(0,3); 

for i in 0 to 3 loop 

if (t1(i) = '1') then 

m1:=m1+1; 

end if; 

end loop; 

 

count <= m1; 

end process jurado1; 

 

count will have the numbers of '1's on vector t1 ( 4 bits ). I don't know how many '1's do want count. For a greater number of switch a sequential counter will be easier. 

 

Of course you have to decode bcd number on count, to 7 segment code. If you count more than 9 '1's you'll need 2 digits, so you need a bin to bcd converter.
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

I posted an example for the DE1 in this thread: 

 

http://www.alteraforum.com/forum/showthread.php?t=35687 

 

Download the zip file and follow the instructions to build it. It includes code for driving the hex displays. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

Thanks Dave, unfortunately (i know that you already hate me for all stupid problem that i posted on forum :) ) but our teacher impose us to use the 9.1 sp3 version 

 

of Quartus II so when i try to lunch the file synth.tcl the console tell me that my version is older than the version in which you create the project! At the moment i want 

 

to tell you "THANK YOU" for your help and kindly ask you another question then i hope that i ll be able to walk with my leg and start to do some experiment with the board...... 

 

consider that on february i must send a project to my teacher.....i am very delay but i have also other 3 exam to prepare! :(  

 

Bertulus wrote on this post that i must create a majority circuit, what is it? It's not possible to work 7 segment display only a VHDL file?? 

 

I tried to do a "stupid" experiment for see that the output work like  

 

HEX <= SW  

 

like switch and led but i also now that is 7 segment display is a device completely different than switch and buttons.....can you tell me how i must do for see the component work? 

 

Thanks a lot for your cooperation 

 

Michele
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

 

--- Quote Start ---  

Thanks Dave, unfortunately (i know that you already hate me for all stupid problem that i posted on forum :) ) 

 

--- Quote End ---  

 

So far your questions have not been stupid, so you're ok :) 

 

 

--- Quote Start ---  

 

but our teacher impose us to use the 9.1 sp3 version 

 

of Quartus II so when i try to lunch the file synth.tcl the console tell me that my version is older than the version in which you create the project! 

 

--- Quote End ---  

 

I downloaded the zip and I see that the qwork/ folder was included in the zip. Just delete that folder and try again. 

 

 

--- Quote Start ---  

 

Bertulus wrote on this post that i must create a majority circuit, what is it? It's not possible to work 7 segment display only a VHDL file?? 

 

--- Quote End ---  

 

Perhaps he misunderstood your request. You just want to be able to use the 7-segment display, right? 

 

 

--- Quote Start ---  

 

I tried to do a "stupid" experiment for see that the output work like  

 

HEX <= SW  

 

like switch and led but i also now that is 7 segment display is a device completely different than switch and buttons.....can you tell me how i must do for see the component work? 

 

--- Quote End ---  

 

Each segment in the display is a like LED. If you want to see numbers, then you have to turn on different segments. Look in the VHDL file with the example I posted (hex_display.vhd) and read the comments in there. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

Thanks Dave, now the project work well! I just start to see your code! If i have other problem i post it on forum :)  

 

Yes i want only use the 7 segment display :)  

 

Thanks a lot for your cooperation 

 

Michele
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

ok now i understand how the 7 segment display work. I try some test like sum HEX0 <= "0000000" + "1" and i saw that the result is not 1 :)  

 

For sum two number into 7 segment display, i must use also clock?
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

 

--- Quote Start ---  

ok now i understand how the 7 segment display work. I try some test like sum HEX0 <= "0000000" + "1" and i saw that the result is not 1 :) 

 

--- Quote End ---  

 

Right, because the 7-segment display is just a bunch of LEDs. If you want those LEDs to "mean" numbers, then you have to decode the number, i.e., 

 

HEX0 <= decode(number); 

 

You could have your code written like this using a function call, or using a hex_display component as shown in the example you downloaded. 

 

 

--- Quote Start ---  

 

For sum two number into 7 segment display, i must use also clock? 

--- Quote End ---  

 

 

No, but its generally useful to use a clock. 

 

In the case of your "tests" just output to the hex display the switch settings or the key settings 

 

u4: hex_display port map( hex => hex_data_d, display => hex_d ); -- Drive with the switches hex_data_d <= sw(3 downto 0); -- Drive with the push buttons -- hex_data_d <= key(3 downto 0);  

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

for assignment a variable to an hardware component, for example an X input with key / sw 

 

is enough do for example:  

 

signal X: KEY[0]
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

 

--- Quote Start ---  

for assignment a variable to an hardware component, for example an X input with key / sw 

 

is enough do for example:  

 

signal X: KEY[0] 

--- Quote End ---  

 

 

Not quite. There's two ways you could do something like this; 

 

signal x : std_logic; -- "Read" the state of key(0) into x x <= key(0);  

 

or the shorthand version 

 

alias x is key(0);  

 

Note: VHDL is case insensitive, so writing capitals makes no difference. A typical "convention" is to write generics in capitals, but even that is not universal. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

Hi Dave, 

 

Thanks a lot for all your help, now i start to use seriously the board and i understood most of their function but there is another request, for that exam i ll prepare 

 

a project. I can decide what prepare and with my colleague we decide to create a simply game like ping pong / arkanoid. I find on youtube video about game like that 

 

but in my book i didn't find any reference about the library that i must use and also a manual of that library. My request is referred to the graphic part of my project. 

 

Thanks a lot for your cooperation  

 

Cheers 

 

Michele
0 Kudos
Altera_Forum
Honored Contributor II
4,915 Views

Hi Michele, 

 

I have not needed to implement graphics. This site has some examples 

 

http://users.ece.gatech.edu/~hamblen/altera/altera.htm 

 

I have not looked at or used this code. 

 

Cheers, 

Dave
0 Kudos
Reply