This example describes how to generate a D flipflop with enable (DFFE) behaviorally with asynchronous preset and reset signals. Both the preset and reset signals are active low, controlling the output of the DFFE whenever either signal goes low.
For more information on using this example in your project, go to:
- How to Use Verilog HDL Examples
- MAX+PLUS II Help
dffeveri.v
module dffeveri (q, d, clk, ena, rsn, prn);
// port declaration
input d, clk, ena, rsn, prn;
output q;
reg q;
always @ (posedge clk or negedge rsn or negedge prn) begin
//asynchronous active-low preset
if (~prn)
begin
if (rsn)
q = 1'b1;
else
q = 1'bx;
end
//asynchronous active-low reset
else if (~rsn)
q = 1'b0;
//enable
else if (ena)
q = d;
end
endmodule
Design Examples Disclaimer
These design examples may only be used within Altera Corporation devices and remain the property of Altera. They are being provided on an “as-is” basis and as an accommodation; therefore, all warranties, representations, or guarantees of any kind (whether express, implied, or statutory) including, without limitation, warranties of merchantability, non-infringement, or fitness for a particular purpose, are specifically disclaimed. Altera expressly does not recommend, suggest, or require that these examples be used in combination with any other product not provided by Altera.

