I want to take in a parameter and assign a number of zeroes equal to the paramter to a constant, and use this constant for comparison. how do I do it ?
For example, say parameter is 3, I want to create a constant
n=3'b000;
and use this n in another statement. Only thing is, I don't know n. How do i initialize 'n' zeroes and to what verilog data type do I assign it to ?
Your looking for the replication operator. The syntax is {replication_constant{value}}
.
An example of creating a bus of size WIDTH
to all zeros.
parameter WIDTH = 3;
wire [WIDTH-1:0] n = {WIDTH{1'b0}};
For full description of the replication operator, see IEEE std 1800-2012 § 11.4.12.1 "Replication operator"