unexpected behavior of non-blocking assignment in an priority arbiter

OP #6655799
Rate this post
• ▲ useful
▼ not useful
I am a hdl noob currently experimenting with various styles of fsm.
My module is a simple priority arbiter. The non-blocking assignment 
statement is not behaving  the way I expected. On line 17 and 18 there 
are two non-blocking assignments, but they don't occur on the same 
cycle... the first one (gnt0 <= #1 0) occurs on cycles later then the 
ensuing assign(state <= next_state)... can someone explain to me why I 
attached the simulation result and complete source code for your 
reference.
1
always @(posedge clk) 
2
 begin : OUTPUT_LOGIC
3
   if (reset) begin
4
     gnt0 <= #1 0;
5
     gnt1 <= #1 0;
6
     state <= #1 IDLE;
7
   end else begin
8
     $monitor(" time for state assignment %d is %d \n",state, $time);
9
     case (state)
10
       IDLE: begin
11
         $display("set both gnt0 and gnt1 0");
12
          state <= #1 next_state;
13
         gnt0<=  #1 0;
14
                gnt1<=  #1 0;
15
       end
16
       GNT0: begin
17
         gnt0 <= #1 1;
18
          state <= #1 next_state;
19
       end
20
       GNT1: begin
21
        $display(" time for gnt1 assertion is %d ", $time); 
22
         gnt1 <= #1 1;
23
         state <= #1 next_state;
24
        $display(" gnt1 is %d at time %d ", gnt1,$time);
25
      end    
26
      default: begin
27
         state <= #1 next_state;
28
         state <= IDLE;
29
      end
30
     endcase
31
   end
32
 end
Attached files:

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.