The operands of the add operator must be expanded to the size of the left side (or the maximum width of the two operands, depending on the context) before the addition is performed.
In this case, mode_u2 needs to be increased to 32 bits. I could not find a link for this, but it seems that the bit extension takes precedence over the ~ operator. It means:
depth = 'h80 + (~mode_u2) = 32'h0000_0080 + (~32h0000_0000) = 32'h0000_0080 + 32'hffff_ffff = 32'h0000_007f
The result of the operator ! , however, by definition, itβs one bit, and I assume that bit expansion occurs twice:
depth = 'h80 + (!mode_u2) = 32'h0000_0080 + (!32'h0000_0000) = 32'h0000_0080 + 1'h1 = 32'h0000_0080 + 32'h0000_0001 = 32'h0000_0081
Similarly for mode :
depth = 'h80 + (~mode) = 32'h0000_0080 + (~32'h0000_0001) = 32'h0000_0080 + 32'hffff_fffe = 32'h0000_007e
source share