GithubHelp home page GithubHelp logo

n-o-o-b-coder / state-machine-based-controller-for-traffic-signal Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 376 KB

This repository provides a Verilog code for a state machine based Traffic Signal Controller

SystemVerilog 100.00%
statemachine mealy-machine systemverilog verilog hdl

state-machine-based-controller-for-traffic-signal's Introduction

A Finite State Machine Based Traffic Signal Controller

This repository provides a verilog source code for implementing a traffic signal controller.

A traffic signal follows a universal colour code. In our code the three colors are denoted by three binaries.

red    => 2b'11
green  => 2b'01
yellow => 2b'10

There are two traffic signals one pointing towards a lane another to the highway. There is a sensor on the lane which detects if there is any vehicle on the lane.

The lane is less congested compared to the highway. So the controller needs to keep the highway signal green for most of the time. Whenever the sensor detects a vehicle in the lane the traffic signal in the lane changes into green from red going through the intermediate yellow stage.

The highway signal will change into yellow from green when the sensor is high i.e. vehicle is present in the lane. In the same time the lane signal will remain in red state. The highway signal will turn to red after a time delay of 3 secs and the lane signal changes to green. The lane signal will remain in green until the sensor turns low i.e, there is no vehicle in the lane and then changes to yellow. In the meantime the highway signal is fixed at red. After a time delay of 3 secs the highway signal changes to green and the lane signal changes to red.

The state machine hence can be designed by 4 states

parameter  high_green_farm_red =2'b00,
        high_yellow_farm_red =2'b01,
        high_red_farm_green =2'b10,
        high_red_farm_yellow =2'b11;

The state diagram will be

state_diaram

The traffic signal control is modelled using system verilog. Edaplayground was used for simulation and plotting the final waveform.

waveform

state-machine-based-controller-for-traffic-signal's People

Contributors

n-o-o-b-coder avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.