supercat
Member level 3
In a CPLD which supports async preset/reset of flip flops, and allows each latch to be configured for either rising edge or falling-edge trigger, but not both, would the following be a good approach to simulating a double-edge-trigger latch:
At least in theory, if the clock is stable, latch1 and latch2 will be made to match. When the clock changes state, latch1 or latch2 will grab the data, and then the other latch will conform to it.
The latch-to-output propagation delay will be different for rising and falling edges (which is faster will depend upon whether one uses latch1 or latch2) but I would expect that things should switch cleanly unless a setup/hold violation between clock and data causes a latch to go metastable. Unless the clock has runt pulses or is otherwise too fast, I wouldn't think metastability would be any worse than with a normal latch.
Has anyone tried such an approach before? Are there any gotchas?
Code:
latch1.clk = Clock;
latch2.clk = !Clock;
latch1.d = Data;
latch2.d = Data;
latch1.ap = !Clock & latch2.q & !latch1.q;
latch1.ar = !Clock & !latch2.q & latch1.q;
latch2.ap = Clock & latch1.q & !latch2.q;
latch2.ar = Clock & !latch1.1 & latch2.q;
At least in theory, if the clock is stable, latch1 and latch2 will be made to match. When the clock changes state, latch1 or latch2 will grab the data, and then the other latch will conform to it.
The latch-to-output propagation delay will be different for rising and falling edges (which is faster will depend upon whether one uses latch1 or latch2) but I would expect that things should switch cleanly unless a setup/hold violation between clock and data causes a latch to go metastable. Unless the clock has runt pulses or is otherwise too fast, I wouldn't think metastability would be any worse than with a normal latch.
Has anyone tried such an approach before? Are there any gotchas?