Forum Discussion
Altera_Forum
Honored Contributor
19 years agoThis is the code that was supplied with the Cubic Cyclonium (LED matrix driver) in a hardware tutorial class. Very simple, just copies the bit across the whole row. For example, if LEDS(0) is high, it turns on the entire top row of the LED matrix.
library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity LED_DRIVER is port ( clock : IN std_logic; resetN : IN std_logic; LEDS : IN std_logic_vector(7 downto 0); LED_MATRIX : OUT std_logic_vector(28 downto 0) ); END LED_DRIVER; architecture rtl of LED_DRIVER is SIGNAL COUNTER : unsigned(15 downto 0); SIGNAL SCANNER : unsigned(20 downto 0); BEGIN LED_MATRIX(28 downto 8) <= std_logic_vector(SCANNER); LED_MATRIX(7 downto 0) <= NOT LEDS; process(clock,resetN) begin if resetN = '0' then COUNTER <= (others => '0'); SCANNER <= to_unsigned(1,21); elsif clock = '1' and clock'event then COUNTER <= COUNTER + 1; if COUNTER = to_unsigned(0,16) then SCANNER(20 downto 1) <= SCANNER(19 downto 0); SCANNER(0) <= SCANNER(20); else SCANNER <= SCANNER; end if; end if; end process; END rtl;