NOTE: I AM ONLY REFERRING TO FLIP FLOPS AND NOT NECESSARILY LATCHES IN THIS PASSAGE
The D Flip Flop is a edge-triggered synchronous device that allows the user to define functionality based on clock edges to forward an input. It is a common and beginner friendly construct, and everything from Clock Trees to Fully Registered combinational circuits, it is an element that needs no better introduction.
Some flip flops have an active low reset pin, meaning that when the pin drives a 0 logic state, or
equivalently ground, the internal logic resets the output to be some 0
state. These can be configured based
on the parameter passed to it. Reset pins in this manner are typically asynchronous, meaning that the pin itself
does not wait for a timing element to be complete for it to reset.
There are more flip flops possible than just the D flip flop, JK flip flops are rather common as well. However in most of my modern academia and in other projects as well I find the D flip flop being a component that is used more commonly than other latches or flip flops.
The characteristic equation for a DFF is as follows: Q* = D
Q* := The next state of the output Q
D := The current input
The side block diagram form of the DFF is done in Xilinx Vivado using the IP generation tool. Note that I have not included a specific package download in my website to account for this, simply because it is likely that your toolset for your FPGA or other board will have an easier time optimizing and improving the efficiency given simply the Verilog code rather than a direct IP package. This also allows you to have more freedom in modifying or recreating such designs if you so desire to improve its implementation tailored to your needs.
module dff_simple(
// input and output ports
input logic d,
input logic clk,
output logic q
);
// sensitivity list
always_ff @(posedge clk) begin
// non-blocking operator within begin-end block
// which does not affect latency or delays
// if other outputs were all channeled using NBA
// (NBA = Non-Blocking Assignment)
//
// does not create race conditions b/c only one
// always block to compute
q <= d;
end
endmodule