UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Newbie krtkeyan
Newbie
5,094 Views
Registered: ‎03-04-2013

need to change the delay for trafiic code in xc3s250e 144 Options

------------ TRAFFIC LIGHT CONTROLLER--------------------

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


entity TrafficLight is
    Port ( Port_A : inout  STD_LOGIC_VECTOR (7 downto 0);
           Port_B : inout  STD_LOGIC_VECTOR (7 downto 0);
           Port_C : inout  STD_LOGIC_VECTOR (7 downto 0);
           clk : in  STD_LOGIC);
end TrafficLight;

architecture Behavioral of TrafficLight is

type main1 is array(1 to 13) of std_logic_vector(7 downto 0);
signal state1:main1:=(x"0f",x"4d",x"8b",x"49",x"01",x"00"

,x"89",x"02",x"00",x"30"
,x"c0",x"f0",x"30");

signal sig : std_logic_vector(29 downto 0) := "000000000000000000000000000000";
signal cnt:integer:=1;


begin
process
begin

wait until clk'event and clk='1';
    sig<=sig+1;
    
    case sig(25 downto 20) is    
    when "000000" =>   
    
              if cnt = 1 then
                    cnt <= cnt+1;
                Port_B <= state1(1);
                     Port_A <= state1(2);                    
                     sig(25 downto 20)<="000111";                                                          
                
                 elsif cnt = 2 then                      
                    cnt <= cnt+1;
                     sig(25 downto 20)<="000110";                                         
                
                
                 elsif cnt = 3 then
                    cnt <= cnt+1;
                     Port_A <= state1(3);
                     sig(25 downto 20)<="000111";
                    
             elsif cnt = 4 then
                    cnt <= cnt+1;
                     sig(25 downto 20)<="000110";
                
                
                 elsif cnt = 5 then
                    cnt <= cnt+1;
                     Port_A <= state1(4);
                     Port_C <= state1(5);
                     sig(25 downto 20)<="000111";                                       
                    
                 elsif cnt <= 6 then
                    cnt <= cnt+1;
                     Port_C <= state1(6);
                     sig(25 downto 20)<="000110";                                     
                
                
                 elsif cnt <= 7 then
                    cnt <= cnt+1;
                     Port_A <= state1(7);
                     Port_C <= state1(8);
                     sig(25 downto 20)<="000111";        
                
                
                 elsif cnt <= 8 then
                    cnt <= cnt+1;
                     Port_C <= state1(9);
                     Port_A <= state1(10);
                     sig(25 downto 20)<="010000";                              
                
                
                 elsif cnt <= 9 then
                    cnt <= cnt+1;
                     Port_A <= state1(11);
                     Port_B <= state1(12);
                     sig(25 downto 20)<="010000";                                                   
                
                
                elsif cnt <= 10 then
                    cnt <= cnt+1;
                     Port_A <= state1(13);
                     sig(25 downto 20)<="010000";
            
                else
                    cnt <= 1;                                              
                
                 end if;
                
    when "000110" =>                -- For Amber delay;
    
             Port_A <= "00111001";        --0x39;
              sig(25 downto 20)<="001000";
   
    when "110000" =>       
              sig(25 downto 20)<="000000";     -- For Delay;

when others => null;
end case;
              
end process;
end architecture;
    
    

 

 

 

 

already there are the comments to change the values but i don't know what value should i give so, please give the sugessions to increase or decrease the delay of this traffic light code.,i'm having  xc3s250e pq144

Tags (1)
0 Kudos
4 Replies
Professor
Professor
5,081 Views
Registered: ‎08-14-2007

Re: need to change the delay for trafiic code in xc3s250e 144 Options

I don't see the comments that you are talking about.  And what delay do you mean?

I can see that there is a long counter and you're only using the upper bits in a case

statement.  Are you talking about the time to go from one state to the next in this

case statement?  Or were you talking about adding additional states?

-- Gabor
0 Kudos
Historian
Historian
5,074 Views
Registered: ‎02-25-2008

Re: need to change the delay for trafiic code in xc3s250e 144 Options

You fail.

 

What you coded is not how one should implement a state machine's state register and decoder.

 

----------------------------Yes, I do this for a living.
0 Kudos
Professor
Professor
5,069 Views
Registered: ‎08-14-2007

Re: need to change the delay for trafiic code in xc3s250e 144 Options


@bassman59 wrote:

You fail.

 

What you coded is not how one should implement a state machine's state register and decoder.

 



Strangely I thought I had already seen this code before.  I looked around and found this:

 

http://forums.xilinx.com/t5/CPLDs/need-to-convert-the-code-for-xc95144TQ100-FROM-xc3s250e/m-p/300385

 

-- Gabor
0 Kudos
Historian
Historian
5,062 Views
Registered: ‎02-25-2008

Re: need to change the delay for trafiic code in xc3s250e 144 Options


@gszakacs wrote:

@bassman59 wrote:

You fail.

 

What you coded is not how one should implement a state machine's state register and decoder.

 



Strangely I thought I had already seen this code before.  I looked around and found this:

 

http://forums.xilinx.com/t5/CPLDs/need-to-convert-the-code-for-xc95144TQ100-FROM-xc3s250e/m-p/300385

 


Well, I've informed his professor that he should be failed for not actually doing the work. ;)

----------------------------Yes, I do this for a living.
0 Kudos