This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > FPGA Technical Tutorials > Design Recipes for FPGAs Using Verilog and VHDL > Finite State Machines in VHDL and Verilog > Implementing Finite State Machines in Verilog

TABLE OF CONTENTS

Xilinx FPGA FPGA Forum

Implementing Finite State Machines in Verilog

FONT SIZE : AAA

The transition diagram can also be implemented in Verilog, again using two case statements (one for the state transitions and one for the outputs):

module fsm (

count, / Output Value

clk, / Clock

rst, / Reset

choice / Decision /Choice Value

);

output [1:0] count;

input clk;

input rst;

input choice;

reg [1:0] count;

reg [1:0] state; / state variable

parameter s0=0, s1=1, s2=2, s3=3;

always @(state)

begin

case (state)

s0:

count = 2’b00;

s1:

count = 2’b01;

s2:

count = 2’b10;

s3:

count = 2’b11;

default:

count = 2’b00;

endcase

end

always @(posedge clk or posedge rst)

begin

if (rst == 0)

state = s0;

else

case (state)

s0:

state = s1;

s1:

if (choice)

state = s3;

else

state = s2;

s2:

state = s0;

s3:

state = s0;

endcase

end

endmodule

  • XC2V2000-5BFG957I

    Manufacturer:Xilinx

  • FPGA Virtex-II Family 2M Gates 24192 Cells 750MHz 0.15um Technology 1.5V 957-Pin FCBGA
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Obsolete -

    RoHS:

  • XC2V2000-5FFG896I

    Manufacturer:Xilinx

  • FPGA Virtex-II Family 2M Gates 24192 Cells 750MHz 0.15um Technology 1.5V 896-Pin FCBGA
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Obsolete -

    RoHS:

  • XC5VLX110T-1FF1136I

    Manufacturer:Xilinx

  • FPGA Virtex-5 LXT Family 110592 Cells 65nm Technology 1V 1136-Pin FCBGA
  • Product Categories: FPGAs

    Lifecycle:Active Active

    RoHS: No RoHS

  • XC5VLX110T-1FFG1738C

    Manufacturer:Xilinx

  • FPGA Virtex-5 LXT Family 110592 Cells 65nm Technology 1V 1738-Pin FCBGA
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Active Active

    RoHS:

  • XC5VLX110T-2FF1738I

    Manufacturer:Xilinx

  • FPGA Virtex-5 LXT Family 110592 Cells 65nm Technology 1V 1738-Pin FCBGA
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Active Active

    RoHS: No RoHS

Need Help?

Support

If you have any questions about the product and related issues, Please contact us.