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 

function vs method

 
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: Sat Aug 11, 2012 7:26 am    Post subject: function vs method Reply with quote

what is the difference between using function in bsv instead of method
lets say we want to make aloop to calculate somthing should I do it in function or in method?
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 500

PostPosted: Sat Aug 11, 2012 9:02 pm    Post subject: Re: function vs method Reply with quote

A BSV module is made of [i]state[/i] elements (sub-module instantiations), an [i]interface[/i], and [i]rules[/i]. Rules describe the internal behavior of the module -- how the state is updated internally. The interface describes how the module interacts with the rest of the system -- how is reacts to inputs and provides outputs. The interface in BSV is like the port list of a module in RTL. The interface is composed of methods, which are independent transactions between the system and the module.

So a method is a part of a module. While a function is just a piece of code that you assign a name to. Functions can be used anywhere -- in module instantiations, inside rules, and inside methods. Until a function is used in a module, it is not part of the hardware. And a single function can be used in many places, in the same module and in other modules.

If you write a loop to calculate something and you put it in a method, then it can only ever be used in that method of that module. If you write it in a function, then you can use the function in a method, and still re-use the function elsewhere.
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