# What are the truncation/conversion rules in this expression?

**URL:** <https://verificationacademy.com/forums/t/what-are-the-truncation-conversion-rules-in-this-expression/40017>\
**Category:** SystemVerilog\
**Tags:** array-manipulation-methods, SystemVerilog, countones, array-sum\
**Created:** [February 1, 2022, 3:06am UTC](https://verificationacademy.com/forums/t/what-are-the-truncation-conversion-rules-in-this-expression/40017 "2022-02-01T03:06:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![a\_stod](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@a\_stod](https://verificationacademy.com/forums/u/a_stod)\
**Post date:** [February 1, 2022, 3:06am UTC](https://verificationacademy.com/forums/t/what-are-the-truncation-conversion-rules-in-this-expression/40017/1 "2022-02-01T03:06:28Z")

</div>

Given the following code:

```verilog

logic [3:0] bitc [64] = '{default:4'hf};
logic [8:0] count;

assign count = bitc.sum() with ($countones(item));

```

The value of count should be 64\*4=256 (or 9’h100), but I am seeing the count as 9’h1FF.

Can someone explain the semantics of what is going on?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [February 1, 2022, 7:47am UTC](https://verificationacademy.com/forums/t/what-are-the-truncation-conversion-rules-in-this-expression/40017/2 "2022-02-01T07:47:22Z")

</div>

_In reply to [a\_stod](https://verificationacademy.com/forums/t/what-are-the-truncation-conversion-rules-in-this-expression/40017):_

It looks like several tools have problems with this code. The correct answer is 256.

This Siemens EDA sponsored public forum is not for discussing tool specific usage or issues. Please contact your tool vendor directly for support.

---

<div class="post-metadata">

**Author:** ![a\_stod](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@a\_stod](https://verificationacademy.com/forums/u/a_stod)\
**Post date:** [February 1, 2022, 3:53pm UTC](https://verificationacademy.com/forums/t/what-are-the-truncation-conversion-rules-in-this-expression/40017/3 "2022-02-01T15:53:53Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/what-are-the-truncation-conversion-rules-in-this-expression/40017/2):_

Ok thank you. I just wanted to make sure that it wasn’t a SystemVerilog misunderstanding on my part.
