What's included in a Verilog always @* sensitivity list?
Asked Answered
C

4

11

I'm a bit confused about what is considered an input when you use the wildcard @* in an always block sensitivity list. For instance, in the following example, which signals are interpreted as inputs that cause the always block to be reevaluated?

From what I understand, clk and reset aren't included because they don't appear on the right hand side of any procedural statement in the always block. a and b are included because they both appear on the right hand side of procedural statements in the always block.

But, where I'm really confused about is en and mux. Because they are used as test conditions in the if and case statements, are they considered inputs? Is the always block reevaluated each time en and mux change value?

module example
( 
    input wire clk, reset, en, a, b,
    input wire [1:0] mux,
    output reg x,y, z
);

always @*    
begin  
 x = a & b;    
  if (en)
    y= a | b;
  case(mux)
    2'b00: z = 0;
    2'b01: z = 1;
    2'b10: z = 1;
    2'b11: z = 0;
  endcase
end
endmodule
Chassidychassin answered 11/3, 2012 at 21:27 Comment(0)
W
13

Any signal that is read inside a block, and so may cause the result of a block to change if it's value changes, will be included by @*. Any change on a read signal used must cause the block to be re-evaluated, as it could cause the outputs of the block to change. As I'm sure you know, if you hadn't used @* you'd be listing those signals out by hand.

In the case of the code you've provided it's any signal that is:

  • Evaluated on the right hand side of an assignment (a and b)
  • Evaluated as part of a conditional (en and mux)

...but it's any signal that would be evaluated for any reason. (I can't think of any other reasons right now, but maybe someone else can)

clk and reset aren't on the sensitivity list because they aren't used. Simple as that. There's nothing special about them; they're signals like any other.

Wakefield answered 12/3, 2012 at 0:50 Comment(1)
Identifiers in nested event expressions are not added.Volute
G
4

In your example, the following signals are included in the implicit sensitivity list:

a
b
en
mux

clk and reset are not part of the sensitivity list.

This is described completely in the IEEE Std for Verilog (1800-2009, for example). The IEEE spec is the best source of detailed information on Verilog. The documentation for your simulator may also describe how @* works.

Gilbert answered 11/3, 2012 at 23:40 Comment(0)
P
0
always@*   // same as always@(a,b,c,d,e,f,g,h,i,j,k)
begin
  result = a && b;
  if (c==d)  flag = e;
  $display("%0d",f);
  case (g)
    h : value = i;
  endcase
  arr[j] = k;
end

Here we can see that implicit sensitivity list automatically fetches those variables that are being read (like-: RHS and other arguments) by the always block.
In your case it would be : a, b, en, mux.

Plexor answered 27/3, 2023 at 18:1 Comment(0)
A
-1

The simplest answer depends on if you are writing RTL, or a testbench. If you are writing RTL then you should try to forget about the concept of Sensitivity lists, as they don't really exist. There is no logic that only updates when an item on the list is triggered. All sensitivity lists can do in RTL is cause your simulation and actual circuit to differ, they don't do anything good.

So, always use "always @*" or better yet "always_comb" and forget about the concept of sensitivity lists. If the item in the code is evaluated it will trigger the process. Simple as that. It an item is in an if/else, a case, assigned to a variable, or anything else, it will be "evaluated" and thus cause the process to be triggered.

But, just remember, in digital circuits, there is no sensitivity list.

Aloise answered 29/8, 2018 at 18:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.