• 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. Allegro X PCB Editor
  3. Help me with Via parameter !

Stats

  • Replies 12
  • Subscribers 159
  • Views 16172
  • Members are here 0
More Content

Help me with Via parameter !

luanvn81
luanvn81 over 13 years ago

 Hi everyone!
I have a skill file ( download from internet), I'm researching it but there are something I don't understand, so I hope evertone can help me. And here is it:
*****************************************************************
axlCmdRegister( "myCompanyViaReport" `myCompanyViaReport)
(defun myCompanyViaReport ()
; Find all of the vias in the design
allViasInDesign=list()
originalVisible=axlVisibleGet()
designName = axlCurrentDesign()
axlVisibleDesign(t)
axlShell("redisplay")
axlSetFindFilter(?enabled '(noall vias) ?onButtons '(noall vias))
allViasInDesign=axlGetSelSet(axlAddSelectAll())
axlClearSelSet()
; Open a file to work on
if(length(allViasInDesign)==0
then
axlUIConfirm("No vias in this design. Please try another design.")
else
writeOutFile = outfile("./TBL-DesignViaReport.csv" "w")
fprintf(writeOutFile strcat("Design Via Report for " designName "\n\n"))
fprintf(writeOutFile "Via Location,Via Net Name,Padstack Name,Via Start
Layer,Via End Layer\n")
; Output data for each via to the file
foreach(via allViasInDesign
viaLocation = sprintf(nil "%L:%L" car(via->xy) cadr(via->xy))
fprintf(writeOutFile strcat(viaLocation ","))
fprintf(writeOutFile strcat(via->net->name ","))
fprintf(writeOutFile strcat(via->name ","))
fprintf(writeOutFile strcat(car(via->startEnd) ","))
fprintf(writeOutFile strcat(cadr(via->startEnd) "\n"))
);end foreach via allViasInDesign
; Close the file and wrap up
fprintf(writeOutFile "END OF FILE")
close(writeOutFile)
axlVisibleSet(originalVisible)
axlShell("redisplay")
axlUIConfirm( "Report has been generated in your working directory." )
; This next line launches Excel and displays the report
axlHttp("TBL-DesignViaReport.csv")
);end if length(allViasInDesign)==0
);end defun myCompanyViaReport
********************************************************************
??????????????????
- How can I know paramerter of Vias such as ViaLocation, via net name, via name, via start layer, end layer in order to make this:
================================================================
viaLocation = sprintf(nil "%L:%L" car(via->xy) cadr(via->xy))
fprintf(writeOutFile strcat(viaLocation ","))
fprintf(writeOutFile strcat(via->net->name ","))
fprintf(writeOutFile strcat(via->name ","))
fprintf(writeOutFile strcat(car(via->startEnd) ","))
fprintf(writeOutFile strcat(cadr(via->startEnd) "\n")
================================================================

I'm using Allegro 16.3 and it seem can't run with BB via.
Tks!
Luanvn81

  • Sign in to reply
  • Cancel
  • luanvn81
    luanvn81 over 13 years ago

    Hi Dave!

    Thank for yours reply! you are really a good man, I really admire you.Your code is perfect, I only fix  the letter "sublass" by "subclass" in your code and then it works now, it has written out  file "tempfile.tmp", but in command line in allegro appear error" :

    E- *Error* fprintf/sprintf: format spec. incompatible with data - "Format is '%s%-30s %-20s %-30s', argument #2 is nil"

    Tks.  I'm so sorry for disturance you.

    Luan.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eDave
    eDave over 13 years ago

    Thanks for finding my typo! I think the "L" key on my keyboard might be stuck.

    This code should be better but look for improvements. It's only meant as a guide. 

     

    subclasses = '("VP24", "VP22")

    foreach(subclass, subclasses

    viaList = stringToSymbol(strcat("viaList_", subclass))

    set(viaList, nil)

    axlVisibleDesign(nil)

    axlVisibleLayer(strcat("via class/", subclass) t)

    ;axlShell("redisplay")

    axlVisibleUpdate(t)

    axlSetFindFilter(?enabled '(noall vias) ?onButtons '(noall vias))

    allViasInSubclass = axlGetSelSet(axlAddSelectAll())

    axlClearSelSet()

    foreach(via allViasInSubclass

    netname = via ->net ->name

    when(netname && (nindex(netname "HC") || nindex(netname "LC") || nindex(netname "GND"))

    set(viaList, cons(via, eval(viaList)))

    )

    );end foreach via

    );end foreach subclass

    writeOutFile = outfile( "TempFile.tmp" ) ; open write tmp file

    foreach(subclass, subclasses

    fprintf(writeOutFile, "                                 %-49s", strcat("Layer ", subclass))

    )

    fprintf(writeOutFile, "\n\n")

    foreach(subclass, subclasses

    fprintf(writeOutFile, "----------------------------------------------------------------------------------")

    )

    fprintf(writeOutFile, "\n\n")

    foreach(subclass, subclasses

    fprintf(writeOutFile, "  Vianame                      Via location         Via net name                  ")

    )

    fprintf(writeOutFile, "\n\n")

     

    while(exists(subclass, subclasses, eval(stringToSymbol(strcat("viaList_", subclass))))

    line = ""

    foreach(subclass, subclasses

    viaList = stringToSymbol(strcat("viaList_", subclass))

    via = car(eval(viaList))

    if(via then

    sprintf(viaLocation "%L:%L" car(via ->xy) cadr(via ->xy))

    sprintf(line, "%s%-30s %-20s %-30s", line, via ->name, viaLocation, via ->net ->name)

    else

    sprintf(line, "%82s", line)

    )

    set(viaList, cdr(eval(viaList)))

    )

    fprintf(writeOutFile, "%s\n", line)

    )

    close(writeOutFile)

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • luanvn81
    luanvn81 over 13 years ago

     Hi ! thank for your code. It works OK, I have changed writting out method in order to apply for many layers.

      Now. Can you show me other problem ?

    I'm testing a code, but there something I don't know. Here the code.

      axlCmdRegister( "Reportvia" `Reportvia)
    (defun Reportvia ()

    if(isFile("netlist.txt") then
    netlist = list()
    netlist = nil
    inPort = infile( "netlist.txt" )
    when( inPort
    while( gets( nextline inPort )
    netlist = cons(concat(nextline),netlist)
    );end while
    close( inPort )
    netlist=reverse(netlist)
    );end when
    else
    axlUIConfirm( "File netlist.txt can't be found!")
    exit()
    );end if

          foreach(netname, netlist
            netlist->netname = 10    ; property of each net name =10
          );end foreach

        writeOutFile = outfile( "./Via_report.txt" )

          foreach(netname, netlist
           fprintf(writeOutFile, "%s %d\n", get_pname(concat(netname)), netlist->netname)
           );end foreach
          close(writeOutFile)

    );end defun

    1/ Can you show me  if the netlist.txt file isn't exist ==> ;E- *Error* eval: unbound variable - netlist. How can I resolve it?

    2/ In order to print netname out, is there any others way to get name of net.

    3/ the result of my code : (via_report.txt), - and the result don't like as I wish.

    D1_HC1_4
     10
    netname 10 
    10 10
    D1_HC2
     10
    D1_HC3
     10
    D1_HC4
     10
    D1_HC5 10
     

     ===> please show me where is wrong?how can I fix it?

    (my netlist is: 

    D1_HC1_4
    D1_HC2
    D1_HC3
    D1_HC4
    D1_HC5

    )

    tks.

    Luan.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eDave
    eDave over 13 years ago

    Hi Luan,

    exit doesn't behave as you are expecting. You can't use it to "exit" your code like this.

    Your code is very confusing. Is this what you are trying to do?

     

    axlCmdRegister( "Reportvia" 'Reportvia)

    defun( Reportvia ()

    if(isFile("netlist.txt") then

    netlist = nil

    inPort = infile( "netlist.txt" )

    when( inPort

    while( gets( nextline inPort )

    nextline = car(parseString(nextline, "\n"))

    netlist = cons(concat(nextline), netlist)

    );end while

    close( inPort )

    netlist = reverse(netlist)

    foreach(netname, netlist

    netname ->count = 10

    );end foreach

    writeOutFile = outfile( "./Via_report.txt" )

    foreach(netname, netlist

    fprintf(writeOutFile, "%s %d\n", get_pname(netname), netname ->count)

    );end foreach

    close(writeOutFile)

     

    );end when

    else

    axlUIConfirm( "File netlist.txt can't be found!")

    );end if

    );end defun

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • luanvn81
    luanvn81 over 13 years ago

     Hi Dave! Actually I want to count number of vias for each net (in netlist.txt)  layer by layer in brd data, and this is whole my code:

     axlCmdRegister( "Reportvia" `Reportvia)
    (defun Reportvia ()
     originalVisible=axlVisibleGet()
     designName = axlCurrentDesign()

    subclasses = '("VP24, VP23, VP22" )

    ;========Check & get input file==========
    if(isFile("netlist.txt") then
    netlist=list()
    netlist=nil
    inPort = infile( "netlist.txt" )
    when( inPort
    while( gets( nextline inPort )
    nextline = car(parseString(nextline, "\n"))
    netlist=cons(concat(nextline),netlist)
    );end while
    close( inPort )
    netlist=reverse(netlist)

    ;==========format what to do for each subclass ==========================
    foreach(subclass, subclasses  

    ;========== Get vias layer by layer & save in a list=====================
    viaList = concat("viaList_", subclass)
    set(viaList, nil)                                       
    axlVisibleDesign(nil)
    axlVisibleLayer(strcat("via class/", subclass) t)
    axlVisibleUpdate(t)
    axlSetFindFilter(?enabled '(noall vias) ?onButtons '(noall vias))
    allViasInSubclass = axlGetSelSet(axlAddSelectAll())
    axlClearSelSet()

    ;===== Create listnetslayer & set list's elements = netlist's element====
    netlistlayer = concat("netlist_", subclass)
    set(netlistlayer,eval(netlist))

    ;========== Caculating number of vias each net in layer =================
    foreach(netname, netlistlayer
       sumvias = setof(via, allViasInSubclass, via->net->name = get_pname(netname))
       netname->count = length(sumvias)
    );end foreach netname
    );end foreach subclass

    ;========== Write out file========
        writeOutFile = outfile( "./Via_by_layer_and_netname_report.txt" ) ; open write tmp file

    ;========== Format outfile =======
       ; ##########NOT FORMAT YET###########
       fprintf(writeOutFile "END OF FILE")

    close(writeOutFile)
    );end when
    ;======= Review begin status======
    else
    axlUIConfirm( "File netlist.txt can't be found!")
    axlVisibleSet(originalVisible)
    axlShell("redisplay")
    );enf if netlist.txt
    );end defun

    ?: =====>  E- *Error* eval: undefined function - D1_HC1_4 , can you show me how to fix this error.

    Thanks alot.

    Luan.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
<>
Cadence Guidelines

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