The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> Reading data from disk
https://designers-guide.org/forum/YaBB.pl?num=1083635544

Message started by dokim4 on May 3rd, 2004, 6:52pm

Title: Reading data from disk
Post by dokim4 on May 3rd, 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
;D

Title: Re: Reading data from disk
Post by Ken Kundert on 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

Title: Re: Reading data from disk
Post by Eugene on 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.

Title: Re: Reading data from disk
Post by Andrew Beckett on 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.

Title: Re: Reading data from disk
Post by Eugene on 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.

Title: Re: Reading data from disk
Post by dokim4 on May 5th, 2004, 4:31pm

I do appreciate very helpful replies from all of gentlemen
who spent valuable efforts and time for me.
:)

Title: Re: Reading data from disk
Post by mgehring on 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

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.