0
\$\begingroup\$

I think this is quick question and assume the range of the wire is 1, but I wonder why they used the following syntax, maybe I am missing something else and would like to know your thoughts.

...
input wire [(1)-1:0]  p1;
output wire [(1)-1:0]  p2;
...
\$\endgroup\$
2
  • 1
    \$\begingroup\$ It's the same as [0:0]. Hard to know without comments. It could have been automatically generated. You need to ask the author of the code. \$\endgroup\$
    – dave_59
    Commented Mar 3, 2021 at 19:32
  • \$\begingroup\$ @dave_59 Indeed, It was automatically generated. \$\endgroup\$
    – JC_Onp
    Commented Mar 3, 2021 at 20:26

1 Answer 1

2
\$\begingroup\$

It appears to just be following a general format of [(WIDTH)-1:0] - bascially the same as [WIDTH-1:0] but with parenthases (for clarity?).

If you want to quickly read how wide it is, just read the number in the brackets. If you want to later change the width, just change the value in the brackets.

Its quite possible that it was code generated from some IP wizard, in which case it would be easier for the wizard to make a signal based on the width by using such code. It wouldn't have to subtract 1 from the width value in the generator code, but instead can simply output to file whatever value (be it number or parameter) you enter as the width.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.