Question

What does ** mean in verilog?

I have the following logic provided for a testbench

localparam NUM_INPUT_BITS       = 1;
localparam NUM_OUTPUT_BITS      = NUM_INPUT_BITS + 1;
localparam MAX_OUTPUT_BIT       = NUM_OUTPUT_BITS - 1;
localparam NUM_TEST_BITS        = (NUM_INPUT_BITS * 2) + 1;
localparam MAX_TEST_BIT         = NUM_TEST_BITS - 1;
localparam NUM_TEST_CASES       = 2 ** NUM_TEST_BITS;
localparam MAX_TEST_VALUE       = NUM_TEST_CASES - 1;
localparam TEST_A_BITTEST_A_BIT = 0;
localparam TEST_B_BIT           = NUM_INPUT_BITS;
localparam TEST_CARRY_IN_BIT    = MAX_TEST_BIT;
localparam TEST_SUM_BIT         = 0;
localparam TEST_CARRY_OUT_BIT   = MAX_OUTPUT_BIT;
localparam TEST_DELAY           = 10;

And I cannot figure out what the NUM_TEST_CASES value will evaluate to. The final answer should be 8, so I'm assumming ** means y ** x = y^x, but I want to confirm.

Was it helpful?

Solution

Double asterisk is a "power" operator introduced in Verilog 2001. It is an arithmetic operator that takes left hand side operand to the power of right hand side operand. In other words, X ** Y raises X to the power of Y. So in your case 2 ** NUM_TEST_BITS means 2 to the power of NUM_TEST_BITS.

OTHER TIPS

** is power operation(raised to the power of).

Often 2 ** N-1 is used to indicate all N bits are 1. For example 2 ** 4 - 1 = 15 means 4'b1111.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top