Author Topic: what does always@(*) do  (Read 1611 times)

0 Members and 2 Guests are viewing this topic.

Offline gauravmpTopic starter

  • Regular Contributor
  • *
  • Posts: 77
  • Country: us
what does always@(*) do
« on: June 08, 2016, 04:19:23 pm »
Hi,

Could someone tell me what always@(*) do? Is the always block executed everytime there is a change in any of the variables?

THanks
 

Offline kfnight

  • Regular Contributor
  • *
  • Posts: 71
Re: what does always@(*) do
« Reply #1 on: June 08, 2016, 04:31:13 pm »
Pretty much. Once upon a time Verilog required a sensitivity list. When any of the signals in the sensitivity list changed value then the simulator would descend into the always block.

Code: [Select]
reg a;

always @(b, c)
begin
  if (b)
    a = 1'b1;
  else if (c)
    a = 1'b0;
  else
    a = 1'b0;
end

Engineers found this annoying since the simulator or synthesis tool should be able to infer the sensitivity list by analyzing the signals in the always block during compilation. So the always @(*) construct was introduced, saving engineers a few keystrokes, and saving a lot of hours debugging the design due to a missing signal in the sensitivity list.

Code: [Select]
reg a;

always @(*)
begin
  if (b)
    a = 1'b1;
  else if (c)
    a = 1'b0;
  else
    a = 1'b0;
end
 
The following users thanked this post: gauravmp

Offline photon

  • Regular Contributor
  • *
  • Posts: 234
  • Country: us
Re: what does always@(*) do
« Reply #2 on: June 08, 2016, 05:39:04 pm »
An issue caused by the old style sensitivity list was that the synthesizer would make a latch for any missing signal from the sensitivity list. Since an always block without a clock is intended for combinational logic, this added latch would be a bug. The new syntax always @(*) prevents this.
 
The following users thanked this post: gauravmp

Offline gauravmpTopic starter

  • Regular Contributor
  • *
  • Posts: 77
  • Country: us
Re: what does always@(*) do
« Reply #3 on: June 10, 2016, 03:28:16 pm »
Thanks guys!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf