To detect any JTAG activity from within the device, you need to monitor any combination of the JTAG TCK, TDI, or TMS line(s) on a BSCANE2 primitive. Because any external JTAG command requires these lines to toggle, activity detectors on any or all of these lines can catch JTAG activity. For example, to monitor any rising edges on the TDI line, the circuit in the following figure could be used.
Any rising edge on the TDI line gets latched, and the detect output of the DFF remains at 1 until the part is reconfigured (that is, until the PROGRAM_B input is asserted). This method can be extended to monitor rising or falling edges on any of the TCK, TDI, or TMS signal lines. When any of the outputs of the JTAG detector DFFs are set, they can be used to initiate a tamper penalty.