Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?

[Ideas For Design]
RECOMMENDED READING:
  •  VHDL Code Offloads LED Blinking Task To A CPLD

VHDL Code Listing



Philip Warren  |   ED Online ID #19222  |   July 10, 2008

Article Rating:

IFD2303code.txt

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity LED_Driver is port
(

clk: in std_logic; -- Clock input
por: in std_logic; -- Power-On Reset
a_bus: in std_logic_vector(3 downto 0); -- 4-Bit Address Bus
d_bus: inout std_logic_vector(7 downto 0); -- 8-Bit Data Bus
led_out: out std_logic); -- Output to Red LED


end LED_Driver;

architecture arch_LED_Driver of LED_Driver is

signal Count: std_logic_vector(15 downto 0); -- Internal 16-Counter
signal LedCtl: std_logic; -- LED Control
signal LedMux: std_logic_vector(3 downto 0); -- Led Mode MUX Control
signal LedOut: std_logic; -- Internal signal for Combitorial Logic

begin
counter:
process (clk, por)
begin
if por = '0' then --If POR event
Count <= "0000000000000000"; -- reset counter
elsif clk='1' and clk'event then --If clk changed and is rising edge
Count <= Count + 1; -- increment counter
end if;
end process counter;

indicate_select:
process (LedMux,Count,LedOut,LedCtl)
begin
if(LedCtl='1') then

case LedMux is
-- Governing equation for pulse width at 50% duty cycle
-- PW = 0.5 * (2^n) * (1/f)
-- Where n = Counter Bit used to drive LED, f = Clock Frequency

when "0000" =>
led_out <= LedOut and Count(0);

when "0001" =>
led_out <= LedOut and Count(1);

when "0010" =>
led_out <= LedOut and Count(2);

when "0011" =>
led_out <= LedOut and Count(3);

when "0100" =>
led_out <= LedOut and Count(4);

when "0101" =>
led_out <= LedOut and Count(5);

when "0110" =>
led_out <= LedOut and Count(6);

when "0111" =>
led_out <= LedOut and Count(7);

when "1000" =>
led_out <= LedOut and Count(8);

when "1001" =>
led_out <= LedOut and Count(9);

when "1010" =>
led_out <= LedOut and Count(10);

when "1011" =>
led_out <= LedOut and Count(11);

when "1100" =>
led_out <= LedOut and Count(12);

when "1101" =>
led_out <= LedOut and Count(13);

when "1110" =>
led_out <= LedOut and Count(14);

when "1111" =>
led_out <= LedOut and Count(15);

when others =>
led_out <= '0'; --OFF

end case;
else
led_out <= '0'; --OFF
end if;

end process indicate_select;

write_bus:
process(a_bus, por, d_bus)

begin
if (por = '0') then
LedMux <= "0000";
LedOut <= '0';
LedCtl <= '0';

else

case a_bus is

when "0001" =>
LedCtl <= d_bus(5);
LedOut <= d_bus(4);
LedMux(3) <= d_bus(3);
LedMux(2) <= d_bus(2);
LedMux(1) <= d_bus(1);
LedMux(0) <= d_bus(0);

when others =>
null;

end case;

end if;

end process write_bus;

end arch_LED_Driver;

See associated file




Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


  • Accellera-SPIRIT Consortium Merger Boosts EDA Standards Efforts
  • Tool Automates Power Optimization Of Embedded SoC Memories
  • EDA Remains The Enabler Of Much-Needed Innovation
  • Software Confronts New Yield-Management Paradigm
  • The Mixed-Signal Angle On DFM
  • Design For Manufacturing Sheds The Hype
  • Virtualization Innovations Drive Cost Optimization
  • When One Plus One Has To Be Less Than One
    1) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (195 views today)
    2) Hot Hands For Some Cool Rock: Motion Sensing Meets Audio Engineering
    (119 views today)
    3) Monitor Your PC's CPU Core Temperature
    (102 views today)
    4) What's All This Double-Clutching Stuff, Anyhow?
    (88 views today)
    5) Seamless Power Switcher And Battery Charger Solution Targets Portable Devices
    (75 views today)
    ALL TOP 20







    Reader Comments

    thank's for the code above,the article is very useful for me. but i have some of problem when i made a blinking text project. for example i must make : "LAB COA", the text mest be display like this L-A-B- -C-O-A (display sequence one by one character),and then display together LAB COA then disappear.please help me to make the vhdl code.i need help,the project deadline is next week......

    yudha -May 03, 2009   (Article Rating: )

    POST YOUR COMMENTS HERE

    Name:

    Email:
    Rate this article:

     less useful more useful 
    1
    2
    3
    4
    5
    Your Comments:

    Enter the text from the image below




    Please refresh the page if you have trouble reading this text.
    (Acceptable Use Policy)
     
     

    PartFinder

    Find real-time pricing, stock status, same-day/next-day shipping options and more. Brought to you by Digi-Key. Go to PartFinder.    
    GlobalSpec

    PART SEARCH :
    Powered by: GlobalSpec - The Engineering Search Engine
    Sponsored Links

    Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
    Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources