热度 28
2011-2-17 22:45
3361 次阅读|
0 个评论
It is the opinion of the authors that in general, every flip-flop in an ASIC should be resettable whether or not it is required by the system. Furthermore, the authors prefer to use asynchronous resets following the guidelines detailed in this paper. There are exceptions to these guidelines. In some cases, when follower flip-flops (shift register flip-flops) are used in high speed applications, reset might be eliminated from some flip-flops to achieve higher performance designs. This type of environment requires a number of clocks during the reset active period to put the ASIC into a known state. Many design issues must be considered before choosing a reset strategy for an ASIC design, such as whether to use synchronous or asynchronous resets, will every flip-flop receive a reset, how will the reset tree be laid out and buffered, how to verify timing of the reset tree, how to functionally test the reset with test scan vectors, and how to apply the reset among multiple clock zones. 1. Synchronous resets There are some advantages to using synchronous resets, but there are also disadvantages. The same is true for asynchronous resets. The designer must use the approach that is appropriate for the design. Synchronous resets are based on the premise that the reset signal will only affect or reset the state of the flip-flop on the active edge of a clock. The reset can be applied to the flip-flop as part of the combinational logic generating the d-input to the flip-flop. If this is the case, the coding style to model the reset should be an if/else priority style with the reset in the if condition and all other combinational logic in the else section. If this style is not strictly observed, two possible problems can occur. First, in some simulators, based on the logic equations, the logic can block the reset from reaching the flip-flop. This is only a simulation issue, not a hardware issue, but remembers, one of the prime objectives of a reset is to put the ASIC into a known state for simulation. Second, the reset could be a “ late arriving signal” relative to the clock period, due to the high fan-out of the reset tree. Even though the reset will be buffered from a reset buffer tree, it is wise to limit the amount of logic the reset must traverse once it reaches the local logic. This style of synchronous reset can be used with any logic or library. Example 3 shows an implementation of this style of synchronous reset as part of a loadable counter with carry out. module ctr8sr ( q, co, d, ld, rst_n, clk); output q; output co; input d; input ld, rst_n, clk; reg q; reg co; always @(posedge clk) if (!rst_n) {co,q} = 9'b0; // sync reset else if (ld) {co,q} = d; // sync load else {co,q} = q + 1'b1; // sync increment endmodule Example 3a - Verilog code for a loadable counter with synchronous reset Figure 3 - Loadable counter with synchronous reset 1.1 Advantages of synchronous resets Synchronous reset 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. If a design is tight, the area savings of one or two gates per flip-flop may ensure the ASIC fits into the die. However, in today’s technology of huge die sizes, the savings of a gate or two per flip-flop is generally irrelevant and will not be a significant factor of whether a design fits into a die. Synchronous reset can be much easier to work with when using cycle based simulators. For this very reason, synchronous resets are recommend in section 3.2.4(2 nd edition, section 3.2.3 in the 1 st edition) of the Reuse Methodology Manual (RMM) . Synchronous resets generally insure that the circuit is 100% synchronous. Synchronous resets insure that reset can only occur at an active clock edge. The clock works as a filter for small reset glitches; however, if these glitches occur near the active clock edge, the flip-flop could go meta-stable. In some designs, the reset must be generated by a set of internal conditions. A synchronous reset is recommended for these types of designs because it will filter the logic equation glitches between clocks. By using synchronous resets and a number of clocks as part of the reset process, flip-flops can be used within the reset buffer tree to help the timing of the buffer tree keep within a clock period. 1.2 Disadvantages of synchronous resets Synchronous resets may need a pulse stretcher to guarantee a reset pulse width wide enough to ensure reset is present during an active edge of the clock . A designer must work with pessimistic vs. optimistic simulators. This can be an issue if the reset is generated by combinational logic in the ASIC or if the reset must traverse many levels of local combinational logic. During simulation, based on how the reset is generated or how the reset is applied to a functional block, the reset can be masked by X’s. A large number of the ESNUG articles addressed this issue. Most simulators will not resolve some X-logic conditions and therefore block out the synchronous reset . By its very nature, a synchronous reset will require a clock in order to reset the circuit. This may not be a disadvantage to some design styles but to others, it may be an annoyance. The requirement of a clock to cause the reset condition is significant if the ASIC/FPGA has an internal tri-state bus. In order to prevent bus contention on an internal tri-state a tri-state bus when a chip is powered up, the chip must have a power on asynchronous reset . 2 Asynchronous resets Asynchronous resets are the authors preferred reset approach. However, asynchronous resets alone can be very dangerous. The biggest problem with asynchronous resets is the reset release, also called reset removal. The subject will be elaborated in detail later. Asynchronous reset flip-flops incorporate a reset pin into the flip-flop design. The reset pin is typically active low(the flip-flop goes into the reset state when the signal attached to the flip-flop reset pin goes to a logic low level.) 2.1 Coding style and example circuit The Verilog code of Example 5a shows the correct way to model asynchronous reset flip-flops. Note that the reset is part of the sensitivity list. For Verilog, adding the reset to the sensitivity list is what makes the reset asynchronous. In order for the Verilog simulation model of an asynchronous flip-flop to simulate correctly, the sensitivity list should only be active on the leading edge of the asynchronous reset signal. Hence, in Example 5a, the always procedure block will be entered on the leading edge of the reset, then the if condition will check for the correct reset level. module async_resetFFstyle (q, d, clk, rst_n); output q; input d, clk, rst_n; reg q; // Verilog-2001: permits comma-separation // @(posedge clk, negedge rst_n) always @(posedge clk or negedge rst_n) if (!rst_n) q = 1'b0; else q = d; endmodule Example 5a - Correct way to model a flip-flop with asynchronous reset using Verilog 2.2 Advantages of asynchronous resets The biggest advantage to using asynchronous resets is that, as long as the vendor library has asynchronously reset-able flip-flops, the data path is guaranteed to be clean. Designs that are pushing the limit for data path timing, cannot afford to have added gates and additional net delays in the data path due to logic inserted to handle synchronous resets. Of course this argument does not hold if the vendor library has flip-flops with synchronous reset inputs and the designer can get Synopsys to actually use those pins. Using an asynchronous reset, the designer is guaranteed not to have the reset added to the data path. The code in Example 7 infers asynchronous resets that will not be added to the data path. module ctr8ar ( q, co, d, ld, rst_n, clk); output q; output co; input d; input ld, rst_n, clk; reg q; reg co; always @(posedge clk or negedge rst_n) if (!rst_n) {co,q} = 9'b0; // async reset else if (ld) {co,q} = d; // sync load else {co,q} = q + 1'b1; // sync increment endmodule Example 7a- Verilog code for a loadable counter with asynchronous reset Figure 4 - Loadable counter with asynchronous reset Another advantage favoring asynchronous resets is that the circuit can be reset with or without a clock present. The experience of the authors is that by using the coding style for asynchronous resets described in this section, the synthesis interface tends to be automatic. That is, there is generally no need to add any synthesis attributes to get the synthesis tool to map to a flip-flop with an asynchronous reset pin. 2.3 Disadvantages of asynchronous resets There are many reasons given by engineers as to why asynchronous resets are evil. The Reuse Methodology Manual (RMM) suggests that asynchronous resets are not to be used because they cannot be used with cycle based simulators. This is simply not true. The basis of a cycle based simulator is that all inputs change on a clock edge. Since timing is not part of cycle based simulation, the asynchronous reset can simply be applied on the inactive clock edge. For DFT, if the asynchronous reset is not directly driven from an I/O pin, then the reset net from the reset driver must be disabled for DFT scanning and testing. This is required for the synchronizer circuit shown later. Some designers claim that static timing analysis is very difficult to do with designs using asynchronous resets. The reset tree must be timed for both synchronous and asynchronous resets to ensure that the release of the reset can occur within one clock period. The timing analysis for a reset tree must be performed after layout to ensure this timing requirement is met. The biggest problem with asynchronous resets is that they are asynchronous, both at the assertion and at the de-assertion of the reset. The assertion is a non issue, the de-assertion is the issue. If the asynchronous reset is released at or near the active clock edge of a flip-flop, the output of the flip-flop could go metastable and thus the reset state of the ASIC could be lost. Another problem that an asynchronous reset can have, depending on its source, is spurious resets due to noise or glitches on the board or system reset. See section later for a possible solution to reset glitches. If this is a real problem in a system, then one might think that using synchronous resets is the solution. A different but similar problem exists for synchronous resets if these spurious reset pulses occur near a clock edge, the flip-flops can still go metastable. This article abstracted from CummingsSNUG2002SJ_Resets , the original author is Clifford E. Cummings and Don Mills.