EmbDev.net

Forum: FPGA, VHDL & Verilog Traffic light controller


Author: SJ Oh (nicenom)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Hi, all

I am doing a traffic light controller project with using DE2 board... 
the code I have is compiled perfectly, but when I use the DE2 board, it 
doesn't work properly... Some lights should be turned on when I switch 
on.. but for some reason it keeps having the same issues although I try 
on and on. So I asked the professor about the issue, and he said this is 
logic problem...

I hope you help me out. I attached the file of the code in case.

Author: Klaus (Guest)
Posted on:

Rate this post
0 useful
not useful
Does you Simulation show the same error?

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
SJ Oh wrote:
> the code I have is compiled perfectly
I can write don some lines of VHDL tha compile rperfectly well, but the 
will do nonsens on the hardware. The debugger for VHDL is the funtional 
simulator.

> but for some reason it keeps having the same issues
Which ones?

One question:
How fast is your clock?
    elsif CLK'event and CLK = '1' then                -- how fast ....
      case traffic_light_controller is
        when GR =>
          if count < sec_5 then  
            traffic_light_controller <= GR;
            count <= Count+1;                         -- ... will count count up?
          else
            traffic_light_controller <= YR;
            count<=X"0";   --count is reset to zero
          end if;
Is it really 1Hz?



This is not the problem, but for me it is a major mistake:
type traffic_light_controller_type is (GR, RY, RR2, YR, RG, RR1);
signal traffic_light_controller: traffic_light_controller_type;


traffic_light_controller_machine: process (CLK,CLR)
begin
    if CLR='1' then  
      traffic_light_controller <= GR;
    elsif CLK'event and CLK = '1' then
      case traffic_light_controller is
        when GR =>

        when YR =>

        when RR1 =>

        when RG =>
  
        when RY =>

        when RR2 =>

        when others =>   -- there are no remaining other states !!!!!!
         
      end case;
when others is not necessary when all of the possible states are used. 
The signal traffic_light_controller has only 6 states and each of them 
is explicitly used, so there are no "others" remaining!

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.