`include "disciplines.vams" `include "constants.h" //Defines the Verilog-A module and device electrical terminals p,n. module analytical (p, n); inout p, n; electrical p, n; //Initial resistive state parameter real RS = 218000; //I-V relationship parameters // v>0 parameter real ap=-0.25896; parameter real bp=-3.05027; // v<0 parameter real an=0.31266; parameter real bn=2.36684; real vin; // Variable that tracks the input voltage. real IVp; // Positive branch of the IV relationship real IVn; // Negative branch of the IV relationship real IV; // Full IV relationship //Implementation of the step function analog function integer stp; //Stp function real arg; input arg; stp = (arg >= 0 ? 1 : 0 ); endfunction analog begin //Assigns the voltage applied at the terminals of the device on 'vin' vin=V(p,n); //The two branches of the I-V expression IVp=ap*(1/RS)*(1-exp(-bp*vin)); IVn=an*(1/RS)*(1-exp(-bn*vin)); //Device I-V expression IV=IVp*stp(vin)+IVn*stp(-vin); //Current flowing through the module's port I(p, n)<+ IV; // Ohms law end endmodule