.PS # Opamp.m4 # https://tex.stackexchange.com/questions/762958/defining-a-detailed-operational-amplifier-subcircuit-with-input-output-anchors sinclude(FOpamp.dim) sinclude(Circuit_macros.dim) sinclude(tst.dim) s_init(Opamp) cct_init A: opamp(,,,\;body=shaded "yellow") thinlines_ s_box(`\tt\shortstack[l]{opam{}p(,{,},\\body=shaded \"`yellow'\")}') \ at A.s-(0,0.35) s_box(\sl Out) below at A.Out spline <- from A.In1 left 0.1 then up 0.1 left 0.1 s_box(\sl In1) rjust above spline <- from A.In2 left 0.1 then down 0.1 left 0.1 s_box(\sl In2) rjust below arrow <- up 0.1 right 0.1 from A.N s_box(\sl N) ljust above arrow <- up 0.1 right 0.1 from A.E1 s_box(\sl E1) ljust above arrow <- up 0.1 right 0.1 from A.E s_box(\sl E) ljust above arrow <- down 0.1 right 0.1 from A.E2 s_box(\sl E2) ljust below arrow <- down 0.1 right 0.1 from A.S s_box(\sl S) ljust below arrow <- left 0.2 from A.W s_box(\sl W) rjust thicklines_ Point_(90) B: opamp(,,,,PR) with .sw at A.se+(0.5,0) thinlines_ s_box(`\tt\shortstack[l]{Point\_(90);\\opam{}p(,{,},{,}PR)}') \ at B.s-(0,0.20) spline <- left arrowht down arrowht from B.V1 then left 0.1 s_box(\sl V1) rjust spline <- right arrowht down arrowht from B.V2 then right 0.1 s_box(\sl V2) ljust thicklines_ right_ sz = dimen_*7/4 C: opamp(right_ dimen_*2,` ',` ',sz,R, X1: 2/3 between S and N X2: 1/3 between S and N pushdef(`dimen_',dimen_/2); thinlines_ line from X1 to X1+(dimen_/3,0); A1:Here; corner line from X2 to X2+(dimen_/3,0); A2:Here; corner Ri: resistor(up_ to A1) s_box(\scriptsize $R_i$) with .w at Ri+(2bp__,0) Cs: consource(up_ dimen_ at Ri+(dimen_,0)); corner; {"{\tiny$\pm$}" at Cs ground(at Cs.start,T) s_box(\scriptsize $Av_d$) with .w at last [].se+(-2bp__,2bp__)} Ro: resistor(right_ dimen_*7/8) {s_box(\scriptsize $R_o$) with .se at last [].nw+(3bp__,1bp__)} line to (Here,E) then to E thicklines_; popdef(`dimen_') ) with .sw at B.se+(0.5,0) s_box(`\tt\shortstack[l]{opam{}p(\ldots)}') at C.s+(-0.2,-0.15) dot(at C.Out,,1); s_box($v_{\hbox{\scriptsize out}}$) with .n at last [].s line from C.X1 left_ dimen_/3 gap(down_ C.X1.y-C.X2.y,1); rlabel(+,v_d,-) line to C.X2 chop dotrad_ chop 0 D: opamp(,,,body=shaded "orange",T) with .sw at C.se+(0.25,0) s_box(`\tt\shortstack[l]{opam{}p(,{,},\\body=shaded \"`orange'\"\\,T)}')\ at D.s+(0.2,-0.25) .PE