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 > A Verilog Primer: The Essentials > Decision Making

TABLE OF CONTENTS

Xilinx FPGA FPGA Forum

Decision Making

FONT SIZE : AAA

The most basic decision-making element is the if statement, and this can be used in a very simple manner as shown in the basic example below, where the variable y is checked and depending on its value, the register dout will be assigned the value of a or b.

1 if (y == 1)

2 dout = a;

3 else

4 dout = b;

If the decision making requires more than a single statement per choice, then use the keywords begin and end to wrap up several statements such as:

1 if (y == 1)

2 begin

3 dout = a;

4 cout = d;

5 end

6 else

7 begin

8 dout = b;

9 cout = e;

10 end

Finally, if statements can also be nested to provide multiple options, as can be seen in the following example, where if y=1, then the second nested if checks for the value of the variable x.

1 if (y == 1)

2 begin

3 if ( x == 1)

4 dout = a;

5 else

6 cout = d;

7 end

8 else

9 begin

10 dout = b;

11 cout = e;

12 end


  • XCR3512XL-7PQG208C

    Manufacturer:Xilinx

  • CPLD CoolRunner XPLA3 Family 12K Gates 512 Macro Cells 135MHz 0.35um Technology 3.3V 208-Pin PQFP EP
  • Product Categories: CPLDs

    Lifecycle:Active Active

    RoHS:

  • XC3S250E-4TQG144CS1

    Manufacturer:Xilinx

  • FPGA Spartan-3E Family 250K Gates 5508 Cells 572MHz 90nm Technology 1.2V 144-Pin TQFP
  • Product Categories:

    Lifecycle:Obsolete -

    RoHS:

  • XC3S250E-5CPG132C

    Manufacturer:Xilinx

  • FPGA Spartan-3E Family 250K Gates 5508 Cells 657MHz 90nm Technology 1.2V 132-Pin CSBGA
  • Product Categories:

    Lifecycle:Active Active

    RoHS: -

  • XC4020E-2HQ208C

    Manufacturer:Xilinx

  • FPGA XC4000E Family 20K Gates 1862 Cells 0.35um Technology 5V 208-Pin HSPQFP EP
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Obsolete -

    RoHS: No RoHS

  • XC2018-50PC68C

    Manufacturer:Xilinx

  • Field Programmable Gate Array (FPGA)
  • Product Categories: Driver IC

    Lifecycle:Any -

    RoHS: -

Need Help?

Support

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