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 

Any easier way to write a BSV wrapper for a verilog code?

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



Joined: 12 Jun 2012
Posts: 17

PostPosted: Tue Jun 12, 2012 3:09 pm    Post subject: Any easier way to write a BSV wrapper for a verilog code? Reply with quote

It seems that all the examples from the pdfs that I can find makes this seem really complicated.

For example, if I just had a simple verilog code that did this:

module add(
input[7:0] a,
input[7:0] b,
input[8:0] out,
input clk);

such that all this module is supposed to do is add "a" and "b" together and output "out" on every clock cycle, how would I do this in terms of BSV assuming that I want to write my own interface?

is there any easy way to just say "setA" and "setB" and just call "getOut"?
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 499

PostPosted: Tue Jun 12, 2012 3:29 pm    Post subject: Re: Any easier way to write a BSV wrapper for a verilog code Reply with quote

You could import it like this:
Code:
interface AddIfc;
   method Bit#(9) add(Bit#(8) a, Bit#(8) b);
endinterface

import "BVI"
module add (AddIfc);
   default_clock (clk);
   no_reset;

   method out add(a, b);
   schedule add CF add;
endmodule

But this implies that the "out" value is computed from the inputs "a" and "b" in the same clock cycle. So it's unclear why the module needs a "clk" input. If the value of "out" is the sum of the inputs from a previous clock cycle, then I would import the module in a different way.
Back to top
View user's profile Send private message
zhangka



Joined: 12 Jun 2012
Posts: 17

PostPosted: Wed Jun 13, 2012 12:38 pm    Post subject: Reply with quote

Doesn't that require me to know how the verilog code behaves specifically (in this example, I know that "out" is dependent on "a" and "b")?

For my specific case, I am handed a verilog file generated by a Xilinx core and so all I'm really given are the pins (with multiple inputs and outputs, and a couple of clock signals).

How would I proceed to write the wrapper for that?
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 499

PostPosted: Wed Jun 13, 2012 12:44 pm    Post subject: Reply with quote

To use a Verilog module, whether in Verilog or in BSV, you don't need to know the internals of the module but you do need to understand the behavior of the ports in and out of the module. Somewhere with the Xilinx core should be documentation on the ports, and you'll need that in order to import the module into BSV.

A number of Xilinx cores are already imported into BSV in the libraries that are provided with the compiler. Perhaps there is already an import-BVI wrapper than you can use or modify. Have a look at the files in ${BLUESPECDIR}/BSVSource/Xilinx/.
Back to top
View user's profile Send private message
zhangka



Joined: 12 Jun 2012
Posts: 17

PostPosted: Wed Jun 13, 2012 3:10 pm    Post subject: Reply with quote

oh wow, I found it there. Thanks!
Back to top
View user's profile Send private message
zhangka



Joined: 12 Jun 2012
Posts: 17

PostPosted: Thu Jun 14, 2012 2:05 pm    Post subject: Reply with quote

Thanks, I think I found the BSV wrapper I need for EMAC:

XilinxTEMAC.bsv.

However, are the verilog files for the wrapper and its dependencies come with Bluespec as well, or should I be generating those myself from Xilinx?
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