Loading simulator…
The solution adds two 8:1 MUXes and one final 2:1 MUX to form the 16-entry LUT.
Connect A, B, C, and D as address bits from MSB to LSB.
The selected LUT value passes through an XOR gate controlled by polarity.
A feedback MUX selects either the previous register value when CE = 0 or the new LUT result when CE = 1.
The active-HIGH synchronous RST path forces the D input LOW before the next rising edge of CLK_G.
A second MUX selects the direct result when mode_sel = 0 or the D flip-flop output when mode_sel = 1.
The final AND gate applies OE, so OE = 0 forces Y = 0.
LUT_RAW = LUT[8.A + 4.B + 2.C + D]
LUT_POL = LUT_RAW ⊕ polarity
D_IN = RST'.(CE.LUT_POL + CE'.Q)
Y = OE.(mode_sel'.LUT_POL + mode_sel.Q)