Flip-flop circuit with controllable copying between slave and scan latches
BACKGROUND OF THE INVENTION 
     Large digital systems are essentially composed of memory elements called &#34;latches&#34; or &#34;flip-flops&#34;, combinational logic, and a clocking system. The memory elements are arranged in sets sometimes called registers. The number of elements in a set is usually the number of bits per word in the system. Between the sets of memory elements are combinational logic circuits. Each of these circuits performs logic operations on the outputs of a register and outputs the results of the operations to the inputs of another register. 
     At the end of a clock cycle, which is also the beginning of the next clock cycle, the data on the outputs of one combinational logic circuit is stored in a register. The data appears on the outputs of the register and, therefore, on the inputs of the next combinational logic circuit. This second combinational logic circuit performs the desired logic functions and applies the resultant data to the inputs of the next register. At the end of the next clock cycle, the data is stored in this second register. This process in repeated as the system operates, that is, data is processed by combinational logic circuits, stored, passed on to the next combinational logic circuit, processed, stored, and so on. 
     One common type of flip-flop is the master-slave flip-flop. The master-slave flip-flop is composed of two latch stages, namely, a master latch stage and a slave latch stage. The flip-flop inputs are coupled to the master latch inputs, and the master latch outputs are coupled to the slave latch inputs. The slave latch outputs are the outputs of the master-slave flip-flop. The coupling in the flip-flop is controlled by a clock signal. When the clock signal is active, the flip-flop input is connected to the master latch input and, therefore, the output of the master latch follows the input to the flip-flop. At the same time, the clock signal isolates the master latch output from the slave latch input. As a result, the flip-flop output is prevented from following every transition on the flip-flop input. When the clock signal changes to its inactive state, the master latch input is disconnected and its output is connected to the slave latch to become the master-slave flip-flop output. 
     A feature commonly used in digital systems is the &#34;scannable latch&#34; or &#34;scannable flip-flop&#34;. A scannable flip-flop includes a latch which can be converted to a stage of a shift register by the use of appropriate clock signals. Whereas a register coupled between combinational logic circuits typically receives and outputs bits of a word in parallel, the shift register receives the bits at one end and shifts them through its stages serially to an opposite end. The scannable flip-flop allows the contents of the shift register to be &#34;scanned&#34; by shifting out the contents for examination. Following this &#34;scan out&#34; operation, the data formerly stored in the flip-flop can be restored to the flip-flop by shifting the data back in. Also, the flip-flop can be loaded with new contents by shifting in new data. Such operations are typically performed during testing and diagnostic procedures. 
     The ability to shift data in and out of registers is a powerful diagnostic tool. For example, if an error is detected during some complicated series of operations, the system can be stopped, and the contents of the registers involved can be shifted out. If further testing is required to isolate the cause of the error, a set of known data can be shifted into the registers. The system can then be allowed to carry out the series of operations one step at a time. After each step, the contents of the registers can be shifted out and compared to expected data. If there is no error, the data is shifted back into the registers, and the next step is executed. This process is continued until an error is detected. In this way, the register in which the error occurred is readily isolated so that the cause of the error can more easily be determined. 
     SUMMARY OF THE INVENTION 
     The present invention is a scannable flip-flop comprising a master latch, a slave latch, and a scan latch. The master and slave latches function as the data storage section of the scannable flip-flop, and the master and scan latches function as the shift register section. The output of the slave latch is used as the Q or data output of the flip-flop. As such, it represents the data contents of the flip-flop. The output of the scan latch is used as the scan output of the flip-flop. The slave latch and scan latch are coupled together such that a value stored in one can be copied into the other. 
     The preferred embodiment of the invention includes a circuit which allows the coupling between the slave latch and the scan latch to be controlled. The two latches may be either connected together or isolated from each other. When they are connected together, data stored in the slave latch is copied into the scan latch, and data stored in the scan latch is copied into the slave latch. When they are isolated from each other, data stored in the slave latch is not copied into the scan latch, and data shifted into the scan latch has no effect on the slave latch. 
     The controllable coupling between the slave and the scan latches provides the present invention with several advantages. With the slave and scan latches connected, the scan latch always contains the present contents (directly or inversely) of the slave latch of the flip-flop. Therefore, no special clock signals are required to load the contents of the slave latch into the scan latch before the contents can be shifted out. Also, the scanning capability of the flip-flop does not degrade system performance- during normal operation. Since the scan output is driven by a separate scan latch, the slave latch, and thus the data output, is not loaded down by any circuitry connected to the scan output. 
     With the slave latch and scan latch isolated from each other, the scan operation has no effect on the contents of the slave latch. Therefore, while scanning data into a register made from these scannable flip-flops, the flip-flop outputs do not change. This prevents any undesirable logic state switching from propagating through the system. Also, scanning data out of a register does not disturb the contents of the register. Therefore, while performing the step-by-step diagnostic testing procedure described above, it is not necessary to restore the data to the register after it is scanned out and examined for errors. The process may continue directly to the next step. 
     In addition, the data inputs to the flip-flops in the register may also be scanned out. After the system is stopped, the outputs of each combinational logic circuit are applied to the inputs of the next register. These inputs may be shifted into the scan latches of the flip-flop and then shifted out for examination. Since the scan latches and slave latches are isolated from each other, this operation does not alter the contents of the register. Therefore, the contents of the register can also still be scanned. 
     Isolating the slave latch and scan latch also prevents the scan latch from following the slave latch. If no output data is required from the scan latch during normal system operation, the two latches can be isolated. This will reduce the number of logic state changes and, therefore, the power consumption of the system. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIGS. 1a and 1b are a block diagram of a portion of a digital system comprising the present invention. 
     FIG. 2 is a logic diagram of a typical latch circuit used to implement the present invention. 
     FIG. 3 is a block diagram of a scannable flip-flop in accordance with the present invention. 
     FIG. 4 is a logic diagram of an implementation of the embodiment of FIG. 3. 
     FIG. 5 is a logic diagram of another embodiment of the present invention. 
     FIG. 6 is a timing diagram for the scan-in and scan-out functions performed by the present invention. 
     FIG. 7 is a timing diagram for a logic testing function performed by the invention. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     FIG. 1 depicts a portion of a digital system comprising the present invention. Scannable flip-flops 10 are grouped together in registers 18 and 20. Parallel data from combinational logic circuits 22 and 24 is applied to the flip-flop data inputs D 1  -D 4  of register 18 and D 5  -D 8  of register 20, respectively. Parallel data appears at the data outputs Q 1  -Q 4  of register 18 and Q 5  -Q 8  of register 20. 
     Registers 18 and 20 can also process serial data. The scan output SO of each flip-flop is connected to the scan input SI of the next flip-flop. Data applied to the scan input of each register 18 and 20 can be serially shifted into the register. Also, data in the register can be serially shifted out of the register at the scan output. 
     FIG. 2 depicts the function of a typical latch circuit used in the embodiments of the invention. Data is applied to INPUT1 when ENABLE1 is asserted. The data is inverted by inverter I1 and appears as the output of the latch. The data is inverted again by inventer I2 and applied back to the input of I1. When ENABLE1 changes states to inactive, the data is stored in the latch and maintained in its latched state by inverter I2. INPUT2 functions in the same manner with signal ENABLE2 controlling the latch. 
     FIG. 3 is a block diagram of the scannable flip-flop circuit. Data at the DATA IN input is enabled to INPUT1 of master latch 12 through transmission gate G3 when control signal SC 13  N is asserted and through G4 when the system clock signal CLK is deasserted. The data appears at the output of master latch 12 at MQ node 11. When CLK is asserted, the data is latched into master latch 12 and is applied through G6 to INPUT1 of slave latch 14 and appears at the output of slave latch 14 and, therefore, at the Q output of the flip-flop. If control signals ISOL --  N and CLKB are asserted, G9 and G10 are enabled, and the data in slave latch 14 is copied into scan latch 16. When CLK is deasserted, G6 is disabled, and the data is latched in the slave latch 14 and scan latch 16. 
     Data at the SCAN IN input is enabled through G5 to INPUT2 of master latch 12 and then latched into master latch 12 by successive state transitions of scan clock signal CLKA provided SC --  N is deasserted. When CLKB is asserted, data latched in master latch 12 is enabled through G7 to INPUT2 of scan latch 16 and appears at the SCAN OUT flip-flop output. The CLKB signal also enables G11; therefore, if ISOL --  N is asserted, G8 is enabled, and the data in scan latch 16 is copied into slave latch 14. When CLKB is deasserted, the data is latched into scan latch 16 and slave latch 14. 
     It should be noted that in each of the three latches in the flip-flops of FIG. 4 and FIG. 5, there is one level of logic inversion between the input and the output. Therefore, in the descriptions below, where a value is said to be &#34;copied&#34;, &#34;transferred&#34;, &#34;clocked&#34;, &#34;stored&#34;, etc. to a latch, that inversion of logic states is implied. However, the present invention can also be implemented with latches which are not made from inverters and thus do not introduce a level of logic inversion. Flip-flops made from latches without inverters are within the spirit and scope of the invention as defined in the appended claims. 
     FIG. 4 depicts an implementation of the embodiment of FIG. 3. In this configuration, each of the latch circuits 12A, 14A, and 16A is implemented with a pair of inverters. One of the inverters in each latch (I3, I5, I7) has stronger drive capability than the other (I4, I6, I8). This enables the output of the latch to drive the input of the next latch regardless of the state of the weaker inverter of the next latch. For example, in FIG. 4, if slave latch 14A has a high output value, the input of inverter I6 is high, and its output is low. The output of I6 drives the input of I5, maintaining the high value at the output of I5 and, therefore, at the output of slave latch 14A. If it is desired to change the value in slave latch 14A to low, the output of inverter I3 in master latch 12A will be set high, and the control signal DCLK (derived from CLK through inverters I9 and I10) will be asserted to enable pass transistor T4. CLK --  N (derived from CLK through I9) is deasserted, thus enabling pass transistor T5. At the input to inverter I5, contention will exist between outputs of inverter I3 and inverter I6. I3 will try to drive the input high, and I6 will try to drive the input low. But, since I3 has stronger drive capability, it will drive the input to I5 high; the output of I5 will change to low, and the output of I6 will change to high. When T4 and T5 are disabled and I3 is no longer driving the input to I5, the output of I6 will maintain I5 in the desired low state. 
     In the circuit of FIG. 4, the control signal SC --  N is used to select the mode of operation. In normal or system mode operation, SC --  N is asserted, and CLKA and CLKB are deasserted. With SC --  N asserted, T1 is enabled. When CLK is deasserted, CLK --  N is asserted and T2 is enabled. Data appearing at the DATA IN input is applied to master latch 12A. When CLK is asserted, transistor T2 is disabled, and the data is latched in master latch 12A. At the same time, DCLK is asserted and CLK --  N is deasserted. T4 and T5 are enabled, and the data in master latch 12A is applied to the input of slave latch 14A and appears on its output and at the Q output of the flip-flop. When CLK is deasserted, T2 is enabled, and T4 and T5 are disabled. The data is latched in slave latch 14A, and new data at the DATA IN input is enabled to master latch 12A. 
     If the control signal ISOL --  N (derived from ISOL through inverter I11) is asserted, transistor T7 is active. Since scan clock CLKB is deasserted, CLKB --  N (derived from CLKB through I12) is asserted, and transistor T10 is also active. Therefore, slave latch 14A and scan latch 16A are not isolated from each other. When data appears at the output of slave latch 14A, it is copied into scan latch 16A. In this way, the three latches act as one flip-flop, with the output of slave latch 14A being the Q output of the flip-flop and the output of scan latch 16A being the -Q output. Another method of obtaining the -Q flip-flop output is simply connecting the Q output to a separate inverter and using the inverter output as -Q. If control signal ISOL --  N is deasserted, T6 and T7 are both disabled, and slave latch 14A and scan latch 16A are isolated from each other. Data at the output of slave latch 14A will not appear in scan latch 16A. Therefore, scan latch 16A does not change state to follow slave latch 14A, thus reducing power consumption of the flip-flop. 
     In the scan mode of operation, SC --  N is deasserted. This prevents data appearing on the DATA IN input from being applied to master latch 12A simultaneously with data on the SCAN IN input. When scan clock CLKA is asserted, T3 is enabled, and data at the SCAN IN input will appear at an input of the master latch. When CLKA is deasserted, the data is latched in master latch 12A. If CLKB is then asserted, T8 is enabled, and data in the master latch 12A is copied into scan latch-16A. When CLKB is deasserted, T8 is disabled, and the data is latched in scan latch 16A. 
     If ISOL --  N is asserted during the CLKB pulse, T6 and T9 are active, and the data appearing at the output of scan latch 16A will be copied into slave latch 14A. If ISOL --  N is deasserted, T6 is inactive, and the scan data will not appear on slave latch 14A. Thus, data may be shifted through the flip-flop via the SCAN IN input and the SCAN OUT output without changing the value of the Q output. 
     FIG. 5 depicts another embodiment of the present invention. This flip-flop circuit 10B is implemented with gate array technology in which all like components are the same size and have the same drive capabilities. Therefore, it cannot be assumed that the input signal to a latch will overcome the opposing inverter gate in the latch. To ensure that the input to each latch will be able to change the state of the output inverter (I13, I15, I17) and, therefore, the latch output, transmission gates (TG) are used to isolate the output of the opposing inverter (I14, I16, I18) from the input of the latch. For example, with CLK asserted, the signal MCLK (derived from CLK and SC --  N through inverter I19, NAND gate 28 and inverter I21) is deasserted. Gate TG1 is disabled, and gate TG2 is enabled. If CLKA is also deasserted, gate TG3 is disabled, and gate TG4 is enabled. Data at the DATA IN or SCAN IN inputs is blocked from master latch 12B. The value in master latch 12B appears at the output of inverter I13. The value is inverted by I14, and the inverted value is applied to the input of I13 through the enabled gates TG2 and TG4. The value in master latch 12B can be changed by enabling data to its inputs from either the DATA IN input or the SCAN IN input by setting appropriate clock signals. With CLK deasserted and SC --  N asserted, MCLK is asserted. TG1 is enabled, and TG2 is disabled, so only data on DATA IN reaches the input to I13 and thus the master latch 12B. If, on the other hand, CLKA is asserted, TG3 is enabled and TG4 is disabled. If SC --  N is deasserted, MCLK is deasserted and maintains TG1 disabled and TG2 enabled. Therefore, only data at SCAN IN reaches the input of I13. 
     In slave latch 14B, data is maintained in I15 by I16 when TG6 and TG8 are enabled. If it is desired to transfer data from master latch 12B to slave latch 14B, DCLK (derived from CLK through inverters I19 and I20) is asserted. TG5 is enabled, and TG6 is disabled, so only data from master latch 12B reaches the input of inverter I15. The data is inverted by I15 and appears at the slave latch output, also the Q output of the flip-flop. If it is desired to transfer data from scan latch 16B to slave latch 14B, ISOL --  N (derived from ISOL through inverter I22) is asserted and DCLK is deasserted. TG7 is enabled, TG8 is disabled, and, since DCLK is deasserted, TG6 is enabled; so, data from scan latch 16B is transferred to slave latch 14B. 
     In scan latch 16B, data is maintained in I17 by I18 when TG10 and TG11 are enabled. If it is desired to transfer data from master latch 12B to scan latch 16B, CLKB is asserted. TG12 is enabled, and TG11 is disabled, so only data from master latch 12B reaches the input of inverter I17. The data is inverted by I17 and appears at the scan latch output, which is also the SCAN OUT output of the flip-flop. If it is desired to transfer data from slave latch 14B to scan latch 16B, ISOL --  N is asserted and CLKB is deasserted. TG9 is enabled, TG10 is disabled, and, since CLKB is deasserted, TG11 is enabled: so, data from slave latch 14B is transferred to scan latch 16B. 
     Functionally, the circuits of FIG. 4 and FIG. 5 are the same, with one minor difference. If the signals DCLK and CLKB are asserted simultaneously, the circuits will behave differently. In FIG. 4, there will be contention between the outputs of I3 and I7 at the input of I5 in the slave latch. Therefore, the output of the slave latch is indeterminate. However, in FIG. 5, because DCLK is asserted, TG5 is enabled, and I13 drives the input of I15 in the slave latch. TG6 is disabled, so no other signal can attempt to drive I15. There is no contention, and I13 controls the output of the slave latch. This difference can be eliminated by selecting I3 in FIG. 4 such that it has higher drive capability than I7. When DCLK and CLKB are asserted simultaneously, I3 will dominate I7 at the input of I5 and will therefore control the output of the slave latch. Thus, the two circuits will behave in the same manner. 
     FIG. 1 depicts a possible configuration in which the scannable flip-flop can be used. Flip-flops 10 are grouped together in registers 18 and 20. The outputs of combinational logic 22 and 24 are the DATA IN inputs to the flip-flops in registers 18 and 20, respectively. The Q outputs of the flip-flops are connected to the inputs of the combinational logic. To allow data to be shifted through the registers, the SCAN OUT output of each flip-flop is connected to the SCAN IN input of the next flip-flop. The SCAN IN input of the first flip-flop in each register is used as the SCAN IN input for the register, and the SCAN OUT output of the last flip-flop in each register is used as the SCAN OUT output for the register. 
     In the normal system mode of operation, control signal SC --  N is asserted and ISOL is deasserted. Data at the outputs of logic 22 is applied to the DATA IN inputs of register 18. After a CLK pulse in which the CLK signal is asserted and then deasserted, the data is latched into register 18 and appears at its Q outputs and the inputs of logic 24. Logic 24 performs the required logic operations on the input data, and the resultant data appears at the outputs of logic 24 and the DATA IN inputs of register 20. Following the next CLK pulse, this data is latched into register 20 and appears at its Q outputs. 
     If it is desirable to shift data out of or into registers 18 and 20, flip-flops 10 must be placed in the scan mode of operation. CLK is deasserted, control signal SC --  N is deasserted and ISOL is asserted to prevent the scan operation from effecting the Q outputs of the register. 
     FIG. 6 is a timing diagram for a scan-in and a scan-out operation performed simultaneously on register 18. The SCAN OUT output of each flip-flop stage is shifted to the next flip-flop stage by a CLKA pulse followed by a CLKB pulse. After four pairs of scan clock pulses, the original contents of the register, V 1 , V 2 , V 3 , V 4 , have been shifted to the SCAN OUT output of register 18. At the same time, new register data, U 1 , U 2 , U 3 , U 4 , has been shifted into the register. During this operation, the outputs of register 18, V 1 , V 2 , V 3 , V 4 , did not change because ISOL was asserted. However, ISOL is deasserted after the last CLKB pulse to allow the new data to be copied into the register outputs. 
     The flip-flop circuit 10 is also capable of shifting the DATA IN flip-flop inputs to the SCAN OUT output. While the system in FIG. 1 is operating in its normal mode, it may become necessary to scan the flip-flop data inputs to examine them for errors. To do this, the system CLK is deasserted. Since SC --  N is asserted, the last set of input data is applied to master latch circuits 12. To scan this data out of the register, ISOL is asserted and a CLKB pulse is applied. This latches the data inputs in scan latches 16 and at the SCAN OUT flip-flop outputs. Thus, by applying the CLKB pulse before the CLKA pulse, the values initially held by the master latches 12 are presented in the scan latches 16 for subsequent scan-out. The values can then be scanned out as described above with the CLKA pulse followed by the CLKB pulse. Since ISOL is asserted during the first scan-out, the flip-flop Q outputs are preserved and can be scanned out next. This is done by deasserting and then asserting ISOL to latch the slave outputs into scan latches 16 and then following the scan-out procedure. Since CLKA precedes CLKB, the values initially held in slave latches 14 copy over the values initially in master latches 12, so the latter are lost in this scan operation. 
     The configuration of FIG. 1 can also be used to test combinational logic 22 and 24. For example, registers 18 and 20 can be used to measure the propagation delays in logic 24. FIG. 7 is a timing diagram for the measurement. To perform the measurement, CLK, SC --  N, and ISOL are deasserted. A set of known data, V 1 , V 2 , V 3 , V 4 , is scanned into register 18. Since ISOL is deasserted, the data is latched in slave latches 14 and appears at the Q outputs of flip-flops 10. With V 1  -V 4  applied to the inputs of logic 24, the resulting outputs Z 5  -Z 8  are applied t IN inputs of register 20. Next, a second set of known data, V 1  &#39;, V 2  &#39;, V 3  &#39;, V 4  &#39;, is scanned in with ISOL asserted. This second set of data is latched in master latches 12 and appears at nodes MQ 1  -MQ 4  of flip-flops 10. Then, at time t 1 , a CLK pulse is applied followed by assertion of SC --  N. Data Z 5  -Z 8  is clocked to the outputs Q 5  -Q 8  of register 20. At the same time, V.sub. 1 &#39;-V 4  &#39; appear at the outputs Q 1  -Q 4  of register 18 and at the inputs of logic 24. This data propagates through logic 24, and some time later, at time t 2 , the outputs of logic 24 change to Z 5  &#39;-Z 8  &#39;. A second CLK pulse is then applied at time t 3 , and the new register 20 DATA IN inputs, Z 5  &#39;-Z 8  &#39;, are clocked to the register 20 outputs Q 5  -Q 8 . If this second clock pulse (time t 3 ) comes after Z 5  &#39;-Z 8  &#39; appear at the logic 24 outputs (time t 2 ), then the register 20 outputs will contain Z 5  &#39;-Z 8  &#39; after time t 3 . However, if the logic 24 outputs have not changed before t 3 , the new data will not appear at the register 20 outputs. Therefore, an accurate measurement of the delays in logic 24 can be obtained by repeatedly performing the procedure described above, each time reducing the separation in time between the two clock pulses. That is, each time the process is repeated, the time between CLK pulses, t 3  -t 1 , is reduced. Eventually, this time will approach the time delay, t 2  -t 1 , in the logic. When the outputs of register 20 do not capture the change in data from Z 5  -Z 8  to Z 5  &#39;-Z 8  &#39;, the time t 3  -t 1 , is equal to or less than the delay in logic 24, t 2  -t 1 . Thus, an accurate measurement of the delay is obtained. 
     While this invention has been particularly shown and described with references to preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.