Signed arithmetic

The data types of the operands are used to determine if signed or unsigned arithmetic should be performed when doing integer math operations. Both operands must be signed to perform signed arithmetic. In Verilog-1995, the integer data type is signed, and the reg and net data types are unsigned.

Verilog-2001 adds five enhancements to provide greater signed arithmetic capability:

Example:

reg signed [7:0] A;
wire signed [7:0] B;
input signed [15:0] C;
function signed [15:0] func1;
16'shCA93                           // 16-bit signed hex value
Result = $signed(D) / 2;            // signed arithmetic
reg signed [7:0] E = 8'b10100011
E >>> 3                             // arithmetic shift yields 8'b11110100 

See also:

Number, Operator