Hello all,
These following functions are intended to be used in b-sources.? The first two replicate edge triggered logic such as is used in the a-device DFLOP clock input.? The last function is more complicated as it includes three behavioral integrators to provide a running integrated average of x (starting on the falling edge of sampling pulse s) that is then held until the next rising edge of sampling pulse s.? In normal use, x would be an analog input and the sampling pulse s would be a series of very narrow 1 volt positive digital pulse.
.func up(s) buf( ddt(s)) ; generates pulse on rising edge of s
.func dn(s) buf(-ddt(s)) ; generates pulse on falling edge of s
* The following averages x between sample pulses s
.func ave(x,s) sdt(0,sdt(x,0,dn(s))/sdt(1,0,dn(s)),up(s))
B1 1 0 V= ave(V(x),V(s)) ; source for x and s not shown