Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Design any FSM in VHDL or Verilog?

Answer Posted / arpan

// Tollbooth controller with VERILOG. My design contains 4
//inputs and one output. Output is : 1. stop_go signal ->
//This signal contains two leds i.e. green and red. Green
//denotes vehicle can go and Red denotes vehicle to stop.
//Input is 1.x -> This signal denotes presence of vehicle
//in toll booth. 2.heavy_light_vehicle -> This signal
//denotes weather its a heavy vehicle or light vehicle and
//pay accordingly. For heavy vehicle pay Rs 5 for light
//vehicle pay Rs 1. 3.Other input signal is clk and clear.

module controller (stop_go,X,heavy_light_vehicle,clk,clear);

input x, clk, clear, heavy_light_vehicle;

output stop_go;

reg stop_go;

reg [2:0]pay; //Amt that is being paid.

reg [0:1] state, next_state;

parameter s0 = 2'b00, s1 = 2'b01, s2 = 2'b10, s3 = 2'b11;

parameter red = 1'b0, green = 1'b1;

always @ (posedge clk)

begin

if (clear)
begin
stop_go <= red;
state <= s0;
pay <= 1'd0;
end
else
state <= next_state;
end

always @ (state or X or pay)

begin

case (state)

s0 : if (X)
next_state = s1;
else
next_state = s0;
pay = 3'd0;

s1 : if (heavy_light_vehicle)
begin
pay = 3'd1;
next_state = s2;
end
else
begin
pay = 3'd5;
next_state = s2;
end

s2 : if (pay == 3'd1 || pay == 3'd5)
begin
stop_go = green;
next_state = s3;
else
next_state = s1; // If correct amount is
//not paid then next_state again goes to s1

s3 : begin
stop_go = red;
next_state = s0;
end

default : next_state = s0;
endcase

end

endmodule

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are set up time & hold time constraints?

1059


Explain the 8051 microcontroller architecture?

1029


State the differences between a procedure and a macro.

1142


Describe the instruction register of 8085?

982


What is the logical difference between move a to b and compute b = a?

1016


Explain the differences between the nmi and intr

1113


How subroutine can be called from the main program and how the program returns from the subroutine?

935


What type of instruction is cpi ā€˜c’ and define the action it performs?

1097


Can you name the different types of processor?

1072


The address capability of 8085 is 64 kb.explain?

1931


What is the use of microprocessors?

933


What are the software instructions related to stack operations?

1050


What is lookup table microcontroller?

934


Write the special functions carried by the general purpose registers of 8086?

958


Which interrupt is not level-sensitive in 8085?

1041