bluespec.com Forum Index bluespec.com
Bluespec Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ReduceOr for Bools

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ...
View previous topic :: View next topic  
Author Message
ShepSiegel



Joined: 14 Aug 2007
Posts: 41

PostPosted: Tue Sep 04, 2012 12:22 pm    Post subject: ReduceOr for Bools Reply with quote

I have a function isEOP that returns Type Bool. I'm trying to let hasEOP tell me if any member of my Vector qbV has an EOP.

Code:
    function Bool isEOP (
    ...
    Bool hasEOP = reduceOr(map(isEOP,qbV)); 


This doesn't work because reduceOr is for Bits. This seems too wordy, but works as expected...

Code:
Bool hasEOP = unpack(reduceOr(pack(map(isEOP,qbV)))); 


Is there a cleaner way, such as reduceXX for Vectors of Bools?
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 500

PostPosted: Tue Sep 04, 2012 1:23 pm    Post subject: Re: ReduceOr for Bools Reply with quote

Hey Shep,

Have a look at the "any", "all", "and", and "or" functions in the Vector (and List) package (Sec C.3.4 in the Reference Guide).
Code:
Bool hasEOP = or(qbV);

Since "and" and "or" are SystemVerilog keywords, you might have to escape the name with a slash, or add the package qualifier:
Code:
Bool hasEOP = \or (qbV);
Bool hasEOP = Vector::or(qbV);
Back to top
View user's profile Send private message
ShepSiegel



Joined: 14 Aug 2007
Posts: 41

PostPosted: Tue Sep 04, 2012 2:06 pm    Post subject: Reply with quote

Terrific! thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ... All times are GMT - 4 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
You can attach files in this forum
You can download files in this forum
bluespec.com topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP