sseg_display

<!DOCTYPE html> <html>

<head> <meta charset="utf-8">

<script async src="https://www.googletagmanager.com/gtag/js?id=G-NG21EXTML9"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());

gtag('config', 'G-NG21EXTML9'); </script> <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no"> <title>SpeakHDL</title> <meta name="keywords" content="FPGA, FPGA Prototyping, FPGA Tool, Voice Coding, procedural programming, FPGA Easy, VHDL, FPGA for beginners"> <meta name="description" content="A practical FPGA design tool that combines procedural programming using native VHDL with command-based programming"> <link rel="icon" type="image/png" sizes="16x16" href="../assets/img/logo/favicon-16x16.png"> <link rel="icon" type="image/png" sizes="32x32" href="../assets/img/logo/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="192x192" href="../assets/img/logo/android-chrome-192x192.png"> <link rel="icon" type="image/png" sizes="512x512" href="../assets/img/logo/android-chrome-512x512.png"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0/css/all.css"> <link rel="stylesheet" href="https://unpkg.com/@bootstrapstudio/bootstrap-better-nav/dist/bootstrap-better-nav.min.css"> <link rel="stylesheet" href="../assets/css/doxy-override.css"> <link rel="stylesheet" href="../assets/css/Footer-Basic.css"> <link rel="stylesheet" href="../assets/css/Login-Form-Clean.css"> <link rel="stylesheet" href="../assets/css/banner.css"> <link rel="stylesheet" href="../assets/css/examples.css"> <link rel="stylesheet" href="../assets/css/speakhdl-styles.css"> </head>

<body class="body-fixed"> <header class="justify-content-center banner-header theme-outline" dx-block="block">

Seven Segment Display Example

</header>

Design Objective(s):

  • Design a 3 digit counter that counts from 0 to 999 with the least significant digit incrementing at 100ms on a 7-segment display using time multiplexing.
  • Use an external data file to contain the binary values that implement the conversion between a decimal to 7-segment display values.
  • Use a mix of command based programming with traditional VHDL when-else statements to complete the design.
Show Hotkey Command Sequence

Top Level Design Structure

Design Discussion

The overall strategy of displaying a 3 digit counter on a 7-segment display is to chain together three separate hardware counters that count from 0 - 9 and time multiplex their count values at a rate fast enough to keep each 7-segment display looking like it is illuminated at all times.  The refresh rate to update the display is set to 1ms by using the divide.count value from the TIME_COUNTER procedure call. The delay.value is used to index through the array of general purpose counters.  This leads to the following time multiplexed integer assignment:
mux_counter_i <= srr.counter(srr.delay.value + 1).value;
Bacause the delay.value increments from 0 to 2 then rolls over, an offset of +1 is added to the delay.value due to the fact we wish to cycle through general purpose counter 1 through 3 and not begin at counter 0 which is used to create the time base of 100ms .  At the exact time we index through each counter value, we illuminate the corresponding 7-segment display by driving the anode value to '0'. All other 7-segment displays are set to a non-illuminated state by driving the anode value to '1'.
anode(0) <= '0' when (srr.delay.value = 0) else '1';
anode(1) <= '0' when (srr.delay.value = 1) else '1';
anode(2) <= '0' when (srr.delay.value = 2) else '1';
anode(7 downto 3) <= (others => '1');
In order to convert the multiplexed integer value, mux_counter_i, to the expected binary values that illuminate the A-G segments on the display, we create a data file of length 10 containing an array of binary values that can be read in as std_logic_vectors.  Once we have a data file, we are able to use commands to read the file into a std_logic_vector_array and use the multiplex counter value, mux_counter_i, to index the array. To make the compiler happy, we need to specify the range of the signal assignment to be (6 downto 0).
sseg(6 downto 0) <= sseg_array(mux_counter_i)(6 downto 0);
<section>

Entry Into Editor

Open the IO_CONFIG.cfg file in the editor and update the following parameters to match the user specific the development board. Then return to the .vhd file and give the 'ok' command.
  • [global]
  • clk_pin = E3
  • reset_pin = U9
  • sys_clk_freq = 100E6
  • reset_polarity = '1'
  • ...

</section> <section>

Create A Data File for the Seven Segment A-G Values

Create a data file named sseg_array.dat. Use the command new sseg_array.dat to create the file. Copy or type the with the following binary values into the data file.
For each row of data, a '0' corresponds to an A-G segment of the display that is illuminated while a '1' corresponds the portion of the display is not illuminated.  The data has a range of 6 downto 0 with the MSB on the left corresponding to letter G.
sseg_array.dat
1000000
1111001
0100100
0110000
0011001
0010010
0000010
1111000
0000000
0010000
First Element in File

</section> <section class="section-pad">

Hotkey Commands

Select a local directory location for output files *
clear .vhd file and rename application module 'sseg_display'
  1. restart
  2. rename sseg_display.vhd
setup counter 0 to be the 100ms time base
  1. cc
  2. count 100ms
setup 3 more counters with the enable parameter set to 'chain'
  1. cc1
  2. count 10
  3. enable chain
  4. cc2
  5. count 10
  6. enable chain
  7. cc3
  8. count 10
  9. enable chain
create a time counter that counts to 3 with a 1ms time base to do the multiplexing
  1. tc
  2. divide 1ms
  3. delay 3
declare constant array for data file and declare shared index
  1. sseg_array is sseg_array.dat
declare the 8 output pins for the anode signals that enable each of the 8 seven segment displays
  1. output anode(8) = N6, M6, M3, N5, N2, N4, L1, M1
declare the 7 output pins that illuminate A-G of the segment display
  1. output sseg(7) = L3, N1, L5, L4, K3, M2, L6
run parser
  1. ok
Pin locations must be changed for user specific development board
  Writing to a local directory is supported with Chrome and Microsoft Edge browsers

</section> <section class="section-pad">

Entry Into Editor

Type or paste the following 'when else' statements into the editor that wire up the output logic and do the time multiplexing of the three integer counter values.  Then give 'ok' hotkey command.
anode(0) <= '0' when (srr.delay.value = 0) else '1';
anode(1) <= '0' when (srr.delay.value = 1) else '1';
anode(2) <= '0' when (srr.delay.value = 2) else'1';
anode(7 downto 3) <= (others => '1');

sseg(6 downto 0) <= sseg_array(mux_counter_i)(6 downto 0);

mux_counter_i <= srr.counter(srr.delay.value + 1).value;

</section>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script> <script src="../assets/js/bss_custom_js.js"></script> <script src="https://unpkg.com/@bootstrapstudio/bootstrap-better-nav/dist/bootstrap-better-nav.min.js"></script> </body>

</html>