Author Topic: spice simulator output vectors to csv in reasonable format  (Read 2734 times)

0 Members and 1 Guest are viewing this topic.

Offline javascripterTopic starter

  • Newbie
  • Posts: 6
  • Country: fi
spice simulator output vectors to csv in reasonable format
« on: March 28, 2021, 03:01:47 pm »
hello,

I am trying to output some vectors (specifically .catvect of measurements of times) to a csv so that I can make nicer looking plots of one of these vectors against another and do some other calculations more easily

Currently I just using one sweep, so I could get something usable by using a separate .printfile or .print command for each catvect and then manually deleting everything except the last line (since .printfile adds a new set of data each time the sweep is run, with every new one including all the previous data as well), but I will soon run a sweep of the sweep and that would be an unreasonable amount of work to do every time I change something and rerun the simulation (and even for just one sweep it is pretty suboptimal to need to copy and paste multiple things to update a picture or whatever).

If it matters and currently using eldo, but I think pretty much any spice commands should work on any spice simulator? I think I also have access to spectre. There is ezwave for viewing results by default, but its export as csv looks the same as results of .printfile

google has been pretty useless on spice simulation info, and eldo user manual doesn't seem to have anything more than print and printfile; so I ask here if anyone knows anything that gives more useful output format
 

Offline PKTKS

  • Super Contributor
  • ***
  • Posts: 1766
  • Country: br
Re: spice simulator output vectors to csv in reasonable format
« Reply #1 on: March 28, 2021, 06:42:33 pm »
it may be easier to just dump the data for post processing.

Post processing data languages are suited for parsing that...
(AWK or PERL mostly).

I usually go this way using just:
Code: [Select]
; in which $argv is the selector
    set dumpfle = 'relavant_vectors'
    write {$dumpfle}.tmp $argv

; or just
set tabular = $argv[1]
wrdata $argv


Paul
 

Offline javascripterTopic starter

  • Newbie
  • Posts: 6
  • Country: fi
Re: spice simulator output vectors to csv in reasonable format
« Reply #2 on: March 29, 2021, 12:01:44 pm »
sorry to bother so much about such a basic thing, but with that I am not able to dump the data

if I try:

Code: [Select]

set dumpfile = 'dumpfile'
write {$dumpfile}.tmp = $vect_name

I get an error of unknown parameter TMP; if I try:

Code: [Select]

set dumpfile = 'dumpfile'
write {$dumpfile} = $vect_name

I get an error of unknown parameter vect_name; if I try:

Code: [Select]
set dumpfile = 'dumpfile'

no output file is created; if I try:

Code: [Select]
set tabular = $vect_name
wrdata $vect_name

I get an error for the line with wrdata that it is not consistent with language usage; if I try:

Code: [Select]
set tabular = $vect_name

then the simulation will run, but again no output file is created. I also get bunch of warnings about the netlist where the simulator things I'm trying to use tabular as part of the netlist.



Also, possibly more important question; how on earth do I google things about spice simulator code? I can just find things about food and a some drug forums. (or like with this I can find some things, but pretty much only issues that either apply specifically to other simulators or that are talking about a slightly different format than you are that gives me similar errors as your format does)




 

Offline PKTKS

  • Super Contributor
  • ***
  • Posts: 1766
  • Country: br
Re: spice simulator output vectors to csv in reasonable format
« Reply #3 on: March 29, 2021, 01:44:16 pm »
Ooops  sorry...

Looks you have missed the point - my fault..

These hints came straight from my scripts...
These "aliens"  are my variables...

SPICE is a programmable tool.. a damn good one..
I can not  enter details here.. the Program Reference will do that...

Here is more or less how parts go together...
Code: [Select]
begin
  unset dumpfle
  set dumpfle = $argv[1]
  set wargs = "$argv[2] $argv[3]"
  write /tmp/{$dumpfle}.tmp $wargs
 (..)
* the other way..
  unset tabular
  set tabular = $argv[1]
  wrdata $argv
  shell processData {$tabular}
(..)

So your scripts should be completed with proper variables
and the external applet is a damn powerful  PERL data parser..

This stuff s a gradual program learning curve..

Also .. in any *NIX environment such script may be executable
by the spice interpreter...

Paul
 

Offline javascripterTopic starter

  • Newbie
  • Posts: 6
  • Country: fi
