• 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 Design
  3. How to append (or write) data into a file in column wise...

Stats

  • Locked Locked
  • Replies 10
  • Subscribers 125
  • Views 5640
  • 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 append (or write) data into a file in column wise using SKILL/OCEAN

RFStuff
RFStuff over 6 years ago

Dear All,

I want to add/append  data  into a file in column wise using Ocean script.

In other words, I run my  1st for loop which will add data in row wise in column 1.

In the next for loop run the data should be added in row wise but in in column 2.

One example:-

In loop 1 data are added into the file as below:-

1,

15,

2,

4,

11

In loop 2 data are added in the 2nd column as below:-

1,       61,

15,      4,

2,       13,

4,        12,

11         7

Similarly, for nth loop run, the data re to be added in nth column.

I know to append data in row wise into a .csv file using script. But I do not know how to add data in column wise.

Can anybody please tell how to achieve this using OCEAN script..

Kind Regards,

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 6 years ago

    The only way to do this would be to read the file each time and re-write with the additional info appended on the end of each line. Given that you're modifying the file, you'd probably need to rename the file first, read it and write back to the original location as you go along.

    Alternatively, keep all the data in memory and only write it out when you've collected all columns.

    There's no file magic that allows you to append on the end of each line in an ASCII file (in any language) - the file is a sequential series of characters, and you're asking to insert a number of characters intermittently throughout the file - so really all you can do is read the existing file and re-write.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RFStuff
    RFStuff over 6 years ago in reply to Andrew Beckett

    Dear Andrew,

    Thanks for your reply.

    Could you please tell how one can store data in a matrix like MATLAB in OCEAN script.

    Kind Regards,

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to RFStuff

    There is no direct equivalent of a Matlab-style Matrix in SKILL. You can of course create a multi-dimension array - SKILL doesn’t provide a direct way of declaring a multi-dimensional array, but the SKILL code abMultiDimArray.il can do this (in this post).

    Then you can easily populate the contents of such a multi-dimension array using simple syntax:

    data=abMultiDimArray(nCols nRows)
    for(col 0 nCols-1
      for(row 0 nRows-1
        data[col][row]=…
      )
    )

    The double array index you see above is because of the fact that the function I provided can create the multiple dimension arrays for you. You could then write into the array in your loop, and at the end, iterate over the rows and columns and write that data to a CSV file.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RFStuff
    RFStuff over 6 years ago in reply to Andrew Beckett

    Dear Andrew,

    Thanks a lot. The SKILL script is really making life simpler.

    Kind Regards

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • RFStuff
    RFStuff over 6 years ago in reply to Andrew Beckett

    Dear Andrew,

    Thanks a lot. The SKILL script is really making life simpler.

    Kind Regards

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • RFStuff
    RFStuff over 6 years ago in reply to RFStuff

    Dear Andrew,

    Though your .il script we are able to store data. There is also a need to plot let's say the the fist column of data vs the 2nd column of data in ViVA.

    Can we use plot command for this. If so how it can be achieved ?

    Kind Regards,

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to RFStuff

    Do something like this (top is just to create some artificial data):

    nCols=5 nRows=20
    data=abMultiDimArray(nCols nRows)
    for(col 0 nCols-1
      for(row 0 nRows-1
        if(col==0 then data[col][row]=row+0.0 else data[col][row]=random(500)+0.0)
      )
    )

    awvPlotList(
      currentWindow()
      list(
        vectorToList(data[1])
        vectorToList(data[2])
      )
      vectorToList(data[0])
     ?expr list("stuff" "nonsense")
    )

    The second argument to awvPlotList is a list of lists, where each is a list of y values to plot - you can just use vectorToList for the data column you want. The third argument is a list of the common x-values. If you only want to plot a single y slice versus x slice then it would be:

    awvPlotList(
      currentWindow()
      list(
        vectorToList(data[2])
      )
      vectorToList(data[0])
     ?expr list("single")
    )

    The ?expr argument is a list with the same number of entries as there are y lists.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RFStuff
    RFStuff over 6 years ago in reply to Andrew Beckett

    Dear Andrew,

    Can we use value() command for 'data[]'.  In other words, if I want to find vectorToList(data[2]) value at a given vectorToList(data[0]) value.

    Similarly can cross() command be used ?

    Kind Regards,

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to RFStuff

    No. These are SKILL lists and not waveform objects which is what the value and cross function use. You could however use abMakeWaveform from this post to create a waveform from the data.

    newWave=abMakeWaveform(vectorToList(data[2]) vectorToList(data[0]))

    That creates a waveform object from a given y list (the first argument) and x list (the second argument). Having done that you can then do:

    value(newWave 15)
    cross(newWave 200)

    (of course, the precise value or cross arguments will depend on the data).

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RFStuff
    RFStuff over 6 years ago in reply to Andrew Beckett

    Dear Andrew,

    It works nicely.

    By the way, can we add axis label by using awvPlotList ?

    Kind Regards,

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to RFStuff

    If it's the axis units, you can do that using the code in these functions: https://community.cadence.com/cadence_technology_forums/f/custom-ic-design/23345/ocean-calculator-expressions-and-their-units/1313940#1313940 

    You'd create a waveform using awvMakeWaveform and then use these functions before you plot the waveform object with (say) plot() . You can't (I think) do this with awvPlotList.

    Regards,

    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