Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to implement a DFF in verilog?

Status
Not open for further replies.

newcpu

Member level 4
Joined
Oct 30, 2005
Messages
76
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,286
Activity points
1,818
verilog dff

Hi,
I want to implement a DFF in verilog. And I know the method in the following:
always@(posedge clk)
begin
if(EN)
q<=d;
else
q<=q;
end
Could we avoid the"else q<=q; q<=q; " with other method?
Best Regards,
newcpu
 

verilog dff with enable

Yes, we could. It is not necessary to use this string in your code. Synthesizer understand this code as a D flip flop:

module D_flipflop (d, q, clock, enable);

input d;
input clock;
input enable;

output q;

reg q;

always @ (posedge clock) begin if (enable) q = d; end

endmodule
 

Is enable really required ?
 

No, Enable is not required. you can write

always @ (posedge clk) q<=d;
 

dude , try this :

always @ (posedge clk )
begin
if (reset)
q<=1'b0;
else
q<=d;
end

Added after 1 minutes:

dude , try this :

always @ (posedge clk )
begin
if (reset)
q<=1'b0;
else
q<=d;
end
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top