Where can I find some help with CACE histogram plo...
# chipalooza
a
Where can I find some help with CACE histogram plot? I found some info in the source code, but I am failing to make it work. My testbench generates a vector with voltages from various monte carlo runs, like this:
Copy code
.control
let it = 0
let iterations = \{iterations|maximum\}
let output_option = \{output_option\}
let vref_data = vector(iterations)
let vref_mean = 0
print iterations
print vref_data
dowhile it < iterations
	reset
	op
	let vref_data[it] = V(vref)
	let vref_mean = vref_mean + V(vref)
	let it = it + 1
end
if output_option = 0
	print vref_data
	wrdata \\\{simpath\\\}/\\\{filename\\\}_\\\{N\\\}.data vref_data
	quit
end
let vref_mean = vref_mean / iterations
if output_option = 1
	print vref_mean
	wrdata \\\{simpath\\\}/\\\{filename\\\}_\\\{N\\\}.data vref_mean
	quit
end
let vref_deviation = 0
let it = 0;
dowhile it < iterations
	let vref_deviation = vref_deviation + (vref_data[it]-vref_mean)^2
	let it = it+1
end
let vref_deviation = (vref_deviation / iterations)^0.5
let vref_accuracy = 3 * vref_deviation / vref_mean
print vref_accuracy
wrdata \\\{simpath\\\}/\\\{filename\\\}_\\\{N\\\}.data vref_accuracy
quit
.endc
Here is what I am using inside the project file:
Copy code
+
	name:			vref_histogram
	status:			skip
	description:	Reference Voltage vs Process Variation
	display:		Vref vs Process Variation
	unit: 			V
	simulate {
		tool:		ngspice
		template:	tb_vref_mc.spice
		format:		ascii .data null result
	}
	plot {
		type: 'histogram'
		filename: vref_vs_process.png
		xaxis: result
	}
	conditions {
		name: iterations
		maximum: 10

		+
		name: output_option
		typical: 0
	}
just found out that the single quotes ' ' around 'histogram' were causing an error. Still having problems with the plot bins, with all results falling in the same bin, or just one result showing? not sure
t
@Adan Kvitschal: What does your output data file look like? Do you see the variation in results in the file?
a
Thanks for the quick reply, I am trying to locate the file now
where does cace store it?
t
In the simulation directory (usually
ngspice/
), but you will need to select "Keep files after simulation" from "Settings".
(or rather "Keep simulation files")
I have a suspicion that all the numbers in the output file are the same. But I want to confirm that before I start explaining how the random number generator in ngspice works. . .
a
i got just one line in the file
Copy code
1.00000000e+00  1.22060486e+00
t
Ah. Okay, first you need to do
set appendwrite
.
a
I am not an expert using ngspice to process data, so I might be comiting a simple mistake
t
I think that works best if you set
appendwrite
after the first write, so the first write creates the data file and after that they all append to it.
a
I tought there would have ocurred a single write using this:
Copy code
wrdata \\\{simpath\\\}/\\\{filename\\\}_\\\{N\\\}.data vref_data
t
Oh, right. But it's a vector. . . maybe you need
$&vref_data
and not just
vref_data
?
a
the backslashes appear when I open the file in vscode, they dont seem to be causing any problems
thanks, that was an issue I wasn't aware of. Now I got all the data, apparently it is mixed with the sim condition. Trying to figure it out, learning the syntax as I go
Copy code
1.80000000e+00  1.22265000e+00  1.80000000e+00  1.22343000e+00  1.80000000e+00  1.22294000e+00  1.80000000e+00  1.22205000e+00  1.80000000e+00  1.21891000e+00  1.80000000e+00  1.22000000e+00  1.80000000e+00  1.22705000e+00  1.80000000e+00  1.22117000e+00  1.80000000e+00  1.22690000e+00  1.80000000e+00  1.22803000e+00
t
Try
set wr_singlescale
. Then you should get only one reference value followed by your vector of 10. However, I'm not sure how that works in CACE with the "format" line. I'm sure I have handled vectors on the result line but I'd have to go back and see how I was handling it.
a
That puts only one ocurrence of avdd in the data
Copy code
1.80000000e+00  1.22372000e+00  1.22527000e+00  1.22636000e+00  1.22325000e+00  1.22343000e+00  1.22383000e+00  1.22062000e+00  1.22614000e+00  1.22326000e+00  1.22702000e+00
I think the data should be in columns, so the vector indices may be the way to fix this. My temp sweep for instance works because it is formated like this:
Copy code
-4.00000000e+01  1.25328232e+00 
-3.50000000e+01  1.25289129e+00 
-3.00000000e+01  1.25259234e+00 
-2.50000000e+01  1.25237311e+00 
-2.00000000e+01  1.25222288e+00 
-1.50000000e+01  1.25213246e+00 
-1.00000000e+01  1.25209394e+00 
-5.00000000e+00  1.25210055e+00 
 0.00000000e+00  1.25214646e+00 
 5.00000000e+00  1.25222661e+00 
 1.00000000e+01  1.25233665e+00 
 1.50000000e+01  1.25247275e+00 
 2.00000000e+01  1.25263159e+00 
 2.50000000e+01  1.25281023e+00 
 3.00000000e+01  1.25300611e+00 
 3.50000000e+01  1.25321695e+00 
 4.00000000e+01  1.25344076e+00 
 4.50000000e+01  1.25367581e+00 
 5.00000000e+01  1.25392061e+00 
 5.50000000e+01  1.25417391e+00 
 6.00000000e+01  1.25443475e+00 
 6.50000000e+01  1.25470249e+00 
 7.00000000e+01  1.25497685e+00 
 7.50000000e+01  1.25525806e+00 
 8.00000000e+01  1.25554702e+00 
 8.50000000e+01  1.25584550e+00
I do not intend to spend much of your time, many thanks for yous answers, you really saved me some hours of work. I will read the ngspice manual some more here
t
This will work:
Copy code
set wr_singlescale
let it = 1
wrdata ngspice/test.data vref_data[0]
set appendwrite
dowhile it < iterations
        wrdata ngspice/test.data vref_data[it]
        let it = it + 1
end
a
works! thank you
👍 1
t
Except for the fact that the Y axis got labeled with "result" instead of "count". Looks like a minor bug I'll have to track down.