net extension in assignment

C

chainastole

Guest
I write something like that:

wire [3:0] a;
assign a = b[3:0] & c[1:0];

The question is: will the "c" be extended to the width 4 with 2 MSB
zero padded during assignment, or the above writing style may lead to
errors and I should extend the "c" manually to be the same width as "a"
and "b"?
 
It will get zero-padded automatically by any tool that is compliant
with the language standard.
 
Why do you want to write it like that?

I would rather see:

assign a = {2'b00, (b[1:0] & c[1:0])};

It is much clearer this way.


"chainastole" <chainastole@yahoo.com> wrote in message
news:1126513698.687535.281810@g14g2000cwa.googlegroups.com...
I write something like that:

wire [3:0] a;
assign a = b[3:0] & c[1:0];

The question is: will the "c" be extended to the width 4 with 2 MSB
zero padded during assignment, or the above writing style may lead to
errors and I should extend the "c" manually to be the same width as "a"
and "b"?
 
Or

assign a = b[3:0] & {2'b00,c[1:0]};

even though the "&" eliminates the upper two bits. I think it would be
more readable.

RAUL
 

Welcome to EDABoard.com

Sponsor

Back
Top