Sequential Circuit

Status
Not open for further replies.

Basit Mehmood

Newbie
Joined
Dec 6, 2022
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
16
What happened if we use blocking assignment in sequential circuit like flip-flop?
I mean is following code correct or not?

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
module dff (q, qn, d, clk);
   input d, clk;
   output q, qn;
   reg q, qn;
   always @(posedge clk)
      begin
         q = d;
         qn = ~d;
      end
endmodule

 
Last edited by a moderator:

conceptually, it is wrong.
depending on the synthesis tool, it might synthesize correctly.
 

    andre_luis

    Points: 2
    Helpful Answer Positive Rating
1. What do you want to achieve? Just playing around?
There's a reason, why design rules say use non-blocking in clocked always block and blocking in combinational. For a comprehensive explanation, read this classical paper http://www.sunburst-design.com/papers/CummingsSNUG2000SJ_NBA_rev1_2.pdf

2. In this special case, non-blocking assignments make no difference. That's because the assigned variable q and qn aren't appearing on RHS of other expressions below the assignment.

3. Sometimes you want intermediate combinational results assigned to a variable inside a clocked always block. In this case, blocking assignments may be used intentionally.
 

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