`*function Bit#(2) haa(Bit#(1)a,Bit#(1)b);
let s=a^b;
let c=a&b;
return {s,c};
endfunction*`
This is my attempt to write a half adder in bsv, but when I try to compile it, it just ended in .bo without forming .v
This is copied from a lecture at mit, but i am not sure it work without package and module keyword. but that also not ended in right way. please help me to write a compilable bsv file based on this (also provide some good sources to study bsv step by step on actual coding).
The function looks correct. In order to generate Verilog out of this, you can either use a
UniqueWrapper*
or expose this function as a value method in the interface provided by a dummy module.When I say dummy module, I mean something like this:
You should now be able to instantiate this module in whatever place you want, and call that value method instead of that function.
Here's how you can compile a bsv file to generate Verilog:
You can find the reference manuals and the user guides here: https://github.com/B-Lang-org/bsc/releases/tag/2023.07
You can find some example bluespec code and a nice little environment where you can simply plug your code, over here: https://github.com/rsnikhil/Bluespec_BSV_Tutorial