summaryrefslogtreecommitdiff
path: root/schematic/mosfet-check.tcl
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--schematic/mosfet-check.tcl27
1 files changed, 27 insertions, 0 deletions
diff --git a/schematic/mosfet-check.tcl b/schematic/mosfet-check.tcl
new file mode 100644
index 0000000..3cdfc23
--- /dev/null
+++ b/schematic/mosfet-check.tcl
@@ -0,0 +1,27 @@
+xschem annotate_op
+xschem unhilight_all
+
+foreach {i n t} [xschem instance_list] {
+ if {$t eq {nmos} || $t eq {pmos}} {
+ set inst x[string tolower $i]
+ lassign [array get ::ngspice::ngspice_data *$inst.*\\\[vth\\\]*] node_vth vth
+ lassign [array get ::ngspice::ngspice_data *$inst.*\\\[vgs\\\]*] node_vgs vgs
+ lassign [array get ::ngspice::ngspice_data *$inst.*\\\[vds\\\]*] node_vds vds
+ set vov [expr {$vgs - $vth}]
+
+ if {$vov <= 0} {
+ # Off.
+ xschem set hilight_color 0
+ } elseif {$vds < $vov} {
+ # Linear/triode.
+ xschem set hilight_color 1
+ } else {
+ # Saturation.
+ xschem set hilight_color 2
+ }
+
+ xschem hilight_instname $i fast
+ }
+}
+
+xschem redraw