From the course: Learning Verilog for FPGA Development

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Arithmetic and logic operators

Arithmetic and logic operators - FPGA Tutorial

From the course: Learning Verilog for FPGA Development

Arithmetic and logic operators

- [Instructor] I've been telling you that Verilog resembles c and operators are not an exception to this. Suppose we have three register variables, a, b and c, which are 32 bits long each. Let's start with the usual arithmetic operators. In Verilog, you can perform arithmetic. Addition with the plus operator, subtraction with minus, multiplication with asterisk, integer division or quotient with a slash, and division remainder, or modulo, with the percentage character. Verilog implements the same logical operators of c. These are the operators you would use between boolean expressions in the condition of an "if" statement. These are "and" with a double "and" percent, or, with a double vertical bar, and not with an exclamation sign. The same goes for bitwise logic operators. For the same registers, a, b and c, you can perform a bitwise "and" operation, with the "and" percent operator, or, with the vertical bar, XOR with…

Contents