• 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. Functional Verification
  3. ncsim: Error within protected source code.

Stats

  • Locked Locked
  • Replies 8
  • Subscribers 65
  • Views 23500
  • 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

ncsim: Error within protected source code.

DylanC
DylanC over 6 years ago

Hello all,

I'm a fairly new user to SimVision and I having some difficulty with my simulation environment.  Continually I am getting the following error:

ncsim: *E,ERRIPR: error within protected source code.

ERROR: SYSTF NULLFD

NULL file descriptor passed to $feof.

(NULL), -1: (NULL)

I can't tell what is causing this and it spams the console making it very hard to find what I'm looking for.  I've read a little that this is mostly benign but I can't even find a way to suppress this error.  

Does anyone know how to resolve this error or at the least make it so it doesn't write to the console?  If it matters I'm simulating some stuff generated from the Intel Qsys program.  

Thank you,

Dylan

  • Cancel
Parents
  • StephenH
    StephenH over 6 years ago

    Hi Dylan.

    Because the offending $feof() call is in some encrypted file, the simulator isn't permitted to give you any detailed information about the context. Normally for unencrypted code you'd see the file/line information to aid debug.

    I played with a few options like "-ncwarn SYSFMT" which can downgrade some soft errors to warnings, and "-plinowarn" to turn off warnings from PLI code, however I couldn't see a way to suppress this error.

    One possibility is to overwrite the implementation of $feof, IF $feof is ONLY used in the offending encrypted file and you can afford to suppress the complete $feof call.

    The following code gives you an example of how to do it; basically registering a new implementation for $feof, which does nothing. You can try it on the small example by pasting the C code into a file "vpi_user.c", and the Verilog code into a file "tb.sv" then use the shell commands from the bottom of this post.

    // vpi_user.c

    #include <stdio.h>

    #include "vpi_user.h"
    #include "vpi_user_cds.h"

    int fake_feof () {return 1;}

    static s_vpi_systf_data systfTestList[] = {{vpiSysFunc, 0, "$feof", fake_feof, 0,0,0},{0}};

    void setup_test_callbacks() {
      p_vpi_systf_data systf_data_p = &(systfTestList[0]);
      vpi_printf("Registering fake_feof\n");
      while (systf_data_p->type) {
        vpi_register_systf(systf_data_p++);
      }
    }

    void (*vlog_startup_routines[MAX_SYSTFS])() = {setup_test_callbacks,0 /*** final entry must be 0 ***/};

    // tb.sv
    module tb;
    integer fh;
    initial
    begin
      if ($feof(fh)) $display("End of file");
    end
    endmodule

    # build VPI library:
    gcc -c -fPIC ./vpi_user.c -o ./vpi_user.o -m32 -I. -I`ncroot`/tools/include
    ld -m elf_i386 -shared -o ./libvpi.so ./vpi_user.o

    # build and run simulation:
    irun tb.sv -loadvpi $PWD/src/libvpi:setup_test_callbacks

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • DylanC
    DylanC over 6 years ago in reply to StephenH

    Hi Stephen,

    Thank you very much for the detailed response.  I have a much better understanding of what's happening now.  I'm having  a little problem with your solution near the end.  I created the library but when I run the simulation it doesn't seem to be loading the library correctly.  I get the following errors:

    failed to load dynamic library ../../../cadence/libvpi:

    ../../..//cadence/libvpi.so: wrong ELF class: ELFCLASS32

    I don't know if these are two separate errors or if the second line is a continuation of the first.  In the irun command what file is $PWD/src/libvpi:setup_test_callbacks pointing to?  Should it be libvpi.so file that was created or something else?

    I'm not very familiar with the software but I tried a few variations but none of them seemed to work. 

    Thanks again!

    Dylan

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

    I actually found my problem.  My server was 64 bit.  Thus I changed the gcc calls to:

    gcc -c -fPIC ./vpi_user.c -o ./vpi_user.o -m64 -I. -I`ncroot`/tools/include
    ld -m elf_x86_64 -shared -o ./libvpi.so ./vpi_user.o

    This problem is improved but still get the following message spammed:

    ncsim: *E,ERRIPR: error within protected source code.

    It does seem like there are less of these than before but I'm not sure.  I can't tell if these are the same errors as before(just without the bottom 3 lines) or if these are other errors generated in the encrypted code.  I notice that I never see 'End of file' outputted.  Is it possible to get these last messages to not display?  This is an improvement though as it's much easier to scan through these than the previous error outputs. 

    Thank you,

    Dylan

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 6 years ago in reply to DylanC

    Hi Dylan.

    Thanks for the update, I'm glad the suggestion has helped. Regarding the remaining error message, I'm not sure what to suggest other than talking to the provider of the encrypted code to get their help to reproduce and debug it (though I realise in your case that might not be possible).It's possible that my fake $feof is only partially correct and that the remaining error is still related to the $feof. I did notice that my small example originally produced a slightly different error message (when run without the VPI library), so perhaps there's something special about the usage of $feof in your encrypted code that means the VPI hack needs to be tuned slightly.

    Steve

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

    OK, I had been running with Xcelium rather than Incisive, but having tried now on Incisive 15.20 I get the correct behaviour too, i.e. there is no "ncsim: *E,ERRIPR: error within protected source code" message, so my guess is that this message relates to something else in your protected code, not the $feof.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • DylanC
    DylanC over 6 years ago in reply to StephenH

    That's good to know that it's working.  I suspected there were probably other errors as well.  The encrypted code is generated from Qsys so I might ask Intel but I'm not terribly optimistic.  Well I think it reduced it enough to be much more usable.

    Thank you,

    Dylan

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

    Dylan, I've been through all the file i/o functions as described in the SV standard, and I can't get any of them to generate the "*E,ERRIPR" message, so I think we can rule out file accesses. It's probably something else that gets broken due to the failed file reads, e.g. some array index is X causing an out of bounds error or something.

    We do have techniques to try to capture the stimulus to a module so you can then replay the stimulus into the module without the surrounding design; this might give you enough to open a support ticket with QSys with a reproducible testcase based only on the waveforms to their block. If you want help with that, drop me an email to my forum ID @cadence.com and I'll try to give you a hand.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • StephenH
    StephenH over 6 years ago in reply to StephenH

    Dylan, I've been through all the file i/o functions as described in the SV standard, and I can't get any of them to generate the "*E,ERRIPR" message, so I think we can rule out file accesses. It's probably something else that gets broken due to the failed file reads, e.g. some array index is X causing an out of bounds error or something.

    We do have techniques to try to capture the stimulus to a module so you can then replay the stimulus into the module without the surrounding design; this might give you enough to open a support ticket with QSys with a reproducible testcase based only on the waveforms to their block. If you want help with that, drop me an email to my forum ID @cadence.com and I'll try to give you a hand.

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

    Nice way to describe the matter you can also visit Holi Wishes to find more information.

    • 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