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.

How to extract parameters from a PSPICE output file using Matlab?

Status
Not open for further replies.

ahmad_abdulghany

Advanced Member level 4
Joined
Apr 12, 2005
Messages
1,206
Helped
102
Reputation
206
Reaction score
22
Trophy points
1,318
Location
San Jose, California, USA
Activity points
11,769
Please see first the shown figure .. it shows a snap shot to the text file that i need to get some data from it automatically with the aid of Matlab..
referring to this topic:

We can say that the MOSFET states are like this:

*Cut off: Vgs < Vt for all Vds
*Linear(triode) : Vgs > Vt and Vds < Vgs-Vt ( I am not sure is it also defined Vds<Vds sat ??)
*Saturation(active): Vgs >Vt and Vds > Vgs-Vt (i have the same wondering about Vds>Vds sat, does this mean MOS is in saturaion??)

How can extract this from the PSPICE output file using Matlab?
I think i have to know some things :
1. How to let Matlab read this text file?
2. How to let Matlab analyze it? i.e. it can search for words like Vgs and take its value that is corresponding to a MOSFET say M_1 as well as its model (n or p) for example
3. Make the required mathematical operations on this data (Vgs-Vt and taking absolute values of Vgs and Vt in case of PMOS) as well as decisions to check state. (cut of, linear, saturation)
4. finally, generate a new Matlab output file saying which MOSFET is in saturation, linear, and which is in cutoff.

I know that this problem needs one to be aware to circuits as well as Matlab programming.. and i hope that i find the person that can help :D

Thanks in advance,
Ahmad,
 
Last edited by a moderator:

Re: Matlab problem!!!

hi
it is easy to open file and search for your parameter.then extract them and use some comparisons.

this code can help you

fid1=fopen('H:\AVANTI\Hspice2004\Project\Gcell\gcell13.tr0');
fid2=fopen('H:\AVANTI\Hspice2004\Project\Gcell\gcell13.CSDF','w+');

while 1
line=fgetl(fid1);
if ~ischar(line), break, end
LL=length(line);
if isempty(line)
continue;
end
if LL>=3
L=line(1:3);
if L=='#N '
disp(char(line(4:LL)))
end
if L=='#C '
fprintf(fid2,'%s\n',char(line(3:LL)));
end
end
end
fclose(fid2);
fclose(fid1);
hspice=load('H:\AVANTI\Hspice2004\Project\Gcell\gcell13.CSDF');
plot(hspice:),1),hspice:),3))
 
Re: Matlab problem!!!

Thank you hr_rezaee for help,
But in fact, I can't fully understand somethings:

First, I am using OrCAD PSPICE (not HSPICE) and i don't know what are files *.tr0 and *.CSDF ?? For my problem, assume that output file is like the snap shot in my post and it contains these fields also..

Second, I don't understand what does the Matlab code you wrote do exactly?

I hope you rewrite it adding comments on it in order to be able to understand it better, also remember that my problem is basically to determine the state of MOSFET (linear, saturation, or cutoff) so please help me to guarantee this funcion.

Thanks in advance,
Ahmad,
 

Matlab problem!!!

hi
if you can, i offer you to use hspice.
that is a sample code that i used to read some output of hspice.
empty lines and lines that begin with #N, ignored and lines that begin with #C copied into file *.csdf
you can arrange your parameter in this style and transfer hole file (*.csdf) into matlab matrix.
see matlab help of load() function.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top