• 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. assigning to ocean script variable result of c-shell command...

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 149
  • Views 15287
  • 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

assigning to ocean script variable result of c-shell command.

tyanata
tyanata over 15 years ago

 Hi,

 

I have following problem I want to count time for cetrain operations in ocean sript.

So I use getCurrentTime() command and after that compareTime command. But the problem is that getCurrentTime counts time with accuracy second, but I need larger resolution so I decided to use c-shell command date, I mean following construction:

csh("date +%s.%N")

 

My question is: how to assing the result of this command to the ocean script variable. Now when I do that

 a = csh("date +%s.%N") . The ocean script considers that a = t.

Thanks in advance if some body can help me.

 

 

 

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 15 years ago

    Well, you could use:

    id=ipcBeginProcess("date +%s.%N")
    ipcWait(id)
    dateInfo=ipcReadProcess(id)

    I'm not convinced it's worthwhile though, because there's some overhead in launching a child process for communication this way, and I think it would wipe out the extra resolution you're after.

    You could potentially run a background "slave" process which sat listening for requests for the time, which responded with the date. That way you could do the ipcBeginProcess() once, and then send a "command" to the child to request the date whenever you wanted the current date, and it would feed it back.

    One way to do this would be to use a little C program like this:

     #include <stdio.h>
    #include <sys/time.h>

    main(argc,argv)
    int argc;
    char *argv[;
    {
        struct timeval time;
        char line[256];

        while(fgets(line,256,stdin)) {
        gettimeofday(&time, NULL);
        fprintf(stdout,"%d.%d\n",time.tv_sec,time.tv_usec);
        fflush(stdout);
        }
    }

    I compiled this with "cc -o datequery datequery.c" and then use this SKILL:

     procedure(CCSgetDate()
        unless(CCSgetDate.cid && ipcIsAliveProcess(CCSgetDate.cid)
            CCSgetDate.cid=ipcBeginProcess("datequery")
            ipcWaitForProcess(CCSgetDate.cid)
        )
        ipcWriteProcess(CCSgetDate.cid "get\n")
        ipcReadProcess(CCSgetDate.cid 2)
    )

    and then call CCSgetDate() whenever you want the date (in form seconds.microseconds).

    Alternatively, if you're trying to optimize code, you could use the SKILL profiler, or use the cputime() function in SKILL. Depends really what you're trying to achieve.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • tyanata
    tyanata over 15 years ago

     Thanks for the help!

    I did the approach with cc progam and calling it as procedure.

    There was one syntaxys error in the C program:

    char *argv[;

    I repaired it. And now system works perferctly

     Best regards,

    tyanata

     

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 15 years ago

    Hi tyanata,

    Something odd must have happened when I posted it, because the syntax is correct in my original code. In fact I just went to edit the earlier post to correct it, and when I hit "Edit" the code is correct... So I don't know why it doesn't have the close square bracket.

    Anyway, glad it worked for you.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 15 years ago
    Hi Tyanata,

    You can use the ipcBeginProcess() SKILL command to start the external shell command and then you can read the result into a variable, for example:

    cid = ipcBeginProcess("date +%s.%N")
    => ipc:0
    a = ipcReadProcess(cid)
    => "1272902857.153277000"

    Check out the "Interprocess Communication SKILL Functions" documentation.

    Regards,
    Lawrence.
    • 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