Showing posts with label interview questions. Show all posts
Showing posts with label interview questions. Show all posts

Friday, September 15, 2017

Setup and hold time Questionaire


Significance of negative setup and hold time
What do you mean by negative setup and hold time i.e what happens if hold time is negative or setup time is negative. Does -ve setup or hold have any advantage ?

Setup times and hold times describe the limits relative to the active clock edge of a "window" within which the input data must be valid for the data to be reliably recognized. The diagram below (you can ignore the bottom Q output part) shows the situation for assumed positive hold and setup times, but you can imagine them negative.

If setup time is negative, then the absolute latest that the data can become valid is actually after the active clock edge, Obviously the hold time must be positive and of greater magnitude or there would be no window for data validity.

If the hold time is negative, then the absolute earliest the data no longer needs to be valid is before the active clock edge, so it can change just before the clock edge and the previous value will be correctly recognized. Obviously, the setup time must be positive and of greater magnitude or there would be no window.

As to possible advantages- think about the situation where you are trying to increase clock frequency as much as possible.

For Hold Time > If the difference between the data path and the clock path is negative, then a timing violation has occurred.

For Setup Time > If the difference between the clock path and the data path is negative, then a timing violation has occurred.

By negative setup and hold times do you mean positive slack time?
Positive slack means the data arrival times are not violating the timing of the circuit. It basically tells you how much timing you have to lose and still be acceptable.

slack time, setup time, hold time

A zero setup time means that the time for the data to propagate within the component and load into the latch is less than the time for the clock to propagate and trigger the latch.

A negative setup or hold time means that there is an even larger difference in path delays, so that even if the data is sent later than the clock (for setup time), it still arrives at the latch first.

slack is different from this because it is the required time - arrival time....


Say an FF as setup time of 1ns.(positive 1ns)
Now re-design this FF, and put a buffer in the clock path with a propagation delay of 2 ns.
Now the setup time of this redesigned FF would be -1ns (negative).

So if the clock is delayed w.r.t data, then you can see negative setup times.


Re: Negative setup and hold time
Negative setup time flops are used on hard-to-meet data paths.
Negative hold time flops already have an "inbuilt hold buffer" embedded and hold closure is eased.


What is metastability?
Whenever there are setup and hold time violations in any flip-flop, it enters a state where its output is unpredictable: this state is known as metastable state (quasi stable state); at the end of metastable state, the flip-flop settles down to either '1' or '0'. This whole process is known as metastability. In the figure below Tsu is the setup time and Th is the hold time. Whenever the input signal D does not meet the Tsu and Th of the given D flip-flop, metastability occurs.

When a flip-flop is in metastable state, its output oscillate between '0' and '1' as shown in the figure below (here the flip-flop output settles down to '0') . How long it takes to settle down, depends on the technology of the flip-flop.

If we look deep inside of the flip-flop we see that the quasi-stable state is reached when the flip-flop setup and hold times are violated. Assuming the use of a positive edge triggered "D" type flip-flop, when the rising edge of the flip-flop clock occurs at a point in time when the D input to the flip-flop is causing its master latch to transition, the flip-flop is highly likely to end up in a quasi-stable state. This rising clock causes the master latch to try to capture its current value while the slave latch is opened allowing the Q output to follow the "latched" value of the master. The most perfectly "caught" quasi-stable state (on the very top of the hill) results in the longest time required for the flip-flop to resolve itself to one of the stable states.


How long does it stay in this state?
The relative stability of states shown in the figure above shows that the logic 0 and logic 1 states (being at the base of the hill) are much more stable than the somewhat stable state at the top of the hill. In theory, a flip-flop in this quasi-stable hilltop state could remain there indefinitely but in reality it won't. Just as the slightest air current would eventually cause a ball on the illustrated hill to roll down one side or the other, thermal and induced noise will jostle the state of the flip-flop causing it to move from the quasi-stable state into either the logic 0 or logic 1 state.



What are the cases in which metastability occurs?
As we have seen that whenever setup and hold violation time occurs, metastability occurs, so we have to see when signals violate this timing requirement:


When the input signal is an asynchronous signal.
When the clock skew/slew is too much (rise and fall time are more than the tolerable values).
When interfacing two domains operating at two different frequencies or at the same frequency but with different phase.
When the combinational delay is such that flip-flop data input changes in the critical window (setup+hold window) 


What is MTBF?
MTBF is Mean time between failure, what does that mean? Well MTBF gives us information on how often a particular element will fail or in other words, it gives the average time interval between two successive failures. The figure below shows a typical MTBF of a flip-flop and also it gives the MTBF equation. I am not looking here to derive MTBF equation :-)


So how do I avoid metastability?
In reality, one cannot avoid metastability and increased clock-to-Q delays in synchronizing asynchronous inputs, without the use of tricky self-timed circuits. So a more appropriate question might be "How do I tolerate metastability?"


In the simplest case, designers can tolerate metastability by making sure the clock period is long enough to allow for the resolution of quasi-stable states and for the delay of whatever logic may be in the path to the next flip-flop. This approach, while simple, is rarely practical given the performance requirements of most modern designs.



