VHDL Program to Represent 2 Digits on 7-Segment Displays

  • Thread starter ee91
  • Start date
  • Tags
    Program
In summary, the conversation is about needing help with a VHDL program that uses 8 inputs to represent 2 digits from 00 to 99 on 7-segment displays. The program should switch on LED1 and LED2 when the values are 20 and 40, respectively. The code provided uses the inputs digit1 and digit2 to determine which output combination should be displayed on the 7-segment displays, but there are some missing double quotes and potential issues with the logic in the code.'
  • #1
ee91
1
0

Homework Statement



i need help for a VHDL program that uses 8 inputs to represent 2 digits from 00 to 99 on the 7-segment displays. LED1 and LED2 will light up when the values are “20” and “40” respectively. digit1(LSB),digit2(MSB)


Homework Equations





The Attempt at a Solution



Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;


entity decoder is
	port (digit1 , digit2 : in std_logic_vector (3 downto 0 );
		output : out_std_vector (6 downto 0)
                led1 , led2: out std_logic);
end decoder;

architecture arc of decoder is	
	
begin

        with input digit1 select
                   output :  "0000001" when "0000";
                                 "1001111"when "0001";
                                 "0010010"when "0010";  
                                 "0000110"when "0011";  
                                  1001100"when "0100"; 
                                 "0100100"when "0101"; 
                                 "0100000"when "0110";  
                                 "0001111"when "0111"; 
                                 "0000000"when "1000";  
                                 "0000100"when "1001"; 
                                 "1111111"when others;


        with input digit2 select
                   output :  "0000001" when "0000";
                                 "1001111"when "0001";
                                 "0010010"when "0010";  
                                 "0000110"when "0011";  
                                  1001100"when "0100"; 
                                 "0100100"when "0101"; 
                                 "0100000"when "0110";  
                                 "0001111"when "0111"; 
                                 "0000000"when "1000";  
                                 "0000100"when "1001"; 
                                 "1111111"when others;

   process( digit1,digit2)
 
       if  (digit1 = "0000" and digit = "0010") then
             led1 = '0' ; --led1 will switched on
             led2 = '0' ; --led2 will switched on
     elsif  (digit2 = "0000" and digit = "0100") then
             led1 = '0' ; --led1 will switch on
             led2 = '0' ; --led2 will switch on
     else
             led1 = '1'; --led1 will switch off
             led2 = '1'; --led1 will switch on
    end if;
  end process;


end arc;

i wrote the code above but i didn't worked. i did a vhdl that represents hexadecimal digits on a 7-segment display before and it worked. I've never done a vhdl that requires 8 inputs so i need help.
 
Physics news on Phys.org
  • #2
ee91 said:

Homework Statement



i need help for a VHDL program that uses 8 inputs to represent 2 digits from 00 to 99 on the 7-segment displays. LED1 and LED2 will light up when the values are “20” and “40” respectively. digit1(LSB),digit2(MSB)


Homework Equations





The Attempt at a Solution



Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;


entity decoder is
	port (digit1 , digit2 : in std_logic_vector (3 downto 0 );
		output : out_std_vector (6 downto 0)
                led1 , led2: out std_logic);
end decoder;

architecture arc of decoder is	
	
begin

        with input digit1 select
                   output :  "0000001" when "0000";
                                 "1001111"when "0001";
                                 "0010010"when "0010";  
                                 "0000110"when "0011";  
        Missing " here -->  1001100"when "0100"; 
                                 "0100100"when "0101"; 
                                 "0100000"when "0110";  
                                 "0001111"when "0111"; 
                                 "0000000"when "1000";  
                                 "0000100"when "1001"; 
                                 "1111111"when others;


        with input digit2 select
                   output :  "0000001" when "0000";
                                 "1001111"when "0001";
                                 "0010010"when "0010";  
                                 "0000110"when "0011";  
      Missing " here -->    1001100"when "0100"; 
                                 "0100100"when "0101"; 
                                 "0100000"when "0110";  
                                 "0001111"when "0111"; 
                                 "0000000"when "1000";  
                                 "0000100"when "1001"; 
                                 "1111111"when others;

   process( digit1,digit2)
 
       if  (digit1 = "0000" and digit = "0010") then
             led1 = '0' ; --led1 will switched on
             led2 = '0' ; --led2 will switched on
     elsif  (digit2 = "0000" and digit = "0100") then
             led1 = '0' ; --led1 will switch on
             led2 = '0' ; --led2 will switch on
     else
             led1 = '1'; --led1 will switch off
             led2 = '1'; --led1 will switch on
    end if;
  end process;


end arc;

i wrote the code above but i didn't worked. i did a vhdl that represents hexadecimal digits on a 7-segment display before and it worked. I've never done a vhdl that requires 8 inputs so i need help.
You are missing two double quotes in the code above.

There are some problems with the following code. In your if statement, you're checking the values of digit1 and digit. I'm pretty sure that digit should be digit2.

In your elsif statement, you have digit again. Do you mean digit1 this time? I don't know enough about the what the states of the two digits should be to switch on the LEDs, but it doesn't seem to me that you are covering all the states correctly. For example, there are 100 possible combinations of the values of digit1 and digit2, and your logic in this process turns on the LEDS in only two combinations, and turns the LEDs off in the other 98 combinations.

Are there any values of the two digits where LED1 is switched on and LED2 is switched off? Are there any values of the two digits where LED1 is switched off and LED2 is switched on? It doesn't seem to me that you have covered these possibilities.
Code:
   process( digit1,digit2)
 
       if  (digit1 = "0000" and digit = "0010") then
             led1 = '0' ; --led1 will switched on
             led2 = '0' ; --led2 will switched on
     elsif  (digit2 = "0000" and digit = "0100") then
             led1 = '0' ; --led1 will switch on
             led2 = '0' ; --led2 will switch on
     else
             led1 = '1'; --led1 will switch off
             led2 = '1'; --led1 will switch on
    end if;
  end process;
[/code'
 

What is VHDL?

VHDL stands for Very High-Speed Integrated Circuit Hardware Description Language. It is a programming language used to describe digital and mixed-signal systems and is commonly used in the design of electronic systems.

What is a 2-digit 7-segment display?

A 2-digit 7-segment display is a type of electronic display commonly used to represent numbers on devices such as calculators, digital clocks, and electronic meters. It consists of two sets of seven LEDs arranged in a specific pattern to represent each digit from 0 to 9.

How does a VHDL program represent 2 digits on 7-segment displays?

A VHDL program uses a combination of logic gates and multiplexers to control the LEDs on the 7-segment display. By manipulating the inputs to these components, the program can selectively turn on and off specific LEDs to form the desired numbers.

What are the advantages of using VHDL for 2-digit 7-segment display programming?

Using VHDL allows for a more efficient and precise way of controlling the 7-segment display compared to traditional methods. It also allows for easier modification and debugging of the program, making it a popular choice for electronic system design.

Can a VHDL program be used for other types of displays?

Yes, VHDL programs can be used to control a variety of electronic displays, including LCDs, LEDs, and OLEDs. The programming principles for controlling these displays are similar to those used for 7-segment displays.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
5K
  • General Engineering
Replies
3
Views
3K
Back
Top