The
WinCUPL code for a basic NAND SR latch looks like this:-
Device g22v10 ;
/* ***************** PINS ************************/
PIN 1 = SET ; /* SET input (active low) */
PIN 2 = RESET ; /* RESET input (active low) */
PIN 23 = Q ; /* Q output */
/******************* EQUATIONS *******************/
Q = (Q & RESET) # !SET;
Though I have designated pin 23 as an output it is also an input, so we can use Q on both sides of the equation to create feedback. "Q = Q" holds the last state of the Q output. "Q & RESET" forces Q low if RESET goes low. "# !SET" (OR NOT SET) forces Q high if SET goes low.
You have an extra NAND gate on the SET input. With your signal names this is:-
PIN 1 = 1MHZ_EB;
PIN 2 = NPGFD_B; /* reset */
NAND_out = !(1MHZ_EB & NPGFD_B) /* set */
Adding the NAND gate to the latch we get:-
PIN 23 = OUTPUT;
OUTPUT = (OUTPUT & NPGFD_B) # !(!(1MHZ_EB & NPGFD_B));
which can be simplified to
OUTPUT = (OUTPUT & NPGFD_B) # (1MHZ_EB & NPGFD_B);