Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] reading a file in verilogA

Status
Not open for further replies.

ashrafsazid

Advanced Member level 4
Full Member level 1
Joined
Sep 17, 2016
Messages
104
Helped
1
Reputation
2
Reaction score
2
Trophy points
18
Location
Germany
Activity points
935
Hi,

I need some helps regarding reading a file (say .txt, could be .csv as well) from a directory path and then generate a voltage signal based on the array of values from the file.

There is a timing event, and the elements of the file array will be accessed based on timing events.

Here is the VerilogA code:
Code:
`include "constants.vams"
`include "disciplines.vams"

module module_filereader (val);


output val;
electrical val;


parameter real period = 1/10k ;
parameter integer maxcount = 128 ;

integer  dataread, cnt;
real mydata1, mydata2;
real datacol1 [maxcount-1:0];

analog begin

@(initial_step) begin
	cnt = 0;
	dataread = $fopen("/home/datafiles/data.txt","r"); //opening file readable access
	end



@(timer(0, period )) begin
    cnt = cnt+1;
	end


while( cnt < maxcount ) begin	
 	mydata1 = $fscanf(dataread,"%e", datacol1[cnt]);

      end

$display ("| Transient:%g | data1: %g |", $realtime, mydata1) ;

@(final_step) $fclose(dataread);



// V(val) <+ transition(mydata1, 1n, 1n, 1n);

end


endmodule

The input file is like this with many values depending on the count:
Code:
1
4
12
3
6
2
6
7
4
10
7
9
9
..... and so on

The problem is I am getting some simulation error regarding the content of the file and it says

Code:
Fatal error found by spectre during IC analysis, during transient analysis `tran'.
    FATAL (ASL-3211): "/home/cadence_libs/mylib/module_filereader/veriloga/veriloga.va" 35: I225:  Digit not found in input file/string to match $fread/$fscanf/$sscanf format string. Change the format string to match the input file/string or correct the input file/string.

Analysis `tran' was terminated prematurely due to an error.

Please help me to solve this.
 

Have you inspected the format string, relative to the
data? First line? All lines? Number of lines / error trap
for EOF?
 

Have you inspected the format string, relative to the
data? First line? All lines? Number of lines / error trap
for EOF?

Found the issue, it is related to the filesystem difference between Unix and Windows text format. The difference of "Line end Character" which has to be a newline (\n) creates the issue.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top