Verilog

Hi I am actually writing a fsm for traffic light controller
How to to write self checker code for the above fsm

Can any one help me with suggestions or solution

In reply to charan v:

Hi I am actually writing a fsm for traffic light controller
How to to write self checker code for the above fsm
Can any one help me with suggestions or solution

I STRONGLY recommend that you use assertions to clarify your requirements and to do the verification. I copied from my SystemVerilog Assertions Handbook the following assertions on a traffic controller example http://systemverilog.us/vf/tlight_asns.pdf
Code for the assertions is at http://systemverilog.us/vf/tlight_props1.sv
My model had the following requirements:
This design represents a simple traffic light controller for a North-South and East-West intersection. The North-South is the main road, and is given the GREEN light unless a sensor on the East-West Street is activated. When that occurs, and the North-South light was GREEN for sufficient time, then the light will change to give way to the East-West traffic. The design also takes into account emergency vehicles that can activate an emergency sensor. When the emergency sensor is activated, then the North-South and East-West lights will turn RED, and will stay RED for a minimum period of 3 cycles.

In my first attempt at the architecture, I used a model where the East-West and North-South FSMs are loosely tied, and there lies the source of errors such as both East-West and North-South lights turning GREEN in the same cycle, as clearly alerted b the assertions .

To resolve this issue, a centralized architecture will be used. The new design relies on the North-South FSM being the master controller. The East-West slave FSM makes an ew_green_request whenever it wants access to the light. That request is granted with the ew_green_grant handshake. It is provided by the North-South FSM when the North-South goes YELLOW. In addition, to maintain this centralized control, the North-South FSM will inform the East-West FSM to go RED with the ew_to_red_cmd command. That command is a function of the value of the emergency sensor, the value of the East-West sensor, and the length of time that East-West light stayed GREEN. A centralized North-South GREEN timer, instead of two independent timers, controls that time.
\Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us

  • SVA Handbook 4th Edition, 2016 ISBN 978-1518681448
  • A Pragmatic Approach to VMM Adoption 2006 ISBN 0-9705394-9-5
  • Using PSL/SUGAR for Formal and Dynamic Verification 2nd Edition, 2004, ISBN 0-9705394-6-0
  • Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn 0-9705394-2-8
  • Component Design by Example ", 2001 ISBN 0-9705394-0-1
  • VHDL Coding Styles and Methodologies, 2nd Edition, 1999 ISBN 0-7923-8474-1
  • VHDL Answers to Frequently Asked Questions, 2nd Edition ISBN 0-7923-8115