Objective
Here I wanted to make a macro model of a relaxation oscillator to simulate in my test bench with other blocks of the chip. I wanted to keep it simple and also control the frequency.Circuit
I came up with the following circuit:Description
So I wanted to avoid any switches to make the simulation as easy as possible with minimum discontinuities. Here the model is totally Mathematical by using polynomial sources. I tried out implementing the reference hysteresis using switches as well to see if that helps Spectre limit the maximum time step.Here there are 2 additional signals SS and PAUSE. SS causes the frequency to reduce to half and PAUSE causes it to reduce to 1/3 but those can be adjusted based on the polynomial coefficients. Doing it with polynomials also keeps the clock synchronized when we change the frequency and does not produce glitches.