# Vector assignment in system verilog

**URL:** <https://verificationacademy.com/forums/t/vector-assignment-in-system-verilog/33342>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, systemverilog-Arrays\
**Created:** [July 26, 2017, 12:41pm UTC](https://verificationacademy.com/forums/t/vector-assignment-in-system-verilog/33342 "2017-07-26T12:41:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![svishnu](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@svishnu](https://verificationacademy.com/forums/u/svishnu)\
**Post date:** [July 26, 2017, 12:41pm UTC](https://verificationacademy.com/forums/t/vector-assignment-in-system-verilog/33342/1 "2017-07-26T12:41:25Z")

</div>

I defined a signal as

```verilog
output logic [15:0]data;

```

what is the difference between the following assignments if mem[addr] is a 16 bit vector?

```verilog
data[15:0] = mem[addr];

```

```verilog
[15:0]data = mem[addr];

```

---

<div class="post-metadata">

**Author:** ![ocmob](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/o/ec9cab/32.png) [@ocmob](https://verificationacademy.com/forums/u/ocmob)\
**Post date:** [July 26, 2017, 1:05pm UTC](https://verificationacademy.com/forums/t/vector-assignment-in-system-verilog/33342/2 "2017-07-26T13:05:05Z")

</div>

The second assignment is illegal. When assigning you can only specify array dimensions, packed or unpacked, at the right side of array name. If you ask about difference between

logic [15:0] data  
logic data [15:0]

it is that dimensions specified before array name are “packed” dimensions which means that elements occupying these indexes are reliably positioned next to each other in memory. The dimensions specified after the array name are “unpacked” dimensions, which means those elements could be arranged in memory in a distributed way, as deemed optimal by the SV engine, not necessarily next to each other.
