• 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 run a Python script within an Ocean script and return...

Stats

  • Replies 3
  • Subscribers 144
  • Views 377
  • Members are here 0

How to run a Python script within an Ocean script and return results to ADE Assembler?

NV202510092256
NV202510092256 15 days ago

Hello everyone,

I would like to confirm whether it is possible to execute an Ocean script through ADE Assembler and have its output displayed in the Assembler’s results tab—so that the output can be used before the next simulation iteration.

In particular, I am interested in running a Python script from within an Ocean script. Is there any example or documentation showing how to do this?

I attempted to run a simple Ocean script using the following command:

ocnxlOutputOceanScript(".../test.ocn" ?name "Vout_dc" ?plot t ?evalType 'point)

However, while I can print output to the job log, the Assembler itself only returns nil.

Has anyone successfully managed to achieve this, or could share a working example?

Thank you in advance for your help.

  • Cancel
  • Sign in to reply
Parents
  • TF202506034656
    TF202506034656 4 days ago

    I've done pretty extensive work on this exact process you're describing!

    From what I've learned, there's two options for running a python/cadence pipeline: 
    - cdspythonsrrkit 
    - ipc/shell processes

    For the first point, to quote a previous discussion post reply from Andrew Beckett:

    "One thing that would help is to use the cdspythonsrr kit that is shipped in Virtuoso since IC23.1 ISR12 - see What’s New in Virtuoso IC23.1 ISR12. Previously we had a standalone kit that had to be requested specially, but now we ship a form of it with the software. This allows you to directly read simulation results from Spectre in Python."

    Personally, I've done most of my work on the second bulletpoint, the ipc process.

    To summarize the pipeline, I take all of the data I am trying to send over (waveforms, vectors, scalars etc), and translate it to JSON with a skill script I created. Any vectors / large lists / waveforms are saved to their own CSV's. This is then fed to a parent python process , and converts JSON to python native variable types.

    Like Andrew notes, ipc was really not meant for transferring large data, so I use it more as an ignition of the desired script, and to pass ACK/ERR markers. 

    Hope this helps,

    Trevor Farias

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • NV202510092256
    NV202510092256 2 days ago in reply to TF202506034656

    Hello Trevor,

    Thank you very much for your helpful comments. Do you have any example code that I could use? For instance, in the case you mentioned, you took all of the data you wanted to send (waveforms, vectors, scalars, etc.) and converted it to JSON using a SKILL script you created. Which specific IPC processes did you use?

    Thank you again,

    Nikos Vasiliadis

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • TF202506034656
    TF202506034656 1 day ago in reply to NV202510092256

    Unfortunately I can't give any code, but if you want a super simple barebones example read up on python subprocesses, then simply create an ipc process, save any data you might need to transfer over to a csv / group of csv's, pass those paths through the processes stdout/stdin and pass the results from python back.

    The IPC Processes needed are ipcCreateProcess, ipcReadProcess, ipcWriteProcess and ipcWaitForProcess. 

    You will need a readCsv and writeCsv procedure to aid with this, here's what I did (I can't speak to the efficiency of them):

    procedure( waveformToCsv( waveid file_path )
    let(( xvec yvec len fp )
    xvec = drGetWaveformXVec(waveid )
    yvec = drGetWaveformYVec(waveid )

    when( or( null(xvec) null(yvec))
    error("invalid waveforms")
    )

    len = min( drVectorLength(xvec) drVectorLength(yvec))
    fp = outfile(file_path)
    unless(portp(fp)
    error("couldnt open file")
    )

    for( i 0 len-1
    fprintf(fp "%.15g,%.15g\n" drGetElem(xvec i) drGetElem(yvec i)
    )
    close(fp)
    )
    )
    )

    procedure( csvToWaveform(file_path)
    prog( (inFile xList yList nextLine)
    xList = '()
    yList = '()
    inFile = infile(file_path)
    unless(inFile
    printf("Error. File not found")
    return()
    )
    when( inFile
    while( gets(nextLine inFile)
    nextLine = parseString(nextLine ",")
    if(numberp(cdfParseFloatString(nth(0 nextLine))) then
    xList = cons(atof(nth(0 nextLine)) xList)
    yList = cons(atof(nth(1 nextLine)) yList)
    )
    )

    close(inFile)
    xList = reverse(xList)
    yList = reverse(yList)
    return(drCreateWaveform(drCreateVec('double xList) drCreateVec('double yList)))
    )
    )
    )

    Thanks, 
    Trevor

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • TF202506034656
    TF202506034656 1 day ago in reply to NV202510092256

    Unfortunately I can't give any code, but if you want a super simple barebones example read up on python subprocesses, then simply create an ipc process, save any data you might need to transfer over to a csv / group of csv's, pass those paths through the processes stdout/stdin and pass the results from python back.

    The IPC Processes needed are ipcCreateProcess, ipcReadProcess, ipcWriteProcess and ipcWaitForProcess. 

    You will need a readCsv and writeCsv procedure to aid with this, here's what I did (I can't speak to the efficiency of them):

    procedure( waveformToCsv( waveid file_path )
    let(( xvec yvec len fp )
    xvec = drGetWaveformXVec(waveid )
    yvec = drGetWaveformYVec(waveid )

    when( or( null(xvec) null(yvec))
    error("invalid waveforms")
    )

    len = min( drVectorLength(xvec) drVectorLength(yvec))
    fp = outfile(file_path)
    unless(portp(fp)
    error("couldnt open file")
    )

    for( i 0 len-1
    fprintf(fp "%.15g,%.15g\n" drGetElem(xvec i) drGetElem(yvec i)
    )
    close(fp)
    )
    )
    )

    procedure( csvToWaveform(file_path)
    prog( (inFile xList yList nextLine)
    xList = '()
    yList = '()
    inFile = infile(file_path)
    unless(inFile
    printf("Error. File not found")
    return()
    )
    when( inFile
    while( gets(nextLine inFile)
    nextLine = parseString(nextLine ",")
    if(numberp(cdfParseFloatString(nth(0 nextLine))) then
    xList = cons(atof(nth(0 nextLine)) xList)
    yList = cons(atof(nth(1 nextLine)) yList)
    )
    )

    close(inFile)
    xList = reverse(xList)
    yList = reverse(yList)
    return(drCreateWaveform(drCreateVec('double xList) drCreateVec('double yList)))
    )
    )
    )

    Thanks, 
    Trevor

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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