Modelling D type Flip Flop in Verilog

Field-Programmable Gate Arrays
Post Reply
User avatar
Magneto
Major
Major
Posts: 430
Joined: Wed Jul 15, 2009 1:52 pm
Location: London

Modelling D type Flip Flop in Verilog

Post by Magneto » Sat Nov 14, 2009 9:24 pm

D.JPG
D.JPG (21.76 KiB) Viewed 5165 times
module D_latch (Q,D,control);
output Q;
input D,control;
reg Q;
always @ (control or D)
if (control) Q = D; //Same as: if (control = 1)
endmodule


//D flip-flop
module D_FF (Q,D,CLK);
output Q;
input D,CLK;
reg Q;
always @ (posedge CLK)
Q = D;
endmodule


//D flip-flop with asynchronous reset.
module DFF (Q,D,CLK,RST);
output Q;
input D,CLK,RST;
reg Q;
always @(posedge CLK or negedge RST)
if (~RST) Q = 1'b0; // Same as: if (RST = 0)
else Q = D;
endmodule

D2.JPG
D2.JPG (27.49 KiB) Viewed 5163 times
D1.JPG
D1.JPG (32.79 KiB) Viewed 5163 times
Post Reply

Return to “FPGA”