Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers

truncated value

Altera_Forum
Honored Contributor II
1,827 Views

Hi all, 

 

when I'm designing a simple mux: 

assign cmp_b = sel_ab1 ? (n+1'b1) : a; 

 

where N = 2 

 

I got this warning: 

"Warning (10230): Verilog HDL assignment warning at determining_pivot_DU.v(69): truncated value with size 32 to match size of target (4)" 

 

What can I do in order to eliminate this warning? 

 

Thanks in advance, 

ty6
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
454 Views

I presume cmp_b and a are 32 bits wide. 

Change the adder to match 32bits:  

assign cmp_b = sel_ab1 ? (N+32'h00000001) : a; 

You may need to modify N width, too.
0 Kudos
Altera_Forum
Honored Contributor II
454 Views

Nope, cmp_b and a are 4 bits, but I define N as below: 

 

parameter N = 2; 

 

should I redefine as: 

 

parameter N = 4'b0010 ? 

 

Thanks 

ty6
0 Kudos
Altera_Forum
Honored Contributor II
454 Views

 

--- Quote Start ---  

 

should I redefine as: 

parameter N = 4'b0010 ? 

 

--- Quote End ---  

 

Right.  

Then: 

assign cmp_b = sel_ab1 ? (N+4'b0001) : a; 

 

However these type of warnings are usually not a problem, provided you are aware of the size mismatch and its implications. 

The compiler will truncate extra bits or pad with zero when missing (i.e. your "+ 1'b1" assignment on a 4bit value would be automatically converted into "+ 4'b0000") 

 

Regards
0 Kudos
Reply