Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

truncated value

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

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- 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