The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 19th, 2024, 2:32am
Pages: 1
Send Topic Print
Single line assignment to multiple variable (Read 3950 times)
Tobben24
New Member
*
Offline



Posts: 2

Single line assignment to multiple variable
Mar 19th, 2013, 4:38am
 
Hi,

Is it possible to do single line assignment to multiple variables? Something like this:

real one,two,three;
one,two,three = 0;
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: Single line assignment to multiple variable
Reply #1 - Mar 20th, 2013, 6:24am
 
I don't believe the syntax allows
 one,two,three = 0;

I believe the lastest (digital) Verilog supports initialization as part of the declaration:
 real one=0,two=0,three=0;

and I've found some simulators support new digital features in the AMS context.

Of course, if you just want to do it on one line, you could do
 one=0; two=0; three=0;
The statements don't have to be on separate lines.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Tobben24
New Member
*
Offline



Posts: 2

Re: Single line assignment to multiple variable
Reply #2 - Mar 20th, 2013, 7:09am
 
Okay, thanks for the reply:)
Back to top
 
 
View Profile   IP Logged
Paul Floyd
New Member
*
Offline



Posts: 8
France
Re: Single line assignment to multiple variable
Reply #3 - Mar 20th, 2013, 9:44am
 
Tobben24 wrote on Mar 19th, 2013, 4:38am:
Hi,

Is it possible to do single line assignment to multiple variables? Something like this:

real one,two,three;
one,two,three = 0;


Variables should be default initialized to zero, so in this case your assignment does nothing. If you want a different value, that's another matter.

If it were allowed, I'd want to follow C++ syntax, where it would be

a = b = c = 0;

A+
Paul

Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.