* test ASRC temperature coeff

v0  9 0  dc=0 ac=0

v1  1 0  dc=100 ac=10

* a real resistor, in devices/res
r2  1 2  1k tc1=0.001
v2  2 0  dc=0 ac=0

* a behavioural resistor, which is mapped to devices/asrc in inpcom.c
r3  1 3  r = {1k + v(9)}  tc1=0.001
v3  3 0  dc=0 ac=0

.temp 127.0

.control

* listing extended

op
let idc_gold = 100 / (1k * (1 + 100*0.001))
let idc2=i(v2)
let idc3=i(v3)

* print idc2 idc3 idc_gold

let err1 = idc2/idc_gold - 1
let err2 = idc3/idc_gold - 1

if abs(err1) > 1e-9 or abs(err2) > 1e-9
  echo "ERROR: dc test failed, err1 = $&err1 err2 = $&err2"
  quit 1
end

ac dec 1 1kHz 1kHz
let iac_gold = 10 / (1k * (1 + 100*0.001))
let iac2=i(v2)
let iac3=i(v3)

* print iac2 iac3 iac_gold

let err3 = iac2/iac_gold - 1
let err4 = iac3/iac_gold - 1

if abs(err3) > 1e-9 or abs(err4) > 1e-9
  echo "ERROR: ac test failed, err3 = $&err3 err4 = $&err4"
  quit 1
end

echo "INFO: success"
quit 0

.endc
