// Qucs analogue andor4x4 model // The structure and theoretical background to the andor4x4 // Verilog-a model are presented in the Qucs digital tutorial. // // This is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // Copyright (C), Mike Brinson, mbrin72043@yahoo.co.uk, December 2008. // `include "disciplines.vams" `include "constants.vams" module andor4x4 (A11, A12, A13, A14, A21, A22, A23, A24, A31, A32, A33, A34, A41, A42, A43, A44, Y); inout A11, A12, A13, A14, A21, A22, A23, A24, A31, A32, A33, A34, A41, A42, A43, A44, Y; electrical A11, A12, A13, A14, A21, A22, A23, A24, A31, A32, A33, A34, A41, A42, A43, A44, Y; electrical n1, n2; // `define attr(txt) (*txt*) parameter real TR=6 from [1.0:20.0] `attr(info="transfer function high scaling factor"); parameter real Delay = 1e-9 from [0: inf] `attr(info="output delay" unit="s"); // real Rd, Cd, Iand; real m1, m2, m3, m4; // analog begin @(initial_model) begin Rd = 1e3; Cd= Delay*1.43/Rd; end m1 = V(A11)*V(A12)*V(A13)*V(A14); m2 = V(A21)*V(A22)*V(A23)*V(A24); m3 = V(A31)*V(A32)*V(A33)*V(A34); m4 = V(A41)*V(A42)*V(A43)*V(A44); Iand = m1+m2+m3+m4; if (Iand > 0.5) Iand = 1; else Iand = 0; I(n1) <+ -0.5*(1+tanh(TR*(Iand-0.5))); I(n1) <+ V(n1); I(n1, n2) <+ V(n1,n2)/Rd; I(n2) <+ ddt(Cd*V(n2)); I(Y) <+ -V(n2); I(Y) <+ V(Y); end endmodule