Verification Guild
A Community of Verification Professionals

 Create an AccountHome | Calendar | Downloads | FAQ | Links | Site Admin | Your Account  

Login
Nickname

Password

Security Code: Security Code
Type Security Code
BACKWARD

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Modules
· Home
· Downloads
· FAQ
· Feedback
· Recommend Us
· Web Links
· Your Account

Advertising

Who's Online
There are currently, 48 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here

  
Verification Guild: Forums

 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile  ProfileDigest    Log inLog in 

inverting multi dimension array in sv

 
Post new topic   Reply to topic    Verification Guild Forum Index -> Main
View previous topic :: View next topic  
Author Message
ravivlsi
Junior
Junior


Joined: Jul 22, 2010
Posts: 5

PostPosted: Tue Apr 17, 2012 12:28 am    Post subject: inverting multi dimension array in sv Reply with quote

I have two dimensional arrays a and b
reg [7:0] a[0:99];
reg [7:0] b[0:99];

and I want to invert entire array by using
b = ~a;

but I got compilation error "bit wise negation, operator operand type is illegal"

Is it possible to invert entire multi dimension array without using loops?
Back to top
View user's profile
dave_59
Senior
Senior


Joined: Jun 22, 2004
Posts: 974
Location: Fremont, CA

PostPosted: Tue Apr 17, 2012 1:39 am    Post subject: Reply with quote

You can't use bit-wise operators on an unpacked array. If you declared your array as

reg [0:99][7:0] a;
reg [0:99][7:0] b;

Then your statement would work.

You could also cast your array to a packed array value, invert it, then cast it back to an unpacked array

b = unpacked_type'(~ packed_type'(a));

But why not a foreach loop.

foreach(b[i]) b[i] = ~a[i];

Dave Rich
Mentor Graphics
Back to top
View user's profile Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Verification Guild Forum Index -> Main All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Verification Guild © 2006 Janick Bergeron
Web site engine's code is Copyright © 2003 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.167 Seconds