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.

Import verilog data into matlab

Status
Not open for further replies.

rsrinivas

Advanced Member level 1
Joined
Oct 10, 2006
Messages
411
Helped
50
Reputation
100
Reaction score
11
Trophy points
1,298
Location
bengalooru
Activity points
3,689
Hi friends
I have a verilog code which provides a output of samples to a stimulus.
Howdo i import it to matlab to plot it.
The samples of the filter output are in an array say array[32627:1].
Thanks in advance

cheers
srinivas
 

If coefficients of the filter are in text file, you can use matlab function 'fread' to input them to matlab workspace.
see 'help fread'

You didn't said in what form or format are data you want to input to matlab.
If you can post some sample, you will get more reliable answer.
 

Hi vadkudr
Thanks for the reply.
I have 16 bit format data(not the coefficients)that are filtered by a digital quantized 6'th order iir butterworth filter.i.e i am feeding data from a test bench(verilog) to the quantized filter and getting some output.I really need to plot these samples in matlab to verify whether my filter is functionally correct and stable.
here is some sample data
16 bit signed quantity 1 bit mantissa and 15 bit fractional part.
an impulse looks like this
7fff in hexadecimal or 0111 1111 1111 1111 in binary.bcos an impulse means a high amplitude, less width, unit area the amplitude has to be represented by the maximum affordable value in this format i.e 16 bit format. and how it is 7fff??

0 sign bit the MSB as it is positive
111 1111 1111 maximum value representable.hence an impulse is
0111 1111 1111 1111

In this way i have lot of data in my testbench say nearly 3000 samples.
pls do let me know any way
i need to plot these samples on a linear or log frequency scale

Pls do correct me if i am wrong anywhere.

Thanks in advance

cheers
srinivas
 

You did not wrote where matlab will get your data from, what is fatrmat of your file containing data.
Assuming that your data are in text file with one sample per row:
for example:
0010100011101010
0101001111101011
1010011011011101
...
etc

you can use next rows of code

fid=fopen(filename,'r')

a=zeros(1,3000);
i=1;

while 1
tline = fgetl(fid);
if ~ischar(tline), break, end
a(i)=bin2dec(tline);
if a(i)>2^15-1, a(i)=2^16-a(i); end
i=i+1;
end

fclose(fid)

It is only sample code, I typed it here without prooving, but main idea is like this
Unfortunztely you didn't said input format of your data :-( So I tried to assume...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top