Ashkan Khademian
Ashkan Khademian

Reputation: 357

Unknown assignment to parameterized variable

Refer to the following code:

parameter N=8;

reg [N-1:0] variable;
.
.
\\ stuff
.
.
variable = N'bx;

Suppose in some cases we want to set all N bits of our vector to x (unknown). How can it be done? The above code does not work, and the error is as follows:

Error: ... : near "'b": syntax error, unexpected BASE, expecting ';'

Upvotes: 1

Views: 399

Answers (1)

toolic
toolic

Reputation: 62037

You can use replicated concatenation to set all bits to x:

variable = {N{1'bx}};

For a complete description, refer to IEEE Std 1800-2017, section 11.4.12.1 Replication operator.

Upvotes: 2

Related Questions