Illegal reference to net

M

maTheMatic

Guest
HI,all
I am learning verilog. The following codes can't be compiled with
the error information "Illegal reference to net "out"" under the
Modelsim SE.

module connect(
input wire in,
output wire out
);

always
begin
#3 out <= in;
end
endmodule

Why can't I direct assign (or connect directly) the input wire to the
output wire? When I change the type of out from wire to reg,then every
thing is ok. Yes, I know the reg can't be assigned with wire type's
things, but how about wire to wire?what is the basic laws behind the
assignment?

Regards
 
Its simple.
Inside always block, you can only assign to reg or variables not nets.
With assign statement, you can assign nets.
In both type of assignments, you can have either wire or reg on RHS.

- Pooja

maTheMatic wrote:

HI,all
I am learning verilog. The following codes can't be compiled with
the error information "Illegal reference to net "out"" under the
Modelsim SE.

module connect(
input wire in,
output wire out
);

always
begin
#3 out <= in;
end
endmodule

Why can't I direct assign (or connect directly) the input wire to the
output wire? When I change the type of out from wire to reg,then every
thing is ok. Yes, I know the reg can't be assigned with wire type's
things, but how about wire to wire?what is the basic laws behind the
assignment?

Regards
 
"maTheMatic" <mathematic@gmail.com> wrote in message news:<1101358479.038808.107440@f14g2000cwb.googlegroups.com>...
HI,all
I am learning verilog. The following codes can't be compiled with
the error information "Illegal reference to net "out"" under the
Modelsim SE.

module connect(
input wire in,
output wire out
);

always
begin
#3 out <= in;
end
endmodule
The rule is you cant assign to a wire inside an always block.
 
what is the consideration behind the above rule? or where can I find
the reference? thx for both of above guys!
 
"maTheMatic" <mathematic@gmail.com> wrote in message news:<1101438966.091391.249440@z14g2000cwz.googlegroups.com>...
what is the consideration behind the above rule? or where can I find
the reference? thx for both of above guys!
Some people will say that a 'wire' type in Verilog
is supposed to be something akin to a physical
wire - that carries a signal but can not store
a value. You will have to use a 'reg' type to do
that.

But, more simply speaking, Verilog being a programming
language, just as all languages, you need to abide by
some rules and regulations. In this case, it is 'a wire
type variable can not be a valid L-value of a procedural
assignment statement'.

Official Verilog Language Reference Manual (IEEE Std.
1364-2001) can be purchased from IEEE store at

http://standards.ieee.org

--
SystemVerilog DPI tutorial on Project VeriPage:
http://www.project-veripage.com/dpi_tutorial_1.php
For subscribing to Project VeriPage mailing list:
<URL: http://www.project-veripage.com/list/?p=subscribe&id=1>
 

Welcome to EDABoard.com

Sponsor

Back
Top