• 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. Compare list items in if condition.

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 17175
  • 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

Compare list items in if condition.

gs748
gs748 over 10 years ago

Hello,

I am running issues while comparing below 2 list items. can you please help me identify the bug.

pline = '( "State" "4" "time")
    i=length(pline)
    item3 = nth(i-1 pline)
    item2 = nth(i-2 pline)
    item1 = nth(i-3 pline)

line = '("4" "Done")
     len_line=length(line)
     item5=nth(len_line-1 line)
     item4=nth(len_line-2 line)

if( (item2 == item4); compare fails and executes else part but if condition should pass as item2 & item4 has "4"!
    then
    lista = list(item1 item2 item3 item4 item5)

else

   item5 = "UNKNOWN"
   lista = list(item1 item2 item3 item4 item5)
 );end if 

printf("List is %L\n" lista)

  • Cancel
Parents
  • gs748
    gs748 over 10 years ago

    Thanks for the reply! I was not sharing the actual code as the logic I use if not that good :)

    But here I am sharing my actual code. I am reading 2 files, one line at a time.

    From the first file, each line is split by ‘,’ and listed as item1-7.

    From second file, each line is split by ‘:’ and listed as item8-7

    Item 2 and item9 are numbers that being compared in IF condition – which doesn’t work. Can you please help look into this. Thanks!

    procedure(readcsv(ln)
     cline=ln;
     pline=parseString(cline ",")
      i=length(pline)
      printf("Length is %d\n" i)
       item7 = nth(i-1 pline)
       item6 = nth(i-2 pline)
       item5 = nth(i-3 pline)
       item4 = nth(i-4 pline)
       item3 = nth(i-5 pline)
       item2 = nth(i-6 pline)
       item1 = nth(i-7 pline)
     ; printf("ITEM'S 1-7:\n %L\n %L\n %L\n %L\n %L\n %L\n" item1 item2 item3 item4 item5 item6 item7)
    port1=infile("codes.csv")
      when(port1
       while(gets(lne port1)
         lne = substring(lne 1 strlen(lne)-1)
        ;printf("LINE: %s\n" ln)
         line=parseString(lne ":")
         len_line=length(line)
         item8=nth(len_line-1 line)
         item9=nth(len_line-2 line)
        ;printf("ITEM'S 8-9:\n %L\n %L\n" item7 item8)
         if( (item2 == item9); if condition is always skipped

           then
           item10 = item8    
           printf("ITEM 10 is:%L\n" item8)
           lista=list(item1 item2 item3 item4 item5 item6 item7 item10)
          else
          item10 = "UNKNOWN"

           lista=list(item1 item2 item3 item4 item5 item6 item7 item10)
         );end if
        );end while
       );end when
    printf("LIST ITEM'S:%L\n" lista)
    lista
    );end proc readcsv openok post

    ;-----------------------------------
    myTable = makeTable("atable1" 0)
    port=infile("postout1")
    count=0
    listN='()
    listNew='()
    when(port
       while(gets(ln port)
    ln = substring(ln 1 strlen(ln)-1)
    ;   printf("PORT LINE: %s\n" ln)
         listb=readcsv(ln)
         listN = cons(listb listN)
        )
    )

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • gs748
    gs748 over 10 years ago

    Thanks for the reply! I was not sharing the actual code as the logic I use if not that good :)

    But here I am sharing my actual code. I am reading 2 files, one line at a time.

    From the first file, each line is split by ‘,’ and listed as item1-7.

    From second file, each line is split by ‘:’ and listed as item8-7

    Item 2 and item9 are numbers that being compared in IF condition – which doesn’t work. Can you please help look into this. Thanks!

    procedure(readcsv(ln)
     cline=ln;
     pline=parseString(cline ",")
      i=length(pline)
      printf("Length is %d\n" i)
       item7 = nth(i-1 pline)
       item6 = nth(i-2 pline)
       item5 = nth(i-3 pline)
       item4 = nth(i-4 pline)
       item3 = nth(i-5 pline)
       item2 = nth(i-6 pline)
       item1 = nth(i-7 pline)
     ; printf("ITEM'S 1-7:\n %L\n %L\n %L\n %L\n %L\n %L\n" item1 item2 item3 item4 item5 item6 item7)
    port1=infile("codes.csv")
      when(port1
       while(gets(lne port1)
         lne = substring(lne 1 strlen(lne)-1)
        ;printf("LINE: %s\n" ln)
         line=parseString(lne ":")
         len_line=length(line)
         item8=nth(len_line-1 line)
         item9=nth(len_line-2 line)
        ;printf("ITEM'S 8-9:\n %L\n %L\n" item7 item8)
         if( (item2 == item9); if condition is always skipped

           then
           item10 = item8    
           printf("ITEM 10 is:%L\n" item8)
           lista=list(item1 item2 item3 item4 item5 item6 item7 item10)
          else
          item10 = "UNKNOWN"

           lista=list(item1 item2 item3 item4 item5 item6 item7 item10)
         );end if
        );end while
       );end when
    printf("LIST ITEM'S:%L\n" lista)
    lista
    );end proc readcsv openok post

    ;-----------------------------------
    myTable = makeTable("atable1" 0)
    port=infile("postout1")
    count=0
    listN='()
    listNew='()
    when(port
       while(gets(ln port)
    ln = substring(ln 1 strlen(ln)-1)
    ;   printf("PORT LINE: %s\n" ln)
         listb=readcsv(ln)
         listN = cons(listb listN)
        )
    )

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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