Range must be bounded by constant expressions

In reply to raja.kuraku:

You can use a shift and mask operation

offset = (DFF_data >> 2*i) & 2**(width)-1

I’ll leave it to you or someone else to figure out the width expression and make sure I have the right operator precedence.