Re: Understanding DFF behaviour
Posted by
cadet1620 on
Apr 18, 2016; 2:01pm
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/Understanding-DFF-behaviour-tp4029740p4029742.html
What you are calling a YES gate is actually called a "buffer". In real world hardware there is a limit to the number of inputs that you can connect to any particular output. This is called "fanout". Buffers typically are designed to have greater fanout than normal gates so they can be used in these special cases.
In the real world, buffers are almost never to make short pulses as shown in the circuits you found. That type of circuit is very unreliable. Those sorts of short pulses occur accidentally in logic and must be taken into consideration when designing. They're called "hazards". See
http://www.marksmath.com/tecs/glitchCheck out
http://play-hookey.com/digital/sequential/d_nand_flip-flop.htmlfor a safe master-slave DFF.
The n2t DFF doesn't actually simulate the behavior of hardware implementing a DFF. It is exactly what you described in your first post — state latched on rising edge, copied to output on falling edge.
Here is the DFF.java source file
/********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (the "License"); you may not use this file except *
* in compliance with the License. You may obtain a copy of the License at *
* http://www.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInChips;
import Hack.Gates.*;
/**
* The DFF chip.
*/
public class DFF extends BuiltInGate {
// The state (0/1) of the DFF.
private short state;
protected void clockUp() {
state = inputPins[0].get();
}
protected void clockDown() {
outputPins[0].set(state);
}
}
--Mark