A latch is a digital logic circuit that can sample a 1-bit digital value and hold it depending upon the state of an enable signal. Based upon the state of enable, latches are categorized into positive level-sensitive and negative level-sensitive latches.
Positive level-sensitive latch: A positive level-sensitive latch follows the input data signal when enable is '1' and keeps its output when the data when it is '0'. Figure 1 below shows the symbol and the timing waveforms for a latch. As can be seen, whenever enable is '1', out follows the data input. And when enable in '0', out remains the same.
|
Figure 1(a): Positive level- Figure 1(b): Timing waveform for a positive level- sensitive latch sensitive latch |
Negative level-sensitive latch: A negative level-sensitive latch follows the input data when enable is '0' and keeps its output when input is '1'.
|
Figure 2(a): Negative level- Figure 2(b): Timing waveform for a negative level- sensitive latch sensitive latch |
|
Latch timing arcs: Data can propagate to the output of the latch in two ways as discussed below:
- Out changes with Data: This happens when enable is in its asserted state (for example, for a positive level latch). When this happens, Out follows Data as there is a direct path between Data and Out when Enable is '1'. This scenario is depicted in figures 1(b) and 2(b) above wherein out is shown toggling when Data toggles. The latch is, thus, said to have a timing arc from Data to Out.
- Out changes with Enable: This happens when Data at input changes when Enable is in its de-asserted state. When this happens, latch waits for Enable to be asserted, then, follows the value of Data. As figure 3 shows, Data had become stable a lot earlier, but out toggled only when enable became asserted. So, in latches, there exists a timing arc from Enable to Out.
|
Figure 3:When data changes during enable is in de-asserted state, output waits for the enable to assert. Only then, the effect of input propagated to output |
- Relation between Data and Enable: If Data toggles very close to the closing edge of Enable, then, there might be a confusion as if its effect will be propagated to output or not (as discussed later in this post). To make things more deterministic, we impose a certain condition that Data should not toggle when Enable is getting de-asserted. This relationship can be modelled as setup and hold arcs. So, there are setup and hold timing arcs between data and enable pins of a latch. These will be discussed below in detail.
Setup time and hold time for a latch: The most commonly used latch circuit is that built using inverters and transmission gates. Figure 4 shows the transmission gate implementation of a positive level-sensitive latch. The Enable has been shown as CLK as usually is the case in sequential state machines. This circuit has two phases, as is expected for a latch:
- When CLK = '1', Transmission gate at the input gets ON and there is a direct path between Data and Out
- When CLK = '0', transmission gate in the loopback path gets ON. Out holds its value
|
Figure 4: Positive level-sensitive latch using transmission gates
|
|
Now, when CLK transitions from '1' to '0', it is important that Data does not toggle. The time before the clock falling edge that Data should remain stable is known as latch setup time. Similarly, the time after the clock falling edge that Data should remain stable is called latch hold time.
Let us go into the details of what latch setup and hold time should be for transmission gate latch. If we want the data to be propagated properly to the output, then Data should be stable for atleast some time before closing of the input transmission gate. This time is such that it goes into the memory of latch; i.e., before input transmission gate closes, Data should traverse both the inverters of the loop. So, setup time of the latch involves the delay of input transmission gate and the two inverters. Figure 5 below shows the setup time for the latch.
|
Figure 5: Setup time for latch |
Similarly, if we do not want the data to propagate to output, it must not cross input transmission gate so that it does not disturb the present state of the latch. This server as the hold time for the latch. Assuming CLK' takes one inverter delay, input transmission gate will close after one inverter delay only. So, the hold time for Data is one inverter delay minus transmission gate delay. Please refer to figure 6 below for the illustration of this. (CLK)' is formed from CLK after a delay equivalent to an inverter delay. Only then, input transmission gate will switch off. If we want the data not to propagate to Out, we have to ensure that it does not cross input transmission gate. So, Data should not be present at the transmission gate's input at time (T(inv) - T(tg)). In other words, it has to be held stable this much time after CLK edge. This is the hold time for the latch.
|
Figure 6: Hold time for latch |
Please note that there are other topologies also possible for latches such as dynamic latches etc. The setup time and hold time calculations for such topologies will vary, but the underlying principle will remain same, which is as follows:
- Setup time ensures that the data propagates to the output at the coming clock edge
- Hold time ensures that the data does not propagate to the output at the present/previous clock edge
Setup checks and hold checks for latches: As discussed above, the decision for the data to be latched or not to be latched is made at the closing edge. So, the setup and hold checks are with respect to latch closing edge only. However, since, latches are transparent during half of the clock period, we can assume as if the capturing edge is flexible and stretches all over the active level of the latch. This property enables a very beautiful concept known as "time borrowing" for latches.
If setup and hold is not met for lath , will it goes to metastable state as similar to flip flop
ReplyDeleteHi
DeleteVery good question, yes latches are also prone to metastability similar to flip-flops. You can go through below post to understand the concept.
https://vlsiuniverse.blogspot.com/2019/10/how-latchflip-flop-goes-metastable.html
I hope it is of help to you. Please let me know if there are any other questions.
setup time of the latch involves the delay of input transmission gate and the two inverters. Why is it two inverters . As output of first inverter is output of the latch . Should not it be delay of input transmission gate and one inverter
ReplyDeleteHi Praveen
DeleteLet us suppose the input transmission gate closes when only the first inverter has toggled its output and has reached pure voltage level (let us say input changed from 0 to 1). Now, both the inverters have 0 as their outputs.
Now, since, the inverter in forward path has more drive strength, the loop will stabilize as desired. Thus, this works as you said. In this case, we can assume that the setup time is equal to delay of transmission gate and 1 inverter.
On the other hand, consider the case when the output of first inverter has just crossed VOL (let us say 0.25 * VDD) while the output of second inverter is pure 0. Now depending upon the relative strengths of both the inverters, the output can settle at any value between 0 and 1. So, it is not right to say that if 1st inverter output has changed, then the inverter loop will work fine.
O hope I was able to make my point. We can discuss further in case of any queries.
If the clock to the transmission gate is delayed by an inverter then should'nt the input be kept stable for a longer time? That is hold time is transmission gate delay + inverter delay??
ReplyDeleteYes, right.
DeleteHere what is delay from clock to output?
ReplyDeleteThanks for the useful info .. Can you comment why a latch fanning out to itself creates an issue/warning?
ReplyDeleteHi Babul
DeleteThis is for the same reason we dont allow a combinational gate fanning out to itself.
1. It can create osillations as inversion can travel from output to input. You can argue that non-inverting paths should be allowed. The same argument is valid for combinational loopback as well. STA tools are not smart enough to handle this.
2. Tool will have hard time to calculate transition and delay since it will be like a chicken and egg problem
3. Setup check calculation will be very complex since latch will keep on borrowing time from itself.