A simple analog block or Subcircuit in PSpice from a Verilog-A code

Thread Starter

Charanraj Mohan

Joined Feb 2, 2016
2
Hi,
I have a small Veriolog-A code and I need to implement it as a subcircuit in PSpice.

Verilog-A code:

// VerilogA for memr, memr_f, veriloga

`include "constants.vams"
`include "disciplines.vams"

module memr_f(vp,vn,vout,vref);
electrical vp,vn,vout,vref;
parameter real vth=1,vo=1,Io=1e-9;
real vd,id;

analog begin
vd = V(vp) - V(vn);
if (vd>vth) begin
id = Io*(exp(vd/vo)-exp(vth/vo));
end else if (vd<-vth) begin
id = -Io*(exp(-vd/vo)-exp(vth/vo));
end else begin
id=0;
end

I(vout,vref) <+ -id;
end

endmodule


The netlist I wrote in PSpice:

.SUBCKT memr_f vp vn vout vref params:vth=1.0, vo=0.1, Io=1e-5
.func vd() {v(vp)-v(vn)}
.func id() {IF(vd >= vth, Io*(exp(vd/vo)-exp(vth/vo)), IF(vd <=- vth, -Io*(exp(-vd/vo)-exp(vth/vo)), 0))}
.func I(vout,vref) {id()}
.ENDS

But I couldn't proceed with the option 'Associate PSpice model'- it shows me an error-'Select a matching model in the grid to proceed'.
How to rectify it ?
 

mvaseem

Joined Jan 31, 2014
48
Since you have a subckt, save it as .lib file. Open the file in model editor.
Do File -> Export to Capture Part
This would generate the capture part in olb with same pins as in subckt.
Instantiate the part and configure lib file in pspice to simulate.

However I think the functions you have written are not going to work.
You would need to use behavioral devices (VCCS,VCVS) which are G and E devices in pspice.
 
Top