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 

Instantiating mutliple rules in a for loop

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



Joined: 06 Aug 2011
Posts: 29

PostPosted: Mon Jun 04, 2012 6:43 am    Post subject: Instantiating mutliple rules in a for loop Reply with quote

I want to do something along the lines of
Code:

for (Integer i=0; i<n; i=i+1) begin
  rule rule_name[i] begin
    ...
  end
end


a. What would be the right syntax for this?
b. Is there anyway to fix priority of these rules in case of conflict?

The intended use case would be to make a round robin arbiter that can be parametrized to an arbitrary number of FIFOs.[/code]
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 495

PostPosted: Mon Jun 04, 2012 1:20 pm    Post subject: Re: Instantiating mutliple rules in a for loop Reply with quote

You can write this:
Code:
for (Integer i=0; i<n; i=i+1) begin
   rule rname (cond);
      ...
   endrule
end

BSC will create rules named "rname", "rname_1", "rname_2", etc.

There is not currently an attribute that you can put here that would be generated for any number "n", although we have plans to fix that.

In the meantime, you can use the "rJoin" family of functions to join rules with certain relationships and then use "addRules" to add the final collection to the module. Here is an example:
Code:
Rules rs = emptyRules;
for (Integer i=0; i<n; i=i+1) begin
   Rules r =
      rules
         rule rname (cond);
            ...
         endrule
      endrules;
   rs = joinRulesDescendingUrgency(rs,r);
end
addRules(rs);

There is an "rJoin" function for each attribute. They are listed in the Reference Guide, if you need more information.
Back to top
View user's profile Send private message
gururaj



Joined: 31 Oct 2012
Posts: 19

PostPosted: Mon Nov 26, 2012 11:09 am    Post subject: Reply with quote

How do I specify the urgency ordering for rules of this kind written inside for loops?

For example.
I have
Code:


for (Integer i=0;i<valueof(N);i=i+1) begin

Rule a ();
endrule

Rule b ();
endrule

Rule c ();
endrule

end


So you say this will generate rules a , a_1, a_2 ... , b , b_1, b_2 ..., c , c_1, c_2 ... . Now I want to set some order of urgency between (a,b,c) , (a_1,b_1,c_1) .., how do I write that? Consider the fact that I have #defined my N to some value and each time I change my N value, I dont want to keep changing the descending urgency list.
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 495

PostPosted: Mon Nov 26, 2012 1:32 pm    Post subject: Reply with quote

gururaj wrote:
Now I want to set some order of urgency between (a,b,c) , (a_1,b_1,c_1) .., how do I write that?

You write it in the same way that I showed in the previous comment:
Code:
Rules rs = emptyRules;
for (Integer i=0;i<valueof(N);i=i+1) begin
   Rules r =
      rules
         Rule a ();
         endrule

         Rule b ();
         endrule

         Rule c ();
         endrule
      endrules;
   rs = joinRulesDescendingUrgency(rs,r);
end
addRules(rs);
Back to top
View user's profile Send private message
bpb



Joined: 19 Dec 2017
Posts: 1

PostPosted: Thu Oct 25, 2018 1:44 am    Post subject: Reply with quote

I suspect joinRulesDescendingUrgency has been renamed to rJoinDescendingUrgency.
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