Func

This statement defines a function. The .FUNC statement is included within a behavioral model equation or other .FUNC statements.

Examples:

.FUNC MAX(a,b) ((a+b+abs(a-b))*0.5) .FUNC MIN(a,b) ((a+b-abs(a-b))*0.5) .FUNC MYLMT(x,a,b) MAX(MIN(x,a),b)

DR. SPICE has a library of built in functions you can use in expressions:

abs(a) atan(a) cos(a)

exp(a) limit(a,min,max) log(a)

log10(a) max(a,b) min(a,b)

pwr(a,b) pwrs(a,b) sin(a)

sqrt(a) table (a,x1,y1,x2,y2,...xn,yn) tan(a)

Behavioral Model (.FUNC) Operators

Name            Meaning              Example                          
                                                                      
+               plus                 a + b                            
                                                                      
-               minus                a - b          or -b             
                                                                      
*               times                a * b                            
                                                                      
/               divide               a / b                            
                                                                      
^               power                a ^ b                            
                                                                      
~               not                  ~ a            = 1 or 0)         
                                                                      
|               or                   a | b          (= 1 or 0)        
                                                                      
&               and                  a & b          (= 1 or 0)        
                                                                      
>             greater than           a > b          (= 1 or 0)        
                                                                      
<             less than              a < b          (= 1 or 0)        
                                                                      
!=              not equal            a != b         (= 1 or 0)        
                                                                      
>=      greater than or equal to     a >= b         (= 1 or 0)        
                                                                      
<=         less than or equal to     a <= b         (= 1 or 0)        
                                                                      
?               if-then-else         x ? a : b                        
                                                                      
:               if-then-else         x ? a : b                        
                                                                      

Behavioral Model (.FUNC) Functions

Name                    Meaning                        
                                                       
abs (a)                 a if (a >= 0)      -a otherwise
                                                       
arctan (a)              atan (a)                       
                                                       
atan (a)                arc tan of a                   
                                                       
cos (a)                 a in radians                   
                                                       
exp (a)                 exponential value of a         
                                                       
limit (a, amin, amax)   amin if (a <= amin)          
                                                       
amax if (a >= amax)    a otherwise                     
                                                       
ln (a)                  log base e of a                
                                                       
log (a)                 ln (a)                         
                                                       
log10 (a)               log base 10 of a               
                                                       
max (a, b)              value equal to larger of a, b  
                                                       
min (a, b)              value equal to smaller of a, b 
                                                       
pwr (a, b)              abs(a) ^ b                     
                                                       
pwrs (a, b)             pwr (a) if (a > 0)   -pwr (a) otherwise
                                                      
sign (a)                1 if (a >= 0)        -1 otherwise
                                                     
sin (a)                 a in radians                   
                                                       
sqrt (a)                square root of a               
                                                       
table (a, a1, y1...)    It is a piece wise linear      
                        function of a                   
                                                       
tan (a)                 a in radians                   
                                                       
xsin (a)                sin (a) / a, a in radians      
                                                       
                        with corners (a1, y1, ...)