keyboardcowboy
Member level 3
Weird compliment problem
I have a 32 bit reg, and 64 bit reg. I have to take the 2's complement of the 32 bit reg and assign it to the 64 bit reg. Here is how I tried doing it
The complement went fine but when it gets assigned to "a" the, bits 63 to 32 of "a" are all set to 1 automatically even though I have assigned 0 to "a" before
To fix this issue I made another 32 bit reg "c", assigned the complement of "b" to "c", and then assigned " c" to "a" it worked this time, but I am a bit confused as to why in the case of direct assignment the upper bits of "a" are all set to 1
I have a 32 bit reg, and 64 bit reg. I have to take the 2's complement of the 32 bit reg and assign it to the 64 bit reg. Here is how I tried doing it
Code:
reg [63:0] a;
reg [31:0] b;
a <= (~b)+1
The complement went fine but when it gets assigned to "a" the, bits 63 to 32 of "a" are all set to 1 automatically even though I have assigned 0 to "a" before
To fix this issue I made another 32 bit reg "c", assigned the complement of "b" to "c", and then assigned " c" to "a" it worked this time, but I am a bit confused as to why in the case of direct assignment the upper bits of "a" are all set to 1