• 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. i want to read (2 dimensional array) , not only the first...

Stats

  • Locked Locked
  • Replies 13
  • Subscribers 125
  • Views 9729
  • 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

i want to read (2 dimensional array) , not only the first line

Hagar Hendy
Hagar Hendy over 2 years ago

i have text file (3x3) as shown below in the screenshot , and when i wrote the below code, it only reads the first line,  however i need to read all number ( 2 dimensional array).

the first line will be on port A, second line on: port b , third line on: port C 

module read_file (a,b,c);
output a,b,c;
electrical a,b;
integer in_file_0,data_value, valid,count_0,count_1,count_2,retval;
real A,B,C,v0_int,v1_int,v2_int;
// real int_value,v0_int,int_valu;

analog begin
@(initial_step) begin
in_file_0 = $fopen("/home/hh1667/ee610/my_library/read_file/data2.csv","r");
if($fscanf (in_file_0, "%f,%f,%f", A,B,C)==3) begin
count_0= A;
$display("%f", A);
count_1 =B;
$display("%f", B);
count_2 =C;
$display("%f", C);
end
//$display("%f,%f,%f", A,B,C);
v0_int = A;
v1_int = B;
v2_int = C;
//$display("%f,%f,%f", v0_int,v1_int,v2_int);
end

// V(a) <+ A;
// V(b) <+ B;


end

endmodule

`

  • Cancel
  • Hagar Hendy
    Hagar Hendy over 2 years ago in reply to Hagar Hendy

    also i am  student, and i am using this version through my institute, so i don't know how to use the newest version, or i think i have to let my advisors know that version that i am using is old. 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 2 years ago in reply to Hagar Hendy

    My guess is that your data2.txt file has Windows line endings. Can you show the output of:

    cat -vet /home/hh1667/ee610/my_library/read_file/data2.txt

    (in a UNIX terminal window)?

    My guess that the solution is to run:

    dos2unix /home/hh1667/ee610/my_library/read_file/data2.txt

    to convert the line endings and it should then work. I tested the file with Windows (DOS) line endings, and it failed with the same error that you saw (with SPECTRE16.1). With newer Spectre versions, it worked fine even with the Windows line endings.

    Regards,

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Hagar Hendy
    Hagar Hendy over 2 years ago in reply to Andrew Beckett

    t:

    yeah, it works thanks a lot for your help, appreciate your support 

    • 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