The most common way to tolerate metastability is to add one or more successive synchronizing flip-flops to the synchronizer. This approach allows for an entire clock period (except for the setup time of the second flip-flop) for metastable events in the first synchronizing flip-flop to resolve themselves. This does, however, increase the latency in the synchronous logic's observation of input changes.


Neither of these approaches can guarantee that metastability cannot pass through the synchronizer; they simply reduce the probability to practical levels.

In quantitative terms, if the Mean Time Between Failure (MTBF) of a particular flip-flop in the context of a given clock rate and input transition rate is 33.33 seconds then the MTBF of two such flip-flops used to synchronize the input would be (33.33* 33.33) = 18.514 Minutes. Well I have taken the worst flip-flop ever designed in history of man kind :-). The figure below shows how to connect two flip-flops in series to achieve this and also the resultant MTBF.

Normally,
We can use a metastable hardened flip-flop
Cascade two or three D-Flip-Flops (two or three stages synchronizer).

Thursday, September 13, 2012

Why we need functional verification?

1) A primary purpose for functional verification is to detect failures so that bugs can be identified and corrected before it gets shipped to costumer.  
2) If RTL designer makes a mistake in designing or coding, this results as a bug in the Chip. If this bug is executed, in certain situations the system will produce wrong results, causing a failure. 
3) Not all mistakes will necessarily result in failures. The bug in the dead code will never result in failure. 
4) A single mistake may result in a wide range of failure symptoms. Not all bugs are caused by coding errors. 
5) There are possibilities that error may in the specification itself. Sometimes miscommunications between teams may lead to wrong design.


Example of coding error:
    
     1 reg [1:0] state;
     2
     3 parameter zero=0, one=1, two=2, three=3;
     4
     5 always @(state)
     6     begin
     7          case (State)
     8               zero:
     9                    out = 4'b0000;
     10               one:
     11                   out = 4'b0001;
     12               two:
     13                   out = 4'b0010;
     14             three:
     15                   out = 4'b0100;
     16            default:
     17                   out = 4'b0000;
     18          endcase
     19     end
    
    

There is a coding error in the preceding example. Designer declared "state" in the line-1. Later in the code it is reference in the line-5. In the line-7 also, the designer intention is to refer "state". But mistakenly he typed "State".  Verilog is a case-sensitive language, and variable "State" and "state" are different and this will produce wrong results.

Monday, April 9, 2012

Synchronous Reset vs Asynchronous Reset

Why Reset?

A Reset is required to initialize a hardware design for system operation and to force an ASIC into a known state for simulation.

A reset simply changes the state of the device/design/ASIC to a user/designer defined state. There are two types of reset, what are they? As you can guess them, they are Synchronous reset and Asynchronous reset.

Synchronous Reset

A synchronous reset signal will only affect or reset the state of the flip-flop on the active edge of the clock. The reset signal is applied as is any other input to the state machine.

Advantages:
  • The advantage to this type of topology is that the reset presented to all functional flip-flops is fully synchronous to the clock and will always meet the reset recovery time.
  • Synchronous reset logic will synthesize to smaller flip-flops, particularly if the reset is gated with the logic generating the d-input. But in such a case, the combinational logic gate count grows so the overall gate count savings may not be that significant.
  • Synchronous resets provide some filtering for the reset signal such that it is not affected by glitches unless they occur right at the clock edge. A synchronous reset is recommended for some types of designs where the reset is generated by a set of internal conditions. As the clock will filter the logic equation glitches between clock edges.
Disadvantages:
  • The problem in this topology is with reset assertion. If the reset signal is not long enough to be captured at an active clock edge (or the clock may be slow to capture the reset signal), it will result in failure of assertion. In such case, the design needs a pulse stretcher to guarantee that a reset pulse is wide enough to be present during the active clock edge.
  • Another problem with synchronous resets is that the logic synthesis cannot easily distinguish the reset signal from any other data signal. So proper care has to be taken with logic synthesis, else the reset signal may take the fastest path to the flip-flop input thereby making worst-case timing hard to meet.
  • In some power saving designs, the clocked is gated. In such designed only asynchronous reset will work.
  • Faster designs that are demanding low data path timing, can not afford to have extra gates and additional net delays in the data path due to logic inserted to handle synchronous resets.
Asynchronous Reset

An asynchronous reset will affect or reset the state of the flip-flop asynchronously i.e. no matter what the clock signal is. This is considered as high priority signal and system reset happens as soon as the reset assertion is detected.

Advantages:
  • High speeds can be achieved, as the data path is independent of a reset signal.
  • Another advantage favouring asynchronous resets is that the circuit can be reset with or without a clock present.
  • As in synchronous reset, no workaround is required for logic synthesis.
Disadvantages:
  • The problem with this type of reset occurs at logic de-assertion rather than at assertion like in synchronous circuits. If the asynchronous reset is released (reset release or reset removal) at or near the active clock edge of a flip-flop, the output of the flip-flop could go metastable.
  • Spurious resets can happen due to reset signal glitches.
Conclusion

Both types of resets have positives and negatives and none of them assures fail-proof design. So there is something called "Asynchronous assertion and Synchronous de-assertion" reset which can be used for best results.

source: internet and my experience 

Ethernet and more

Ethernet is a protocol under IEEE 802.33 standard User Datagram Protocol (UDP) UDP is a connectionless transport protocol. I...