proc SCHEMATIC_ds_ct_ord2_candy_mbit {} {
make input -name in -origin {-320 150}
make input -name clk -origin {-320 450}
make sub2 -name xi1 -origin {-130 150}
make sub2 -name xi3 -origin {320 150}
make output -name out -origin {1060 150}
make name_net -name error -origin {-50 150}
make name_net -name x2 -origin {670 150}
make name_net -name x1 -origin {220 150}
make add2 -orient RY -name xi10 -origin {-250 150}
make voltage_noise_cpp -orient RX -name xi2 -en_noise en_noise -thermal_noise therm_noise -flicker_corner flicker_corner -origin {60 -60}
make name_net -name error2 -origin {410 150}
make gain -orient R270 -name xi6 -gain vref -origin {-130 320}
make gain -orient R270 -name xi4 -gain vref*1.5 -origin {320 320}
make integrator_w_sat -name xi7 -k clk_freq -max_val 10*vref -min_val -10*vref -origin {90 150}
make integrator_w_sat -name xi0 -k clk_freq -max_val 10*vref -min_val -10*vref -origin {540 150}
make output -name out_int -origin {1060 220}
make quant_mbit -name xi5 -vref vref -num_bits num_bits -origin {810 170}
  make_wire 940 150 1020 150
  make_wire 1020 150 1060 150
  make_wire -320 150 -280 150
  make_wire -100 150 -50 150
  make_wire -50 150 20 150
  make_wire -250 -60 -250 120
  make_wire 220 150 290 150
  make_wire -130 530 -130 360
  make_wire -320 450 700 450
  make_wire 220 150 160 150
  make_wire 610 150 670 150
  make_wire 410 150 350 150
  make_wire 410 150 470 150
  make_wire -130 180 -130 270
  make_wire 320 180 320 270
  make_wire -160 150 -220 150
  make_wire -250 -60 -20 -60
  make_wire 740 220 700 220
  make_wire -130 530 320 530
  make_wire 320 530 1020 530
  make_wire 1060 220 940 220
  make_wire 740 150 670 150
  make_wire 320 360 320 530
  make_wire 700 220 700 450
  make_wire 1020 150 1020 530
}

proc ICON_ds_ct_ord2_candy_mbit args {
  icon_setup $args {{origin {0 0}} {orient R0} {name x} {num_bits 4} {vref 1.0} {clk_freq 1e6} {en_noise 0} {therm_noise 10e-9} {flicker_corner 1e3}}
icon_term -type input -origin {-130 -30} -name in
icon_term -type input -origin {-130 50} -name clk
icon_term -type output -origin {130 -30} -name out
icon_term -type output -origin {130 10} -name out_int
icon_property -origin {-120 -30} -label in
icon_property -origin {-120 50} -label clk
icon_property -origin {120 -30} -anchor e -label out
icon_property -origin {-120 -80} -label {$name}
icon_property -origin {-120 -60} -label ds_ct_ord2_candy_mbit
  icon_line -130 -70 130 -70 130 70 -130 70 -130 -70
  icon_property -origin {-120 220} -type user -name name -default x
  icon_line -130 40 -120 50 -130 60
icon_property -origin {-80 30} -label {in: range is -vref to vref}
  icon_property -origin {-120 240} -type user -name num_bits -default 4
  icon_property -origin {-120 260} -type user -name vref -default 1.0
  icon_property -origin {-120 280} -type user -name clk_freq -default 1e6
  icon_property -origin {-120 300} -type user -name en_noise -default 0
  icon_property -origin {-120 320} -type user -name therm_noise -default 10e-9
  icon_property -origin {-120 340} -type user -name flicker_corner -default 1e3
icon_property -origin {-120 80} -label {num_bits=$num_bits (>=2)}
icon_property -origin {-120 100} -label {vref=$vref (V)}
icon_property -origin {-120 120} -label {clk_freq=$clk_freq (Hz)}
icon_property -origin {-120 140} -label {en_noise=$en_noise (0 or 1)}
icon_property -origin {-120 160} -label {therm_noise=$therm_noise (V/rHz)}
icon_property -origin {-120 180} -label {flicker_corner=$flicker_corner (Hz)}
icon_property -origin {-80 50} -label {out: -1 to 1}
icon_property -origin {120 10} -anchor e -label out_int
}

