Search This Blog

Saturday, July 27, 2013

Timer Based Single Way Traffic Light Controller using FSM Technique (VHDL Code).






Timer Based Single way Traffic Light Controller using FSM Technique -



Output Waveform :   Timer Based Single Way Traffic Light Controller.



VHDL Code -


-------------------------------------------------------------------------------
--
-- Title       : TLC_timer
-- Design      : vhdl_upload2
-- Author      : Naresh Singh Dobal
-- Company     : nsdobal@gmail.com
-- VHDL Programs &  Exercise with Naresh Singh Dobal.
--
-------------------------------------------------------------------------------
--
-- File        : Timer based Single Way Traffic Light Controller  using FSM.vhd



library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity TLC_timer is
     port(
         clk : in STD_LOGIC;
         r : out STD_LOGIC;
         y : out STD_LOGIC;
         g : out STD_LOGIC
         );
end TLC_timer;


architecture TLC_timer_arc of TLC_timer is

type color is (red,yellow,green) ;

signal p_state : color ;
signal n_state : color ;

begin
   
    present_state : process (clk) is
    begin
        if (rising_edge (clk)) then
            p_state <= n_state;
        end if;
    end process present_state;           
   
    next_state : process (p_state) is
    begin
        case (p_state) is
            when red =>
            n_state <= green;
            r <= '1';
            y <= '0';
            g <= '0';
           
            when green =>
            n_state <= yellow;
            r <= '0';
            y <= '0';
            g <= '1';
           
            when yellow =>
            n_state <= red ;
            r <= '0';
            y <= '1';
            g <= '0';
       
        end case;
    end process next_state;


end TLC_timer_arc;

5 comments:

  1. pls give the rtl schematic of the above pgm.

    ReplyDelete
  2. plz give the testbench for the above code

    ReplyDelete
  3. Can u give the block diagram and algorithm for the above programme sir.

    ReplyDelete
  4. my email is: minhdatqng94@gmail.com
    Please explain to help me. I don't simulate this wave.It display this wave error

    ReplyDelete