hafiz2431
New Member
Offline
Posts: 8
|
Thanks, Ken and Geoffrey for your valuable inputs. I appreciate that.
How do you think about the code now:
`include "constants.vams" `include "disciplines.vams"
module drv_ideal(A, Y, vcc); output Y; electrical Y; input A,vcc; electrical A,vcc;
// INSTANCE PARAMETERS: parameter real vhi = 0.8; parameter real vlo = 0 ; parameter real vth = 0.5*(vhi+vlo) ; parameter real tr = 15p; parameter real tf = 15p; parameter real tdel =0; parameter real rpuon =35; parameter real rpdon =35; parameter real roff =10M;
// LOCAL VARIABLES: real vy,rpu,rpd; //integer y;
analog begin @ (cross(V(A) - vth, 0) ) vy = (V(A) > vth); // vy = y ? vhi : vlo; if (V(A) > vth) vy = vhi; else vy = vlo; // V(Y) <+ transition( vy, tdel, tr, tf); //rpu = transition(V(A)>vth ? rpuon : roff ,tdel, tr,tf); rpu = transition(vy ? rpuon : roff ,tdel, tr,tf); I(vcc,Y) <+ V(vcc,Y)/rpu;
// rpd = transition(V(A)<vth ? rpdon : roff ,tdel, tr,tf); rpd = transition(!vy ? rpdon : roff ,tdel, tr,tf); I(Y) <+ V(Y)/rpd; end
endmodule
|