Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

why assignment to a single bit of a reg report a error?

440 views
Skip to first unread message

lzh

unread,
Apr 3, 1997, 3:00:00 AM4/3/97
to

Hi,everyone
This is a simple example module of my question
module test(a,b);
input a;
output [1:0] b;
reg [1:0] b;
always @(a)
begin
assign b[0]=a;
assign b[1]=!a;
end
endmodule

when i use Cadence Verilog-XL to compile it ,Verilog-XL report a
error "Illegal
left-hand-side in assignment",but when i use Veriwell to compile it ,it
does work!
and if i use "assign b={a,!a};"instead of it,the Verilog-XL can compile it
without any error,can anybody explain why?
i really need your help!
thanks!

Jurgen Schulz

unread,
Apr 3, 1997, 3:00:00 AM4/3/97
to

you don't use assign in an always block, just try
b[0]=a;
b[1]=!a;

Regards, Jurgen.

Raghu

unread,
Apr 6, 1997, 4:00:00 AM4/6/97
to

lzh wrote:
>
> Hi,everyone
> This is a simple example module of my question
> module test(a,b);
> input a;
> output [1:0] b;
> reg [1:0] b;
> always @(a)
> begin
> assign b[0]=a;
> assign b[1]=!a;
> end
> endmodule
>

Hi,

A few related questions:

1. Can you use `assign' statements to
assign values to a `reg' type variable?
I thought you could only `assign' to
nets.

2. Can you combine dataflow (`assign') and
functional (`always') constructs as shown
above?? I thought you could not.

Am I wrong??

Thanks!

--
Raghu ---------------------
ra...@iastate.edu,
(H)(515) 292 1269
---- Grad Student Cpr E ---

m...@silicon-sorcery.com

unread,
Apr 6, 1997, 4:00:00 AM4/6/97
to ra...@iastate.edu

Raghu <ra...@iastate.edu> writes:


: lzh wrote:
: >
: > Hi,everyone
: > This is a simple example module of my question
: > module test(a,b);
: > input a;
: > output [1:0] b;
: > reg [1:0] b;
: > always @(a)
: > begin
: > assign b[0]=a;
: > assign b[1]=!a;
: > end
: > endmodule
: >
:
: Hi,
:
: A few related questions:
:
: 1. Can you use `assign' statements to
: assign values to a `reg' type variable?
: I thought you could only `assign' to
: nets.
:
: 2. Can you combine dataflow (`assign') and
: functional (`always') constructs as shown
: above?? I thought you could not.

:

Due to a very unfortunate language design choice, there are
two uses of the keyword "assign" in the Verilog language.

One is the familiar continuous assign, which can be used only
at module scope, and can have as its target only an expression of
wires.

The other is the procedural continuous assign, a version of
the force statment, and can be used only in behavorial scopes, and can
have as its target only an expression of registers. This force is in
effect until deassigned (either by using the deassign keyword or by
executing some other procedural continuous assign).

So, the answer to your questions is yes to both; it's just
that the assign isn't the assign you were thinking of...

--
Michael McNamara Silicon Sorcery [37 15.7878' -121 57.4658']
Get my verilog emacs mode (subscribe for free updates!) at
<http://www.silicon-sorcery.com/verilog-mode.html>

Clifford R. Warren

unread,
Apr 8, 1997, 3:00:00 AM4/8/97
to


Raghu <ra...@iastate.edu> wrote in article <33475D...@iastate.edu>...


> lzh wrote:
> >
> > Hi,everyone
> > This is a simple example module of my question
> > module test(a,b);
> > input a;
> > output [1:0] b;
> > reg [1:0] b;
> > always @(a)
> > begin
> > assign b[0]=a;
> > assign b[1]=!a;
> > end
> > endmodule
> >
>
> Hi,
>
> A few related questions:
>
> 1. Can you use `assign' statements to
> assign values to a `reg' type variable?
> I thought you could only `assign' to
> nets.

Nope. Sorry you cannot. Continuous assignments can only be
made to "nets", (the "wire" data type).

>
> 2. Can you combine dataflow (`assign') and
> functional (`always') constructs as shown
> above?? I thought you could not.

True, you cannot. A continuous assignment (assign)
cannot be made within a procedural assignment statement
(always).

I like to think of these two type of assignments as:

"continuous" -- assign statements made to wires

and

"procedural" -- assignments made to regs within an always
or an initial statement

By remembering "continuous" and "procedural" this helps me
keep them straight.

David Emrich

unread,
Apr 10, 1997, 3:00:00 AM4/10/97
to lzh

lzh wrote:
...

> module test(a,b);
> input a;
> output [1:0] b;
> reg [1:0] b;
> always @(a)
> begin
> assign b[0]=a;
> assign b[1]=!a;
> end
> endmodule
>
> when i use Cadence Verilog-XL to compile it ,Verilog-XL report a
> error "Illegal
> left-hand-side in assignment",but when i use Veriwell to compile it ,it
> does work!
> and if i use "assign b={a,!a};"instead of it,the Verilog-XL can compile it
> without any error,can anybody explain why?

Bit select on the left side of a continuous procedural assignment is
prohibited in the OVI 2.0 Verilog LRM.

David Emrich
Exemplar Logic
emr...@exemplar.com

.

Message has been deleted
Message has been deleted

Hill Stone

unread,
Dec 26, 2021, 6:11:29 PM12/26/21
to
четвер, 10 квітня 1997 р. о 08:00:00 UTC+1 David Emrich пише:
This may be a temporary error. I came across this too. This problem is easy to fix. My assignment with writing nursing papers is especially troublesome for me more. I'm so tired of it that I just want to quit. Only https://www.nursingpaper.com/ help me out and I am happy with the fact that there is very little time left before the graduation ceremony.

Ирен Гнидковская

unread,
Apr 24, 2023, 9:48:28 AM4/24/23
to
It’s a great chance to show your skills https://essaysforme.com/write-my-comparison-essay and prove to committee members that you, among other applicants, indeed deserve financial aid to the committee. A careful combination of strong arguments, careful editing, and reasonable demonstration of your goals will improve the effectiveness of your college scholarship essay. Moreover, the deeper you realize the meaning of particular key abilities, the higher chances are to win the desired place.
0 new messages