component estop_latch "ESTOP latch which sets ok-out true and fault-out false only if ok-in is true, fault-in is false, and a rising edge is seen on reset. While ok-out is true, watchdog toggles, and can be used for chargepumps or similar needs."; pin in bit ok_in; pin in bit fault_in; pin in bit reset; pin out bit ok_out; pin out bit fault_out; pin out bit watchdog; function _ nofp; option data estop_data; license "GPL"; ;; typedef struct { int old_reset; } estop_data; FUNCTION(_) { /* check inputs */ if ( ok_in && !fault_in) { /* no fault conditions, check for reset edge */ if ( reset && !data.old_reset ) { /* got a rising edge, indicate "OK" on outputs */ ok_out = 1; fault_out = 0; } if( ok_out ) { /* toggle watchdog */ watchdog = !watchdog; } } else { /* fault condition exists, trip */ ok_out = 0; fault_out = 1; } /* store state of reset input for next pass (for edge detect) */ data.old_reset = reset; }