• 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. Reading a data file in Veriloga code

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 125
  • Views 16822
  • 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

Reading a data file in Veriloga code

Sali
Sali over 11 years ago

Dear all,

I'm a new user with Veriloga in Cadence I wrote the following model and created a symbol to simulated it with other components but I got the following error:

FATAL (VLOGA-5096):  16: I50:  Cannot open file 'scanftest' for reading. Check this file to verify that it exists and that you have permission to open it for reading and try again. The idea is reading the numbers from the file then store each colomn in a separete array to use it after in the claculations. where I must svae the data file, it is two colomns of 9 decimal numbers and thsi is the code:

`include "constants.vams"
`include "disciplines.vams"

module VxijwithFile(x);
inout x;
electrical x;
real parameter c=1e-9,r=1e3,I=0,Vx0=1,t=5e-6;
integer A[1:9], Vxij[1:9],mcd,retval,count,f;
real Vykl[1:9],a,vx;
genvar i;

analog begin
 @(initial_step) begin
      mcd=$fopen("/home/VxijwithFile/veriloga/scanftest","r");
      retval=2;
      count=0;
      while(retval==2) begin
         retval=$fscanf(mcd,"%f %f",a,vx);
         A[count]=a;
         Vxij[count]=vx;
         Vykl[count]=0.5*(abs(Vxij[count]+1)-abs(Vxij[count]-1));
count=count+1;
      end
$fclose(mcd);

       f=0;
       for (i=1;i<8;i=i+1) begin
       f=f+A[f]*Vykl[f];
       end
end
V(x) <+ exp(-t/(r*c))+idt(exp((t-c*r)/(r*c))*(f/c));

end

endmodule

 

thank you 

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    I tried your module and did not have the problem with reading the file, so I can only assume the issue you have is because either the path you've given is incorrect or that the permissions are such that you can't read the file.

    I did however have a problem due to the fact that your arrays are [1:9] whereas the code tries to write (and read) from index 0, and so they should be defined as [0:9] (maybe [0:8] would be OK). But after fixing that, it ran (not sure whether it was correct, because I'm not sure what it's supposed to be doing).

    So do as the error suggested, and check the path exists and that you have sufficient permissions to read it.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sali
    Sali over 11 years ago

     Thank you so much I corrected the code but it gives me this error, I'm wondering about the "idt" could be used for an expression like this or just with voltage/current signal?

    RROR (VACOMP-2154):
            "/home/VxijwithFile/veriloga/veriloga.va",
            line 34: Encountered the `idt' analog operator embedded in a
            conditionally-executed statement or in an expression. The software does
            not support this use. Do not use the `idt' analog operator in a
            conditionally-executed statement or in an expression.

     -----------The code-------------
    `include "constants.vams"
    `include "disciplines.vams"

    module VxijwithFile(x,n);
    inout x,n;
    electrical x,n;
    real parameter c=1e-9,r=1e3,I=0,Vx0=1,t=5e-6;
    integer mcd,retval,count,f;
    real Vykl[1:9],a,vx,A[1:9],Vxij[1:9];
    genvar i;
    analog begin

     @(initial_step) begin

     mcd=$fopen("/home/Documents/scanftest.dat","r");
          retval=2;
          count=1;
          while(retval==2) begin
             retval=$fscanf(mcd,"%f, %f",a,vx);
             A[count]=a;
             Vxij[count]=vx;
             Vykl[count]=0.5*(abs(Vxij[count]+1)-abs(Vxij[count]-1));
             count=count+1;
          end
    $fclose(mcd);

           f=0;
           for (i=1;i<10;i=i+1) begin
           f=f+A[f]*Vykl[f];

    end
    V(x,n) <+ exp(-t/(r*c))+idt(exp((t-c*r)/(r*c))*(f/c));

    end
    end


    endmodule





     

    Thank you,

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

    Your contribution statement appears to be inside the begin/end block for @(initial_step), whereas it should be outside (it was earlier). So you have two end statements below the contribution statement (the V(x,n) <+ ... line), and one above - there should be two end statements above and one below.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sali
    Sali over 11 years ago

    Thank you so much for your help. This error dissappeared I have another dc convergance error i'm trying to change the design.

    Thanks again 

     

    • 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