The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Apr 29th, 2024, 6:40am
Pages: 1
Send Topic Print
Reading data from disk (Read 7162 times)
dokim4
New Member
*
Offline



Posts: 2

Reading data from disk
May 03rd, 2004, 6:52pm
 
Hi Ken,

I am working with some design using Verilog-A,
in which the goal of the design is "to read an external disk data into a local module of a top-level schematic".

The data is basically a collection of pure numbers that are generated by other products such as MATLAB or C, and it will be used as sort of gain or weighting factor in a local module. In that sense, it has neither
"voltage" or "current" dimension but just pure numbers.

I want to read them at regular clock times set by a local module using "timer event" statement of Verilog-A.

I tried "vsource" mapping using the option of "pwl" or "pulse" type but they don't work successfully because
I couldn't determine the time format that is required
by "vsource". In my case the data really don't need to have time-dependency.

I tried to do this in many ways and talked to CADENCE feedback a lot so far but they didn't give me a clear
solution. In my opinion, reading data from disk file
is one of common operations that a variety of language
program today can offer.

In addition, I wonder why there is no read statements
in Verilog-A langhuage. You see there are a couple of
"write statements" for example, $fdisplay, $fstrobe,
and $fwrite.

It would be much appreciated if you can help me with soulutions for this problem.

Best regards.


Donghyun Kim

Analog ASICS Lab.
amsung Electromechanics Co.
Tel: +82-31-210-6412
Fax: +82-31-210-6380
Grin
Back to top
 
 

Donghyun Kim
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: Reading data from disk
Reply #1 - May 4th, 2004, 12:12am
 
Verilog-A and Verilog-AMS do not provide a read function because they are based on Verilog, and Verilog does not provide a read function.

Instead, you can use a Spectre voltage source that reads a PWL waveform from a file. There is a seldom used feature in Spectre that allows it to read SPW waveform files.  In this case, you do not need to specify the time value for each point. It has the following format ...
Code:
$SIGNAL
Sampling Frequency = 1e6
Starting Time = 0
Number of points = 100
$DATA ASCII
0.0
0.1
0.2
0.3
...
 


The code that reads these files is quite unforgiving of errors in the format, so be careful with the case of the letters, spaces, etc. If the waveform is contained in a file wave.spw, then you can read it by adding a line like the following to your netlist ...
Code:
Vin (n 0) vsource type=pwl file="wave.spw" 



-Ken
Back to top
 
 
View Profile WWW   IP Logged
Eugene
Senior Member
****
Offline



Posts: 262

Re: Reading data from disk
Reply #2 - May 4th, 2004, 9:14am
 
You could also drop the data into a VerilogA array using an "include" statement. The file format would have to be something like:

var[1]=2.33
var[2]=4.22 etc.

Then you could use the array in the @timer block or with any other trigger you like. You would have access the array with an index variable that you increment with each access. It's a little cumbersome but I am sure it would work and it is not much trouble to generate the proper format in Matlab or C.
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: Reading data from disk
Reply #3 - May 4th, 2004, 2:06pm
 
Actually as part of IEEE1364 Verilog-2001, LDV40 onwards support $fread (and other file reading functions). I suspect these can be used in Verilog-AMS models too, but probably only in the digital context.

It's not available in Verilog-A in spectre yet though, although there do seem to be plans to do that in the not too distant future.

Regards,

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
Eugene
Senior Member
****
Offline



Posts: 262

Re: Reading data from disk
Reply #4 - May 4th, 2004, 7:37pm
 
One small correction to the file format. You will have to include semicolons too.

var[1]=3.22;
var[2]=5.33;
etc.
Back to top
 
 
View Profile   IP Logged
dokim4
New Member
*
Offline



Posts: 2

Re: Reading data from disk
Reply #5 - May 5th, 2004, 4:31pm
 
I do appreciate very helpful replies from all of gentlemen
who spent valuable efforts and time for me.
Smiley
Back to top
 
 

Donghyun Kim
View Profile   IP Logged
mgehring
New Member
*
Offline



Posts: 6
Portland, OR
Re: Reading data from disk
Reply #6 - Mar 7th, 2005, 12:41pm
 
I have not tried this, but you could also use the $table_model function. I noticed this in the V2.2 Accellera manual I got here. I need this too, but I have been using SpectreHDL instead, which nicely supports lookup tables from a disk file. It also allows the filename to be passed as a paramter, making it easy to point several symbols to different data so you can have one generic block for your schematics. I use multiple instances of the same one that point to different files, so I can get typical and worst case sims with one simulation.

BTW, there is nothing on the $table_model function in the "Designer's Guide to AMS" book - perhaps it is a new function since the book came out.

Mark
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.