proc SCHEMATIC_opamp_basic_diff_with_cm {} {
make input -name in_pos -origin {-160 490}
make input -name in_neg -origin {-160 400}
make output -name out_pos -origin {-30 400}
make output -name out_neg -origin {-30 490}
make input -name out_cm -origin {-160 540}
}

proc ICON_opamp_basic_diff_with_cm args {
  icon_setup $args {{origin {0 0}} {orient R0} {name x} {dc_gain 40} {f_unity 100e6} {input_thermal_noise 20e-9} {input_flicker_corner_frequency 1e6} {noise_enable 0} {voffset 0} {vsat_pos 100} {vsat_neg -100}}
icon_term -type input -origin {-50 20} -name in_pos
icon_term -type input -origin {-50 -20} -name in_neg
icon_term -type output -origin {50 -20} -name out_pos
icon_term -type output -origin {50 20} -name out_neg
icon_term -type input -origin {0 40} -orient R90Y -name out_cm
icon_property -origin {-40 20} -label in_pos
icon_property -origin {-40 -20} -label in_neg
icon_property -origin {50 -10} -anchor e -label out_pos
icon_property -origin {-50 -70} -label {$name}
icon_property -origin {-10 -50} -label opamp_basic_diff_with_cm
  icon_line -50 -60 80 0 80 0 -50 60 -50 -60
icon_property -origin {-50 70} -label {dc_gain=$dc_gain (dB)}
  icon_property -origin {-50 240} -type user -name name -default x
  icon_property -origin {-50 260} -type user -name dc_gain -default 40
icon_property -origin {-50 90} -label {f_unity=$f_unity (Hz)}
  icon_property -origin {-50 280} -type user -name f_unity -default 100e6
  icon_property -origin {-50 300} -type user -name input_thermal_noise -default 20e-9
  icon_property -origin {-50 320} -type user -name input_flicker_corner_frequency -default 1e6
  icon_property -origin {-50 340} -type user -name noise_enable -default 0
  icon_property -origin {-50 190} -text {[if {$noise_enable != 0} {set x "input_thermal_noise=$input_thermal_noise (V/sqrt(Hz) single-sided)"}]}
  icon_property -origin {-50 170} -text {[if {$noise_enable != 0} {set x "noise_enable=$noise_enable"}]}
  icon_property -origin {-50 210} -text {[if {$noise_enable != 0} {set x "input_flicker_corner_frequency=$input_flicker_corner_frequency (Hz)"}]}
  icon_property -origin {-50 360} -type user -name voffset -default 0
  icon_property -origin {-50 110} -text {[if {$voffset != 0} {set x "voffset=$voffset (V)"}]}
  icon_property -origin {-50 380} -type user -name vsat_pos -default 100
  icon_property -origin {-50 400} -type user -name vsat_neg -default -100
  icon_property -origin {-50 130} -text {[if {$vsat_pos != 100} {set x "vsat_pos=$vsat_pos (Volts)"}]}
  icon_property -origin {-50 150} -text {[if {$vsat_neg != -100} {set x "vsat_neg=$vsat_neg (Volts)"}]}
icon_property -origin {50 10} -anchor e -label out_neg
  icon_line 50 -20 40 -20
  icon_line 50 20 40 20
icon_property -origin {10 40} -label out_cm
}

