Design a level-sensitive SR latch with an enable input. When enabled, it behaves like an active-high SR latch with deterministic handling of the illegal input combination; when disabled, it holds its current state.
Requirements
sr_latch_enableENSRQQnEN=1:S=1, R=0 β Set: Q=1, Qn=0S=0, R=1 β Reset: Q=0, Qn=1S=1, R=1 β Illegal; treat as Reset: Q=0, Qn=1S=0, R=0 β HoldEN=0:S/R and hold previous statealways @(*)) to infer level-sensitive storage.EN=1, use priority reset > set > hold.Behaviour / Worked Example
From a reset state (Q=0,Qn=1):
EN=1,S=0,R=0 β hold Q=0,Qn=1EN=1,S=1,R=0 β set Q=1,Qn=0EN=0,S=0,R=1 β hold (enable low) Q=1,Qn=0EN=1,S=0,R=1 β reset Q=0,Qn=1EN=1,S=1,R=1 β illegal; treated as reset Q=0,Qn=1EN=1,S=0,R=0 β hold Q=0,Qn=1