# Casting unpacked objects with width mismatch

**URL:** <https://verificationacademy.com/forums/t/casting-unpacked-objects-with-width-mismatch/34372>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog\
**Created:** [April 22, 2018, 12:40am UTC](https://verificationacademy.com/forums/t/casting-unpacked-objects-with-width-mismatch/34372 "2018-04-22T00:40:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [April 22, 2018, 4:49pm UTC](https://verificationacademy.com/forums/t/casting-unpacked-objects-with-width-mismatch/34372/2 "2018-04-22T16:49:09Z")

</div>

_In reply to [puranik.sunil@tcs.com](https://verificationacademy.com/forums/t/casting-unpacked-objects-with-width-mismatch/34372):_

This is because of [mixing strong and weak types in SystemVerilog](https://www.mentor.com/products/fv/resources/overview/using-strong-types-in-your-systemverilog-design-and-verification-c953bc93-075a-4b67-9e03-aab28f5bf696). Integral packed types are weak types in SystemVerilog, they are silently truncated or extended when making assignments between differently sized types. A cast simply makes your intent explicit. Unpacked types have strong typing, and SystemVerilog requires the bit sizes to match.

The streaming operators don’t care about packed or unpacked. They have many features beyond just simple casting, like bit re-ordering. They also have more intelligent ways of dealing with dynamically sized arrays.

---

_[View the full topic](https://verificationacademy.com/forums/t/casting-unpacked-objects-with-width-mismatch/34372)._
