I am developing a verilog-A model for a device. I want to write a function that is executed only one time in the simulation during the device first transition from high resistive state to a low resistive state. I looked at analog events but did not find a function that provides this functionality I want. I tried to do it using an if..else statement but it gave me convergence error.
Can someone help me with that?
It might help if you gave more detail as to what you're trying to do - i.e. the code you tried. In general if you want something just to execute once, you could have some kind of state variable which starts off at 0, and then you set it to 1 once you've executed the code - and have the code check that the value of the variable is 0 before executing it.
However, there's probably little point giving an example of that because the problem you are having may be related to some other detail of the model - it's not clear.
So please show what you've tried, so folks here can give you a steer in the right direction.
Please comment your code (with explanation as to what each variable is for, and what each section does) - and indent it to make it readable. Right now it's too hard to try to figure out what it's doing (and what the intent is), so I'm afraid I can't spend the time figuring that out for you - it would take a large amount of time to try to unravel what you're actually trying to do here.
If doing that on the full code is too much effort, please provide a simpler (commented and properly indented) example that illustrates what you're trying to achieve.
That's barely any better. I can see that the if(f==0) line doesn't have a "begin" which looks wrong, but the code is so hard to read that I can't do more debugging.
I suggest you format it better and contact customer support.