Hi All,
Long time reader, first time poster. I have a complicated problem to try and explain but it relates to trimming a circuit.
Problem Statement:
I have a voltage-to-current circuit that takes a bandgap voltage across a resistor to create a current, then mirrors it. The resistor is trimmable since it has a temperature coefficient. The goal is to run my simulation over PVT and have a automated circuit find the optimum resistor setting to use.
V2I Circuit:
The current produced is 4uA.
The Testbench:
The top left is the V2I circuit. On the bottom right is an ideal current source with a tempco that is similar to the overall V2I. It produces an equivalent voltage across an ideal resistor. Ideally, it will always be 400 mV. A VCVS source compares an ideal source to the generated source to get an error signal. That error signal is fed into a verilog-A modeled 5-bit ADC (see attached).
The ADC is configurable to perform an inversion and/or 2's complement number. I currently have it set to 2's complement + inversion. The trim code is a 2's complement number (middle of the range is all zeros) and I want an inversion to cancel out the positive error slope being fed to it.
Here is a snapshot of the circuit working well when there is no feedback from the V2I:
At the bottom is the error signal being fed to the ADC and it is correctly providing a inverted digital code to the V2I. The very top signal (IS("/V5/PLUS") is the corrected 4uA output. As you can see, it is somewhat compensated, but not as well as I think it could be.
The problem occurs now if I directly connect the 4uA output of the V2I to the input of my tuning circuit (ie remove the ideal 4uA current source and replace it with one from the V2I). Now there is feedback in the circuit and for whatever reason, I cannot establish a DC operating point, nor a transient one. Can anyone suggest why and what I could do to fix this problem? Is there an easier solution to this?
I'm thinking I do not understand completely the way the VerilogA code is working and how/when it evaluates the expressions inside. I'm thinking that when the operating point does not converge, it is oscillating between two trim codes and never finding the optimum point. Maybe I need some sort type of hysteresis in the ADC or circuit to prevent this from happening and give up a little accuracy?
Has anyone done something like this or similar and can share with me what they did? I feel certain that this is a common problem that every designer has to solve.....
Many thanks - I'm tired of pounding sand.