Re: spice simulator output vectors to csv in reasonable format
« Reply #4 on: March 29, 2021, 07:04:28 pm »
that script is some linux script (I don't know the proper word for them, but the sort you run just by typing the filename in a terminal) or part of a spice script?

*NIX = unix, or something more specific? (I'm using some strange old version of linux) (this is for school; otherwise I wouldn't be worried about making nice graphs and would be happy with results from ezwave)


if it is spice, I provide minimum (ish) nonworking example: (less sure of what variables need replacing now though than I was before)

Code: [Select]
*test sweep

.param Hres=100
.param Vdd=1

Vsup VSUP 0 pwl(0 0 1p Vdd)
Rdiv VSUP VDiv Hres
Ccon VDiv 0 1p

.step param Hres 100 200 50
.step param Vdd 1 2 .5

.tran 1p 1n 0 1p

.meas CATVECT tran risetime TRIG V(VDiv) VAL={.1} TARG V(VDiv) VAL={.9}

*begin *line not consistent with langauge syntax
*unset tabular *object "ynset": model TRIG not yet defined
*set tabular = risetime[1]
*wrdata risetime *line not consistent with language syntax
*shell processData {$tabular} *object "shell" missing pins

*unset dumpfile *object "ynset": model TRIG not yet defined
*set dumpfile = risetime[1]
*set wargs = "risetime[2] risetime[3]" *warning object "=" already defined
*write ./{$dumpfile}.tmp $wargs *object "{" unknown parameter


*write "./tmp.txt" "risetime" *line not consistent with language syntax


.printfile tran meas(risetime) FILE="./tmp.txt" *this gives something but not in a sensible way


also, here is some of the file that is outputted by the printfile bit:

Code: [Select]
# PARAM HRES = 2.000000e+02
# PARAM VDD = 1.500000e+00
# TEMPERATURE = 2.700000e+01
# X MEAS(RISETIME[1]) MEAS(RISETIME[2]) MEAS(RISETIME[3]) MEAS(RISETIME[4]) MEAS(RISETIME[5]) MEAS(RISETIME[6]) MEAS(RISETIME[7]) MEAS(RISETIME[8])
1.50000000000e+00 2.19720379586e-10 8.47298349919e-11 5.46541021738e-11 3.29582759339e-10 1.27094267242e-10 8.19812766547e-11 4.39444440386e-10 1.69459315783e-10


# PARAM HRES = 2.000000e+02
# PARAM VDD = 2.000000e+00
# TEMPERATURE = 2.700000e+01
# X MEAS(RISETIME[1]) MEAS(RISETIME[2]) MEAS(RISETIME[3]) MEAS(RISETIME[4]) MEAS(RISETIME[5]) MEAS(RISETIME[6]) MEAS(RISETIME[7]) MEAS(RISETIME[8]) MEAS(RISETIME[9])
2.00000000000e+00 2.19720379586e-10 8.47298349919e-11 5.46541021738e-11 3.29582759339e-10 1.27094267242e-10 8.19812766547e-11 4.39444440386e-10 1.69459315783e-10 1.09308636106e-10

also, to be clear writing a parser isn't the problem; I will avoid using PERL/AWK because I haven't used them before; but it shouldn't be too hard in anything that can read text files (just a bit annoying), I was just hoping there is an easier way build into spice than writing a parser (also given that if I were to have multiple measurements in that file it would still only have one line per step of the sweep of output data)
 

Offline PKTKS

  • Super Contributor
  • ***
  • Posts: 1766
  • Country: br
Re: spice simulator output vectors to csv in reasonable format
« Reply #5 on: March 30, 2021, 04:45:27 pm »


that script is some linux script (I don't know the proper word for them, but the sort you run just by typing the filename in a terminal) or part of a spice script?

*NIX = unix, or something more specific? (I'm using some strange old version of linux) (this is for school; otherwise I wouldn't be worried about making nice graphs and would be happy with results from ezwave)

if it is spice, I provide minimum (ish) nonworking example: (less sure of what variables need replacing now though than I was before)


Here the things:
  • It is a SPICE specific script - it works as a repository of common re-usable stuff
  • each script takes arguments when called from the SPICE terminal or other SPICE script
  • I AM USING NGSPICE on generic LINUX (it works on any *NIX as well)
  • you can *think* of it as a library of *functions* you call at will
  • and the PIPE and SHELL interaction are just a BONUS
  • by running PERL data analysis tools the job is piece of cake
  • the vectors should be properly *named* and referenced to be exported
  • *OR*  dumped in TABULAR formats...
  • on *ANY* *NIX machine a proper SHELL uses the "shebang" indicator to run any script
  • in this case the shebang will run the spice (ngspice) ..

Consult NGSPICE Programmer reference from the folks there...
very clear to understand.. but gradual steep

 http://ngspice.sourceforge.net/

start slow and grow your script library..

Paul  :-+
« Last Edit: March 30, 2021, 04:47:50 pm by PKTKS »
 

Offline javascripterTopic starter

  • Newbie
  • Posts: 6
  • Country: fi
Re: spice simulator output vectors to csv in reasonable format
« Reply #6 on: March 31, 2021, 04:20:07 pm »
Thanks, that link is something I was unable to find with google, hadn't even heard of ngspice before

anyway, I will just write a parser for the csv format I'm getting, I look through that user manual and still get same errors for wrdata and write; only place I can find the errors referenced is eldo user manual which doesn't actually give any more information on them than the error log

i guess maybe eldo just doesn't support wrdata/write, seems strange for something so expensive that I can't find the price
and the other simulator available to me (spectre) seems to not even support category vectors (or something with the .meas it has a problem with at least)
 

Offline PKTKS

  • Super Contributor
  • ***
  • Posts: 1766
  • Country: br
Re: spice simulator output vectors to csv in reasonable format
« Reply #7 on: April 01, 2021, 01:06:42 pm »
Perhaps the current best alternative..

Runs integrated in KiCAD although you won't benefit
the power of programmable scripts in any GUI.

http://ngspice.sourceforge.net/docs/ngspice-manual.pdf

Holger and the folks integrated also wide PSPICE and VDMOS
(ala LTSPICE MOS) into ngspice.. so currently you can convert
old  LTSPICE  directly to SPICE and use VDMOS directly.

I already converted all my old stuff to ngspice..

Single comment is that now the compilation requires at
least  a very very recent GCC version... which limits
the hardware based support.

IMHO? proprietary stuff will only lock you out from all the
new good stuff popping due to the OSS new user base..

Paul
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf