• Support PF! Buy your school textbooks, materials and every day products Here!

VHDL program

  • Thread starter ee91
  • Start date
  • #1
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.
 

Answers and Replies

  • #2
33,506
5,192

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'
 

Related Threads on VHDL program

  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
1
Views
4K
Replies
1
Views
1K
  • Last Post
Replies
2
Views
10K
  • Last Post
Replies
6
Views
2K
  • Last Post
Replies
1
Views
563
  • Last Post
Replies
3
Views
30K
  • Last Post
Replies
0
Views
10K
  • Last Post
Replies
3
Views
2K
Replies
7
Views
1K
Top