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.

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top