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 

multiplying two Bits

 
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 9:26 am    Post subject: multiplying two Bits Reply with quote

hey,

Is there any way to do multiplying in BSV between two Bits which are not the
same size , I have tried to do this but I get an error the compiler expects
to get two inputs at the same size and returns one with the same size for example:

Bit x=00010
Bit y=00011
both in binary
x*y=00101

I need to control the size of each Bit is there any way?
thanks in advance
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:17 am    Post subject: Re: multiplying two Bits Reply with quote

You can zero-extend the arguments to be the same length, and truncate the result if necessary. (Using the functions "zeroExtend" and "truncate".)

Also, the functions "unsignedMul" and "signedMul" exist, which can take arguments of different sizes. They work for types UInt and Int.
Back to top
View user's profile Send private message
flashdisk



Joined: 29 May 2012
Posts: 56

PostPosted: Tue Jun 19, 2012 12:29 pm    Post subject: Reply with quote

where can I find the declaration of the two functions you have mentioned
plus,can I use the last two function in Bits?
thanks for ur reply
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 500

PostPosted: Tue Jun 19, 2012 12:46 pm    Post subject: Reply with quote

There should be a Reference Guide in your Bluespec installation which you can search for information on these functions. You should find it at: ${BLUESPECDIR}/../doc/BSV/reference-guide.pdf.

The "unsignedMul" function cannot be used on Bit#(n) values, though you could use "pack" and "unpack" to convert between them. That's functionally equivalent to using "zeroExtend" and "truncate". A better idea, though, would be to use the type UInt#(n) everywhere, instead of Bit#(n), if you're only using it as a number.
Back to top
View user's profile Send private message
flashdisk



Joined: 29 May 2012
Posts: 56

PostPosted: Tue Jun 19, 2012 1:16 pm    Post subject: Reply with quote

I am building a floating point processor in bsv which can do three operations:multiply,devide,root of anumber by using an algorithm which stands for the I-EEE standard in the algorithm you should make number of iterations that in each one you are multiplying the a certain mantissas !
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