user7696297
user7696297

Reputation:

What does '1 mean in verilog?

I have a register with 4bits.

 reg[3:0] a;

And I want to assign a single bit to it like

 a <= '1;

Apparently it is not the same 1'b1 and 1. I am new to verilog and not sure about its syntax. Can anyone enlighten me please.

Upvotes: 3

Views: 14140

Answers (2)

G Eitan
G Eitan

Reputation: 430

Just to answer the original question,
To assign '1' to a[3:0], do one of the following (assuming you're in an always block):

a <= 4'b1;    // binary 1 in 4 digits
a <= 4'h1;    // hexadecimal 1 in 4 digits
a <= 4'd1;    // decimal
a <= 4'b0001; // I prefer this syntax with explicit zero padding

Each of the above assignments can also explicitly specify the range of the signal:

a[3:0] <= 4'h1;

Note that the assignment <= could be replaced with = depending on your needs.

Upvotes: 1

Colonder
Colonder

Reputation: 1576

This sets all bits to 1, I believe.

Upvotes: 9

Related Questions