• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. how to merge a list of pins back into bus<0:7> data<8:15...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 560
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to merge a list of pins back into bus<0:7> data<8:15>

ebecheto
ebecheto 7 months ago

Hi all, does anyone knows if this function already exist :

I have a list of expanded nets. Let say, they are already removed from duplicates, and sorted alphanumerically

nets='("net<0>" "net<1>" "net<2>" "clk" "data<0>" "data<1>" "data<3>" "reset" "sig<9>" "sig<10>" "sig<11>" "sig<12>")

; Expected result :

netBusListMerge(nets)=='("net<0:2>" "clk" "data<0:1>" "data<3>" "reset" "sig<9:12>" )

It is a bit like the reverse function of dbProduceMemName() i want, but for a list of sorted random pins.

I assume i am not the first one who add this need.

Any help is welcomed.

Regards

  • Cancel
  • henker
    henker 7 months ago


    I remember vaguely to have seen something like this either in the forum or in support but was not able to find it again. Maybe somebody else has a better memory.
    However, I have an older piece of code that might almost fit your requirements, although prob. not very efficient. I've not used it in applications so it may not cover corner cases (was just a proof-of-concept). So, handle with care. 

    One thing is that the bus order is not determined from the input sequence. Although it accepts the bits ascending/descending/mixed, the output is always MSB-first. If you need it the other way, change the "base binx ainx" arguments to "base ainx binx", or extend it to also remember the order of the bits (would go into the 'merge' part).

    Regards,

    ; unroll list of bus and bit names
    procedure(unroll_busNameList(nameList)
        let( (res tmp new n a b base ainx binx fnc)
            fnc = lambda( ()
                when( base
                    new = if(binx==ainx
                        sprintf(nil "%s<%L>"    base ainx)
                        sprintf(nil "%s<%L:%L>" base binx ainx)
                    )
                    res = tconc(res new)
                    base=nil
                )
            )
            foreach(name nameList
                tmp=parseString(name "<:>")
                n = car(tmp)
                if( cadr(tmp) then
                    ; name is bus or single bit
                    a = atoi(cadr(tmp))
                    b = if(caddr(tmp) atoi(caddr(tmp)) a)
                    cond(
                        ( !numberp(a) || !numberp(b)
                            error("invalid indices in %L\n" name)
                        )
                        ; merge
                        ( base==n && binx+1==a a=ainx)
                        ( base==n && ainx-1==b b=binx)
                        ; output cache
                        ( t funcall(fnc))
                    ); cond
                    base = n
                    ainx = a
                    binx = b
                else
                    ; name is scalar
                    ; output cache
                    funcall(fnc)
                    res = tconc(res n)
                )
            )
            ; output remaining cache
            funcall(fnc)
            car(res)
        ); let
    )
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett 7 months ago in reply to henker

    Here's some code I've posted before which does this. This does preserve the order...

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information