kanan
Junior Member
![* *](https://designers-guide.org/forum/Templates/Forum/default/starblue.gif)
Offline
Posts: 17
|
Hi,
I'm trying to generate digital (and analog) output signals for certain input voltage behavior. My code for generating the digital signals looks like this : parameter real vbathigh_thres = 3.4; parameter real vbatlow_thres = 3.0; always @(above(V(vbat) - vbathigh_thres)) begin vbatlow18 = 1'b0; vbathigh18 = 1'b1; end always @(above(vbatlow_thres - V(vbat))) begin vbatlow18 = 1'b1; vbathigh18 = 1'b0; end
When I simulate this model in AMS Spectre by varying vbat from 0-5V, it shows me the expected behavior, however when varying from 5-0V it doesn't work. The code seems to be unable to detect that vbat > vbathigh_thres at the start of simulation and put vbathigh18 = 1, vbatlow18 = 0. See attached waveform (blue - V(vbat)). Is there something wrong with the code or the way I simulate it. The LRM makes a mention about : "above() function is almost identical to the cross() function, except that it also triggers during initialization or dc analysis. It generates a monitored analog event to detect threshold crossings in analog signals when the expression crosses zero (0) from below."
Is it this crossing from below part causing the problem? Why isn't it triggering properly during initialization?
Thanks D
|