Assign statement

In reply to cgales:

Hi, i also checked same question on verification academy :-https://verificationacademy.com/forums/systemverilog/drive-reg-using-continuous-assign, Problem here is that in Verilog we can not write reg type variable on the L.H.S of the assign statement.

Verilog there are 3 types of assignments 1.continuous assignment 2.procedral assignment 3. procedural continuous assignment, and for continuous assignment at the L.H.S must be a net it can not be a reg type, but when it is procedural continuous assignment then it is valid to have reg at L.H.S but we can not write net.

System Verilog also has this 3 types but here with continuous assignment when we write reg at L.H.S it is valid and net type also valid, with the procedural continuous assignment the L.H.S must be reg, wire is invalid.

Also one observation is that in system Verilog when you drive net with assign statement then the display is executed first(out = x) and then the assignment to the net is done if i put #0 delay as per the code the display will be executed in inactive region and the new value will be displayed(out = 1) and with reg it is working fine no need to put #0 delay, i am not able to find out why this is happening?

module test;
  reg a = 1'b1;
  wire out;
  
  assign out = a ? 1:0;
  
  initial begin
    #0 $display("out = %b",out);
  end
endmodule

Thank you.