cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
8,651 Views
Registered: ‎05-20-2012

VHDL code for a LED matrix

I'm using Spartan 3E Starter Board( Nexys2 from Digilent).

Have to design: dynamic light on a LED matrix 4*4.

External board connects with FPGA board via PMOD connectors

I could use some help or some guidance with a digital schematic.Let's say I want

                                            the LED's from the first line to light up in succesion,from left to right

                                            second line:the same

                                            third and fourth line:the same

 

One idea that springs to my mind would be to use:Ring counter or modulo-4 counter

ROM memory to read vectors(4 bit).

 

Any idea?

 

0 Kudos
6 Replies
Highlighted
Teacher
Teacher
8,638 Views
Registered: ‎08-14-2007

Re: VHDL code for a LED matrix

Hi,

what other ideas than a bunch of counters and decoders/ROMs do you expect for such a simple problem?

 

Just work it out and you will come across enough other problems.

(How do you make the counting/display seqence slow enough to be observable by the human eye?)

 

A solution with dedicated hardware will work, but is not very flexible.

If you want to put something else on the display you start your design from scratch.

Also, if things become more complex than simple sequences the logic becomes strange too.

 

How about something more flexible. e.g. a sequencing ROM N*8 and a N-bit counter for address generation?

(Assuming that the 4x4 Matrix needs 8 wires to connect.)

Then you could simply change the rom contents to change the display output. Your hardware remains the same.

 

The next more flexible solution would be a microcontroller-IP like the PicoBlaze.

There you can do almost anything with your display and add flexible reaction to inputs (e.g. cursor keys) as well.

 

Have a nice synthesis

 Eilert 

0 Kudos
Highlighted
8,630 Views
Registered: ‎05-20-2012

Re: VHDL code for a LED matrix

I'm gonna go for this solution

--How about something more flexible. e.g. a sequencing ROM N*8 and a N-bit counter for address generation?
--(Assuming that the 4x4 Matrix needs 8 wires to connect.)
--Then you could simply change the rom contents to change the display output. Your hardware remains the same.

 

Here is the code for ROM 32*8:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;        
use ieee.std_logic_unsigned.all;
-- 32*8 ROM module
-- ROM model has predefined content for read only purpose

entity ROM is port( Clock   : in std_logic;
                    Reset    : in std_logic;    
                    Enable    : in std_logic;
                    Read    : in std_logic;
                    Address    : in std_logic_vector(4 downto 0);
                    Data_out: out std_logic_vector(7 downto 0));
end ROM;

architecture Behav of ROM is
  type ROM_Array is array (0 to 31) of std_logic_vector(7 downto 0);

    constant Content: ROM_Array := (
        0 => "00000001",        -- Suppose ROM has
        1 => "00000010",        -- prestored value
        2 => "00000011",        -- like this table
        3 => "00000100",           
        4 => "00000101",        
        5 => "00000110",           
        6 => "00000111",        
        7 => "00001000",           
        8 => "00001001",           
        9 => "00001010",           
        10 => "00001011",        
        11 => "00001100",           
        12 => "00001101",      
        13 => "00001110",        
        14 => "00001111",        
    OTHERS => "11111111" );     
begin
  process(Clock, Reset, Read, Address)
    begin
      if( Reset = '1' ) then
          Data_out <= "ZZZZZZZZ";
      elsif( Clock'event and Clock = '1' ) then
          if Enable = '1' then
           if( Read = '1' ) then
             Data_out <= Content(conv_integer(Address));
             else
               Data_out <= "ZZZZZZZZ";
           end if;
           end if;
        end if;
    end process;
end Behav;


 

Not sure how  link memory adress with counter(as an internal signal)?

0 Kudos
Highlighted
Instructor
Instructor
8,625 Views
Registered: ‎07-21-2009

A little bit of top-down design, a few comments here and there...

Here is what is missing from your posts, so far:

 

  1. This is what my design does (in other words, what I am designing).
  2. This is how my design works, step by step.
  3. Comments in my code which explain which lines of code match the portions of the step-by-step design description.

This is (I think) a simple design, so these missing items should be quite simple for you to compose.  Agreed?

 

Not sure how  link memory adress with counter(as an internal signal)?

 

What does this mean?

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Highlighted
8,621 Views
Registered: ‎05-20-2012

Re: A little bit of top-down design, a few comments here and there...

Could you sketch or explain a simple digital schematic to this problem:using a ROM and a counter,

to make things more clear?

0 Kudos
Highlighted
Instructor
Instructor
8,618 Views
Registered: ‎07-21-2009

Re: A little bit of top-down design, a few comments here and there...

Could you sketch or explain a simple digital schematic to this problem:using a ROM and a counter, to make things more clear?

 

I think the designer should do this.  Are you the designer?

I would suggest a summary description of the entire design, before all else.  Then follow with a block diagram which describes the various parts and pieces of the entire design.

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Highlighted
Teacher
Teacher
8,604 Views
Registered: ‎08-14-2007

Re: VHDL code for a LED matrix

Hi Michael,

you asked

"Not sure how  link memory adress with counter(as an internal signal)?".

 

The question already contains the answer.

Dou you know about instantiation and VHDL netlists?

(That's what you get when you canvert a schematic to VHDL e.g. with sch2vhdl. Look for *.vhf files in your projects and open these in a text editor for inspection.)

Also ISE can create symbols from your HDL blocks, so you can use thm in the schematic editor, if you prefer this for connecting small entities to build something more complex.

 

Have a nice synthesis

     Eilert

0 Kudos