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 

method problem!

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



Joined: 29 May 2012
Posts: 56

PostPosted: Tue Jun 19, 2012 5:43 am    Post subject: method problem! Reply with quote

hello,

I am working on my project in bsv(building multiplier) and my problem is how to call method from my current method ?

method a(x)
.
.
endmethod

method b()
.
integer x;
//how to call method a and send to it x as parameter
.
endmethod

thanks
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 500

PostPosted: Tue Jun 19, 2012 7:54 am    Post subject: Re: method problem! Reply with quote

Methods cannot call other methods of the same module. If you want to share code between methods, you can use a function:
Code:

module mkMod(...);
   ...
   function f(x);
      ...
   endfunction
   ...
   method a(x) = f(x);
   method b(...);
      ... f(x) ...
   endmethod
endmodule
Back to top
View user's profile Send private message
flashdisk



Joined: 29 May 2012
Posts: 56

PostPosted: Tue Jun 19, 2012 9:13 am    Post subject: Reply with quote

thanks for your reply

all i want to do is to get an array which is calculated by one method and
use the result in other method is there any way to define an array in the same file and let the two methods make changes in it
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 500

PostPosted: Tue Jun 19, 2012 11:40 am    Post subject: Reply with quote

For the value to persist, it needs to be written to an instantiated state element (a submodule), such as a register (see "mkReg" etc). There are also wire modules that can persist a value for the duration of the current clock cycle (see "mkWire" etc).

Also, I'm not sure what you mean by "array", but both registers and wires can contain bit arrays. And an array of registers (or an array of wires) can be instantiated.
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