Skip to content

[minor] hacompile doc, periodic off by one on pin ranges #4714

Open

Description

@dirkx

When using a constructs such as:

pin in bit  in-##[32:personality] "Inputs to select a channel";

With personality==32 one defines the pins in-00 to in-31. But the documentation will show 00 to 32:

PINS
       radiobutton.N.sel-MM bit in (MM=00..personality)
              Inputs to select a channel

       radiobutton.N.out-MM bit out (MM=00..personality)
              output selected

The fix may be as simple as below ?

diff --git a/src/hal/utils/halcompile.g b/src/hal/utils/halcompile.g
index ed605845e7..e5ddf56ce0 100644
--- a/src/hal/utils/halcompile.g
+++ b/src/hal/utils/halcompile.g
@@ -986,7 +986,7 @@ def document(filename, outfilename):
         if array:
             sz = name.count("#")
             if isinstance(array, tuple):
-                print(" (%s=%0*d..%s)" % ("M" * sz, sz, 0, array[1]), end=' ', file=f)
+                print(" (%s=%0*d..%s-1)" % ("M" * sz, sz, 0, array[1]), end=' ', file=f)
             else:
                 print(" (%s=%0*d..%0*d)" % ("M" * sz, sz, 0, sz, array-1), end=' ', file=f)
         if personality:
``

Activity

  1. BsAtHome commented on Oct 23, 2026

    @BsAtHome
    Contributor

    There is an open PR I think to address this. But that uses some heavy matching.

    I think the correct spec is to do:

       print(" (%s=%0*d..(%s)-1)" % ("M" * sz, sz, 0, array[1]), end=' ', file=f)

    Note the extra parentheses around the %s. The expansion of the string can be a complex expression that is copied in verbatim.

  2. tzuohann commented on Oct 26, 2026

    @tzuohann
    Contributor

    Fixed in #4729 with BsAtHome's one-liner, applied to both pins and params: the ranges now print as MM=00..(personality)-1, e.g. logic shows MM=00..(personality & 0xff)-1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions