• 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. Help needed in parsing file!!!!!

Stats

  • Locked Locked
  • Replies 11
  • Subscribers 143
  • Views 16642
  • 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

Help needed in parsing file!!!!!

Messi
Messi over 14 years ago

Hi,

    I am trying to parse a rule file and make into a table.My input file was like:

          ;RULE NO.  LAYER      TYPE       VALUE
               R1A,      POLY,      WIDTH,      0.6
               R1B,      POLY,      SPACE,      0.75
               R2A,      ACTIVE,    WIDTH,      1.5
               R2B,      ACTIVE,    SPACE,      0.75

 I was sucessful in parsing this and making into table using the following code:

               procedure( parseFile( ipFile )
                    let( ( index Table rulesFile value key line ruleLookup)
                      unless( ruleFile = infile( ipFile)
                      error( "Cannot open file %L for reading" ipFile)
                       ) ; unless
  
  
                Table = makeTable("myTable" nil)
                   rulesFile = infile( ipFile )
                  while( gets( line rulesFile )
                  index = parseString( line ",")
                  when(index
                   value = nil
          ;;Remove Headers of the rules file
                       unless(rexMatchp("RULE NO" car(index))
                        rexCompile("^ *")
                       key = rexReplace(car(index) "" 0)
                        foreach(col cdr(index)
                          col = buildString(parseString(col))
                           value = append1(value col))
                          when(key && value
                           Table[key] = value))
                           )
                          ) ;while file
                         close( rulesFile )
   
                   ;;Return values and arrange table
                  foreach(key sort(Table~>? 'alphalessp)
                      printf("%s:  " key)
                        foreach(col Table[key]
                        printf("%-15s " col))
                       printf("\n")
                         )
                      Table
                      ) ;let
                ) ;procedure

But if i modify my input file as:

             ;RULE NO.     LAYER/LAYERS      PURPOSE  MIN.VALUE    COMMENTS
                 R1A,          POLY,                     WIDTH,          0.5
                 R1B,          POLY/ACTIVE,      SPACING,         0.25        ;spacing btn POLY and ACTIVE
                 R1C,          POLY:PIN,                WIDTH,          0.5         ;                "
                 R2A,          ACTIVE,                    WIDTH,          0.5         ; 
                 R2B,          ACTIVE,                 SPACING,         0.25
                 R3A,          MET1:PIN,                 WIDTH,          0.5
                 R3B,          MET1/POLY,           SPACING,         0.3

 What changes i need to make in my earlier code so that it checks the layers instead of a single layer and parse them and put in list?? ie in the Table the layers section should have both the layers specified in rulefile after parsing them(eg: (POLY ACTIVE) in layer section for R1B...

Also i want to know how to ignore the COMMENTS section present in the input file.If anyone in the forum find solution for it,please help me out....

Thanks,

Messi

  • Cancel
  • Austin CAD Guy
    Austin CAD Guy over 14 years ago

     You could check the length of the list you get after parseString. If the list is length 3, you can assume the single layer rule. If the list is length 4, it is a two layer rule and the second layer is the cadr of the list.

     

    Ted

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Messi
    Messi over 14 years ago

    Hi Ted,

       i think checking length wont work as: if i have two layers and after parsing also length would be same as single layer as layers section will be together

    ie: after parsing it would be "R1A"        "POLY"           "WIDTH"     "0.6"        length = 4

                                            "R1B"  "POLY/ACTIVE"    "SPACE"  "0.25"         length=4

    I think i am correct,if not please let me know...

    Thanks,

    Messi

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • kbhow
    kbhow over 14 years ago

    Hi Messi,

    Actually u can manipulate the parseString function to space up the string as below:

    line = "R1A   POLY/ACTIVE    WIDTH     0.6"

    parseString(line "/") -> "R1B"   "POLY"    "ACTIVE"    "SPACE"  "0.25"         length=5

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • kbhow
    kbhow over 14 years ago

    Hi Messi,

    Actually u can manipulate the parseString function to space up the string as below:

    line = "R1A   POLY/ACTIVE    WIDTH     0.6"

    parseString(line "/") -> "R1B"   "POLY"    "ACTIVE"    "SPACE"  "0.25"         length=5

     
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • kbhow
    kbhow over 14 years ago

    Hi Messi,

    Actually u can manipulate the parseString function to space up the string as below:

    line = "R1A   POLY/ACTIVE    WIDTH     0.6"

    parseString(line "/") -> "R1B"   "POLY"    "ACTIVE"    "SPACE"  "0.25"         length=5

     
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Messi
    Messi over 14 years ago

    Hi,

      thanks as per expert help i have modified my code as:

     

              
    procedure( parseFile( ipFile )
      let( ( index Table rulesFile value key line ruleLookup)
       unless( ruleFile = infile( ipFile)
          error( "Cannot open file %L for reading" ipFile)
          ) ; unless
     
     
        Table = makeTable("DRC_Table" nil)
        rulesFile = infile( ipFile )
        while( gets( line rulesFile )
          index = parseString( line ",")
      ;; To process two layers:
         i         =   setof(x parseString(line "/" equal(length(x)  5)
         index  =  appendl(list(cadr(x) caddr(x)) line)
         ipin    =   setof(y parseString(line ":" equal(length(y)  5)
         index  =  append1(list(cadr(y) caddr(y)) line)   
          when(index
            value = nil
     ;;Remove Headers of the rules file
            unless(rexMatchp("RULE NO" car(index))
            rexCompile("^ *")
              key = rexReplace(car(index) "" 0)
              foreach(col cdr(index)
                  col = buildString(parseString(col))
                  value = append1(value col))
          
                   )
           when(key && value
                  Table[key] = value)
             )
          ) ;while file
        close( rulesFile )
        

     ;;Return values and arrange table
        foreach(key sort(Table~>? 'alphalessp)
            printf("%s:  " key)
            foreach(col Table[key]
                printf("%-15s " col))
                printf("\n")
              )
             Table
       ) ;let
    ) ;procedure

    But i am not able to get the output,modified part is shown in bold font.If anyone can debug the error please help.

     Thanks,

    Messi
     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Messi
    Messi over 14 years ago

    Hi,

      I also want to know if i could do rexMatchp simulateonusly for two cases.ie here want to try to match "/ and :" if it is possible please tell me how is possible? i meant syntax to do so!

    Thanks,

    Messi

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago
    Hi Messi,

    Use:

    "[:/]"

    As the pattern. If using IC6, you also have pcreMatchp which has a far more powerful pattern syntax (these are the Perl Compatible Regular Expression functions)

    Regards,

    Andrew
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Messi
    Messi over 14 years ago

    Hi Andrew,

      Thanks for that similarly can i parse string simulatenously

          index = parseString( line "/" or line ":")

    is this possible??

    Thanks,

    Messi

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Messi
    Messi over 14 years ago

    Hi,

     I solved the issues.ignore the posts. :-)

    Thanks,

      Messi

    • 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