VHDL 7seg display questions

Thread Starter

Micro9000

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

Rich (BB code):
package const is  -- ?ABCDEFG?
  constant ZERO : std_logic_vector(6 downto 0) := "1111110";
  constant ONE  : std_logic_vector(6 downto 0) := "0110000";
  constant TWO  : std_logic_vector(6 downto 0) := "1101101";
  constant THREE: std_logic_vector(6 downto 0) := "1111001";
  constant FOUR : std_logic_vector(6 downto 0) := "0110011";
  constant FIVE : std_logic_vector(6 downto 0) := "1011011";
  constant SIX  : std_logic_vector(6 downto 0) := "1011111";
  constant SEVEN: std_logic_vector(6 downto 0) := "1110000";

 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?

Rich (BB code):
netI <= "0000",
"0001" after 20 ns, "0010" after 40 ns,
"0011" after 60 ns, "0100" after 80 ns,
"0101" after 100 ns, "0110" after 120 ns,
"0111" after 140 ns, "1000" after 160 ns,

etc..
BTW, I am using the program ModelSim.
 
Last edited:
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.

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?
You can do whatever you want hah! But generally copy-pasting large amounts of code is considered bad style.
 
Top