Adan Kvitschal
03/16/2024, 11:36 PM.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:
+
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
}
Adan Kvitschal
03/17/2024, 12:36 AMTim Edwards
03/17/2024, 12:54 AMAdan Kvitschal
03/17/2024, 12:55 AMAdan Kvitschal
03/17/2024, 12:55 AMTim Edwards
03/17/2024, 12:55 AMngspice/
), but you will need to select "Keep files after simulation" from "Settings".Tim Edwards
03/17/2024, 12:56 AMTim Edwards
03/17/2024, 12:57 AMAdan Kvitschal
03/17/2024, 12:58 AM1.00000000e+00 1.22060486e+00
Tim Edwards
03/17/2024, 12:59 AMset appendwrite
.Adan Kvitschal
03/17/2024, 12:59 AMTim Edwards
03/17/2024, 12:59 AMappendwrite
after the first write, so the first write creates the data file and after that they all append to it.Adan Kvitschal
03/17/2024, 1:00 AMwrdata \\\{simpath\\\}/\\\{filename\\\}_\\\{N\\\}.data vref_data
Tim Edwards
03/17/2024, 1:01 AM$&vref_data
and not just vref_data
?Adan Kvitschal
03/17/2024, 1:01 AMAdan Kvitschal
03/17/2024, 1:07 AM1.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
Tim Edwards
03/17/2024, 1:09 AMset 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.Adan Kvitschal
03/17/2024, 1:15 AM1.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:
-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
Adan Kvitschal
03/17/2024, 1:17 AMTim Edwards
03/17/2024, 1:19 AMset 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
Adan Kvitschal
03/17/2024, 1:28 AMTim Edwards
03/17/2024, 2:12 PM