VHDL Program to Represent 2 Digits on 7-Segment Displays

  • Thread starter Thread starter ee91
  • Start date Start date
  • Tags Tags
    Program
Click For Summary
SUMMARY

The discussion focuses on creating a VHDL program to represent two digits (00 to 99) on 7-segment displays using 8 inputs. The provided code contains errors, including missing double quotes and incorrect variable references, specifically using 'digit' instead of 'digit2'. Additionally, the logic for controlling LEDs based on the digit values is insufficient, as it only accounts for two specific combinations, neglecting the other 98 possible states.

PREREQUISITES
  • Understanding of VHDL syntax and structure
  • Familiarity with 7-segment display encoding
  • Knowledge of digital logic design principles
  • Experience with conditional statements in VHDL
NEXT STEPS
  • Review VHDL syntax for defining entities and architectures
  • Learn about 7-segment display encoding for decimal digits
  • Investigate how to implement state machines in VHDL
  • Explore debugging techniques for VHDL code
USEFUL FOR

Students and professionals working on digital design projects, particularly those involving VHDL programming and 7-segment display interfacing.

ee91
Messages
1
Reaction score
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
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[/color].

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'
 

Similar threads

Replies
4
Views
5K
  • · Replies 3 ·
Replies
3
Views
4K