VHDL Code Listing

July 10, 2008
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

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

Sponsored Recommendations

TTI Transportation Resource Center

April 8, 2024
From sensors to vehicle electrification, from design to production, on-board and off-board a TTI Transportation Specialist will help you keep moving into the future. TTI has been...

Cornell Dubilier: Push EV Charging to Higher Productivity and Lower Recharge Times

April 8, 2024
Optimized for high efficiency power inverter/converter level 3 EV charging systems, CDE capacitors offer high capacitance values, low inductance (< 5 nH), high ripple current ...

TTI Hybrid & Electric Vehicles Line Card

April 8, 2024
Components for Infrastructure, Connectivity and On-board Systems TTI stocks the premier electrical components that hybrid and electric vehicle manufacturers and suppliers need...

Bourns: Automotive-Grade Components for the Rough Road Ahead

April 8, 2024
The electronics needed for transportation today is getting increasingly more demanding and sophisticated, requiring not only high quality components but those that interface well...

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!