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: Not Rated

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?


  • Cadence Comes At Power From Two Perspectives
  • Collaboration Results In First IEEE 1149.7 cJTAG Semiconductor IP Core
  • Yield Enhancement Software To Aid Solar Cell Fabs
  • Audio Engine Codec Library Expands With Dolby Pro Logic Additions
  • Accellera Rolls New Version of Analog, Mixed-Signal Standard
  • 45-nm Via-Programmable ASICs Add High-Speed I/O Transceivers To Feature Mix
  • Verification Evolves Into Lean, Mean Bug-Stomping Machines
  • User Advisory Group To Guide Open Verification Methodology’s Evolution
    1) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (304 views today)
    2) Use Inexpensive Components To Create An Infrared Close-Object Alert Circuit
    (205 views today)
    3) Easily Convert Decimal Numbers To Their Binary And BCD Formats
    (157 views today)
    4) Narrow-Shift Digital Discriminator Detects Differential GPS Corrections
    (155 views today)
    5) Embedded: FPGA Toolkit Supports Hard And Soft Processor Designs
    (140 views today)
    ALL TOP 20







    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.
     
     

    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 RF Design
    Schematics Find Power Products Military Electronics Featured Vendors EE Events Free Design Resources