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
77
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
 

maksya

Full Member level 3
Joined
Jun 2, 2005
Messages
151
Helped
16
Reputation
32
Reaction score
3
Trophy points
1,298
Activity points
2,256
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
 

spauls

Advanced Member level 2
Joined
Dec 17, 2002
Messages
524
Helped
26
Reputation
52
Reaction score
9
Trophy points
1,298
Activity points
3,354
Is enable really required ?
 

avimit

Banned
Joined
Nov 16, 2005
Messages
413
Helped
91
Reputation
182
Reaction score
23
Trophy points
1,298
Location
Fleet, UK
Activity points
0
No, Enable is not required. you can write

always @ (posedge clk) q<=d;
 

venu pradeepa

Newbie level 4
Joined
May 26, 2005
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,332
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

Top