Search code examples
verilogsystem-verilog

What is the goal of declaring an array with an offset? [8:1] instead of [7:0]


What is the goal of declaring an array with an offset? [8:1] instead of [7:0]

I'm used to declare my signals with reg [7:0] sig; for an 8b signal.

Declaring reg [8:1] sig; or even reg [1008:1000] sig; gives the same value with sig = 1; $display("sig=%d", sig);

What's the purpose of defining them like that? Is there any disadvantage on calculation(mismatch)? Especially when used with other signals starting from 0.


Solution

  • It depends on the logic you want to create that addresses each individual bit (you might want to read this article on Big-Endian versus Little-Endian. If you don't need to select individual bits, then the ordering and start bit is completely arbitrary.

    If you are designing a positioning system, then it might even make sense to have negative indexes.