module V_ctrl_pwl_limited_amp(in,ctrl,out); input in,ctrl; output out; voltage in,ctrl,out; parameter real vin_offset = 0, // input dc offset vctrl_offset = 0, // ctrl dc offset vout_offset= 0, // output dc offset gain = 1, // amplifier gain vout_max = 10, // max. output voltage vout_min = -10 from (-inf:vout_max); // min. output voltage real vout; analog begin vout = gain * (V(ctrl)-vctrl_offset) * (V(in)-vin_offset) + vout_offset; @(cross(vout-vout_max)) discontinuity(1); @(cross(vout-vout_min)) discontinuity(1); if (vout > vout_max) vout = vout_max; else if (vout < vout_min) vout = vout_min; V(out) <+ vout; end endmodule