noreng
Junior Member
Offline
Posts: 20
|
Now, I have removed the piecewise linear values and replaced them by linear ones. That is, reff1 is always decreasing with increasing vctr1 and vice versa.
I'm able to switch currents as wanted. However, the p node of the verilog-a module is being pulled up to VDD when I'm simulating. Although this works fine for an ideal current source, it won't work with a transistor current source.
Any suggestions? Thanks in advance.
module test_switch (p,n1,n2,s1,s2,z); // p/n1,n2: i/o; s1,s2: ctrl; z: avss parameter real ron = 10 from (0:inf); // on resistance (ohms) parameter real roff = 100M from (ron:inf); // off resistance (ohms) parameter real rload = 1k from (0.1:inf); // load resistance
inout p, n1, n2, z, s1, s2; electrical p, n1, n2, z, s1, s2;
real reff1, reff2, vctr1, vctr2;
branch (p,n1) res1; branch (p,n2) res2;
analog begin vctr1 = V(s1); vctr2 = V(s2);
reff1 = roff+(ron-roff)*vctr1; reff2 = roff+(ron-roff)*vctr2;
V(p,n1) <+ I(p,n1)*reff1; V(p,n2) <+ I(p,n2)*reff2;
I(res1) <+ I(<p>)*(reff1+rload)/(reff1+reff2+2*rload); I(res2) <+ I(<p>)*(reff2+rload)/(reff1+reff2+2*rload); end endmodule
|