VHDL 7seg display questions

Discussion in 'Programmer's Corner' started by Micro9000, Feb 22, 2011.

  1. Micro9000

    Thread Starter New Member

    Sep 22, 2009
    10
    0
    I am a bit confused between Common Anode and Common cathode. I believe I accidentally used common cathode in my code below:

    Code ( (Unknown Language)):
    1. package const is  -- ?ABCDEFG?
    2.   constant ZERO : std_logic_vector(6 downto 0) := "1111110";
    3.   constant ONE  : std_logic_vector(6 downto 0) := "0110000";
    4.   constant TWO  : std_logic_vector(6 downto 0) := "1101101";
    5.   constant THREE: std_logic_vector(6 downto 0) := "1111001";
    6.   constant FOUR : std_logic_vector(6 downto 0) := "0110011";
    7.   constant FIVE : std_logic_vector(6 downto 0) := "1011011";
    8.   constant SIX  : std_logic_vector(6 downto 0) := "1011111";
    9.   constant SEVEN: std_logic_vector(6 downto 0) := "1110000";
    10.  
    11.  etc..
    I was given this link by the professor: http://www.meskauskas.us/howard/de/Unit5Combinational/SevenSegment.htm

    I had a bit of trouble understanding the wording used to describe each. After I finished my code I managed to find a truth table for a common anode here: http://www.sxlist.com/images/com/ubicom/www/http/pdf_files/seven_seg.pdf (reads from right to left)

    I noticed it was the inverse of my orientation signifying that I accidentally implemented common cathode. So, do I need to inverse the bits in my code for common anode?


    I also managed to implement the test bench. I managed to use a signal statement to define specific intervals for each condition. Is this method okay? It seemed to work just fine when I ran it for 300ns. Should I implement some type of loop instead?

    Code ( (Unknown Language)):
    1. netI <= "0000",
    2. "0001" after 20 ns, "0010" after 40 ns,
    3. "0011" after 60 ns, "0100" after 80 ns,
    4. "0101" after 100 ns, "0110" after 120 ns,
    5. "0111" after 140 ns, "1000" after 160 ns,
    6.  
    7. etc..
    BTW, I am using the program ModelSim.
     
    Last edited: Feb 22, 2011
  2. guitarguy12387

    Active Member

    Apr 10, 2008
    359
    12
    Common cathode/anode just defines which direction the diode is pointing. Effectively allows you to choose active high or low.

    If it's backwards, just flip all the bits somewhere.

    You can do whatever you want hah! But generally copy-pasting large amounts of code is considered bad style.
     
Loading...