 |
bluespec.com Bluespec Forums
|
View previous topic :: View next topic |
Author |
Message |
chiraag
Joined: 06 Aug 2011 Posts: 29
|
Posted: Mon Jun 04, 2012 6:43 am Post subject: Instantiating mutliple rules in a for loop |
|
|
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 |
|
 |
quark Site Admin
Joined: 02 Nov 2007 Posts: 499
|
Posted: Mon Jun 04, 2012 1:20 pm Post subject: Re: Instantiating mutliple rules in a for loop |
|
|
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 |
|
 |
gururaj
Joined: 31 Oct 2012 Posts: 19
|
Posted: Mon Nov 26, 2012 11:09 am Post subject: |
|
|
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 |
|
 |
quark Site Admin
Joined: 02 Nov 2007 Posts: 499
|
Posted: Mon Nov 26, 2012 1:32 pm Post subject: |
|
|
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 |
|
 |
bpb
Joined: 19 Dec 2017 Posts: 2
|
Posted: Thu Oct 25, 2018 1:44 am Post subject: |
|
|
I suspect joinRulesDescendingUrgency has been renamed to rJoinDescendingUrgency. |
|
Back to top |
|
 |
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|