2

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.

1
  • 1
    I asked long time ago what was the meaning of +: Here is the link stackoverflow.com/questions/18067571/…. In that case B and C will be sum Commented Jan 7, 2014 at 22:13

1 Answer 1

4

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]

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.