How to write a rising-edge D flip flop program using a Verilog

Status
Not open for further replies.

smeschke

Newbie level 3
Joined
Oct 29, 2017
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
20
here is what I have but it keeps failing:


Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
module DFF(clock,D,Q,Qbar);
  input clock, D;
  output reg Q; 
always block
    output Qbar;
    assign Qbar = ~ Q; 
    always @(posedge clock) 
      Q = D;
endmodule



Any ideas?
 
Last edited by a moderator:

Re: how to write a rising-edge D flip flop program using a Verilog

Hi,

but it keeps failing:
...means what?

Klaus
 

Re: how to write a rising-edge D flip flop program using a Verilog

Oops, forgot to post the output:

testbench.sv:7: syntax error
testbench.sv:7: error: malformed statement
testbench.sv:8: warning: implicit definition of wire 'Qbar'.
Exit code expected: 0, received: 1
Done
 
Last edited by a moderator:

Re: how to write a rising-edge D flip flop program using a Verilog

I found it - I had accidentally added something from a comment block in as code and that is what the issue was. I removed it and then it complied successfully.


Code Verilog - [expand]
1
always block

 

Re: how to write a rising-edge D flip flop program using a Verilog

I found it - I had accidentally added something from a comment block in as code and that is what the issue was. I removed it and then it complied successfully.


Code Verilog - [expand]
1
always block


that's good. but... now think about the task at hand. describing a flip-flop module is not what RTL is supposed to be used for. you want to write code that will infer a flop. it's a subtle but important difference.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…