G
Gary Spivey
Guest
It was my understanding that Verilog would zero pad when assigning a smaller
number to a larger one.
In the following module:
module tilde (output reg[7:0] z, input [3:0] a);
always @* begin
z = ~a;
end
endmodule
I would have expected the upper four bits of z to always be 0. I assumed
that the four bits of a would be inverted, and then the resulting number
would be zero-padded and assigned to z.
However, in ModelSim at least, the upper four bits of z are always 1 -
regardless of the value of a. Can somebody explain this behavior to me? It
appears that either I or ModelSim are mistaken (and I am not taking odds on
which one).
-Gary
number to a larger one.
In the following module:
module tilde (output reg[7:0] z, input [3:0] a);
always @* begin
z = ~a;
end
endmodule
I would have expected the upper four bits of z to always be 0. I assumed
that the four bits of a would be inverted, and then the resulting number
would be zero-padded and assigned to z.
However, in ModelSim at least, the upper four bits of z are always 1 -
regardless of the value of a. Can somebody explain this behavior to me? It
appears that either I or ModelSim are mistaken (and I am not taking odds on
which one).
-Gary