0

For example, here:

a = b[16:0] + c[0+:WIDTH];

What does the + sign do? Let's say b was 16'h1234 and c was 16'ABCD.

Arash Fotouhi
  • 1,405
  • 1
  • 18
  • 32
  • 1
    I asked long time ago what was the meaning of +: Here is the link http://stackoverflow.com/questions/18067571/indexing-vectors-and-arrays-with. In that case B and C will be sum – DOS Jan 07 '14 at 22:13

1 Answers1

2

reg1[a+:b] means start with "a" and increment index until "b" cells.

reg1[a-:b] means start with "a" and decrement index until "b" cells.

so

reg1[0+:8] is equivalent to reg1[0:7]

reg1[7-:8] is equivalent to reg1[7:0]

Arash Fotouhi
  • 1,405
  • 1
  • 18
  • 32
  • 1
    Worth mentioning why this is important: It's not possible to perform slicing in the form reg1[i:i+8] as the compiler interprets this as a variable width slice. Therefore if trying to take a slice of a vector using a variable offset (e.g. in a loop) this notation must be used. – Chiggs Jan 07 '14 at 21:55