How to cast integer to a bits-vector of a certain length?

Hi All,

How to cast integer to a bits-vector of a certain length?

Let’s say I have an int A and bits-vector B: logic [7:0] B.

I’d like to compare them (bit-wise XOR between A and B). So, how can I convert (cast) the A to a vector of 8 bits?

Thank you!

In reply to dmitryl:

You don’t need to cast, you can use int type as normal 2 state bit vector with certain const length.
The difference between then is int supports 2 states (0, 1), and logic supports 4 states (0, 1, x, z).

So if you want to XOR 8 bits of int A and logic[7:0] B, you can:


A[7:0] ^ B

In reply to dmitryl:

8'(A ^ B) or 
8'(A) ^ B will do